magic-pill 9.0.0 → 9.1.0

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.
Files changed (149) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +259 -15
  3. package/dist/MagicPill/MagicPill.d.mts +7 -1
  4. package/dist/MagicPill/MagicPill.d.ts +7 -1
  5. package/dist/MagicPill/MagicPill.js +40 -17
  6. package/dist/MagicPill/MagicPill.mjs +42 -19
  7. package/dist/MagicPill/choreography.js +1 -1
  8. package/dist/MagicPill/choreography.mjs +1 -1
  9. package/dist/Pill/Pill.js +53 -17
  10. package/dist/Pill/Pill.mjs +54 -18
  11. package/dist/Pill/PillContext.js +3 -1
  12. package/dist/Pill/PillContext.mjs +3 -1
  13. package/dist/Pill/PillPanel.d.mts +5 -5
  14. package/dist/Pill/PillPanel.d.ts +5 -5
  15. package/dist/Pill/PillPanel.js +28 -20
  16. package/dist/Pill/PillPanel.mjs +28 -20
  17. package/dist/Pill/morph.js +25 -7
  18. package/dist/Pill/morph.mjs +22 -8
  19. package/dist/Pill/scene.js +90 -0
  20. package/dist/Pill/scene.mjs +89 -0
  21. package/dist/Pill/themed.js +36 -0
  22. package/dist/Pill/themed.mjs +34 -0
  23. package/dist/Pill/types.d.mts +50 -0
  24. package/dist/Pill/types.d.ts +50 -0
  25. package/dist/Pill/zone.js +160 -0
  26. package/dist/Pill/zone.mjs +159 -0
  27. package/dist/PillForm/Calendar.d.mts +15 -0
  28. package/dist/PillForm/Calendar.d.ts +16 -0
  29. package/dist/PillForm/Calendar.js +371 -0
  30. package/dist/PillForm/Calendar.mjs +370 -0
  31. package/dist/PillForm/FormContext.d.mts +2 -0
  32. package/dist/PillForm/FormContext.d.ts +2 -0
  33. package/dist/PillForm/FormContext.js +8 -0
  34. package/dist/PillForm/FormContext.mjs +8 -0
  35. package/dist/PillForm/PillCheckbox.d.mts +8 -0
  36. package/dist/PillForm/PillCheckbox.d.ts +8 -0
  37. package/dist/PillForm/PillCheckbox.js +45 -0
  38. package/dist/PillForm/PillCheckbox.mjs +45 -0
  39. package/dist/PillForm/PillChoices.d.mts +39 -0
  40. package/dist/PillForm/PillChoices.d.ts +39 -0
  41. package/dist/PillForm/PillChoices.js +103 -0
  42. package/dist/PillForm/PillChoices.mjs +103 -0
  43. package/dist/PillForm/PillCode.d.mts +12 -0
  44. package/dist/PillForm/PillCode.d.ts +12 -0
  45. package/dist/PillForm/PillCode.js +60 -0
  46. package/dist/PillForm/PillCode.mjs +60 -0
  47. package/dist/PillForm/PillColor.d.mts +10 -0
  48. package/dist/PillForm/PillColor.d.ts +10 -0
  49. package/dist/PillForm/PillColor.js +56 -0
  50. package/dist/PillForm/PillColor.mjs +56 -0
  51. package/dist/PillForm/PillDate.d.mts +44 -0
  52. package/dist/PillForm/PillDate.d.ts +44 -0
  53. package/dist/PillForm/PillDate.js +193 -0
  54. package/dist/PillForm/PillDate.mjs +193 -0
  55. package/dist/PillForm/PillField.d.mts +38 -0
  56. package/dist/PillForm/PillField.d.ts +38 -0
  57. package/dist/PillForm/PillField.js +81 -0
  58. package/dist/PillForm/PillField.mjs +80 -0
  59. package/dist/PillForm/PillFields.d.mts +11 -0
  60. package/dist/PillForm/PillFields.d.ts +11 -0
  61. package/dist/PillForm/PillFields.js +21 -0
  62. package/dist/PillForm/PillFields.mjs +21 -0
  63. package/dist/PillForm/PillFile.d.mts +8 -0
  64. package/dist/PillForm/PillFile.d.ts +8 -0
  65. package/dist/PillForm/PillFile.js +55 -0
  66. package/dist/PillForm/PillFile.mjs +55 -0
  67. package/dist/PillForm/PillForm.d.mts +29 -0
  68. package/dist/PillForm/PillForm.d.ts +29 -0
  69. package/dist/PillForm/PillForm.js +66 -0
  70. package/dist/PillForm/PillForm.mjs +65 -0
  71. package/dist/PillForm/PillFormPanel.d.mts +24 -0
  72. package/dist/PillForm/PillFormPanel.d.ts +24 -0
  73. package/dist/PillForm/PillFormPanel.js +53 -0
  74. package/dist/PillForm/PillFormPanel.mjs +53 -0
  75. package/dist/PillForm/PillInput.d.mts +20 -0
  76. package/dist/PillForm/PillInput.d.ts +20 -0
  77. package/dist/PillForm/PillInput.js +84 -0
  78. package/dist/PillForm/PillInput.mjs +84 -0
  79. package/dist/PillForm/PillSelect.d.mts +23 -0
  80. package/dist/PillForm/PillSelect.d.ts +23 -0
  81. package/dist/PillForm/PillSelect.js +87 -0
  82. package/dist/PillForm/PillSelect.mjs +87 -0
  83. package/dist/PillForm/PillSlider.d.mts +17 -0
  84. package/dist/PillForm/PillSlider.d.ts +17 -0
  85. package/dist/PillForm/PillSlider.js +61 -0
  86. package/dist/PillForm/PillSlider.mjs +61 -0
  87. package/dist/PillForm/PillStepper.d.mts +13 -0
  88. package/dist/PillForm/PillStepper.d.ts +13 -0
  89. package/dist/PillForm/PillStepper.js +84 -0
  90. package/dist/PillForm/PillStepper.mjs +84 -0
  91. package/dist/PillForm/PillSubmit.d.mts +14 -0
  92. package/dist/PillForm/PillSubmit.d.ts +14 -0
  93. package/dist/PillForm/PillSubmit.js +90 -0
  94. package/dist/PillForm/PillSubmit.mjs +89 -0
  95. package/dist/PillForm/PillSwitch.d.mts +5 -0
  96. package/dist/PillForm/PillSwitch.d.ts +5 -0
  97. package/dist/PillForm/PillSwitch.js +38 -0
  98. package/dist/PillForm/PillSwitch.mjs +38 -0
  99. package/dist/PillForm/PillTextarea.d.mts +5 -0
  100. package/dist/PillForm/PillTextarea.d.ts +5 -0
  101. package/dist/PillForm/PillTextarea.js +49 -0
  102. package/dist/PillForm/PillTextarea.mjs +49 -0
  103. package/dist/PillForm/dates.d.mts +1 -0
  104. package/dist/PillForm/dates.d.ts +1 -0
  105. package/dist/PillForm/dates.js +155 -0
  106. package/dist/PillForm/dates.mjs +139 -0
  107. package/dist/PillForm/glyphs.js +65 -0
  108. package/dist/PillForm/glyphs.mjs +56 -0
  109. package/dist/PillForm/keyboard.js +34 -0
  110. package/dist/PillForm/keyboard.mjs +34 -0
  111. package/dist/PillForm/popover.js +84 -0
  112. package/dist/PillForm/popover.mjs +83 -0
  113. package/dist/PillForm/send.d.mts +6 -0
  114. package/dist/PillForm/send.d.ts +6 -0
  115. package/dist/PillForm/send.js +44 -0
  116. package/dist/PillForm/send.mjs +44 -0
  117. package/dist/PillForm/validity.js +74 -0
  118. package/dist/PillForm/validity.mjs +72 -0
  119. package/dist/PillNavbar/PillNavbar.d.mts +29 -6
  120. package/dist/PillNavbar/PillNavbar.d.ts +29 -6
  121. package/dist/PillNavbar/PillNavbar.js +35 -11
  122. package/dist/PillNavbar/PillNavbar.mjs +36 -12
  123. package/dist/PillNavbar/room.js +84 -0
  124. package/dist/PillNavbar/room.mjs +83 -0
  125. package/dist/PillNotification/PillNotification.d.mts +6 -0
  126. package/dist/PillNotification/PillNotification.d.ts +6 -0
  127. package/dist/PillNotification/PillNotification.js +3 -0
  128. package/dist/PillNotification/PillNotification.mjs +3 -0
  129. package/dist/PillOptics/PillOptics.d.mts +8 -0
  130. package/dist/PillOptics/PillOptics.d.ts +8 -0
  131. package/dist/PillOptics/PillOptics.js +195 -0
  132. package/dist/PillOptics/PillOptics.mjs +195 -0
  133. package/dist/PillOptics/adaptive.js +212 -0
  134. package/dist/PillOptics/adaptive.mjs +208 -0
  135. package/dist/PillOptics/lens.js +77 -0
  136. package/dist/PillOptics/lens.mjs +73 -0
  137. package/dist/PillOptics/light.js +37 -0
  138. package/dist/PillOptics/light.mjs +36 -0
  139. package/dist/calendar.css +499 -0
  140. package/dist/forms.css +1452 -0
  141. package/dist/index.d.mts +24 -3
  142. package/dist/index.d.ts +24 -3
  143. package/dist/index.js +36 -0
  144. package/dist/index.mjs +19 -1
  145. package/dist/styles.css +169 -19
  146. package/dist/themes.css +449 -0
  147. package/dist/utils/visuallyHidden.js +18 -0
  148. package/dist/utils/visuallyHidden.mjs +18 -0
  149. package/package.json +4 -1
@@ -0,0 +1,449 @@
1
+ /*
2
+ * Magic Pill v9 themes: glass and liquid (Liquid Glass), the material custom
3
+ * themes are built on, and the modal's glow. Optional: import it next to
4
+ * styles.css, in any order, for pills with a `theme` or a `backdrop`. Others
5
+ * don't use it.
6
+ *
7
+ * - Same rules as styles.css: everything is in the magic-pill layer (your
8
+ * unlayered CSS wins), public tokens (--mp-*) are only read, and nothing is
9
+ * loaded from the network.
10
+ * - Booleans are 1 and 0, to be used in calc().
11
+ * - Browsers without relative colours or pow() keep the plain look.
12
+ */
13
+
14
+ /* Between the look and the behaviour, even when this file is imported first */
15
+ @layer magic-pill.look, magic-pill.theme, magic-pill.forms, magic-pill.behaviour;
16
+
17
+ /* Registered so they can be transitioned */
18
+ @property --_mp-veil {
19
+ syntax: "<color>";
20
+ inherits: false;
21
+ initial-value: transparent;
22
+ }
23
+
24
+ @property --_mp-frost {
25
+ syntax: "<length>";
26
+ inherits: false;
27
+ initial-value: 0px;
28
+ }
29
+
30
+ /* Read by <PillOptics>: registered, their computed values are numbers and px */
31
+ @property --_mp-refraction {
32
+ syntax: "<number>";
33
+ inherits: false;
34
+ initial-value: 0;
35
+ }
36
+
37
+ @property --_mp-edge {
38
+ syntax: "<length>";
39
+ inherits: false;
40
+ initial-value: 0px;
41
+ }
42
+
43
+ @property --_mp-fringe {
44
+ syntax: "<number>";
45
+ inherits: false;
46
+ initial-value: 0;
47
+ }
48
+
49
+ @property --_mp-follow {
50
+ syntax: "<number>";
51
+ inherits: false;
52
+ initial-value: 0;
53
+ }
54
+
55
+ @property --_mp-adaptive {
56
+ syntax: "<number>";
57
+ inherits: false;
58
+ initial-value: 0;
59
+ }
60
+
61
+ /* How much the actions are glass too, and whether they can be given it */
62
+ @property --_mp-action-glass {
63
+ syntax: "<number>";
64
+ inherits: true;
65
+ initial-value: 0;
66
+ }
67
+
68
+ @property --_mp-action-layer {
69
+ syntax: "<number>";
70
+ inherits: false;
71
+ initial-value: 0;
72
+ }
73
+
74
+ /* The corners of what opens over the page: forms.css sets them */
75
+ @property --_mp-list-radius {
76
+ syntax: "<length>";
77
+ inherits: true;
78
+ initial-value: 0px;
79
+ }
80
+
81
+ @property --_mp-action-radius {
82
+ syntax: "<length>";
83
+ inherits: false;
84
+ initial-value: 0px;
85
+ }
86
+
87
+ /* Tinted by <PillOptics>: registered so it can be transitioned. The actions read it too */
88
+ @property --_mp-light-color {
89
+ syntax: "<color>";
90
+ inherits: true;
91
+ initial-value: white;
92
+ }
93
+
94
+ /* How much of a panel's text has scrolled into view, and how softly it ends:
95
+ all of it, for a text that doesn't scroll */
96
+ @property --_mp-seen {
97
+ syntax: "<percentage>";
98
+ inherits: false;
99
+ initial-value: 100%;
100
+ }
101
+
102
+ @property --_mp-soft {
103
+ syntax: "<length>";
104
+ inherits: false;
105
+ initial-value: 0px;
106
+ }
107
+
108
+ @property --_mp-drift {
109
+ syntax: "<angle>";
110
+ inherits: false;
111
+ initial-value: 0deg;
112
+ }
113
+
114
+ @layer magic-pill.theme {
115
+ /* The modal's glow, for any theme: two soft lights drifting around the
116
+ centre, over the backdrop's own colour and blur (styles.css) */
117
+ [data-mp="pill"][data-backdrop="glow"]:not([data-unstyled])::backdrop {
118
+ background:
119
+ radial-gradient(
120
+ 60vmax 60vmax at calc(50% + 30% * cos(var(--_mp-drift))) calc(50% + 30% * sin(var(--_mp-drift))),
121
+ var(--mp-glow-1, rgb(213 210 232 / 0.45)),
122
+ transparent 70%
123
+ ),
124
+ radial-gradient(
125
+ 50vmax 50vmax at calc(50% - 35% * cos(var(--_mp-drift))) calc(50% - 25% * sin(var(--_mp-drift))),
126
+ var(--mp-glow-2, rgb(63 114 83 / 0.4)),
127
+ transparent 70%
128
+ ),
129
+ var(--mp-backdrop, rgb(20 20 20 / 0.4));
130
+ animation: mp-drift var(--mp-glow-duration, 14s) linear infinite;
131
+
132
+ @media (prefers-reduced-motion: reduce) {
133
+ animation: none;
134
+ }
135
+
136
+ @media (prefers-reduced-transparency: reduce), (prefers-contrast: more), (forced-colors: active) {
137
+ background: var(--mp-backdrop, rgb(20 20 20 / 0.4));
138
+ animation: none;
139
+ }
140
+ }
141
+
142
+ @keyframes mp-settle {
143
+ from,
144
+ to {
145
+ -webkit-backdrop-filter: none;
146
+ backdrop-filter: none;
147
+ }
148
+ }
149
+
150
+ @keyframes mp-seen {
151
+ from {
152
+ --_mp-seen: 0%;
153
+ --_mp-soft: 4rem;
154
+ }
155
+
156
+ 90% {
157
+ --_mp-soft: 4rem;
158
+ }
159
+
160
+ to {
161
+ --_mp-seen: 100%;
162
+ --_mp-soft: 0rem;
163
+ }
164
+ }
165
+
166
+ @keyframes mp-drift {
167
+ to {
168
+ --_mp-drift: 360deg;
169
+ }
170
+ }
171
+
172
+ @supports (color: oklch(from red l c h / calc(pow(l, 2)))) {
173
+ [data-mp="pill"][data-theme]:not([data-theme="plain"], [data-unstyled]) {
174
+ /* How much of the surface's colour stays: 1 is solid. A custom theme
175
+ is, until it sets --mp-tint */
176
+ --_mp-own-tint: var(--mp-tint, 1);
177
+ --_mp-tint: var(--_mp-own-tint);
178
+ --_mp-clear: clamp(0, (1 - var(--_mp-tint)) * 1000, 1);
179
+ --_mp-rays: var(--mp-rays, var(--_mp-clear));
180
+ --_mp-own-frost: var(--mp-frost, 14px);
181
+ --_mp-frost: var(--_mp-own-frost);
182
+ --_mp-refraction: calc(var(--_mp-rays) * var(--mp-refraction, 0));
183
+ --_mp-edge: var(--mp-edge, 10px);
184
+ --_mp-fringe: var(--mp-fringe, 0);
185
+ --_mp-follow: calc(var(--_mp-rays) * var(--mp-light-follow, 0));
186
+ --_mp-adaptive: calc(var(--_mp-rays) * var(--mp-adaptive, 0));
187
+ --_mp-action-glass: calc(var(--_mp-rays) * var(--mp-action-glass, 0));
188
+ --_mp-action-layer: var(--_mp-action-glass);
189
+ --_mp-action-radius: calc(var(--_mp-action-size) / 2);
190
+ --_mp-light: calc(var(--_mp-rays) * var(--mp-light, 0.7));
191
+ --_mp-light-color: var(--mp-light-color, #fff);
192
+ --_mp-drop: 0 0.5rem 0.5rem rgb(20 20 20 / 0.45);
193
+ /* How thick the glass looks: its inner glow */
194
+ --_mp-thick: 0;
195
+ --_mp-edge-light: 0.5;
196
+ /* Where the light comes from, as a direction */
197
+ /* (--_mp-angle and --_mp-sheen-*: <PillOptics>, following the pointer) */
198
+ --_mp-toward: var(--_mp-angle, var(--mp-light-angle, 235deg));
199
+ --_mp-light-x: cos(var(--_mp-toward));
200
+ --_mp-light-y: sin(var(--_mp-toward));
201
+
202
+ /* Keeps the text readable whatever the page shows: a black veil under
203
+ light text, a white one under dark text (the surface's lightness
204
+ tells which), just strong enough for 4.5:1 over the worst page (white
205
+ or black) with the highlight on top.
206
+ pow(l, 1.364) is about the sRGB value of a grey of lightness l. A
207
+ solid surface is left alone. */
208
+ --_mp-peak: calc((0.44 - 0.1 * var(--_mp-light)) / (1 - 0.1 * var(--_mp-light)));
209
+ --_mp-veil: oklch(
210
+ from var(--_mp-surface) clamp(0, (l - 0.62) * 1000, 1) 0 0 /
211
+ calc(
212
+ var(--mp-readable, 1) * var(--_mp-clear) *
213
+ max(
214
+ 0,
215
+ clamp(0, (0.62 - l) * 1000, 1) *
216
+ (1 - var(--_mp-peak) / (1 - var(--_mp-tint) + var(--_mp-tint) * pow(l, 1.364))) +
217
+ clamp(0, (l - 0.62) * 1000, 1) * (0.53 - var(--_mp-tint) * pow(l, 1.364)) /
218
+ (1.001 - var(--_mp-tint) * pow(l, 1.364))
219
+ )
220
+ )
221
+ );
222
+
223
+ /* Joins the pill's own transitions (styles.css). The 1ms ones only tell
224
+ <PillOptics> that a token has changed: with reduced motion too */
225
+ --_mp-watch: --_mp-refraction 1ms, --_mp-edge 1ms, --_mp-fringe 1ms, --_mp-follow 1ms, --_mp-adaptive 1ms,
226
+ --_mp-action-layer 1ms, --_mp-action-radius 1ms;
227
+ --_mp-also: color var(--_mp-change) ease-in-out, --_mp-veil var(--_mp-change) ease-in-out,
228
+ --_mp-frost var(--_mp-change) ease-in-out, --_mp-light-color var(--_mp-change) ease-in-out, var(--_mp-watch),
229
+ var(--_mp-still, visibility 0s);
230
+
231
+ /* The glass, as values: it's painted by the pill itself, or by a layer
232
+ of its own (below) */
233
+ --_mp-image:
234
+ radial-gradient(
235
+ circle 13rem at var(--_mp-sheen-x, calc(50% + var(--_mp-light-x) * 45%))
236
+ var(--_mp-sheen-y, calc(50% + var(--_mp-light-y) * 160%)),
237
+ rgb(from var(--_mp-light-color) r g b / calc(0.1 * var(--_mp-light))),
238
+ transparent
239
+ ),
240
+ linear-gradient(var(--_mp-veil), var(--_mp-veil));
241
+ --_mp-fill: color-mix(in srgb, var(--_mp-surface) calc(var(--_mp-tint) * 100%), transparent);
242
+ --_mp-filter: blur(var(--_mp-frost)) saturate(calc(1 + var(--_mp-rays) * (var(--mp-vibrancy, 1.9) - 1)));
243
+ /* A rim all around, the light on the edge that faces it and through the
244
+ opposite one, then the glow inside */
245
+ --_mp-rim:
246
+ inset 0 0 0 1px
247
+ rgb(from var(--_mp-light-color) r g b / calc(var(--_mp-clear) * (0.16 - 0.06 * min(1, var(--_mp-light))))),
248
+ inset calc(var(--_mp-light-x) * -1.25px) calc(var(--_mp-light-y) * -1.25px) 0.75px -0.25px
249
+ rgb(from var(--_mp-light-color) r g b / calc(0.85 * var(--_mp-light))),
250
+ inset calc(var(--_mp-light-x) * 1.25px) calc(var(--_mp-light-y) * 1.25px) 0.75px -0.25px
251
+ rgb(from var(--_mp-light-color) r g b / calc(0.45 * var(--_mp-light))),
252
+ inset calc(var(--_mp-light-x) * -6px) calc(var(--_mp-light-y) * -6px) 10px -6px
253
+ rgb(from var(--_mp-light-color) r g b / calc(0.4 * var(--_mp-light) * var(--_mp-edge-light))),
254
+ inset 0 0 14px rgb(from var(--_mp-light-color) r g b / calc(0.16 * var(--_mp-light) * var(--_mp-thick)));
255
+ /* What opens over the page (a list, a calendar: forms.css), of the same
256
+ glass: frosted nearly as a panel is, and with a little more of the
257
+ veil, as it's all text and may lie over the pill's own */
258
+ --_mp-list-color: var(--_mp-surface);
259
+ --_mp-list-ink: var(--_mp-on-surface);
260
+ --_mp-list-veil: oklch(
261
+ from var(--_mp-surface) clamp(0, (l - 0.62) * 1000, 1) 0 0 / calc(0.08 * var(--mp-readable, 1) * var(--_mp-clear))
262
+ );
263
+ --_mp-list-glass: linear-gradient(var(--_mp-list-veil), var(--_mp-list-veil)), var(--_mp-image), var(--_mp-fill);
264
+ --_mp-list-filter: blur(max(var(--_mp-own-frost), calc(var(--mp-panel-frost, 12px) * 0.67)))
265
+ saturate(calc(1 + var(--_mp-rays) * (var(--mp-vibrancy, 1.9) - 1)));
266
+ --_mp-list-rim: var(--_mp-rim);
267
+ --_mp-list-hover: 6%;
268
+ --_mp-list-dim: 0.86;
269
+ background: var(--_mp-image), var(--_mp-fill);
270
+ -webkit-backdrop-filter: var(--_mp-filter);
271
+ /* The lens comes last: blurring after it would blur its edge */
272
+ backdrop-filter: var(--_mp-filter) var(--_mp-lens,);
273
+ box-shadow: var(--mp-shadow, var(--_mp-drop)), var(--_mp-rim);
274
+
275
+ &:is([data-theme="glass"], [data-theme="liquid"]) {
276
+ --_mp-own-tint: var(--mp-tint, 0.35);
277
+ --_mp-rays: var(--mp-rays, 1);
278
+ --_mp-refraction: calc(var(--_mp-rays) * var(--mp-refraction, 0.16));
279
+ --_mp-drop: 0 0.5rem 1.25rem rgb(20 20 20 / 0.28);
280
+ /* Actions made of the same glass, unless the app colours them. Filled
281
+ with the lightest (under dark text, the darkest) grey the text can
282
+ sit on, so they stand out without taking its contrast away */
283
+ --_mp-action: var(
284
+ --_mp-own-action,
285
+ oklch(from var(--_mp-on-surface) clamp(0.548, 0.548 + (0.62 - l) * 1000, 0.628) 0 0 / 0.3)
286
+ );
287
+ --_mp-on-action: var(--_mp-own-on-action, var(--_mp-on-surface));
288
+ --_mp-action-rim: var(--mp-action-rim, var(--_mp-own-action, rgb(from var(--_mp-on-surface) r g b / 0.2)));
289
+ --_mp-action-current: var(--mp-action-current, var(--_mp-own-action, var(--_mp-on-surface)));
290
+ --_mp-on-action-current: var(--mp-on-action-current, var(--_mp-own-on-action, var(--_mp-surface)));
291
+ }
292
+
293
+ &[data-theme="liquid"] {
294
+ --_mp-own-tint: var(--mp-tint, 0.18);
295
+ --_mp-own-frost: var(--mp-frost, 3px);
296
+ --_mp-refraction: calc(var(--_mp-rays) * var(--mp-refraction, 0.55));
297
+ --_mp-edge: var(--mp-edge, 22px);
298
+ --_mp-fringe: var(--mp-fringe, 0.15);
299
+ --_mp-thick: 1;
300
+ --_mp-edge-light: 1;
301
+ }
302
+
303
+ /* Adaptive: the light takes the hue of what's behind, and so does a
304
+ neutral pill, which turns light over light pages */
305
+ &[data-scheme] {
306
+ --_mp-light-color: color-mix(in oklab, var(--_mp-ambient) 45%, var(--mp-light-color, #fff));
307
+ }
308
+
309
+ &[data-scheme][data-variant="neutral"] {
310
+ --_mp-surface: color-mix(in oklab, var(--_mp-ambient) 14%, var(--mp-surface, #141414));
311
+ }
312
+
313
+ &[data-scheme="light"][data-variant="neutral"] {
314
+ --_mp-surface: color-mix(in oklab, var(--_mp-ambient) 14%, var(--mp-adaptive-surface, #f9f9f9));
315
+ --_mp-on-surface: var(--mp-adaptive-on-surface, #141414);
316
+
317
+ &:not([data-theme="glass"], [data-theme="liquid"]) {
318
+ --_mp-action: var(--_mp-own-action, var(--_mp-on-surface));
319
+ --_mp-on-action: var(--_mp-own-on-action, var(--_mp-surface));
320
+ }
321
+ }
322
+
323
+ /* A status must still read as one */
324
+ &:is([data-variant="success"], [data-variant="danger"]) {
325
+ --_mp-tint: max(var(--_mp-own-tint), var(--mp-status-tint, 0.75));
326
+ }
327
+
328
+ /* More text, more frosting, readable or not */
329
+ &[data-presence="panel"] {
330
+ --_mp-frost: max(var(--_mp-own-frost), var(--mp-panel-frost, 12px));
331
+ }
332
+
333
+ /* Glass actions (--mp-action-glass): the light on their own edges… */
334
+ & [data-mp="action-body"] {
335
+ --_mp-shine: calc(var(--_mp-light) * var(--_mp-action-glass));
336
+ box-shadow:
337
+ inset 0 0 0 1px var(--_mp-action-rim),
338
+ inset calc(var(--_mp-light-x) * -1px) calc(var(--_mp-light-y) * -1px) 0.75px -0.25px
339
+ rgb(from var(--_mp-light-color) r g b / calc(0.75 * var(--_mp-shine))),
340
+ inset calc(var(--_mp-light-x) * 1px) calc(var(--_mp-light-y) * 1px) 0.75px -0.25px
341
+ rgb(from var(--_mp-light-color) r g b / calc(0.4 * var(--_mp-shine))),
342
+ inset 0 0 8px rgb(from var(--_mp-light-color) r g b / calc(0.14 * var(--_mp-shine) * var(--_mp-thick)));
343
+ }
344
+
345
+ /* …then the rest, with <PillOptics>. Nothing in a pill can see through
346
+ it while it has a backdrop-filter of its own (it would only see the
347
+ pill's tint), so the pill's glass moves to a layer under its content.
348
+ Not while a panel is open: the layer would scroll away with it */
349
+ &[data-actions="glass"] {
350
+ /* The fill goes from one to the other at once, or it would show twice */
351
+ --_mp-still: background-color 0s;
352
+
353
+ &:not([data-presence="panel"]) {
354
+ background: none;
355
+ -webkit-backdrop-filter: none;
356
+ backdrop-filter: none;
357
+ box-shadow: var(--mp-shadow, var(--_mp-drop));
358
+
359
+ &::before {
360
+ content: "";
361
+ position: absolute;
362
+ z-index: -1;
363
+ inset: 0;
364
+ border-radius: inherit;
365
+ background: var(--_mp-image), var(--_mp-fill);
366
+ -webkit-backdrop-filter: var(--_mp-filter);
367
+ backdrop-filter: var(--_mp-filter) var(--_mp-lens,);
368
+ box-shadow: var(--_mp-rim);
369
+ pointer-events: none;
370
+ transition: background-color var(--_mp-change) ease-in-out;
371
+ }
372
+ }
373
+
374
+ /* A fading parent hides the page from them too (they'd turn black),
375
+ so they wait for the content to have faded in */
376
+ &:is([data-presence="compact"], [data-presence="expanded"]) [data-mp="action-body"] {
377
+ --_mp-action-filter: blur(calc(var(--_mp-own-frost) * 0.35));
378
+ -webkit-backdrop-filter: var(--_mp-action-filter);
379
+ backdrop-filter: var(--_mp-action-filter) var(--_mp-action-lens,);
380
+ animation: mp-settle calc(var(--_mp-change) + var(--_mp-fade));
381
+ }
382
+ }
383
+
384
+ /* The panel's text can't fade into a see-through surface. It's masked
385
+ instead, down to the footer, as it scrolls */
386
+ @supports (animation-timeline: view()) {
387
+ & [data-mp="panel-footer"]::before {
388
+ content: none;
389
+ }
390
+
391
+ & [data-mp="panel-body"] {
392
+ mask-image: linear-gradient(#000 calc(var(--_mp-seen) - var(--_mp-soft)), transparent var(--_mp-seen));
393
+ animation: mp-seen linear both;
394
+ animation-timeline: view(block 0px calc(var(--_mp-action-size) + var(--_mp-gap)));
395
+ animation-range: entry-crossing 0% entry-crossing 100%;
396
+ }
397
+ }
398
+
399
+ /* Elsewhere, the footer covers it */
400
+ @supports not (animation-timeline: view()) {
401
+ & [data-mp="panel-footer"] {
402
+ &::before {
403
+ inset: 0 calc(var(--_mp-padding) * -2.5) calc(var(--_mp-padding) * -2.5);
404
+ background: color-mix(in srgb, var(--_mp-surface) calc(max(0.5, var(--_mp-tint)) * 100%), transparent);
405
+ -webkit-backdrop-filter: blur(8px);
406
+ backdrop-filter: blur(8px);
407
+ -webkit-mask: linear-gradient(transparent, #000 40%);
408
+ mask: linear-gradient(transparent, #000 40%);
409
+ }
410
+
411
+ & [data-mp="action-body"] {
412
+ -webkit-backdrop-filter: blur(8px);
413
+ backdrop-filter: blur(8px);
414
+ }
415
+ }
416
+ }
417
+ }
418
+
419
+ /* Nothing moves by itself with reduced motion: the light stays put. And
420
+ pills fade, which would hide the page from the actions' glass */
421
+ @media (prefers-reduced-motion: reduce) {
422
+ [data-mp="pill"][data-theme]:not([data-theme="plain"], [data-unstyled]) {
423
+ --_mp-follow: 0;
424
+ --_mp-action-layer: 0;
425
+ }
426
+ }
427
+
428
+ /* Preferences: solid surfaces and solid actions, as in the plain look */
429
+ @media (prefers-reduced-transparency: reduce), (prefers-contrast: more), (forced-colors: active) {
430
+ [data-mp="pill"][data-theme]:not([data-theme="plain"], [data-unstyled]) {
431
+ &,
432
+ &[data-variant] {
433
+ --_mp-tint: 1;
434
+ --_mp-rays: 0;
435
+ --_mp-filter: none;
436
+ --_mp-list-filter: none;
437
+ }
438
+
439
+ &:is([data-theme="glass"], [data-theme="liquid"]) {
440
+ --_mp-action: var(--_mp-own-action, #f9f9f9);
441
+ --_mp-on-action: var(--_mp-own-on-action, #141414);
442
+ --_mp-action-rim: var(--mp-action-rim, transparent);
443
+ --_mp-action-current: var(--mp-action-current, var(--_mp-action));
444
+ --_mp-on-action-current: var(--mp-on-action-current, var(--_mp-on-action));
445
+ }
446
+ }
447
+ }
448
+ }
449
+ }
@@ -0,0 +1,18 @@
1
+ // src/utils/visuallyHidden.ts
2
+ /**
3
+ * Readable by screen readers, invisible on screen. Inline, so it's independent
4
+ * of the stylesheets: it must work for unstyled pills too.
5
+ */
6
+ const VISUALLY_HIDDEN = {
7
+ position: "absolute",
8
+ width: 1,
9
+ height: 1,
10
+ margin: -1,
11
+ padding: 0,
12
+ overflow: "hidden",
13
+ clip: "rect(0 0 0 0)",
14
+ whiteSpace: "nowrap",
15
+ border: 0
16
+ };
17
+
18
+ exports.VISUALLY_HIDDEN = VISUALLY_HIDDEN;
@@ -0,0 +1,18 @@
1
+ // src/utils/visuallyHidden.ts
2
+ /**
3
+ * Readable by screen readers, invisible on screen. Inline, so it's independent
4
+ * of the stylesheets: it must work for unstyled pills too.
5
+ */
6
+ const VISUALLY_HIDDEN = {
7
+ position: "absolute",
8
+ width: 1,
9
+ height: 1,
10
+ margin: -1,
11
+ padding: 0,
12
+ overflow: "hidden",
13
+ clip: "rect(0 0 0 0)",
14
+ whiteSpace: "nowrap",
15
+ border: 0
16
+ };
17
+
18
+ export { VISUALLY_HIDDEN };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-pill",
3
- "version": "9.0.0",
3
+ "version": "9.1.0",
4
4
  "type": "commonjs",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -17,6 +17,9 @@
17
17
  }
18
18
  },
19
19
  "./styles.css": "./dist/styles.css",
20
+ "./themes.css": "./dist/themes.css",
21
+ "./forms.css": "./dist/forms.css",
22
+ "./calendar.css": "./dist/calendar.css",
20
23
  "./magicpill.css": "./dist/styles.css",
21
24
  "./dist/magicpill.css": "./dist/styles.css",
22
25
  "./package.json": "./package.json"