glasslikeui 1.1.0 → 1.2.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/LICENSE +21 -21
- package/README.md +215 -215
- package/dist/components/glass/Glass.svelte +164 -164
- package/dist/components/glass/GlassCard.svelte +71 -71
- package/dist/components/glass/GlassDimLayer.svelte +37 -37
- package/dist/components/glass/GlassEffectContainer.svelte +58 -58
- package/dist/components/glass/GlassMorph.svelte +42 -42
- package/dist/components/glass/GlassSection.svelte +82 -82
- package/dist/components/glass/LensFilters.svelte +41 -41
- package/dist/components/glass/Sheet.svelte +266 -266
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +2 -0
- package/dist/components/interactive/Badge.svelte +52 -52
- package/dist/components/interactive/Button.svelte +168 -168
- package/dist/components/interactive/IconButton.svelte +74 -74
- package/dist/components/layout/Divider.svelte +31 -31
- package/dist/components/layout/Grid.svelte +52 -52
- package/dist/components/layout/HStack.svelte +76 -76
- package/dist/components/layout/ScrollView.svelte +83 -83
- package/dist/components/layout/Spacer.svelte +18 -18
- package/dist/components/layout/VStack.svelte +56 -56
- package/dist/components/layout/ZStack.svelte +51 -51
- package/dist/components/list/List.svelte +50 -50
- package/dist/components/list/ListRow.svelte +181 -181
- package/dist/components/media/SymbolImage.svelte +46 -46
- package/dist/components/menu/Menu.svelte +206 -0
- package/dist/components/menu/Menu.svelte.d.ts +10 -0
- package/dist/components/menu/MenuItem.svelte +114 -0
- package/dist/components/menu/MenuItem.svelte.d.ts +12 -0
- package/dist/components/menu/index.d.ts +6 -0
- package/dist/components/menu/index.js +6 -0
- package/dist/components/navigation/NavigationBar.svelte +195 -195
- package/dist/components/navigation/NavigationLink.svelte +45 -45
- package/dist/components/typography/Text.svelte +98 -98
- package/dist/icons/index.js +4 -1
- package/dist/styles/glasslikeui.css +192 -192
- package/dist/styles/lens.css +93 -93
- package/dist/styles/squircle.css +17 -17
- package/dist/styles/typography.css +27 -27
- package/package.json +50 -50
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Beau Ayres
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Beau Ayres
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,215 +1,215 @@
|
|
|
1
|
-
# GlassLikeUI
|
|
2
|
-
|
|
3
|
-
Svelte component library with frosted glass materials. Pseudo-element
|
|
4
|
-
lensing, two-axis variant API, drag-snap sheets, View Transitions morph,
|
|
5
|
-
accessibility-aware out of the box, cross-platform typography.
|
|
6
|
-
|
|
7
|
-
Svelte 5 only. MIT licensed.
|
|
8
|
-
|
|
9
|
-
## Install
|
|
10
|
-
|
|
11
|
-
```sh
|
|
12
|
-
npm install glasslikeui
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Peer dependency: `svelte ^5.0.0`.
|
|
16
|
-
|
|
17
|
-
## Setup
|
|
18
|
-
|
|
19
|
-
Mount `LensFilters` once near the root of your app, and import the
|
|
20
|
-
stylesheets you want:
|
|
21
|
-
|
|
22
|
-
```svelte
|
|
23
|
-
<script>
|
|
24
|
-
import { LensFilters } from 'glasslikeui';
|
|
25
|
-
import 'glasslikeui/glasslikeui.css';
|
|
26
|
-
import 'glasslikeui/lens.css';
|
|
27
|
-
import 'glasslikeui/squircle.css';
|
|
28
|
-
import 'glasslikeui/typography.css';
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<LensFilters />
|
|
32
|
-
<!-- rest of app -->
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Optional: wire browser accessibility prefs into the library's fallback
|
|
36
|
-
attributes on non-Safari browsers:
|
|
37
|
-
|
|
38
|
-
```svelte
|
|
39
|
-
<script>
|
|
40
|
-
import { onMount } from 'svelte';
|
|
41
|
-
import { syncAccessibilityPreferences } from 'glasslikeui';
|
|
42
|
-
onMount(() => syncAccessibilityPreferences());
|
|
43
|
-
</script>
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Basic use
|
|
47
|
-
|
|
48
|
-
```svelte
|
|
49
|
-
<script>
|
|
50
|
-
import { Glass, Button } from 'glasslikeui';
|
|
51
|
-
</script>
|
|
52
|
-
|
|
53
|
-
<Glass variant="regular" intensity="standard">
|
|
54
|
-
{#snippet children()}
|
|
55
|
-
<h2>Frosted card</h2>
|
|
56
|
-
<Button variant="filled">Action</Button>
|
|
57
|
-
{/snippet}
|
|
58
|
-
</Glass>
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Variants and intensity
|
|
62
|
-
|
|
63
|
-
`Glass` (and its consumers: `GlassCard`, `GlassSection`, `List`,
|
|
64
|
-
`TabView`) takes two orthogonal props:
|
|
65
|
-
|
|
66
|
-
- `variant` -- `regular` (default) or `clear`. Clear requires a
|
|
67
|
-
`<GlassDimLayer />` companion for legibility.
|
|
68
|
-
- `intensity` -- `subtle`, `standard` (default), or `prominent`.
|
|
69
|
-
Controls blur, edge displacement, and saturation together.
|
|
70
|
-
|
|
71
|
-
## Components
|
|
72
|
-
|
|
73
|
-
| Component | Purpose |
|
|
74
|
-
| ------------------------ | ------------------------------------------------ |
|
|
75
|
-
| `Glass` | Core frosted surface. |
|
|
76
|
-
| `GlassCard` | Header / body / footer card. |
|
|
77
|
-
| `GlassSection` | Titled section block. |
|
|
78
|
-
| `GlassEffectContainer` | Groups glass siblings with shared shadow. |
|
|
79
|
-
| `GlassDimLayer` | Required under `variant="clear"`. |
|
|
80
|
-
| `GlassMorph` | Tag a subtree for View Transitions morph. |
|
|
81
|
-
| `LensFilters` | SVG filter defs (mount once). |
|
|
82
|
-
| `Sheet` | Bottom sheet with detents + drag-to-snap. |
|
|
83
|
-
| `NavigationBar` | Top chrome; supports `largeTitle` collapse. |
|
|
84
|
-
| `NavigationLink` | Pill-style link. |
|
|
85
|
-
| `TabView` | Floating tab bar. |
|
|
86
|
-
| `Button` / `IconButton` | `filled` / `outlined` / `plain` / `tinted` / `destructive`. |
|
|
87
|
-
| `Badge` | `default` / `accent`. |
|
|
88
|
-
| `Text` | Dynamic-Type-aware text. |
|
|
89
|
-
| `List` / `ListRow` | Grouped list with insets. |
|
|
90
|
-
| `HStack` / `VStack` / `ZStack` / `Grid` / `Spacer` / `Divider` / `ScrollView` | Layout primitives. |
|
|
91
|
-
| `SymbolImage` | SVG icon renderer. |
|
|
92
|
-
|
|
93
|
-
## Actions
|
|
94
|
-
|
|
95
|
-
| Export | Purpose |
|
|
96
|
-
| -------------------------------- | ------------------------------------------------------ |
|
|
97
|
-
| `scrollEdge` | Fade a scroll container at edges meeting glass chrome. |
|
|
98
|
-
| `dragSnap` | Detent-based drag gesture (used by `Sheet`). |
|
|
99
|
-
| `deviceMotion` | Ties the glass highlight angle to device tilt. |
|
|
100
|
-
| `withGlassTransition` | Wraps a DOM update in a view transition. |
|
|
101
|
-
| `syncAccessibilityPreferences` | Bridges `prefers-*` media to data-attrs at `:root`. |
|
|
102
|
-
| `requestMotionPermission` | Triggers the iOS user-gesture permission flow. |
|
|
103
|
-
|
|
104
|
-
## Device motion (opt-in)
|
|
105
|
-
|
|
106
|
-
The `motion` prop on `Glass` ties the highlight angle to the device's
|
|
107
|
-
tilt. iOS Safari requires a **user-gesture permission grant** before
|
|
108
|
-
tilt events fire. You MUST call `requestMotionPermission()` from a
|
|
109
|
-
click or tap handler -- not from `onMount`, an effect, or module init.
|
|
110
|
-
|
|
111
|
-
```svelte
|
|
112
|
-
<script>
|
|
113
|
-
import { Glass, requestMotionPermission } from 'glasslikeui';
|
|
114
|
-
|
|
115
|
-
let permission = $state('pending');
|
|
116
|
-
|
|
117
|
-
async function enable() {
|
|
118
|
-
permission = await requestMotionPermission();
|
|
119
|
-
// 'granted' | 'denied' | 'unavailable'
|
|
120
|
-
}
|
|
121
|
-
</script>
|
|
122
|
-
|
|
123
|
-
{#if permission === 'pending'}
|
|
124
|
-
<button onclick={enable}>Enable tilt effect</button>
|
|
125
|
-
{/if}
|
|
126
|
-
|
|
127
|
-
<Glass motion={permission === 'granted'}>
|
|
128
|
-
{#snippet children()}...{/snippet}
|
|
129
|
-
</Glass>
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
Requirements:
|
|
133
|
-
|
|
134
|
-
- **User gesture** -- call inside `onclick` / `ontap` / form handler.
|
|
135
|
-
Called outside a gesture, iOS silently returns `denied` without
|
|
136
|
-
showing the prompt.
|
|
137
|
-
- **HTTPS** -- `http://localhost` works for dev; plain HTTP on a real
|
|
138
|
-
device does not expose the API.
|
|
139
|
-
- **Per-origin** -- granted or denied once, then remembered. A denied
|
|
140
|
-
decision can only be reset by the user in
|
|
141
|
-
Settings -> Safari -> Advanced.
|
|
142
|
-
- **Non-iOS browsers** (Android Chrome, desktop Chrome / Firefox /
|
|
143
|
-
Safari) grant access implicitly; the helper returns `'granted'`
|
|
144
|
-
without any prompt on those.
|
|
145
|
-
- **Unsupported browsers** (no `DeviceOrientationEvent`) -- helper
|
|
146
|
-
returns `'unavailable'` and the action is a no-op.
|
|
147
|
-
|
|
148
|
-
## Icons
|
|
149
|
-
|
|
150
|
-
A small SF-symbol-inspired set ships in `ICONS`. Register your own
|
|
151
|
-
before rendering:
|
|
152
|
-
|
|
153
|
-
```ts
|
|
154
|
-
import { registerIcons } from 'glasslikeui';
|
|
155
|
-
registerIcons({
|
|
156
|
-
'custom-symbol': '<path d="..." />'
|
|
157
|
-
});
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Accessibility
|
|
161
|
-
|
|
162
|
-
Native preference handling with zero config:
|
|
163
|
-
|
|
164
|
-
- `prefers-reduced-transparency` -- surfaces go opaque, blur off
|
|
165
|
-
- `prefers-contrast: more` -- thicker borders, higher opacity
|
|
166
|
-
- `prefers-reduced-motion` -- transitions and motion highlights off
|
|
167
|
-
|
|
168
|
-
Cross-browser fallback attributes (flip at `:root`):
|
|
169
|
-
|
|
170
|
-
- `data-reduced-transparency="true"`
|
|
171
|
-
- `data-contrast="more"`
|
|
172
|
-
- `data-reduced-motion="true"`
|
|
173
|
-
|
|
174
|
-
Call `syncAccessibilityPreferences()` to manage these automatically.
|
|
175
|
-
|
|
176
|
-
## Theming
|
|
177
|
-
|
|
178
|
-
All design tokens are CSS custom properties. Toggle dark / light with
|
|
179
|
-
the `data-theme` attribute on `:root`:
|
|
180
|
-
|
|
181
|
-
```html
|
|
182
|
-
<html data-theme="light">...</html>
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
Override any token via your own stylesheet, e.g.:
|
|
186
|
-
|
|
187
|
-
```css
|
|
188
|
-
:root {
|
|
189
|
-
--color-accent: #FF6A00;
|
|
190
|
-
--glass-radius-lg: 28px;
|
|
191
|
-
}
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## Browser support
|
|
195
|
-
|
|
196
|
-
| Browser | Support |
|
|
197
|
-
| ---------------------- | ----------------------------------------------------- |
|
|
198
|
-
| Chrome / Edge 111+ | Full. |
|
|
199
|
-
| Safari 16.4+ | Full, including native `prefers-reduced-transparency`.|
|
|
200
|
-
| Firefox 115+ | Full. 103-114 works without edge lensing. |
|
|
201
|
-
| Older | Opaque fallback via `@supports not`. |
|
|
202
|
-
| SSR | All actions guard `typeof window`. |
|
|
203
|
-
|
|
204
|
-
## Build / test
|
|
205
|
-
|
|
206
|
-
```sh
|
|
207
|
-
npm run package # svelte-package build
|
|
208
|
-
npm test # vitest once
|
|
209
|
-
npm run test:watch # vitest watch
|
|
210
|
-
npm run test:coverage # with v8 coverage
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
## License
|
|
214
|
-
|
|
215
|
-
MIT. See `LICENSE`.
|
|
1
|
+
# GlassLikeUI
|
|
2
|
+
|
|
3
|
+
Svelte component library with frosted glass materials. Pseudo-element
|
|
4
|
+
lensing, two-axis variant API, drag-snap sheets, View Transitions morph,
|
|
5
|
+
accessibility-aware out of the box, cross-platform typography.
|
|
6
|
+
|
|
7
|
+
Svelte 5 only. MIT licensed.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install glasslikeui
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Peer dependency: `svelte ^5.0.0`.
|
|
16
|
+
|
|
17
|
+
## Setup
|
|
18
|
+
|
|
19
|
+
Mount `LensFilters` once near the root of your app, and import the
|
|
20
|
+
stylesheets you want:
|
|
21
|
+
|
|
22
|
+
```svelte
|
|
23
|
+
<script>
|
|
24
|
+
import { LensFilters } from 'glasslikeui';
|
|
25
|
+
import 'glasslikeui/glasslikeui.css';
|
|
26
|
+
import 'glasslikeui/lens.css';
|
|
27
|
+
import 'glasslikeui/squircle.css';
|
|
28
|
+
import 'glasslikeui/typography.css';
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<LensFilters />
|
|
32
|
+
<!-- rest of app -->
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Optional: wire browser accessibility prefs into the library's fallback
|
|
36
|
+
attributes on non-Safari browsers:
|
|
37
|
+
|
|
38
|
+
```svelte
|
|
39
|
+
<script>
|
|
40
|
+
import { onMount } from 'svelte';
|
|
41
|
+
import { syncAccessibilityPreferences } from 'glasslikeui';
|
|
42
|
+
onMount(() => syncAccessibilityPreferences());
|
|
43
|
+
</script>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Basic use
|
|
47
|
+
|
|
48
|
+
```svelte
|
|
49
|
+
<script>
|
|
50
|
+
import { Glass, Button } from 'glasslikeui';
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<Glass variant="regular" intensity="standard">
|
|
54
|
+
{#snippet children()}
|
|
55
|
+
<h2>Frosted card</h2>
|
|
56
|
+
<Button variant="filled">Action</Button>
|
|
57
|
+
{/snippet}
|
|
58
|
+
</Glass>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Variants and intensity
|
|
62
|
+
|
|
63
|
+
`Glass` (and its consumers: `GlassCard`, `GlassSection`, `List`,
|
|
64
|
+
`TabView`) takes two orthogonal props:
|
|
65
|
+
|
|
66
|
+
- `variant` -- `regular` (default) or `clear`. Clear requires a
|
|
67
|
+
`<GlassDimLayer />` companion for legibility.
|
|
68
|
+
- `intensity` -- `subtle`, `standard` (default), or `prominent`.
|
|
69
|
+
Controls blur, edge displacement, and saturation together.
|
|
70
|
+
|
|
71
|
+
## Components
|
|
72
|
+
|
|
73
|
+
| Component | Purpose |
|
|
74
|
+
| ------------------------ | ------------------------------------------------ |
|
|
75
|
+
| `Glass` | Core frosted surface. |
|
|
76
|
+
| `GlassCard` | Header / body / footer card. |
|
|
77
|
+
| `GlassSection` | Titled section block. |
|
|
78
|
+
| `GlassEffectContainer` | Groups glass siblings with shared shadow. |
|
|
79
|
+
| `GlassDimLayer` | Required under `variant="clear"`. |
|
|
80
|
+
| `GlassMorph` | Tag a subtree for View Transitions morph. |
|
|
81
|
+
| `LensFilters` | SVG filter defs (mount once). |
|
|
82
|
+
| `Sheet` | Bottom sheet with detents + drag-to-snap. |
|
|
83
|
+
| `NavigationBar` | Top chrome; supports `largeTitle` collapse. |
|
|
84
|
+
| `NavigationLink` | Pill-style link. |
|
|
85
|
+
| `TabView` | Floating tab bar. |
|
|
86
|
+
| `Button` / `IconButton` | `filled` / `outlined` / `plain` / `tinted` / `destructive`. |
|
|
87
|
+
| `Badge` | `default` / `accent`. |
|
|
88
|
+
| `Text` | Dynamic-Type-aware text. |
|
|
89
|
+
| `List` / `ListRow` | Grouped list with insets. |
|
|
90
|
+
| `HStack` / `VStack` / `ZStack` / `Grid` / `Spacer` / `Divider` / `ScrollView` | Layout primitives. |
|
|
91
|
+
| `SymbolImage` | SVG icon renderer. |
|
|
92
|
+
|
|
93
|
+
## Actions
|
|
94
|
+
|
|
95
|
+
| Export | Purpose |
|
|
96
|
+
| -------------------------------- | ------------------------------------------------------ |
|
|
97
|
+
| `scrollEdge` | Fade a scroll container at edges meeting glass chrome. |
|
|
98
|
+
| `dragSnap` | Detent-based drag gesture (used by `Sheet`). |
|
|
99
|
+
| `deviceMotion` | Ties the glass highlight angle to device tilt. |
|
|
100
|
+
| `withGlassTransition` | Wraps a DOM update in a view transition. |
|
|
101
|
+
| `syncAccessibilityPreferences` | Bridges `prefers-*` media to data-attrs at `:root`. |
|
|
102
|
+
| `requestMotionPermission` | Triggers the iOS user-gesture permission flow. |
|
|
103
|
+
|
|
104
|
+
## Device motion (opt-in)
|
|
105
|
+
|
|
106
|
+
The `motion` prop on `Glass` ties the highlight angle to the device's
|
|
107
|
+
tilt. iOS Safari requires a **user-gesture permission grant** before
|
|
108
|
+
tilt events fire. You MUST call `requestMotionPermission()` from a
|
|
109
|
+
click or tap handler -- not from `onMount`, an effect, or module init.
|
|
110
|
+
|
|
111
|
+
```svelte
|
|
112
|
+
<script>
|
|
113
|
+
import { Glass, requestMotionPermission } from 'glasslikeui';
|
|
114
|
+
|
|
115
|
+
let permission = $state('pending');
|
|
116
|
+
|
|
117
|
+
async function enable() {
|
|
118
|
+
permission = await requestMotionPermission();
|
|
119
|
+
// 'granted' | 'denied' | 'unavailable'
|
|
120
|
+
}
|
|
121
|
+
</script>
|
|
122
|
+
|
|
123
|
+
{#if permission === 'pending'}
|
|
124
|
+
<button onclick={enable}>Enable tilt effect</button>
|
|
125
|
+
{/if}
|
|
126
|
+
|
|
127
|
+
<Glass motion={permission === 'granted'}>
|
|
128
|
+
{#snippet children()}...{/snippet}
|
|
129
|
+
</Glass>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Requirements:
|
|
133
|
+
|
|
134
|
+
- **User gesture** -- call inside `onclick` / `ontap` / form handler.
|
|
135
|
+
Called outside a gesture, iOS silently returns `denied` without
|
|
136
|
+
showing the prompt.
|
|
137
|
+
- **HTTPS** -- `http://localhost` works for dev; plain HTTP on a real
|
|
138
|
+
device does not expose the API.
|
|
139
|
+
- **Per-origin** -- granted or denied once, then remembered. A denied
|
|
140
|
+
decision can only be reset by the user in
|
|
141
|
+
Settings -> Safari -> Advanced.
|
|
142
|
+
- **Non-iOS browsers** (Android Chrome, desktop Chrome / Firefox /
|
|
143
|
+
Safari) grant access implicitly; the helper returns `'granted'`
|
|
144
|
+
without any prompt on those.
|
|
145
|
+
- **Unsupported browsers** (no `DeviceOrientationEvent`) -- helper
|
|
146
|
+
returns `'unavailable'` and the action is a no-op.
|
|
147
|
+
|
|
148
|
+
## Icons
|
|
149
|
+
|
|
150
|
+
A small SF-symbol-inspired set ships in `ICONS`. Register your own
|
|
151
|
+
before rendering:
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { registerIcons } from 'glasslikeui';
|
|
155
|
+
registerIcons({
|
|
156
|
+
'custom-symbol': '<path d="..." />'
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Accessibility
|
|
161
|
+
|
|
162
|
+
Native preference handling with zero config:
|
|
163
|
+
|
|
164
|
+
- `prefers-reduced-transparency` -- surfaces go opaque, blur off
|
|
165
|
+
- `prefers-contrast: more` -- thicker borders, higher opacity
|
|
166
|
+
- `prefers-reduced-motion` -- transitions and motion highlights off
|
|
167
|
+
|
|
168
|
+
Cross-browser fallback attributes (flip at `:root`):
|
|
169
|
+
|
|
170
|
+
- `data-reduced-transparency="true"`
|
|
171
|
+
- `data-contrast="more"`
|
|
172
|
+
- `data-reduced-motion="true"`
|
|
173
|
+
|
|
174
|
+
Call `syncAccessibilityPreferences()` to manage these automatically.
|
|
175
|
+
|
|
176
|
+
## Theming
|
|
177
|
+
|
|
178
|
+
All design tokens are CSS custom properties. Toggle dark / light with
|
|
179
|
+
the `data-theme` attribute on `:root`:
|
|
180
|
+
|
|
181
|
+
```html
|
|
182
|
+
<html data-theme="light">...</html>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Override any token via your own stylesheet, e.g.:
|
|
186
|
+
|
|
187
|
+
```css
|
|
188
|
+
:root {
|
|
189
|
+
--color-accent: #FF6A00;
|
|
190
|
+
--glass-radius-lg: 28px;
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## Browser support
|
|
195
|
+
|
|
196
|
+
| Browser | Support |
|
|
197
|
+
| ---------------------- | ----------------------------------------------------- |
|
|
198
|
+
| Chrome / Edge 111+ | Full. |
|
|
199
|
+
| Safari 16.4+ | Full, including native `prefers-reduced-transparency`.|
|
|
200
|
+
| Firefox 115+ | Full. 103-114 works without edge lensing. |
|
|
201
|
+
| Older | Opaque fallback via `@supports not`. |
|
|
202
|
+
| SSR | All actions guard `typeof window`. |
|
|
203
|
+
|
|
204
|
+
## Build / test
|
|
205
|
+
|
|
206
|
+
```sh
|
|
207
|
+
npm run package # svelte-package build
|
|
208
|
+
npm test # vitest once
|
|
209
|
+
npm run test:watch # vitest watch
|
|
210
|
+
npm run test:coverage # with v8 coverage
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
MIT. See `LICENSE`.
|