diff --git a/assets/bootstrap.js b/assets/bootstrap.js index 2a0c6a0..4d08a22 100644 --- a/assets/bootstrap.js +++ b/assets/bootstrap.js @@ -1,6 +1,8 @@ import { startStimulusApp } from '@symfony/stimulus-bundle'; import Popover from '@stimulus-components/popover' +import Dialog from '@stimulus-components/dialog' const app = startStimulusApp(); // register any custom, 3rd party controllers here app.register('popover', Popover); +app.register('dialog', Dialog); diff --git a/assets/styles/app.css b/assets/styles/app.css index cd77417..00101cd 100644 --- a/assets/styles/app.css +++ b/assets/styles/app.css @@ -11,3 +11,40 @@ font-size: var(--text-xl); } } + +/* Prevent scrolling while dialog is open */ +body:has(dialog[data-dialog-target="dialog"][open]) { + overflow: hidden; +} + +/* Customize the dialog backdrop */ +dialog { + box-shadow: 0 0 0 100vw rgb(0 0 0 / 0.5); +} + +@keyframes fade-in { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } +} + +@keyframes fade-out { + 0% { + opacity: 1; + } + 100% { + opacity: 0; + } +} + +/* Add animations */ +dialog[data-dialog-target="dialog"][open] { + animation: fade-in 200ms forwards; +} + +dialog[data-dialog-target="dialog"][closing] { + animation: fade-out 200ms forwards; +} diff --git a/importmap.php b/importmap.php index 7f6c5f6..a295579 100644 --- a/importmap.php +++ b/importmap.php @@ -31,4 +31,7 @@ return [ '@stimulus-components/popover' => [ 'version' => '7.0.0', ], + '@stimulus-components/dialog' => [ + 'version' => '1.0.1', + ], ]; diff --git a/src/Twig/Components/Modal.php b/src/Twig/Components/Modal.php new file mode 100644 index 0000000..2df52ee --- /dev/null +++ b/src/Twig/Components/Modal.php @@ -0,0 +1,10 @@ +