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.
Files changed (40) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +215 -215
  3. package/dist/components/glass/Glass.svelte +164 -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 +266 -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/layout/Divider.svelte +31 -31
  17. package/dist/components/layout/Grid.svelte +52 -52
  18. package/dist/components/layout/HStack.svelte +76 -76
  19. package/dist/components/layout/ScrollView.svelte +83 -83
  20. package/dist/components/layout/Spacer.svelte +18 -18
  21. package/dist/components/layout/VStack.svelte +56 -56
  22. package/dist/components/layout/ZStack.svelte +51 -51
  23. package/dist/components/list/List.svelte +50 -50
  24. package/dist/components/list/ListRow.svelte +181 -181
  25. package/dist/components/media/SymbolImage.svelte +46 -46
  26. package/dist/components/menu/Menu.svelte +206 -0
  27. package/dist/components/menu/Menu.svelte.d.ts +10 -0
  28. package/dist/components/menu/MenuItem.svelte +114 -0
  29. package/dist/components/menu/MenuItem.svelte.d.ts +12 -0
  30. package/dist/components/menu/index.d.ts +6 -0
  31. package/dist/components/menu/index.js +6 -0
  32. package/dist/components/navigation/NavigationBar.svelte +195 -195
  33. package/dist/components/navigation/NavigationLink.svelte +45 -45
  34. package/dist/components/typography/Text.svelte +98 -98
  35. package/dist/icons/index.js +4 -1
  36. package/dist/styles/glasslikeui.css +192 -192
  37. package/dist/styles/lens.css +93 -93
  38. package/dist/styles/squircle.css +17 -17
  39. package/dist/styles/typography.css +27 -27
  40. package/package.json +50 -50
@@ -1,181 +1,181 @@
1
- <script lang="ts">
2
- import type { Snippet } from 'svelte';
3
- import { HStack } from '../layout';
4
- import { VStack } from '../layout';
5
- import { SymbolImage } from '../media';
6
-
7
- interface Props {
8
- children: Snippet;
9
- leading?: Snippet;
10
- trailing?: Snippet;
11
- subtitle?: string;
12
- showDivider?: boolean;
13
- interactive?: boolean;
14
- href?: string;
15
- onclick?: () => void;
16
- class?: string;
17
- }
18
-
19
- let {
20
- children,
21
- leading,
22
- trailing,
23
- subtitle = '',
24
- showDivider = true,
25
- interactive = false,
26
- href,
27
- onclick,
28
- class: className = ''
29
- }: Props = $props();
30
-
31
- const isInteractive = $derived(interactive || !!href || !!onclick);
32
- </script>
33
-
34
- {#if href}
35
- <a {href} class="list-row {className}" class:interactive={isInteractive} class:has-divider={showDivider}>
36
- <HStack spacing="sm" alignment="center" class="row-content">
37
- {#if leading}
38
- <div class="row-leading">
39
- {@render leading()}
40
- </div>
41
- {/if}
42
-
43
- <VStack spacing="none" alignment="leading" class="row-main">
44
- <div class="row-title">
45
- {@render children()}
46
- </div>
47
- {#if subtitle}
48
- <div class="row-subtitle">{subtitle}</div>
49
- {/if}
50
- </VStack>
51
-
52
- {#if trailing}
53
- <div class="row-trailing">
54
- {@render trailing()}
55
- </div>
56
- {:else if isInteractive}
57
- <SymbolImage name="chevron.right" size="sm" color="tertiary" />
58
- {/if}
59
- </HStack>
60
- </a>
61
- {:else if onclick}
62
- <button class="list-row {className}" class:interactive={isInteractive} class:has-divider={showDivider} {onclick}>
63
- <HStack spacing="sm" alignment="center" class="row-content">
64
- {#if leading}
65
- <div class="row-leading">
66
- {@render leading()}
67
- </div>
68
- {/if}
69
-
70
- <VStack spacing="none" alignment="leading" class="row-main">
71
- <div class="row-title">
72
- {@render children()}
73
- </div>
74
- {#if subtitle}
75
- <div class="row-subtitle">{subtitle}</div>
76
- {/if}
77
- </VStack>
78
-
79
- {#if trailing}
80
- <div class="row-trailing">
81
- {@render trailing()}
82
- </div>
83
- {:else if isInteractive}
84
- <SymbolImage name="chevron.right" size="sm" color="tertiary" />
85
- {/if}
86
- </HStack>
87
- </button>
88
- {:else}
89
- <div class="list-row {className}" class:has-divider={showDivider}>
90
- <HStack spacing="sm" alignment="center" class="row-content">
91
- {#if leading}
92
- <div class="row-leading">
93
- {@render leading()}
94
- </div>
95
- {/if}
96
-
97
- <VStack spacing="none" alignment="leading" class="row-main">
98
- <div class="row-title">
99
- {@render children()}
100
- </div>
101
- {#if subtitle}
102
- <div class="row-subtitle">{subtitle}</div>
103
- {/if}
104
- </VStack>
105
-
106
- {#if trailing}
107
- <div class="row-trailing">
108
- {@render trailing()}
109
- </div>
110
- {/if}
111
- </HStack>
112
- </div>
113
- {/if}
114
-
115
- <style>
116
- .list-row {
117
- display: block;
118
- width: 100%;
119
- padding: 0;
120
- background: transparent;
121
- border: none;
122
- text-decoration: none;
123
- color: inherit;
124
- text-align: left;
125
- font-family: inherit;
126
- cursor: default;
127
- }
128
-
129
- .list-row.interactive {
130
- cursor: pointer;
131
- }
132
-
133
- .list-row.interactive:hover {
134
- background: var(--glass-hover-subtle);
135
- }
136
-
137
- .list-row.interactive:active {
138
- background: var(--glass-active-subtle);
139
- }
140
-
141
- :global(.row-content) {
142
- padding: var(--spacing-sm) var(--spacing-md);
143
- min-height: 44px;
144
- }
145
-
146
- .list-row.has-divider {
147
- border-bottom: 1px solid var(--glass-divider);
148
- }
149
-
150
- .list-row:last-child {
151
- border-bottom: none;
152
- }
153
-
154
- .row-leading {
155
- display: flex;
156
- align-items: center;
157
- justify-content: center;
158
- }
159
-
160
- :global(.row-main) {
161
- flex: 1;
162
- min-width: 0;
163
- }
164
-
165
- .row-title {
166
- font-size: 1rem;
167
- color: var(--color-text);
168
- }
169
-
170
- .row-subtitle {
171
- font-size: 0.8125rem;
172
- color: var(--color-text-secondary);
173
- margin-top: 2px;
174
- }
175
-
176
- .row-trailing {
177
- display: flex;
178
- align-items: center;
179
- color: var(--color-text-tertiary);
180
- }
181
- </style>
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import { HStack } from '../layout';
4
+ import { VStack } from '../layout';
5
+ import { SymbolImage } from '../media';
6
+
7
+ interface Props {
8
+ children: Snippet;
9
+ leading?: Snippet;
10
+ trailing?: Snippet;
11
+ subtitle?: string;
12
+ showDivider?: boolean;
13
+ interactive?: boolean;
14
+ href?: string;
15
+ onclick?: () => void;
16
+ class?: string;
17
+ }
18
+
19
+ let {
20
+ children,
21
+ leading,
22
+ trailing,
23
+ subtitle = '',
24
+ showDivider = true,
25
+ interactive = false,
26
+ href,
27
+ onclick,
28
+ class: className = ''
29
+ }: Props = $props();
30
+
31
+ const isInteractive = $derived(interactive || !!href || !!onclick);
32
+ </script>
33
+
34
+ {#if href}
35
+ <a {href} class="list-row {className}" class:interactive={isInteractive} class:has-divider={showDivider}>
36
+ <HStack spacing="sm" alignment="center" class="row-content">
37
+ {#if leading}
38
+ <div class="row-leading">
39
+ {@render leading()}
40
+ </div>
41
+ {/if}
42
+
43
+ <VStack spacing="none" alignment="leading" class="row-main">
44
+ <div class="row-title">
45
+ {@render children()}
46
+ </div>
47
+ {#if subtitle}
48
+ <div class="row-subtitle">{subtitle}</div>
49
+ {/if}
50
+ </VStack>
51
+
52
+ {#if trailing}
53
+ <div class="row-trailing">
54
+ {@render trailing()}
55
+ </div>
56
+ {:else if isInteractive}
57
+ <SymbolImage name="chevron.right" size="sm" color="tertiary" />
58
+ {/if}
59
+ </HStack>
60
+ </a>
61
+ {:else if onclick}
62
+ <button class="list-row {className}" class:interactive={isInteractive} class:has-divider={showDivider} {onclick}>
63
+ <HStack spacing="sm" alignment="center" class="row-content">
64
+ {#if leading}
65
+ <div class="row-leading">
66
+ {@render leading()}
67
+ </div>
68
+ {/if}
69
+
70
+ <VStack spacing="none" alignment="leading" class="row-main">
71
+ <div class="row-title">
72
+ {@render children()}
73
+ </div>
74
+ {#if subtitle}
75
+ <div class="row-subtitle">{subtitle}</div>
76
+ {/if}
77
+ </VStack>
78
+
79
+ {#if trailing}
80
+ <div class="row-trailing">
81
+ {@render trailing()}
82
+ </div>
83
+ {:else if isInteractive}
84
+ <SymbolImage name="chevron.right" size="sm" color="tertiary" />
85
+ {/if}
86
+ </HStack>
87
+ </button>
88
+ {:else}
89
+ <div class="list-row {className}" class:has-divider={showDivider}>
90
+ <HStack spacing="sm" alignment="center" class="row-content">
91
+ {#if leading}
92
+ <div class="row-leading">
93
+ {@render leading()}
94
+ </div>
95
+ {/if}
96
+
97
+ <VStack spacing="none" alignment="leading" class="row-main">
98
+ <div class="row-title">
99
+ {@render children()}
100
+ </div>
101
+ {#if subtitle}
102
+ <div class="row-subtitle">{subtitle}</div>
103
+ {/if}
104
+ </VStack>
105
+
106
+ {#if trailing}
107
+ <div class="row-trailing">
108
+ {@render trailing()}
109
+ </div>
110
+ {/if}
111
+ </HStack>
112
+ </div>
113
+ {/if}
114
+
115
+ <style>
116
+ .list-row {
117
+ display: block;
118
+ width: 100%;
119
+ padding: 0;
120
+ background: transparent;
121
+ border: none;
122
+ text-decoration: none;
123
+ color: inherit;
124
+ text-align: left;
125
+ font-family: inherit;
126
+ cursor: default;
127
+ }
128
+
129
+ .list-row.interactive {
130
+ cursor: pointer;
131
+ }
132
+
133
+ .list-row.interactive:hover {
134
+ background: var(--glass-hover-subtle);
135
+ }
136
+
137
+ .list-row.interactive:active {
138
+ background: var(--glass-active-subtle);
139
+ }
140
+
141
+ :global(.row-content) {
142
+ padding: var(--spacing-sm) var(--spacing-md);
143
+ min-height: 44px;
144
+ }
145
+
146
+ .list-row.has-divider {
147
+ border-bottom: 1px solid var(--glass-divider);
148
+ }
149
+
150
+ .list-row:last-child {
151
+ border-bottom: none;
152
+ }
153
+
154
+ .row-leading {
155
+ display: flex;
156
+ align-items: center;
157
+ justify-content: center;
158
+ }
159
+
160
+ :global(.row-main) {
161
+ flex: 1;
162
+ min-width: 0;
163
+ }
164
+
165
+ .row-title {
166
+ font-size: 1rem;
167
+ color: var(--color-text);
168
+ }
169
+
170
+ .row-subtitle {
171
+ font-size: 0.8125rem;
172
+ color: var(--color-text-secondary);
173
+ margin-top: 2px;
174
+ }
175
+
176
+ .row-trailing {
177
+ display: flex;
178
+ align-items: center;
179
+ color: var(--color-text-tertiary);
180
+ }
181
+ </style>
@@ -1,46 +1,46 @@
1
- <script lang="ts">
2
- import { ICON_SIZES, TEXT_COLORS } from '../../constants';
3
- import { getIconPath } from '../../icons';
4
- import type { IconSize, TextColor } from '../../constants';
5
-
6
- interface Props {
7
- name: string;
8
- size?: IconSize;
9
- color?: TextColor;
10
- class?: string;
11
- }
12
-
13
- let {
14
- name,
15
- size = 'md',
16
- color = 'primary',
17
- class: className = ''
18
- }: Props = $props();
19
-
20
- // Security Note: iconPath is always from hardcoded ICONS map, never user input
21
- const iconPath = $derived(getIconPath(name));
22
- const pixelSize = $derived(ICON_SIZES[size]);
23
- const colorValue = $derived(TEXT_COLORS[color]);
24
- </script>
25
-
26
- <svg
27
- class="symbol-image {className}"
28
- xmlns="http://www.w3.org/2000/svg"
29
- width={pixelSize}
30
- height={pixelSize}
31
- viewBox="0 0 24 24"
32
- fill="none"
33
- stroke={colorValue}
34
- stroke-width="2"
35
- stroke-linecap="round"
36
- stroke-linejoin="round"
37
- style="color: {colorValue}"
38
- >
39
- {@html iconPath}
40
- </svg>
41
-
42
- <style>
43
- .symbol-image {
44
- flex-shrink: 0;
45
- }
46
- </style>
1
+ <script lang="ts">
2
+ import { ICON_SIZES, TEXT_COLORS } from '../../constants';
3
+ import { getIconPath } from '../../icons';
4
+ import type { IconSize, TextColor } from '../../constants';
5
+
6
+ interface Props {
7
+ name: string;
8
+ size?: IconSize;
9
+ color?: TextColor;
10
+ class?: string;
11
+ }
12
+
13
+ let {
14
+ name,
15
+ size = 'md',
16
+ color = 'primary',
17
+ class: className = ''
18
+ }: Props = $props();
19
+
20
+ // Security Note: iconPath is always from hardcoded ICONS map, never user input
21
+ const iconPath = $derived(getIconPath(name));
22
+ const pixelSize = $derived(ICON_SIZES[size]);
23
+ const colorValue = $derived(TEXT_COLORS[color]);
24
+ </script>
25
+
26
+ <svg
27
+ class="symbol-image {className}"
28
+ xmlns="http://www.w3.org/2000/svg"
29
+ width={pixelSize}
30
+ height={pixelSize}
31
+ viewBox="0 0 24 24"
32
+ fill="none"
33
+ stroke={colorValue}
34
+ stroke-width="2"
35
+ stroke-linecap="round"
36
+ stroke-linejoin="round"
37
+ style="color: {colorValue}"
38
+ >
39
+ {@html iconPath}
40
+ </svg>
41
+
42
+ <style>
43
+ .symbol-image {
44
+ flex-shrink: 0;
45
+ }
46
+ </style>
@@ -0,0 +1,206 @@
1
+ <script module>
2
+ let counter = 0;
3
+ </script>
4
+
5
+ <script lang="ts">
6
+ import type { Snippet } from 'svelte';
7
+ import { tick } from 'svelte';
8
+
9
+ interface Props {
10
+ label: Snippet;
11
+ children: Snippet;
12
+ align?: 'start' | 'end';
13
+ class?: string;
14
+ }
15
+
16
+ let { label, children, align = 'start', class: className = '' }: Props = $props();
17
+
18
+ // Note: counter resets between SSR and client hydration; aria-controls mismatch
19
+ // is inert because the panel is not rendered on initial load (open defaults false).
20
+ const panelId = `glass-menu-${++counter}`;
21
+ const isBrowser = typeof window !== 'undefined';
22
+
23
+ let open = $state(false);
24
+ let triggerEl = $state<HTMLButtonElement>();
25
+ let panelEl = $state<HTMLDivElement>();
26
+
27
+ function menuItems(): HTMLElement[] {
28
+ if (!panelEl) return [];
29
+ return Array.from(panelEl.querySelectorAll<HTMLElement>('[role="menuitem"]'));
30
+ }
31
+
32
+ async function openMenu() {
33
+ open = true;
34
+ await tick();
35
+ menuItems()[0]?.focus();
36
+ }
37
+
38
+ function closeMenu(focusTrigger = false) {
39
+ open = false;
40
+ if (focusTrigger) triggerEl?.focus();
41
+ }
42
+
43
+ function toggle() {
44
+ if (open) closeMenu();
45
+ else openMenu();
46
+ }
47
+
48
+ function handlePanelKeydown(e: KeyboardEvent) {
49
+ const items = menuItems();
50
+ if (items.length === 0) return;
51
+ const current = items.indexOf(document.activeElement as HTMLElement);
52
+
53
+ if (e.key === 'Escape') {
54
+ e.preventDefault();
55
+ closeMenu(true);
56
+ } else if (e.key === 'ArrowDown') {
57
+ e.preventDefault();
58
+ items[(current + 1) % items.length]?.focus();
59
+ } else if (e.key === 'ArrowUp') {
60
+ e.preventDefault();
61
+ items[(current - 1 + items.length) % items.length]?.focus();
62
+ } else if (e.key === 'Home') {
63
+ e.preventDefault();
64
+ items[0]?.focus();
65
+ } else if (e.key === 'End') {
66
+ e.preventDefault();
67
+ items[items.length - 1]?.focus();
68
+ }
69
+ }
70
+
71
+ function handlePanelClick(e: MouseEvent) {
72
+ const target = e.target as HTMLElement;
73
+ if (target.closest('[role="menuitem"]')) {
74
+ closeMenu();
75
+ }
76
+ }
77
+
78
+ $effect(() => {
79
+ if (!open || !isBrowser) return;
80
+ const panel = panelEl;
81
+ if (!panel) return;
82
+
83
+ function onPointerDown(e: PointerEvent) {
84
+ const target = e.target as Node;
85
+ if (triggerEl?.contains(target) || panel.contains(target)) return;
86
+ closeMenu();
87
+ }
88
+
89
+ panel.addEventListener('keydown', handlePanelKeydown);
90
+ panel.addEventListener('click', handlePanelClick);
91
+ document.addEventListener('pointerdown', onPointerDown, true);
92
+
93
+ return () => {
94
+ panel.removeEventListener('keydown', handlePanelKeydown);
95
+ panel.removeEventListener('click', handlePanelClick);
96
+ document.removeEventListener('pointerdown', onPointerDown, true);
97
+ };
98
+ });
99
+ </script>
100
+
101
+ <div class="glass-menu">
102
+ <button
103
+ bind:this={triggerEl}
104
+ type="button"
105
+ class="glass-menu-trigger {className}"
106
+ aria-haspopup="menu"
107
+ aria-expanded={open}
108
+ aria-controls={panelId}
109
+ onclick={toggle}
110
+ >
111
+ {@render label()}
112
+ </button>
113
+
114
+ {#if open}
115
+ <div
116
+ bind:this={panelEl}
117
+ id={panelId}
118
+ role="menu"
119
+ class="glass-menu-panel"
120
+ class:align-end={align === 'end'}
121
+ >
122
+ {@render children()}
123
+ </div>
124
+ {/if}
125
+ </div>
126
+
127
+ <style>
128
+ .glass-menu {
129
+ position: relative;
130
+ display: inline-flex;
131
+ }
132
+
133
+ .glass-menu-trigger {
134
+ display: inline-flex;
135
+ align-items: center;
136
+ gap: 4px;
137
+ margin: 0;
138
+ padding: 0;
139
+ background: none;
140
+ border: none;
141
+ font: inherit;
142
+ color: inherit;
143
+ cursor: pointer;
144
+ }
145
+
146
+ .glass-menu-panel {
147
+ position: absolute;
148
+ top: calc(100% + 8px);
149
+ left: 0;
150
+ min-width: 220px;
151
+ padding: 0;
152
+ overflow: hidden;
153
+ background: var(--glass-sheet-bg);
154
+ backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
155
+ -webkit-backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
156
+ border: var(--glass-border-width) solid var(--glass-border);
157
+ border-radius: var(--glass-radius-md);
158
+ box-shadow:
159
+ 0 12px 40px -8px var(--glass-shadow),
160
+ 0 4px 12px -2px var(--glass-shadow);
161
+ z-index: 200;
162
+ transform-origin: top left;
163
+ animation: glass-menu-pop 0.18s cubic-bezier(0.32, 0.72, 0, 1);
164
+ }
165
+
166
+ .glass-menu-panel.align-end {
167
+ left: auto;
168
+ right: 0;
169
+ transform-origin: top right;
170
+ }
171
+
172
+ /* Hairline divider between consecutive items. */
173
+ .glass-menu-panel :global(.menu-item + .menu-item) {
174
+ border-top: var(--glass-border-width) solid var(--glass-divider);
175
+ }
176
+
177
+ @keyframes glass-menu-pop {
178
+ from {
179
+ opacity: 0;
180
+ transform: scale(0.92);
181
+ }
182
+ to {
183
+ opacity: 1;
184
+ transform: scale(1);
185
+ }
186
+ }
187
+
188
+ @media (prefers-reduced-motion: reduce) {
189
+ .glass-menu-panel {
190
+ animation: glass-menu-fade 0.01s linear;
191
+ }
192
+ }
193
+
194
+ :global([data-reduced-motion='true']) .glass-menu-panel {
195
+ animation: glass-menu-fade 0.01s linear;
196
+ }
197
+
198
+ @keyframes glass-menu-fade {
199
+ from {
200
+ opacity: 0;
201
+ }
202
+ to {
203
+ opacity: 1;
204
+ }
205
+ }
206
+ </style>
@@ -0,0 +1,10 @@
1
+ import type { Snippet } from 'svelte';
2
+ interface Props {
3
+ label: Snippet;
4
+ children: Snippet;
5
+ align?: 'start' | 'end';
6
+ class?: string;
7
+ }
8
+ declare const Menu: import("svelte").Component<Props, {}, string>;
9
+ type Menu = ReturnType<typeof Menu>;
10
+ export default Menu;