Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[next] feat(NcModal): migrate to vue 3 #4722

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module.exports = {
'src/components/NcDashboard*/*.vue',
'src/components/NcAvatar*/*.vue',
'src/components/NcHeaderMenu*/*.vue',
'src/components/NcModal*/*.vue',
'src/components/NcRelatedResourcesPanel*/*.vue',
'src/components/NcRich*/**/*.vue',
'src/components/NcUserBubble*/*.vue',
Expand Down
1 change: 0 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default defineConfig({
},

excludeSpecPattern: [
'cypress/component/modal.cy.ts',
'cypress/component/richtext.cy.ts',
'cypress/visual/**/*.{j,t}s',
],
Expand Down
11 changes: 6 additions & 5 deletions cypress/component/modal.cy.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import { mount } from 'cypress/vue2'
import { mount } from 'cypress/vue'
import NcModal from '../../src/components/NcModal/NcModal.vue'
import type { Component } from 'vue'
import { h } from 'vue'

describe('NcModal', () => {
it('close button is visible when content is scrolled', () => {
mount(NcModal, {
propsData: {
props: {
show: true,
size: 'small',
name: 'Name',
},
slots: {
// Create two div as children, first is 100vh = overflows the content, second just gets some data attribute so we can scroll into view
default: {
render: (h) =>
render: () =>
h('div', [
h('div', { style: 'height: 100vh;' }),
h('div', { attrs: { 'data-cy': 'bottom' } }),
h('div', { style: { height: '100vh' } }),
h('div', { 'data-cy': 'bottom' }),
]),
} as Component,
},
Expand Down
20 changes: 10 additions & 10 deletions src/components/NcModal/NcModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
-->

<docs>
For showing the modal you can use either `:show.sync="showModal"` or `v-if` on the `NcModal`,
For showing the modal you can use either `v-model:show="showModal"` or `v-if` on the `NcModal`,
depending on whether you require the Modal to stay within the DOM or not. Do not mix both, as this will break the out transition animation.

```vue
<template>
<div>
<NcButton @click="showModal">Show Modal</NcButton>
<NcModal
:show.sync="modal"
v-model:show="modal"
@close="closeModal"
size="small"
name="Name"
Expand Down Expand Up @@ -79,10 +79,10 @@ export default {
<div class="modal__content">
<h2>Please enter your name</h2>
<div class="form-group">
<NcTextField label="First Name" :value.sync="firstName" />
<NcTextField label="First Name" v-model="firstName" />
</div>
<div class="form-group">
<NcTextField label="Last Name" :value.sync="lastName" />
<NcTextField label="Last Name" v-model="lastName" />
</div>
<div class="form-group">
<label for="pizza">What is the most important pizza item?</label>
Expand Down Expand Up @@ -582,7 +582,7 @@ export default {
beforeMount() {
window.addEventListener('keydown', this.handleKeydown)
},
beforeDestroy() {
beforeUnmount() {
window.removeEventListener('keydown', this.handleKeydown)
this.mc.stop()
},
Expand All @@ -603,7 +603,7 @@ export default {
}
}
},
destroyed() {
unmounted() {
this.clearFocusTrap()
this.$el.remove()
},
Expand Down Expand Up @@ -1041,12 +1041,12 @@ export default {
transition: opacity 250ms;
}

.fade-enter,
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}

.fade-visibility-enter,
.fade-visibility-enter-from,
.fade-visibility-leave-to {
visibility: hidden;
opacity: 0;
Expand All @@ -1059,9 +1059,9 @@ export default {
transition: opacity 250ms;
}

.modal-in-enter,
.modal-in-enter-from,
.modal-in-leave-to,
.modal-out-enter,
.modal-out-enter-from,
.modal-out-leave-to {
opacity: 0;
}
Expand Down
1 change: 0 additions & 1 deletion styleguide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ module.exports = async () => {
// Not yet adjusted for vue3
'src/components/NcAvatar*/*.vue',
'src/components/NcHeaderMenu*/*.vue',
'src/components/NcModal*/*.vue',
'src/components/NcRelatedResourcesPanel*/*.vue',
'src/components/NcRichContenteditable*/*.vue',
'src/components/NcUserBubble*/*.vue',
Expand Down
1 change: 0 additions & 1 deletion vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ const overrides = defineConfig({
'./tests/unit/components/NcAvatar',
'./tests/unit/components/NcAppNavigation',
'./tests/unit/components/NcAppSidebar',
'./tests/unit/components/NcModal',
'./tests/unit/components/NcRichContenteditable',
'./tests/unit/components/NcRichText',
'./tests/unit/mixins/*',
Expand Down