Skip to content

Commit 2b79fe3

Browse files
authored
refactor: update js modal customisation & design (#591)
1 parent 2038f50 commit 2b79fe3

File tree

2 files changed

+33
-18
lines changed

2 files changed

+33
-18
lines changed

resources/assets/css/_components.css

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,6 @@
219219
.modal-content {
220220
max-width: 100% !important;
221221
}
222-
223-
.modal-content-wrapper {
224-
max-width: 100% !important;
225-
}
226222
}
227223

228224
@screen md {

resources/views/js-modal.blade.php

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'init' => false,
33
'xData' => '{}',
44
'class' => '',
5-
'widthClass' => 'max-w-2xl',
5+
'widthClass' => 'max-w-full md:max-w-2xl',
66
'contentClass' => null,
77
'title' => null,
88
'titleClass' => 'inline-block pb-3 font-bold dark:text-theme-secondary-200',
@@ -15,21 +15,32 @@
1515
'backdrop' => null,
1616
'square' => false,
1717
'hideCross' => false,
18+
'padding' => 'p-8 sm:p-10',
19+
'breakpoint' => 'md',
20+
'closeButtonClass' => 'absolute top-0 right-0 p-0 mt-0 mr-0 w-11 h-11 rounded-none sm:mt-6 sm:mr-6 sm:rounded button button-secondary text-theme-secondary-900',
1821
])
1922

23+
@php
24+
$contentWrapperBreakpointClass = [
25+
'sm' => 'sm:m-auto',
26+
'md' => 'md:m-auto',
27+
][$breakpoint] ?? 'md:m-auto';
28+
@endphp
29+
2030
<div
2131
{{ $attributes }}
2232
x-ref="modal"
2333
data-modal="{{ $name }}"
2434
x-cloak
2535
@if($init)
26-
x-data="Modal.alpine({{ $xData }}, '{{ $name }}')"
36+
x-data="Modal.alpine({{ $xData }}, '{{ $name }}')"
2737
@else
28-
x-data="{{ $xData }}"
38+
x-data="{{ $xData }}"
2939
@endif
40+
3041
@if(!$closeButtonOnly && $escToClose)
31-
@keydown.escape="hide"
32-
tabindex="0"
42+
@keydown.escape="hide"
43+
tabindex="0"
3344
@endif
3445
x-show="shown"
3546
class="flex overflow-y-auto fixed inset-0 z-50 md:py-10 md:px-8"
@@ -41,9 +52,14 @@ class="flex overflow-y-auto fixed inset-0 z-50 md:py-10 md:px-8"
4152
@endif
4253

4354
<div
44-
class="modal-content-wrapper md:m-auto w-full {{ $class }} {{ $widthClass }}"
55+
@class([
56+
'w-full',
57+
$class,
58+
$widthClass,
59+
$contentWrapperBreakpointClass,
60+
])"
4561
@if(! $closeButtonOnly && ! $disableOutsideClick)
46-
@click.outside="hide"
62+
@click.outside="hide"
4763
@endif
4864
>
4965
<div @class([
@@ -53,14 +69,17 @@ class="modal-content-wrapper md:m-auto w-full {{ $class }} {{ $widthClass }}"
5369
$widthClass,
5470
$contentClass,
5571
])>
56-
<div class="p-8 sm:p-10">
72+
<div @class($padding)>
5773
@if(! $closeButtonOnly && ! $hideCross)
58-
<button
59-
class="modal-close"
60-
@click="hide"
61-
>
62-
<x-ark-icon name="cross" size="sm" class="m-auto" />
63-
</button>
74+
<button
75+
@class([
76+
'transition-default',
77+
$closeButtonClass,
78+
])
79+
@click="hide"
80+
>
81+
<x-ark-icon name="cross" size="sm" class="m-auto" />
82+
</button>
6483
@endif
6584
6685
@if ($title)

0 commit comments

Comments
 (0)