glasslikeui 1.7.0 → 1.8.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.
- package/README.md +236 -5
- package/dist/actions/dragSnapMath.js +4 -3
- package/dist/actions/focusRingFit.d.ts +22 -0
- package/dist/actions/focusRingFit.js +115 -0
- package/dist/actions/focusTrap.js +24 -4
- package/dist/actions/viewTransition.d.ts +2 -1
- package/dist/actions/viewTransition.js +4 -2
- package/dist/components/glass/Glass.svelte +56 -0
- package/dist/components/glass/GlassMorph.svelte +21 -0
- package/dist/components/glass/Sheet.svelte +19 -4
- package/dist/components/interactive/Badge.svelte +2 -1
- package/dist/components/interactive/Button.svelte +164 -18
- package/dist/components/interactive/IconButton.svelte +23 -1
- package/dist/components/interactive/TabView.svelte +24 -1
- package/dist/components/interactive/Toggle.svelte +22 -4
- package/dist/components/layout/ScrollView.svelte +6 -0
- package/dist/components/list/ListRow.svelte +13 -0
- package/dist/components/menu/Menu.svelte +23 -0
- package/dist/components/menu/MenuItem.svelte +15 -2
- package/dist/components/navigation/NavigationLink.svelte +38 -2
- package/dist/components/typography/Text.svelte +2 -2
- package/dist/styles/glasslikeui.css +116 -19
- package/dist/styles/lens.css +36 -0
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import { fitFocusRing } from '../../actions/focusRingFit';
|
|
3
4
|
|
|
4
5
|
interface Props {
|
|
5
6
|
children: Snippet;
|
|
@@ -16,7 +17,9 @@
|
|
|
16
17
|
}: Props = $props();
|
|
17
18
|
</script>
|
|
18
19
|
|
|
19
|
-
<a {href} class="navigation-link {className}" class:active aria-current={active ? 'page' : undefined}
|
|
20
|
+
<a {href} class="navigation-link {className}" class:active aria-current={active ? 'page' : undefined}
|
|
21
|
+
{@attach fitFocusRing}
|
|
22
|
+
>
|
|
20
23
|
{@render children()}
|
|
21
24
|
</a>
|
|
22
25
|
|
|
@@ -35,11 +38,44 @@
|
|
|
35
38
|
z-index: 1;
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
/* Shared focus ring. :where keeps it at zero specificity, so a page's own
|
|
42
|
+
focus rules win. */
|
|
43
|
+
:where(.navigation-link:focus-visible) {
|
|
44
|
+
outline: var(--glass-focus-ring-width, 2px) solid var(--glass-focus-ring-color, var(--glass-focus-ring-color-default, #9ecbff));
|
|
45
|
+
outline-offset: var(--glass-focus-ring-offset, 2px);
|
|
46
|
+
box-shadow: 0 0 0 var(--glass-focus-ring-offset, 2px) var(--glass-focus-ring-halo-color, var(--glass-focus-ring-halo-color-default, #000000));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* The same ring moved inside, for a part flush in a container that would clip
|
|
50
|
+
it (see focusRingFit). The label colour stands out on the part's own fill. */
|
|
51
|
+
:where(.navigation-link:global([data-focus-ring='inset']):focus-visible) {
|
|
52
|
+
outline-color: var(--glass-focus-ring-color, currentColor);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* A page's own :focus-visible rule must not push the ring back out, where
|
|
56
|
+
the container cuts it off. Only the offset outranks it. */
|
|
57
|
+
.navigation-link:global([data-focus-ring='inset']):where(:focus-visible) {
|
|
58
|
+
outline-offset: calc(-2 * var(--glass-focus-ring-width, 2px));
|
|
59
|
+
}
|
|
60
|
+
|
|
38
61
|
.navigation-link:hover {
|
|
39
62
|
color: var(--color-text);
|
|
40
63
|
}
|
|
41
64
|
|
|
65
|
+
/* The active link has a fill of its own, as a filled Button does, so its label
|
|
66
|
+
holds 4.5:1 over any page or bar behind it. */
|
|
42
67
|
.navigation-link.active {
|
|
43
|
-
|
|
68
|
+
background: var(--color-accent);
|
|
69
|
+
color: var(--color-on-accent, white);
|
|
70
|
+
transition: color var(--transition-spring), background-color var(--transition-spring);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.navigation-link.active:hover {
|
|
74
|
+
background: var(--color-accent-hover);
|
|
75
|
+
color: var(--color-on-accent, white);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.navigation-link.active:active {
|
|
79
|
+
background: var(--color-accent-active);
|
|
44
80
|
}
|
|
45
81
|
</style>
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
primary: 'var(--color-text)',
|
|
49
49
|
secondary: 'var(--color-text-secondary)',
|
|
50
50
|
tertiary: 'var(--color-text-tertiary)',
|
|
51
|
-
accent: 'var(--color-accent)',
|
|
51
|
+
accent: 'var(--color-accent-text, color-mix(in srgb, var(--color-accent) var(--glass-accent-text-strength, 33%), var(--glass-text-toward, white)))',
|
|
52
52
|
white: '#ffffff',
|
|
53
|
-
danger: 'var(--color-danger, #
|
|
53
|
+
danger: 'var(--color-danger-text, color-mix(in srgb, var(--color-danger, #d23c3c) var(--glass-danger-text-strength, 30%), var(--glass-text-toward, white)))'
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
const alignmentMap = {
|
|
@@ -48,8 +48,20 @@
|
|
|
48
48
|
--glass-sheet-bg: rgba(28, 28, 30, 0.80);
|
|
49
49
|
--glass-backdrop-blur: 4px;
|
|
50
50
|
|
|
51
|
+
/* Keyboard focus ring, shared by every interactive part. Set
|
|
52
|
+
--glass-focus-ring-color, --glass-focus-ring-width and
|
|
53
|
+
--glass-focus-ring-offset on any element to restyle the rings inside it.
|
|
54
|
+
They are left unset here so a value set anywhere wins in both themes;
|
|
55
|
+
these are the colours used until then.
|
|
56
|
+
The ring has two tones so that it holds 3:1 against any backdrop: the
|
|
57
|
+
outline, and a halo against it on the inside, set with
|
|
58
|
+
--glass-focus-ring-halo-color. Keep the two at least 9:1 apart. */
|
|
59
|
+
--glass-focus-ring-color-default: #9ecbff;
|
|
60
|
+
--glass-focus-ring-halo-color-default: #000000;
|
|
61
|
+
|
|
51
62
|
/* Sheet close button focus ring. The inner ring hugs the button and the
|
|
52
|
-
outer ring sits against the sheet. Override to rebrand.
|
|
63
|
+
outer ring sits against the sheet. Override to rebrand.
|
|
64
|
+
--glass-focus-ring-color, when set, replaces the outer tone. */
|
|
53
65
|
--sheet-focus-ring-inner: #ffffff;
|
|
54
66
|
--sheet-focus-ring-outer: #3b8eea;
|
|
55
67
|
|
|
@@ -57,18 +69,30 @@
|
|
|
57
69
|
Accent system
|
|
58
70
|
======================================== */
|
|
59
71
|
--color-accent: #0071e3;
|
|
60
|
-
--color-accent-hover: color-mix(in srgb, var(--color-accent)
|
|
72
|
+
--color-accent-hover: color-mix(in srgb, var(--color-accent) 92%, black);
|
|
61
73
|
--color-accent-active: color-mix(in srgb, var(--color-accent) 85%, black);
|
|
62
74
|
--color-accent-10: color-mix(in srgb, var(--color-accent) 10%, transparent);
|
|
63
75
|
--color-accent-15: color-mix(in srgb, var(--color-accent) 15%, transparent);
|
|
64
76
|
--color-accent-25: color-mix(in srgb, var(--color-accent) 25%, transparent);
|
|
65
77
|
--color-accent-50: color-mix(in srgb, var(--color-accent) 50%, transparent);
|
|
66
78
|
|
|
67
|
-
/* Semantic danger — adapts to light/dark via color-mix
|
|
68
|
-
|
|
69
|
-
--color-danger
|
|
79
|
+
/* Semantic danger — adapts to light/dark via color-mix. The default is the
|
|
80
|
+
lightest red a white label holds 4.5:1 on. */
|
|
81
|
+
--color-danger: #d23c3c;
|
|
82
|
+
--color-danger-hover: color-mix(in srgb, var(--color-danger) 92%, black);
|
|
70
83
|
--color-danger-active: color-mix(in srgb, var(--color-danger) 85%, black);
|
|
71
84
|
|
|
85
|
+
/* Text in the accent or danger colour, as in an outlined Button or a
|
|
86
|
+
destructive MenuItem, is the colour mixed toward white in the dark theme and
|
|
87
|
+
toward black in the light one, so that it holds 4.5:1 on the theme's own
|
|
88
|
+
surfaces. Each part works it out from its own --color-accent or
|
|
89
|
+
--color-danger. Set --color-accent-text, --color-accent-text-hover or
|
|
90
|
+
--color-danger-text to use a colour of your own instead. */
|
|
91
|
+
--glass-accent-text-strength: 33%;
|
|
92
|
+
--glass-accent-text-strength-hover: 26%;
|
|
93
|
+
--glass-danger-text-strength: 30%;
|
|
94
|
+
--glass-text-toward: white;
|
|
95
|
+
|
|
72
96
|
/* ========================================
|
|
73
97
|
Radius system
|
|
74
98
|
======================================== */
|
|
@@ -105,6 +129,37 @@
|
|
|
105
129
|
/* Typography tokens are defined in styles/typography.css. */
|
|
106
130
|
}
|
|
107
131
|
|
|
132
|
+
/* ========================================
|
|
133
|
+
Shades for a scope with its own colours
|
|
134
|
+
The shades above are worked out on :root, so a wrapper that sets
|
|
135
|
+
--color-accent or --color-danger would inherit the root's. They are worked
|
|
136
|
+
out again for a wrapper that sets either inline, and for one marked
|
|
137
|
+
.glass-accent-scope, which a colour set from a stylesheet needs: CSS cannot
|
|
138
|
+
find it unmarked. :where adds no specificity, so a shade you set wins.
|
|
139
|
+
======================================== */
|
|
140
|
+
:where(.glass-accent-scope) {
|
|
141
|
+
--color-accent-hover: color-mix(in srgb, var(--color-accent) 92%, black);
|
|
142
|
+
--color-accent-active: color-mix(in srgb, var(--color-accent) 85%, black);
|
|
143
|
+
--color-accent-10: color-mix(in srgb, var(--color-accent) 10%, transparent);
|
|
144
|
+
--color-accent-15: color-mix(in srgb, var(--color-accent) 15%, transparent);
|
|
145
|
+
--color-accent-25: color-mix(in srgb, var(--color-accent) 25%, transparent);
|
|
146
|
+
--color-accent-50: color-mix(in srgb, var(--color-accent) 50%, transparent);
|
|
147
|
+
--color-danger-hover: color-mix(in srgb, var(--color-danger) 92%, black);
|
|
148
|
+
--color-danger-active: color-mix(in srgb, var(--color-danger) 85%, black);
|
|
149
|
+
}
|
|
150
|
+
:where([style*='--color-accent:']) {
|
|
151
|
+
--color-accent-hover: color-mix(in srgb, var(--color-accent) 92%, black);
|
|
152
|
+
--color-accent-active: color-mix(in srgb, var(--color-accent) 85%, black);
|
|
153
|
+
--color-accent-10: color-mix(in srgb, var(--color-accent) 10%, transparent);
|
|
154
|
+
--color-accent-15: color-mix(in srgb, var(--color-accent) 15%, transparent);
|
|
155
|
+
--color-accent-25: color-mix(in srgb, var(--color-accent) 25%, transparent);
|
|
156
|
+
--color-accent-50: color-mix(in srgb, var(--color-accent) 50%, transparent);
|
|
157
|
+
}
|
|
158
|
+
:where([style*='--color-danger:']) {
|
|
159
|
+
--color-danger-hover: color-mix(in srgb, var(--color-danger) 92%, black);
|
|
160
|
+
--color-danger-active: color-mix(in srgb, var(--color-danger) 85%, black);
|
|
161
|
+
}
|
|
162
|
+
|
|
108
163
|
/* ========================================
|
|
109
164
|
Light mode overrides
|
|
110
165
|
======================================== */
|
|
@@ -131,6 +186,14 @@
|
|
|
131
186
|
--glass-nav-bg: rgba(255, 255, 255, 0.85);
|
|
132
187
|
--glass-sheet-bg: rgba(255, 255, 255, 0.88);
|
|
133
188
|
|
|
189
|
+
--glass-accent-text-strength: 72%;
|
|
190
|
+
--glass-accent-text-strength-hover: 62%;
|
|
191
|
+
--glass-danger-text-strength: 78%;
|
|
192
|
+
--glass-text-toward: black;
|
|
193
|
+
|
|
194
|
+
--glass-focus-ring-color-default: #00408a;
|
|
195
|
+
--glass-focus-ring-halo-color-default: #ffffff;
|
|
196
|
+
|
|
134
197
|
--sheet-focus-ring-inner: #000000;
|
|
135
198
|
--sheet-focus-ring-outer: #0071e3;
|
|
136
199
|
}
|
|
@@ -141,44 +204,78 @@
|
|
|
141
204
|
Consumers on Chrome/Firefox can wire matchMedia into data-attrs manually.
|
|
142
205
|
======================================== */
|
|
143
206
|
|
|
144
|
-
|
|
207
|
+
/* More contrast comes before reduced transparency, so that asking for both
|
|
208
|
+
leaves surfaces solid. */
|
|
209
|
+
@media (prefers-contrast: more) {
|
|
145
210
|
:root {
|
|
146
|
-
--glass-
|
|
211
|
+
--glass-border-width: 1.5px;
|
|
212
|
+
--glass-opacity: 0.98;
|
|
213
|
+
}
|
|
214
|
+
/* The light theme block outranks a bare :root, so repeat the opacity. */
|
|
215
|
+
:root[data-theme='light'] {
|
|
216
|
+
--glass-opacity: 0.98;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
:root[data-contrast='more'] {
|
|
220
|
+
--glass-border-width: 1.5px;
|
|
221
|
+
--glass-opacity: 0.98;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
225
|
+
/* :root:root outranks a page's plain :root values, so see-through sheets and
|
|
226
|
+
bars set that way after this file do not outlive the preference before a
|
|
227
|
+
script has set the attribute. It does not outrank everything: a selector of
|
|
228
|
+
the same weight that comes later, such as :root[data-theme='dark'], or a
|
|
229
|
+
heavier one, still wins. */
|
|
230
|
+
:root:root {
|
|
231
|
+
--glass-opacity: 1;
|
|
147
232
|
--glass-blur: 0px;
|
|
148
233
|
--glass-displacement-scale: 0;
|
|
149
234
|
--glass-saturation: 1;
|
|
150
235
|
--glass-blur-nav: 0px;
|
|
151
236
|
--glass-backdrop-blur: 0px;
|
|
152
237
|
--glass-sheet-bg: rgba(28, 28, 30, 0.98);
|
|
238
|
+
--glass-nav-bg: rgba(0, 0, 0, 0.98);
|
|
153
239
|
}
|
|
154
|
-
/*
|
|
155
|
-
:root[data-theme='light'] {
|
|
240
|
+
/* One :root more than the dark values above, so the light ones win. */
|
|
241
|
+
:root:root[data-theme='light'] {
|
|
242
|
+
--glass-opacity: 1;
|
|
156
243
|
--glass-sheet-bg: rgba(255, 255, 255, 0.98);
|
|
244
|
+
--glass-nav-bg: rgba(255, 255, 255, 0.98);
|
|
157
245
|
}
|
|
158
246
|
}
|
|
159
247
|
:root[data-reduced-transparency='true'] {
|
|
160
|
-
--glass-opacity:
|
|
248
|
+
--glass-opacity: 1;
|
|
161
249
|
--glass-blur: 0px;
|
|
162
250
|
--glass-displacement-scale: 0;
|
|
163
251
|
--glass-saturation: 1;
|
|
164
252
|
--glass-blur-nav: 0px;
|
|
165
253
|
--glass-backdrop-blur: 0px;
|
|
166
254
|
--glass-sheet-bg: rgba(28, 28, 30, 0.98);
|
|
255
|
+
--glass-nav-bg: rgba(0, 0, 0, 0.98);
|
|
167
256
|
}
|
|
168
257
|
/* One more attribute than the light theme block, so it beats it whatever the order. */
|
|
169
258
|
:root[data-reduced-transparency='true'][data-theme='light'] {
|
|
170
259
|
--glass-sheet-bg: rgba(255, 255, 255, 0.98);
|
|
260
|
+
--glass-nav-bg: rgba(255, 255, 255, 0.98);
|
|
171
261
|
}
|
|
172
262
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
263
|
+
/* The attribute on an element inside the page, such as a preview. The surface
|
|
264
|
+
background is repeated because it is otherwise resolved on :root. */
|
|
265
|
+
[data-reduced-transparency='true']:where(:not(:root)) {
|
|
266
|
+
--glass-opacity: 1;
|
|
267
|
+
--glass-surface-bg: rgb(var(--glass-surface-color));
|
|
268
|
+
--glass-blur: 0px;
|
|
269
|
+
--glass-displacement-scale: 0;
|
|
270
|
+
--glass-saturation: 1;
|
|
271
|
+
--glass-blur-nav: 0px;
|
|
272
|
+
--glass-backdrop-blur: 0px;
|
|
273
|
+
--glass-sheet-bg: rgba(28, 28, 30, 0.98);
|
|
274
|
+
--glass-nav-bg: rgba(0, 0, 0, 0.98);
|
|
178
275
|
}
|
|
179
|
-
:root[data-
|
|
180
|
-
--glass-
|
|
181
|
-
--glass-
|
|
276
|
+
:root[data-theme='light'] [data-reduced-transparency='true']:where(:not(:root)) {
|
|
277
|
+
--glass-sheet-bg: rgba(255, 255, 255, 0.98);
|
|
278
|
+
--glass-nav-bg: rgba(255, 255, 255, 0.98);
|
|
182
279
|
}
|
|
183
280
|
|
|
184
281
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -217,7 +314,7 @@
|
|
|
217
314
|
/* The small viewport block above comes later and has the same specificity as the
|
|
218
315
|
reduced transparency media block, so repeat the nav blur reset after it. */
|
|
219
316
|
@media (max-width: 768px) and (prefers-reduced-transparency: reduce) {
|
|
220
|
-
:root {
|
|
317
|
+
:root:root {
|
|
221
318
|
--glass-blur-nav: 0px;
|
|
222
319
|
}
|
|
223
320
|
}
|
package/dist/styles/lens.css
CHANGED
|
@@ -121,6 +121,42 @@
|
|
|
121
121
|
transform: scale(calc(1 - 0.005 * var(--glass-motion-enabled)));
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
/* Reduced transparency: no blur, no lens and no blended highlight. Glass writes
|
|
125
|
+
its effect values inline, where no token can reach them, so the properties
|
|
126
|
+
that read them are replaced. The tokens make the background solid, and the
|
|
127
|
+
empty ::before layer goes, so contrast checkers can read it.
|
|
128
|
+
:where keeps each rule as specific as the one it replaces. */
|
|
129
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
130
|
+
.glass-surface::before {
|
|
131
|
+
content: none;
|
|
132
|
+
}
|
|
133
|
+
.glass-surface::before {
|
|
134
|
+
backdrop-filter: none;
|
|
135
|
+
-webkit-backdrop-filter: none;
|
|
136
|
+
}
|
|
137
|
+
.glass-surface.has-lensing::before {
|
|
138
|
+
filter: none;
|
|
139
|
+
}
|
|
140
|
+
.glass-surface::after {
|
|
141
|
+
background: none;
|
|
142
|
+
mix-blend-mode: normal;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
:where([data-reduced-transparency='true']) .glass-surface::before {
|
|
146
|
+
content: none;
|
|
147
|
+
}
|
|
148
|
+
:where([data-reduced-transparency='true']) .glass-surface::before {
|
|
149
|
+
backdrop-filter: none;
|
|
150
|
+
-webkit-backdrop-filter: none;
|
|
151
|
+
}
|
|
152
|
+
:where([data-reduced-transparency='true']) .glass-surface.has-lensing::before {
|
|
153
|
+
filter: none;
|
|
154
|
+
}
|
|
155
|
+
:where([data-reduced-transparency='true']) .glass-surface::after {
|
|
156
|
+
background: none;
|
|
157
|
+
mix-blend-mode: normal;
|
|
158
|
+
}
|
|
159
|
+
|
|
124
160
|
.glass-dim-layer {
|
|
125
161
|
position: absolute;
|
|
126
162
|
inset: 0;
|