From 8ef6526fa73fcc3a7685e0dc49235ce4ad32fb6d Mon Sep 17 00:00:00 2001 From: Dmitri <19738862+Dmitri-2@users.noreply.github.com> Date: Wed, 31 Aug 2022 10:14:18 -0700 Subject: [PATCH 1/6] Add basic modal component --- docs/.vitepress/config.ts | 2 +- .../modal/examples/ModalExample.vue | 25 ++++++- docs/components/modal/modal.md | 36 +++++++++- src/components/Modal/Modal.vue | 65 +++++++++++-------- 4 files changed, 97 insertions(+), 31 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index d81f580..a3733c3 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -42,6 +42,7 @@ function getComponents() { { text: 'Tabs', link: '/components/tabs/tabs.md' }, { text: 'ListGroup', link: 'components/listGroup/listGroup.md' }, { text: 'Toast', link: 'components/toast/toast.md' }, + { text: 'Modal', link: 'components/modal/modal.md' }, { text: '- Accordion', link: 'components/accordion/accordion.md' }, { text: '- Avatar', link: 'components/avatar/avatar.md' }, @@ -50,7 +51,6 @@ function getComponents() { { text: '- Card', link: 'components/card/card.md' }, { text: '- Carousel', link: 'components/carousel/carousel.md' }, { text: '- Footer', link: 'components/footer/footer.md' }, - { text: '- Modal', link: 'components/modal/modal.md' }, { text: '- Navbar', link: 'components/navbar/navbar.md' }, { text: '- Pagination', link: 'components/pagination/pagination.md' }, { text: '- Progress', link: 'components/progress/progress.md' }, diff --git a/docs/components/modal/examples/ModalExample.vue b/docs/components/modal/examples/ModalExample.vue index aea1c27..df2b134 100644 --- a/docs/components/modal/examples/ModalExample.vue +++ b/docs/components/modal/examples/ModalExample.vue @@ -1,6 +1,29 @@ # Modal +### Demo + + + ```vue ``` - +### Slot Properties + +Modal slots recieve the following functions to interact with the modal: +1. `show` = show the modal +2. `hide` = hide the modal +3. `toggle` = toggles the modal from current state (e.g. if shown, then hide) diff --git a/src/components/Modal/Modal.vue b/src/components/Modal/Modal.vue index aa38a79..28b10d0 100644 --- a/src/components/Modal/Modal.vue +++ b/src/components/Modal/Modal.vue @@ -1,37 +1,36 @@ From 8a3071cb46b493ceb04b5d39d9e5825788bf6fa9 Mon Sep 17 00:00:00 2001 From: Dmitri <19738862+Dmitri-2@users.noreply.github.com> Date: Wed, 31 Aug 2022 10:31:32 -0700 Subject: [PATCH 2/6] Update modal functions --- src/components/Modal/Modal.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/Modal/Modal.vue b/src/components/Modal/Modal.vue index 28b10d0..c248f0c 100644 --- a/src/components/Modal/Modal.vue +++ b/src/components/Modal/Modal.vue @@ -63,10 +63,10 @@ function toggleModal() { isHidden.value = !isHidden.value } function hideModal() { - isHidden.value = !isHidden.value + isHidden.value = true } function showModal() { - isHidden.value = !isHidden.value + isHidden.value = false } From 8d3390c44099237df28b75bd5576832cb483e40f Mon Sep 17 00:00:00 2001 From: Dmitri <19738862+Dmitri-2@users.noreply.github.com> Date: Thu, 1 Sep 2022 02:54:29 -0700 Subject: [PATCH 3/6] Make title and footer conditional --- src/components/Modal/Modal.vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/components/Modal/Modal.vue b/src/components/Modal/Modal.vue index c248f0c..7e14112 100644 --- a/src/components/Modal/Modal.vue +++ b/src/components/Modal/Modal.vue @@ -2,12 +2,13 @@
-
+
-
+

@@ -16,11 +17,11 @@
-
+
-
+
From bf4880876e0d88b2e0cba4f0dbd26dd3f5e6b507 Mon Sep 17 00:00:00 2001 From: Dmitri <19738862+Dmitri-2@users.noreply.github.com> Date: Thu, 8 Sep 2022 10:22:50 -0700 Subject: [PATCH 4/6] Update modal to have generic slots --- .../modal/examples/ModalExample.vue | 27 ++++++++++++----- docs/components/modal/modal.md | 29 ++++++++++++++----- src/components/Modal/Modal.vue | 18 +++++------- 3 files changed, 48 insertions(+), 26 deletions(-) diff --git a/docs/components/modal/examples/ModalExample.vue b/docs/components/modal/examples/ModalExample.vue index df2b134..c354d8f 100644 --- a/docs/components/modal/examples/ModalExample.vue +++ b/docs/components/modal/examples/ModalExample.vue @@ -6,7 +6,18 @@ Show Modal - +
diff --git a/docs/components/modal/modal.md b/docs/components/modal/modal.md index 38a79c0..cf3b674 100644 --- a/docs/components/modal/modal.md +++ b/docs/components/modal/modal.md @@ -18,7 +18,18 @@ import { Modal } from 'flowbite-vue' Show Modal - + @@ -41,7 +54,7 @@ import { Modal } from 'flowbite-vue' ### Slot Properties -Modal slots recieve the following functions to interact with the modal: +Modal slots receive the following functions to interact with the modal: 1. `show` = show the modal 2. `hide` = hide the modal 3. `toggle` = toggles the modal from current state (e.g. if shown, then hide) diff --git a/src/components/Modal/Modal.vue b/src/components/Modal/Modal.vue index 7e14112..e88f688 100644 --- a/src/components/Modal/Modal.vue +++ b/src/components/Modal/Modal.vue @@ -2,26 +2,22 @@
-
+
-
-

- -

- +
+
-
+
-
+
From 19542da005decca415c130c52d8a63648e0f6730 Mon Sep 17 00:00:00 2001 From: Dmitri <19738862+Dmitri-2@users.noreply.github.com> Date: Sun, 18 Sep 2022 19:01:59 -0700 Subject: [PATCH 5/6] Add modal sizes --- .../modal/examples/ModalExample.vue | 34 +++++++++++++++++-- .../modal/examples/ModalSizeExample.vue | 19 +++++++++++ docs/components/modal/modal.md | 33 ++++++++++++++++-- src/components/Modal/Modal.vue | 17 +++++++++- 4 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 docs/components/modal/examples/ModalSizeExample.vue diff --git a/docs/components/modal/examples/ModalExample.vue b/docs/components/modal/examples/ModalExample.vue index c354d8f..c590f72 100644 --- a/docs/components/modal/examples/ModalExample.vue +++ b/docs/components/modal/examples/ModalExample.vue @@ -1,9 +1,9 @@ ``` -### Slot Properties +## Slot Properties Modal slots receive the following functions to interact with the modal: 1. `show` = show the modal 2. `hide` = hide the modal 3. `toggle` = toggles the modal from current state (e.g. if shown, then hide) + +These properties allow your code to set the open/closed state of the modal easily. + +## Sizes + +The modal can come in the following sizes (based on TailwindCSS classes). + +`xs`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl`, `7xl` + +The default value is: `2xl` + +Demo: + + + +```vue + + +``` \ No newline at end of file diff --git a/src/components/Modal/Modal.vue b/src/components/Modal/Modal.vue index e88f688..da29f54 100644 --- a/src/components/Modal/Modal.vue +++ b/src/components/Modal/Modal.vue @@ -4,7 +4,8 @@
-
+
@@ -54,6 +55,20 @@ const props = defineProps({ }, }) +const modalSizeClasses = { + xs: 'max-w-xs', + sm: 'max-w-sm', + md: 'max-w-md', + lg: 'max-w-lg', + xl: 'max-w-xl', + '2xl': 'max-w-2xl', + '3xl': 'max-w-3xl', + '4xl': 'max-w-4xl', + '5xl': 'max-w-5xl', + '6xl': 'max-w-6xl', + '7xl': 'max-w-7xl', +} + const isHidden: Ref = ref(!props.show) function toggleModal() { From 923645b4b3598402593a09152b0672b249483fb8 Mon Sep 17 00:00:00 2001 From: Dmitri <19738862+Dmitri-2@users.noreply.github.com> Date: Sun, 2 Oct 2022 17:25:01 -0700 Subject: [PATCH 6/6] Address PR comments --- .../modal/examples/ModalExample.vue | 10 ++++++---- .../modal/examples/ModalSizeExample.vue | 8 ++++---- src/components/Modal/Modal.vue | 19 +++++++++++-------- src/components/Modal/types.ts | 2 ++ 4 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 src/components/Modal/types.ts diff --git a/docs/components/modal/examples/ModalExample.vue b/docs/components/modal/examples/ModalExample.vue index c590f72..10886cf 100644 --- a/docs/components/modal/examples/ModalExample.vue +++ b/docs/components/modal/examples/ModalExample.vue @@ -39,8 +39,10 @@
-