@duskmoon-dev/core 1.20.0 → 1.20.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,33 +5,39 @@ export const css = `/**
5
5
  */
6
6
 
7
7
  @layer components {
8
- /* Modal Container */
9
- .modal {
8
+ /* Native HTML dialog owns visibility and modal behavior. */
9
+ dialog.modal {
10
10
  position: fixed;
11
11
  inset: 0;
12
- z-index: 999;
13
- display: flex;
14
- align-items: center;
15
- justify-content: center;
16
- padding: 1rem;
17
- visibility: hidden;
12
+ margin: auto;
13
+ padding: 0;
14
+ border: none;
15
+ width: calc(100% - 2rem);
16
+ max-width: 32rem;
17
+ max-height: calc(100dvh - 2rem);
18
+ box-sizing: border-box;
19
+ background-color: transparent;
20
+ color: var(--color-on-surface);
21
+ border-radius: var(--radius-lg);
22
+ overflow: visible;
18
23
  opacity: 0;
19
- transition: visibility 200ms ease-out, opacity 200ms ease-out;
24
+ transition: opacity 200ms ease-out, display 200ms allow-discrete, overlay 200ms allow-discrete;
20
25
  }
21
26
 
22
- /* Modal Open State */
23
- .modal.modal-open,
24
- .modal:target {
25
- visibility: visible;
27
+ dialog.modal[open] {
26
28
  opacity: 1;
27
29
  }
28
30
 
31
+ dialog.modal:not([open]) {
32
+ display: none;
33
+ }
34
+
29
35
  /* Modal Box */
30
36
  .modal-box {
31
37
  position: relative;
32
- z-index: 1;
33
- max-width: 32rem;
34
- max-height: calc(100dvh - 5rem);
38
+ width: 100%;
39
+ box-sizing: border-box;
40
+ max-height: calc(100dvh - 2rem);
35
41
  padding: 1.5rem;
36
42
  background-color: var(--color-surface);
37
43
  color: var(--color-on-surface);
@@ -42,24 +48,19 @@ export const css = `/**
42
48
  transition: transform 200ms ease-out;
43
49
  }
44
50
 
45
- .modal.modal-open .modal-box,
46
- .modal:target .modal-box {
51
+ dialog.modal[open] .modal-box {
47
52
  transform: scale(1);
48
53
  }
49
54
 
50
- /* Modal Backdrop */
51
- .modal-backdrop {
52
- position: fixed;
53
- inset: 0;
54
- z-index: -1;
55
+ /* The browser renders the backdrop in the top layer. */
56
+ dialog.modal::backdrop {
55
57
  background-color: color-mix(in srgb, var(--color-scrim) 50%, transparent);
56
- cursor: pointer;
58
+ opacity: 0;
59
+ transition: opacity 200ms ease-out, display 200ms allow-discrete, overlay 200ms allow-discrete;
57
60
  }
58
61
 
59
- .modal-backdrop::before {
60
- content: '';
61
- position: absolute;
62
- inset: 0;
62
+ dialog.modal[open]::backdrop {
63
+ opacity: 1;
63
64
  }
64
65
 
65
66
  /* Modal Action */
@@ -73,61 +74,47 @@ export const css = `/**
73
74
  padding-top: 1rem;
74
75
  }
75
76
 
76
- /* Modal Toggle (CSS-only) */
77
- .modal-toggle {
78
- position: fixed;
79
- width: 0;
80
- height: 0;
81
- appearance: none;
82
- opacity: 0;
83
- }
84
-
85
- .modal-toggle:checked + .modal {
86
- visibility: visible;
87
- opacity: 1;
88
- }
89
-
90
- .modal-toggle:checked + .modal .modal-box {
91
- transform: scale(1);
92
- }
93
-
94
77
  /* Modal Sizes */
95
- .modal-sm .modal-box {
78
+ dialog.modal.modal-sm {
96
79
  max-width: 20rem;
97
80
  }
98
81
 
99
- .modal-md .modal-box {
82
+ dialog.modal.modal-md {
100
83
  max-width: 32rem;
101
84
  }
102
85
 
103
- .modal-lg .modal-box {
86
+ dialog.modal.modal-lg {
104
87
  max-width: 48rem;
105
88
  }
106
89
 
107
- .modal-xl .modal-box {
90
+ dialog.modal.modal-xl {
108
91
  max-width: 64rem;
109
92
  }
110
93
 
111
- .modal-full .modal-box {
94
+ dialog.modal.modal-full {
112
95
  max-width: calc(100vw - 2rem);
113
- max-height: calc(100vh - 2rem);
114
- width: 100%;
96
+ max-height: calc(100dvh - 2rem);
97
+ width: calc(100% - 2rem);
98
+ height: calc(100dvh - 2rem);
99
+ }
100
+
101
+ dialog.modal.modal-full .modal-box {
115
102
  height: 100%;
116
103
  }
117
104
 
118
105
  /* Modal Positions */
119
- .modal-top {
120
- align-items: flex-start;
121
- padding-top: 2rem;
106
+ dialog.modal.modal-top {
107
+ margin-top: 2rem;
108
+ margin-bottom: auto;
122
109
  }
123
110
 
124
- .modal-bottom {
125
- align-items: flex-end;
126
- padding-bottom: 2rem;
111
+ dialog.modal.modal-bottom {
112
+ margin-top: auto;
113
+ margin-bottom: 2rem;
127
114
  }
128
115
 
129
- .modal-middle {
130
- align-items: center;
116
+ dialog.modal.modal-middle {
117
+ margin: auto;
131
118
  }
132
119
 
133
120
  /* Animation Variants */
@@ -143,22 +130,21 @@ export const css = `/**
143
130
  transform: scale(0.75);
144
131
  }
145
132
 
146
- :is(.modal-slide-up, .modal-slide-down, .modal-zoom).modal-open .modal-box,
147
- :is(.modal-slide-up, .modal-slide-down, .modal-zoom):target .modal-box {
133
+ dialog.modal:is(.modal-slide-up, .modal-slide-down, .modal-zoom)[open] .modal-box {
148
134
  transform: translateY(0) scale(1);
149
135
  }
150
136
 
151
137
  /* Backdrop Variants */
152
- .modal-backdrop-light {
138
+ dialog.modal.modal-backdrop-light::backdrop {
153
139
  background-color: color-mix(in srgb, white 80%, transparent);
154
140
  }
155
141
 
156
- .modal-backdrop-blur {
142
+ dialog.modal.modal-backdrop-blur::backdrop {
157
143
  background-color: color-mix(in srgb, var(--color-scrim) 30%, transparent);
158
144
  backdrop-filter: blur(8px);
159
145
  }
160
146
 
161
- .modal-no-backdrop {
147
+ dialog.modal.modal-no-backdrop::backdrop {
162
148
  background-color: transparent;
163
149
  }
164
150
 
@@ -228,55 +214,50 @@ export const css = `/**
228
214
 
229
215
  /* Responsive Modal */
230
216
  @media (max-width: 640px) {
231
- .modal-box {
232
- max-width: calc(100vw - 2rem);
233
- margin: 1rem;
234
- }
235
-
236
- .modal-responsive {
237
- align-items: flex-end;
238
- padding: 0;
217
+ dialog.modal.modal-responsive {
218
+ width: 100%;
219
+ max-width: 100%;
220
+ max-height: 90dvh;
221
+ margin: auto 0 0;
222
+ border-radius: var(--radius-lg) var(--radius-lg) 0 0;
239
223
  }
240
224
 
241
225
  .modal-responsive .modal-box {
242
- max-width: 100%;
243
226
  max-height: 90dvh;
244
- margin: 0;
245
227
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
246
228
  }
247
229
  }
248
230
 
249
231
  /* Drawer Modal */
250
- .drawer-modal {
251
- align-items: stretch;
252
- justify-content: flex-end;
253
- padding: 0;
232
+ dialog.modal.drawer-modal {
233
+ width: min(20rem, 100%);
234
+ max-width: 20rem;
235
+ max-height: 100dvh;
236
+ height: 100dvh;
237
+ margin: 0 0 0 auto;
238
+ border-radius: 0;
254
239
  }
255
240
 
256
241
  .drawer-modal .modal-box {
257
- max-width: 20rem;
258
242
  max-height: 100dvh;
259
243
  height: 100%;
260
- margin: 0;
261
244
  border-radius: 0;
262
245
  transform: translateX(100%);
263
246
  }
264
247
 
265
- .drawer-modal.modal-open .modal-box,
266
- .drawer-modal:target .modal-box {
248
+ dialog.modal.drawer-modal[open] .modal-box {
267
249
  transform: translateX(0);
268
250
  }
269
251
 
270
- .drawer-modal-left {
271
- justify-content: flex-start;
252
+ dialog.modal.drawer-modal-left {
253
+ margin: 0 auto 0 0;
272
254
  }
273
255
 
274
256
  .drawer-modal-left .modal-box {
275
257
  transform: translateX(-100%);
276
258
  }
277
259
 
278
- .drawer-modal-left.modal-open .modal-box,
279
- .drawer-modal-left:target .modal-box {
260
+ dialog.modal.drawer-modal-left[open] .modal-box {
280
261
  transform: translateX(0);
281
262
  }
282
263
 
@@ -285,7 +266,7 @@ export const css = `/**
285
266
  text-align: center;
286
267
  }
287
268
 
288
- .alert-dialog .modal-box {
269
+ dialog.modal.alert-dialog {
289
270
  max-width: 24rem;
290
271
  }
291
272
 
@@ -324,32 +305,45 @@ export const css = `/**
324
305
  justify-content: center;
325
306
  }
326
307
 
327
- /* Reduce Motion */
328
- @media (prefers-reduced-motion: reduce) {
329
- .modal {
330
- transition: visibility 0ms, opacity 0ms;
308
+ /* Entry styles retain motion without changing native visibility. */
309
+ @starting-style {
310
+ dialog.modal[open],
311
+ dialog.modal[open]::backdrop {
312
+ opacity: 0;
331
313
  }
332
314
 
333
- .modal-box {
334
- transition: transform 0ms;
315
+ dialog.modal[open] .modal-box {
316
+ transform: scale(0.95);
335
317
  }
336
- }
337
318
 
338
- /* Focus Trap Helper */
339
- .modal-focus-trap {
340
- position: absolute;
341
- width: 1px;
342
- height: 1px;
343
- padding: 0;
344
- margin: -1px;
345
- overflow: hidden;
346
- clip: rect(0, 0, 0, 0);
347
- white-space: nowrap;
348
- border: 0;
319
+ dialog.modal.modal-slide-up[open] .modal-box {
320
+ transform: translateY(6rem) scale(0.95);
321
+ }
322
+
323
+ dialog.modal.modal-slide-down[open] .modal-box {
324
+ transform: translateY(-6rem) scale(0.95);
325
+ }
326
+
327
+ dialog.modal.modal-zoom[open] .modal-box {
328
+ transform: scale(0.75);
329
+ }
330
+
331
+ dialog.modal.drawer-modal[open] .modal-box {
332
+ transform: translateX(100%);
333
+ }
334
+
335
+ dialog.modal.drawer-modal-left[open] .modal-box {
336
+ transform: translateX(-100%);
337
+ }
349
338
  }
350
339
 
351
- body.modal-open {
352
- overflow: hidden;
340
+ /* Reduce Motion */
341
+ @media (prefers-reduced-motion: reduce) {
342
+ dialog.modal,
343
+ dialog.modal::backdrop,
344
+ .modal-box {
345
+ transition: none;
346
+ }
353
347
  }
354
348
  }
355
349
  `;