glasslikeui 1.1.0 → 1.2.1

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 (41) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +215 -215
  3. package/dist/components/glass/Glass.svelte +165 -164
  4. package/dist/components/glass/GlassCard.svelte +71 -71
  5. package/dist/components/glass/GlassDimLayer.svelte +37 -37
  6. package/dist/components/glass/GlassEffectContainer.svelte +58 -58
  7. package/dist/components/glass/GlassMorph.svelte +42 -42
  8. package/dist/components/glass/GlassSection.svelte +82 -82
  9. package/dist/components/glass/LensFilters.svelte +41 -41
  10. package/dist/components/glass/Sheet.svelte +261 -266
  11. package/dist/components/index.d.ts +1 -0
  12. package/dist/components/index.js +2 -0
  13. package/dist/components/interactive/Badge.svelte +52 -52
  14. package/dist/components/interactive/Button.svelte +168 -168
  15. package/dist/components/interactive/IconButton.svelte +74 -74
  16. package/dist/components/interactive/TabView.svelte +1 -1
  17. package/dist/components/layout/Divider.svelte +31 -31
  18. package/dist/components/layout/Grid.svelte +52 -52
  19. package/dist/components/layout/HStack.svelte +76 -76
  20. package/dist/components/layout/ScrollView.svelte +84 -83
  21. package/dist/components/layout/Spacer.svelte +18 -18
  22. package/dist/components/layout/VStack.svelte +56 -56
  23. package/dist/components/layout/ZStack.svelte +51 -51
  24. package/dist/components/list/List.svelte +50 -50
  25. package/dist/components/list/ListRow.svelte +181 -181
  26. package/dist/components/media/SymbolImage.svelte +46 -46
  27. package/dist/components/menu/Menu.svelte +189 -0
  28. package/dist/components/menu/Menu.svelte.d.ts +10 -0
  29. package/dist/components/menu/MenuItem.svelte +114 -0
  30. package/dist/components/menu/MenuItem.svelte.d.ts +12 -0
  31. package/dist/components/menu/index.d.ts +6 -0
  32. package/dist/components/menu/index.js +6 -0
  33. package/dist/components/navigation/NavigationBar.svelte +195 -195
  34. package/dist/components/navigation/NavigationLink.svelte +45 -45
  35. package/dist/components/typography/Text.svelte +98 -98
  36. package/dist/icons/index.js +4 -1
  37. package/dist/styles/glasslikeui.css +192 -192
  38. package/dist/styles/lens.css +93 -93
  39. package/dist/styles/squircle.css +17 -17
  40. package/dist/styles/typography.css +27 -27
  41. package/package.json +50 -50
@@ -1,266 +1,261 @@
1
- <script lang="ts">
2
- import type { Snippet } from 'svelte';
3
- import { HStack, Spacer } from '../layout';
4
- import {
5
- dragSnap,
6
- detentFractions,
7
- type SheetDetentName
8
- } from '../../actions/dragSnap';
9
-
10
- const isBrowser = typeof window !== 'undefined';
11
-
12
- interface Props {
13
- isOpen?: boolean;
14
- title?: string;
15
- children: Snippet;
16
- onClose?: () => void;
17
- onDetentChange?: (name: SheetDetentName) => void;
18
- detents?: readonly SheetDetentName[];
19
- initialDetent?: SheetDetentName;
20
- showHandle?: boolean;
21
- draggable?: boolean;
22
- class?: string;
23
- }
24
-
25
- let {
26
- isOpen = $bindable(false),
27
- title = '',
28
- children,
29
- onClose,
30
- onDetentChange,
31
- detents = ['medium', 'large'],
32
- initialDetent = 'medium',
33
- showHandle = true,
34
- draggable = true,
35
- class: className = ''
36
- }: Props = $props();
37
-
38
- const fractions = $derived(detentFractions(detents));
39
- const initialIndex = $derived(Math.max(0, detents.indexOf(initialDetent)));
40
-
41
- let currentIndex = $state(0);
42
- let sheetEl = $state<HTMLElement | undefined>();
43
-
44
- $effect(() => {
45
- currentIndex = initialIndex;
46
- });
47
-
48
- function close() {
49
- isOpen = false;
50
- onClose?.();
51
- if (isBrowser) {
52
- document.body.style.overflow = '';
53
- }
54
- }
55
-
56
- function handleKeydown(e: KeyboardEvent) {
57
- if (e.key === 'Escape') {
58
- close();
59
- }
60
- }
61
-
62
- function handleBackdropClick(e: MouseEvent) {
63
- if (e.target === e.currentTarget) {
64
- close();
65
- }
66
- }
67
-
68
- function handleSnap(index: number) {
69
- currentIndex = index;
70
- const name = detents[index];
71
- if (name) onDetentChange?.(name);
72
- }
73
-
74
- $effect(() => {
75
- if (isBrowser && isOpen) {
76
- document.body.style.overflow = 'hidden';
77
- }
78
- return () => {
79
- if (isBrowser) {
80
- document.body.style.overflow = '';
81
- }
82
- };
83
- });
84
- </script>
85
-
86
- <svelte:window onkeydown={handleKeydown} />
87
-
88
- {#if isOpen}
89
- <div
90
- class="sheet-backdrop"
91
- class:open={isOpen}
92
- onclick={handleBackdropClick}
93
- onkeydown={(e) => e.key === 'Escape' && close()}
94
- role="presentation"
95
- >
96
- <div
97
- bind:this={sheetEl}
98
- class="sheet-container {className}"
99
- class:open={isOpen}
100
- >
101
- {#if showHandle}
102
- <div
103
- class="sheet-handle-container"
104
- use:dragSnap={{
105
- target: sheetEl,
106
- detents: fractions,
107
- initial: currentIndex,
108
- disabled: !draggable || fractions.length < 2,
109
- onSnap: handleSnap
110
- }}
111
- >
112
- <div class="sheet-handle"></div>
113
- </div>
114
- {/if}
115
-
116
- {#if title}
117
- <header class="sheet-header">
118
- <HStack alignment="center">
119
- <button class="sheet-close-btn" onclick={close} aria-label="Close">
120
- <svg
121
- xmlns="http://www.w3.org/2000/svg"
122
- width="20"
123
- height="20"
124
- viewBox="0 0 24 24"
125
- fill="none"
126
- stroke="currentColor"
127
- stroke-width="2"
128
- stroke-linecap="round"
129
- stroke-linejoin="round"
130
- >
131
- <polyline points="15 18 9 12 15 6"></polyline>
132
- </svg>
133
- <span>Back</span>
134
- </button>
135
- <Spacer />
136
- <h2 class="sheet-title">{title}</h2>
137
- <Spacer />
138
- <div class="sheet-spacer"></div>
139
- </HStack>
140
- </header>
141
- {/if}
142
-
143
- <div class="sheet-content">
144
- {@render children()}
145
- </div>
146
- </div>
147
- </div>
148
- {/if}
149
-
150
- <style>
151
- .sheet-backdrop {
152
- position: fixed;
153
- inset: 0;
154
- background: rgba(0, 0, 0, 0.4);
155
- backdrop-filter: blur(4px);
156
- -webkit-backdrop-filter: blur(4px);
157
- z-index: 1000;
158
- opacity: 0;
159
- visibility: hidden;
160
- transition: all 0.3s ease;
161
- }
162
-
163
- .sheet-backdrop.open {
164
- opacity: 1;
165
- visibility: visible;
166
- }
167
-
168
- .sheet-container {
169
- --sheet-y: 100vh;
170
- position: fixed;
171
- left: 0;
172
- right: 0;
173
- top: 0;
174
- height: 100vh;
175
- margin: 0 auto;
176
- background: var(--glass-sheet-bg);
177
- backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
178
- -webkit-backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
179
- border-radius: var(--glass-radius-xl) var(--glass-radius-xl) 0 0;
180
- overflow: hidden;
181
- display: flex;
182
- flex-direction: column;
183
- transform: translateY(var(--sheet-y));
184
- transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
185
- z-index: 1001;
186
- border-top: 1px solid var(--glass-border);
187
- box-shadow:
188
- 0 -8px 32px -8px var(--glass-shadow),
189
- inset 0 1px 0 0 var(--glass-highlight);
190
- touch-action: none;
191
- }
192
-
193
- .sheet-handle-container {
194
- display: flex;
195
- justify-content: center;
196
- padding: 8px 0;
197
- cursor: grab;
198
- }
199
- .sheet-handle-container:active {
200
- cursor: grabbing;
201
- }
202
-
203
- .sheet-handle {
204
- width: 36px;
205
- height: 5px;
206
- background: var(--glass-handle);
207
- border-radius: 3px;
208
- }
209
-
210
- .sheet-header {
211
- padding: 0 var(--spacing-md);
212
- height: 56px;
213
- border-bottom: 1px solid var(--glass-divider);
214
- display: flex;
215
- align-items: center;
216
- }
217
-
218
- .sheet-close-btn {
219
- display: flex;
220
- align-items: center;
221
- gap: 4px;
222
- background: none;
223
- border: none;
224
- color: var(--color-accent);
225
- font-size: 17px;
226
- font-weight: 400;
227
- cursor: pointer;
228
- padding: 8px 0;
229
- transition: opacity var(--transition-fast);
230
- font-family: var(--font-system);
231
- }
232
-
233
- .sheet-close-btn:hover {
234
- opacity: 0.7;
235
- }
236
-
237
- .sheet-close-btn svg {
238
- margin-left: -6px;
239
- }
240
-
241
- .sheet-title {
242
- font-size: 17px;
243
- font-weight: 600;
244
- color: var(--color-text);
245
- text-align: center;
246
- font-family: var(--font-system);
247
- }
248
-
249
- .sheet-spacer {
250
- width: 80px;
251
- }
252
-
253
- .sheet-content {
254
- flex: 1;
255
- overflow-y: auto;
256
- overflow-x: hidden;
257
- -webkit-overflow-scrolling: touch;
258
- font-family: var(--font-system);
259
- }
260
-
261
- @media (min-width: 769px) {
262
- .sheet-container {
263
- max-width: 900px;
264
- }
265
- }
266
- </style>
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import { fromAction } from 'svelte/attachments';
4
+ import { HStack, Spacer } from '../layout';
5
+ import {
6
+ dragSnap,
7
+ detentFractions,
8
+ type SheetDetentName
9
+ } from '../../actions/dragSnap';
10
+
11
+ const isBrowser = typeof window !== 'undefined';
12
+
13
+ interface Props {
14
+ isOpen?: boolean;
15
+ title?: string;
16
+ children: Snippet;
17
+ onClose?: () => void;
18
+ onDetentChange?: (name: SheetDetentName) => void;
19
+ detents?: readonly SheetDetentName[];
20
+ initialDetent?: SheetDetentName;
21
+ showHandle?: boolean;
22
+ draggable?: boolean;
23
+ class?: string;
24
+ }
25
+
26
+ let {
27
+ isOpen = $bindable(false),
28
+ title = '',
29
+ children,
30
+ onClose,
31
+ onDetentChange,
32
+ detents = ['medium', 'large'],
33
+ initialDetent = 'medium',
34
+ showHandle = true,
35
+ draggable = true,
36
+ class: className = ''
37
+ }: Props = $props();
38
+
39
+ const fractions = $derived(detentFractions(detents));
40
+ const initialIndex = $derived(Math.max(0, detents.indexOf(initialDetent)));
41
+
42
+ let currentIndex = $derived(initialIndex);
43
+ let sheetEl = $state<HTMLElement | undefined>();
44
+
45
+ function close() {
46
+ isOpen = false;
47
+ onClose?.();
48
+ if (isBrowser) {
49
+ document.body.style.overflow = '';
50
+ }
51
+ }
52
+
53
+ function handleKeydown(e: KeyboardEvent) {
54
+ if (e.key === 'Escape') {
55
+ close();
56
+ }
57
+ }
58
+
59
+ function handleBackdropClick(e: MouseEvent) {
60
+ if (e.target === e.currentTarget) {
61
+ close();
62
+ }
63
+ }
64
+
65
+ function handleSnap(index: number) {
66
+ currentIndex = index;
67
+ const name = detents[index];
68
+ if (name) onDetentChange?.(name);
69
+ }
70
+
71
+ $effect(() => {
72
+ if (isOpen) {
73
+ document.body.style.overflow = 'hidden';
74
+ }
75
+ return () => {
76
+ document.body.style.overflow = '';
77
+ };
78
+ });
79
+ </script>
80
+
81
+ <svelte:window onkeydown={handleKeydown} />
82
+
83
+ {#if isOpen}
84
+ <div
85
+ class="sheet-backdrop"
86
+ class:open={isOpen}
87
+ onclick={handleBackdropClick}
88
+ onkeydown={(e) => e.key === 'Escape' && close()}
89
+ role="presentation"
90
+ >
91
+ <div
92
+ bind:this={sheetEl}
93
+ class="sheet-container {className}"
94
+ class:open={isOpen}
95
+ >
96
+ {#if showHandle}
97
+ <div
98
+ class="sheet-handle-container"
99
+ {@attach fromAction(dragSnap, () => ({
100
+ target: sheetEl,
101
+ detents: fractions,
102
+ initial: currentIndex,
103
+ disabled: !draggable || fractions.length < 2,
104
+ onSnap: handleSnap
105
+ }))}
106
+ >
107
+ <div class="sheet-handle"></div>
108
+ </div>
109
+ {/if}
110
+
111
+ {#if title}
112
+ <header class="sheet-header">
113
+ <HStack alignment="center">
114
+ <button class="sheet-close-btn" onclick={close} aria-label="Close">
115
+ <svg
116
+ xmlns="http://www.w3.org/2000/svg"
117
+ width="20"
118
+ height="20"
119
+ viewBox="0 0 24 24"
120
+ fill="none"
121
+ stroke="currentColor"
122
+ stroke-width="2"
123
+ stroke-linecap="round"
124
+ stroke-linejoin="round"
125
+ >
126
+ <polyline points="15 18 9 12 15 6"></polyline>
127
+ </svg>
128
+ <span>Back</span>
129
+ </button>
130
+ <Spacer />
131
+ <h2 class="sheet-title">{title}</h2>
132
+ <Spacer />
133
+ <div class="sheet-spacer"></div>
134
+ </HStack>
135
+ </header>
136
+ {/if}
137
+
138
+ <div class="sheet-content">
139
+ {@render children()}
140
+ </div>
141
+ </div>
142
+ </div>
143
+ {/if}
144
+
145
+ <style>
146
+ .sheet-backdrop {
147
+ position: fixed;
148
+ inset: 0;
149
+ background: rgba(0, 0, 0, 0.4);
150
+ backdrop-filter: blur(4px);
151
+ -webkit-backdrop-filter: blur(4px);
152
+ z-index: 1000;
153
+ opacity: 0;
154
+ visibility: hidden;
155
+ transition: all 0.3s ease;
156
+ }
157
+
158
+ .sheet-backdrop.open {
159
+ opacity: 1;
160
+ visibility: visible;
161
+ }
162
+
163
+ .sheet-container {
164
+ --sheet-y: 100vh;
165
+ position: fixed;
166
+ left: 0;
167
+ right: 0;
168
+ top: 0;
169
+ height: 100vh;
170
+ margin: 0 auto;
171
+ background: var(--glass-sheet-bg);
172
+ backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
173
+ -webkit-backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
174
+ border-radius: var(--glass-radius-xl) var(--glass-radius-xl) 0 0;
175
+ overflow: hidden;
176
+ display: flex;
177
+ flex-direction: column;
178
+ transform: translateY(var(--sheet-y));
179
+ transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
180
+ z-index: 1001;
181
+ border-top: 1px solid var(--glass-border);
182
+ box-shadow:
183
+ 0 -8px 32px -8px var(--glass-shadow),
184
+ inset 0 1px 0 0 var(--glass-highlight);
185
+ touch-action: none;
186
+ }
187
+
188
+ .sheet-handle-container {
189
+ display: flex;
190
+ justify-content: center;
191
+ padding: 8px 0;
192
+ cursor: grab;
193
+ }
194
+ .sheet-handle-container:active {
195
+ cursor: grabbing;
196
+ }
197
+
198
+ .sheet-handle {
199
+ width: 36px;
200
+ height: 5px;
201
+ background: var(--glass-handle);
202
+ border-radius: 3px;
203
+ }
204
+
205
+ .sheet-header {
206
+ padding: 0 var(--spacing-md);
207
+ height: 56px;
208
+ border-bottom: 1px solid var(--glass-divider);
209
+ display: flex;
210
+ align-items: center;
211
+ }
212
+
213
+ .sheet-close-btn {
214
+ display: flex;
215
+ align-items: center;
216
+ gap: 4px;
217
+ background: none;
218
+ border: none;
219
+ color: var(--color-accent);
220
+ font-size: 17px;
221
+ font-weight: 400;
222
+ cursor: pointer;
223
+ padding: 8px 0;
224
+ transition: opacity var(--transition-fast);
225
+ font-family: var(--font-system);
226
+ }
227
+
228
+ .sheet-close-btn:hover {
229
+ opacity: 0.7;
230
+ }
231
+
232
+ .sheet-close-btn svg {
233
+ margin-left: -6px;
234
+ }
235
+
236
+ .sheet-title {
237
+ font-size: 17px;
238
+ font-weight: 600;
239
+ color: var(--color-text);
240
+ text-align: center;
241
+ font-family: var(--font-system);
242
+ }
243
+
244
+ .sheet-spacer {
245
+ width: 80px;
246
+ }
247
+
248
+ .sheet-content {
249
+ flex: 1;
250
+ overflow-y: auto;
251
+ overflow-x: hidden;
252
+ -webkit-overflow-scrolling: touch;
253
+ font-family: var(--font-system);
254
+ }
255
+
256
+ @media (min-width: 769px) {
257
+ .sheet-container {
258
+ max-width: 900px;
259
+ }
260
+ }
261
+ </style>
@@ -9,3 +9,4 @@ export * from './navigation';
9
9
  export * from './list';
10
10
  export * from './typography';
11
11
  export * from './media';
12
+ export * from './menu';
@@ -16,3 +16,5 @@ export * from './list';
16
16
  export * from './typography';
17
17
  // Media
18
18
  export * from './media';
19
+ // Menu
20
+ export * from './menu';
@@ -1,52 +1,52 @@
1
- <script lang="ts">
2
- interface Props {
3
- label: string;
4
- variant?: 'default' | 'accent';
5
- size?: 'sm' | 'md';
6
- class?: string;
7
- }
8
-
9
- let {
10
- label,
11
- variant = 'default',
12
- size = 'md',
13
- class: className = ''
14
- }: Props = $props();
15
- </script>
16
-
17
- <span class="badge variant-{variant} size-{size} {className}">
18
- {label}
19
- </span>
20
-
21
- <style>
22
- .badge {
23
- display: inline-flex;
24
- align-items: center;
25
- justify-content: center;
26
- border-radius: var(--glass-radius-full);
27
- font-weight: 500;
28
- white-space: nowrap;
29
- }
30
-
31
- .badge.size-sm {
32
- padding: 4px 10px;
33
- font-size: 0.6875rem;
34
- }
35
-
36
- .badge.size-md {
37
- padding: 6px 14px;
38
- font-size: 0.75rem;
39
- }
40
-
41
- .badge.variant-default {
42
- background: var(--glass-badge-bg);
43
- color: var(--color-text-secondary);
44
- border: 1px solid var(--glass-border);
45
- }
46
-
47
- .badge.variant-accent {
48
- background: var(--color-accent-15);
49
- color: var(--color-accent);
50
- border: 1px solid var(--color-accent-25);
51
- }
52
- </style>
1
+ <script lang="ts">
2
+ interface Props {
3
+ label: string;
4
+ variant?: 'default' | 'accent';
5
+ size?: 'sm' | 'md';
6
+ class?: string;
7
+ }
8
+
9
+ let {
10
+ label,
11
+ variant = 'default',
12
+ size = 'md',
13
+ class: className = ''
14
+ }: Props = $props();
15
+ </script>
16
+
17
+ <span class="badge variant-{variant} size-{size} {className}">
18
+ {label}
19
+ </span>
20
+
21
+ <style>
22
+ .badge {
23
+ display: inline-flex;
24
+ align-items: center;
25
+ justify-content: center;
26
+ border-radius: var(--glass-radius-full);
27
+ font-weight: 500;
28
+ white-space: nowrap;
29
+ }
30
+
31
+ .badge.size-sm {
32
+ padding: 4px 10px;
33
+ font-size: 0.6875rem;
34
+ }
35
+
36
+ .badge.size-md {
37
+ padding: 6px 14px;
38
+ font-size: 0.75rem;
39
+ }
40
+
41
+ .badge.variant-default {
42
+ background: var(--glass-badge-bg);
43
+ color: var(--color-text-secondary);
44
+ border: 1px solid var(--glass-border);
45
+ }
46
+
47
+ .badge.variant-accent {
48
+ background: var(--color-accent-15);
49
+ color: var(--color-accent);
50
+ border: 1px solid var(--color-accent-25);
51
+ }
52
+ </style>