Skip to content

Commit

Permalink
pkp/pkp-lib#10001 Add Cancel buttons in Modal and SideModal stories w…
Browse files Browse the repository at this point in the history
…ith form
  • Loading branch information
blesildaramirez committed Jun 25, 2024
1 parent 50e7c5b commit 56218dc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
14 changes: 13 additions & 1 deletion src/components/Modal/Modal.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ export const WithForm = {

const form = ref({
...cloneDeep(FormMock),
pages: [
{
id: 'default',
submitButton: {
label: 'Submit',
isPrimary: true,
},
cancelButton: {
label: 'Cancel',
},
},
],
action: 'https://httpbin.org',
method: 'GET',
});
Expand All @@ -67,7 +79,7 @@ export const WithForm = {
:open="isModalOpened"
@close="isModalOpened = false"
>
<PkpForm v-bind="form" @set="setForm" @success="formSuccess" />
<PkpForm v-bind="form" @set="setForm" @success="formSuccess" @cancel="isModalOpened = false" />
</Modal>
`,
}),
Expand Down
24 changes: 21 additions & 3 deletions src/components/Modal/SideModal.stories.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {within, userEvent} from '@storybook/test';
import {ref} from 'vue';
import {ref, inject} from 'vue';
import SideModal from './SideModal.vue';
import {useModal} from '@/composables/useModal.js';
import SideModalBody from './SideModalBody.vue';
Expand Down Expand Up @@ -171,11 +171,29 @@ const SideModalWithForm = {
setup() {
const form = ref({
...cloneDeep(FormMock),
pages: [
{
id: 'default',
submitButton: {
label: 'Submit',
isPrimary: true,
},
cancelButton: {
label: 'Cancel',
},
},
],
action: 'https://httpbin.org',
method: 'GET',
});

return {form};
const closeModal = inject('closeModal');

function closeSideModal() {
closeModal();
}

return {form, closeSideModal};
},
template: `
<SideModalBody>
Expand All @@ -187,7 +205,7 @@ const SideModalWithForm = {
</template>
<div class="p-4">
<div class="bg-secondary">
<PkpForm v-bind="form" @set="setForm" @success="formSuccess" />
<PkpForm v-bind="form" @set="setForm" @success="formSuccess" @cancel="closeSideModal" />
</div>
</div>
</SideModalBody>
Expand Down

0 comments on commit 56218dc

Please sign in to comment.