Skip to content

Commit

Permalink
feat: open and close modal
Browse files Browse the repository at this point in the history
  • Loading branch information
ell-ska committed Feb 7, 2025
1 parent 1c82ec5 commit 94fc1f9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
7 changes: 6 additions & 1 deletion resources/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
}

@layer utils {
@layer utilities {
.hide-scrollbar::-webkit-scrollbar {
display: none;
}
Expand All @@ -29,4 +29,9 @@
-ms-overflow-style: none;
scrollbar-width: none;
}

/* this is used by alpine.js to properly hide elements on load */
[x-cloak] {
@apply hidden;
}
}
42 changes: 40 additions & 2 deletions resources/views/components/modal/base.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,42 @@
<div class="modal fixed inset-0 flex justify-center overflow-y-scroll">
<div class="absolute inset-0 bg-slate-800/80 backdrop-blur-sm"></div>
@props([
'name',
'show' => false,
])

<div
x-data="{
show: @js($show),
}"
x-show="show"
x-on:open-modal.window="
if ($event.detail === '{{ $name }}') {
show = true
}
"
x-on:close-modal.window="
if ($event.detail === '{{ $name }}') {
show = false
}
"
x-init="
$watch('show', (show) => {
if (show) {
document.body.classList.add('overflow-hidden')
} else {
document.body.classList.remove('overflow-hidden')
}
})
"
x-cloak
@class([
'flex' => $show,
'hidden' => "$show",
'fixed inset-0 flex justify-center overflow-y-scroll',
])
>
<div
@click="show = false"
class="absolute inset-0 bg-slate-800/80 backdrop-blur-sm"
></div>
{{ $slot }}
</div>

0 comments on commit 94fc1f9

Please sign in to comment.