From 591789b10f8955a1b618fa9de549be34c9d66f2f Mon Sep 17 00:00:00 2001 From: Ilya Artamonov Date: Sat, 15 Jul 2023 13:19:22 +0300 Subject: [PATCH] feat: Some improvements for modal component Added click outside, persistent and close on Esc --- docs/components/modal.md | 47 ++++++++++++- .../modal/examples/ModalExample.vue | 48 ++++--------- .../modal/examples/ModalPersistentExample.vue | 8 +++ src/components/Modal/Modal.vue | 69 +++++++++---------- 4 files changed, 100 insertions(+), 72 deletions(-) create mode 100644 docs/components/modal/examples/ModalPersistentExample.vue diff --git a/docs/components/modal.md b/docs/components/modal.md index b098539..da22950 100644 --- a/docs/components/modal.md +++ b/docs/components/modal.md @@ -2,10 +2,23 @@ import ModalExample from './modal/examples/ModalExample.vue'; import ModalSizeExample from './modal/examples/ModalSizeExample.vue'; import ModalEscapableExample from './modal/examples/ModalEscapableExample.vue'; +import ModalPersistentExample from './modal/examples/ModalPersistentExample.vue'; # Vue Modal - Flowbite -## Demo +#### Use the modal component to show interactive dialogs and notifications to your website users available in multiple sizes, colors, and styles + +--- + +:::tip +Original reference: [https://flowbite.com/docs/components/modal/](https://flowbite.com/docs/components/modal/) +::: + +The modal component can be used as an interactive dialog on top of the main content area of the website to show notifications and gather information using form elements from your website users. + +Get started with multiple sizes, colors, and styles built with the utility classes from Tailwind CSS and the components from Flowbite. + +## Default modal @@ -101,3 +114,35 @@ import { Modal } from 'flowbite-vue' ``` + +## Persistent + +Clicking outside of the element or pressing esc key will not send `close` event. + +Demo: + + +```vue + + +``` + +## API + +### Props: + +| Name | Values | Default | +|------------|-----------------------------------------------------------|---------| +| size | `md`,`lg`, `xl`, `2xl`, `3xl`, `4xl`, `5xl`, `6xl`, `7xl` | 2xl | +| escapable | `true`, `false` | `true` | +| persistent | `true`, `false` | `true` | + +### Events: +| Name | Type | +|---------------------|----------------------------------------------------------------------------------| +| `close` | Clicked on the close button, pressed `Esc`, or clicked outside the modal content | +| `click:outside` | Clicked outside the modal content | diff --git a/docs/components/modal/examples/ModalExample.vue b/docs/components/modal/examples/ModalExample.vue index ff5a911..9abf5ca 100644 --- a/docs/components/modal/examples/ModalExample.vue +++ b/docs/components/modal/examples/ModalExample.vue @@ -3,7 +3,7 @@ - + diff --git a/src/components/Modal/Modal.vue b/src/components/Modal/Modal.vue index 5b91768..bc0354b 100644 --- a/src/components/Modal/Modal.vue +++ b/src/components/Modal/Modal.vue @@ -2,13 +2,14 @@
-
@@ -16,7 +17,7 @@
-