glasslikeui 1.0.0 → 1.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.
- 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/interactive/Badge.svelte +52 -52
- package/dist/components/interactive/Button.svelte +168 -168
- package/dist/components/interactive/IconButton.svelte +74 -74
- package/dist/components/interactive/TabView.svelte +107 -18
- 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/navigation/NavigationBar.svelte +195 -195
- package/dist/components/navigation/NavigationLink.svelte +45 -45
- package/dist/components/typography/Text.svelte +98 -98
- 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
|
@@ -1,168 +1,168 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
children: Snippet;
|
|
6
|
-
variant?: 'filled' | 'outlined' | 'plain' | 'tinted' | 'destructive';
|
|
7
|
-
size?: 'sm' | 'md' | 'lg';
|
|
8
|
-
fullWidth?: boolean;
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
href?: string | undefined;
|
|
11
|
-
onclick?: ((e: MouseEvent) => void) | undefined;
|
|
12
|
-
class?: string;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
let {
|
|
16
|
-
children,
|
|
17
|
-
variant = 'filled',
|
|
18
|
-
size = 'md',
|
|
19
|
-
fullWidth = false,
|
|
20
|
-
disabled = false,
|
|
21
|
-
href,
|
|
22
|
-
onclick,
|
|
23
|
-
class: className = ''
|
|
24
|
-
}: Props = $props();
|
|
25
|
-
|
|
26
|
-
const sizeStyles = {
|
|
27
|
-
sm: { padding: '8px 16px', fontSize: '0.875rem' },
|
|
28
|
-
md: { padding: '12px 24px', fontSize: '1rem' },
|
|
29
|
-
lg: { padding: '16px 32px', fontSize: '1.0625rem' }
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const styles = $derived(sizeStyles[size]);
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
{#if href}
|
|
36
|
-
<a
|
|
37
|
-
{href}
|
|
38
|
-
class="button variant-{variant} size-{size} {className}"
|
|
39
|
-
class:full-width={fullWidth}
|
|
40
|
-
class:disabled
|
|
41
|
-
onclick={onclick}
|
|
42
|
-
style="
|
|
43
|
-
--btn-padding: {styles.padding};
|
|
44
|
-
--btn-font-size: {styles.fontSize};
|
|
45
|
-
"
|
|
46
|
-
>
|
|
47
|
-
{@render children()}
|
|
48
|
-
</a>
|
|
49
|
-
{:else}
|
|
50
|
-
<button
|
|
51
|
-
class="button variant-{variant} size-{size} {className}"
|
|
52
|
-
class:full-width={fullWidth}
|
|
53
|
-
{disabled}
|
|
54
|
-
{onclick}
|
|
55
|
-
style="
|
|
56
|
-
--btn-padding: {styles.padding};
|
|
57
|
-
--btn-font-size: {styles.fontSize};
|
|
58
|
-
"
|
|
59
|
-
>
|
|
60
|
-
{@render children()}
|
|
61
|
-
</button>
|
|
62
|
-
{/if}
|
|
63
|
-
|
|
64
|
-
<style>
|
|
65
|
-
.button {
|
|
66
|
-
display: inline-flex;
|
|
67
|
-
align-items: center;
|
|
68
|
-
justify-content: center;
|
|
69
|
-
gap: 8px;
|
|
70
|
-
padding: var(--btn-padding);
|
|
71
|
-
font-size: var(--btn-font-size);
|
|
72
|
-
font-weight: 500;
|
|
73
|
-
font-family: inherit;
|
|
74
|
-
border: none;
|
|
75
|
-
border-radius: var(--glass-radius-full);
|
|
76
|
-
cursor: pointer;
|
|
77
|
-
text-decoration: none;
|
|
78
|
-
transition: all var(--transition-fast);
|
|
79
|
-
position: relative;
|
|
80
|
-
overflow: hidden;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.button.full-width {
|
|
84
|
-
width: 100%;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
.button.disabled {
|
|
88
|
-
opacity: 0.5;
|
|
89
|
-
pointer-events: none;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/* Filled variant */
|
|
93
|
-
.button.variant-filled {
|
|
94
|
-
background: var(--color-accent);
|
|
95
|
-
color: white;
|
|
96
|
-
box-shadow: 0 4px 16px -4px var(--color-accent-50);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
.button.variant-filled:hover {
|
|
100
|
-
background: var(--color-accent-hover);
|
|
101
|
-
box-shadow: 0 8px 28px -6px var(--color-accent-50);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.button.variant-filled:active {
|
|
105
|
-
background: var(--color-accent-active);
|
|
106
|
-
box-shadow: 0 2px 10px -4px var(--color-accent-50);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/* Outlined variant */
|
|
110
|
-
.button.variant-outlined {
|
|
111
|
-
background: transparent;
|
|
112
|
-
color: var(--color-accent);
|
|
113
|
-
border: 1.5px solid var(--color-accent);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
.button.variant-outlined:hover {
|
|
117
|
-
background: var(--color-accent-10);
|
|
118
|
-
border-color: var(--color-accent-hover);
|
|
119
|
-
color: var(--color-accent-hover);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
.button.variant-outlined:active {
|
|
123
|
-
background: var(--color-accent-15);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/* Plain variant */
|
|
127
|
-
.button.variant-plain {
|
|
128
|
-
background: transparent;
|
|
129
|
-
color: var(--color-accent);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
.button.variant-plain:hover {
|
|
133
|
-
color: var(--color-accent-hover);
|
|
134
|
-
text-decoration: underline;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/* Tinted variant */
|
|
138
|
-
.button.variant-tinted {
|
|
139
|
-
background: var(--color-accent-15);
|
|
140
|
-
color: var(--color-accent);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.button.variant-tinted:hover {
|
|
144
|
-
background: var(--color-accent-25);
|
|
145
|
-
color: var(--color-accent-hover);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.button.variant-tinted:active {
|
|
149
|
-
background: var(--color-accent-10);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/* Destructive variant */
|
|
153
|
-
.button.variant-destructive {
|
|
154
|
-
background: var(--color-danger);
|
|
155
|
-
color: white;
|
|
156
|
-
box-shadow: 0 4px 16px -4px color-mix(in srgb, var(--color-danger) 50%, transparent);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.button.variant-destructive:hover {
|
|
160
|
-
background: var(--color-danger-hover);
|
|
161
|
-
box-shadow: 0 8px 28px -6px color-mix(in srgb, var(--color-danger) 50%, transparent);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
.button.variant-destructive:active {
|
|
165
|
-
background: var(--color-danger-active);
|
|
166
|
-
box-shadow: 0 2px 10px -4px color-mix(in srgb, var(--color-danger) 50%, transparent);
|
|
167
|
-
}
|
|
168
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
children: Snippet;
|
|
6
|
+
variant?: 'filled' | 'outlined' | 'plain' | 'tinted' | 'destructive';
|
|
7
|
+
size?: 'sm' | 'md' | 'lg';
|
|
8
|
+
fullWidth?: boolean;
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
href?: string | undefined;
|
|
11
|
+
onclick?: ((e: MouseEvent) => void) | undefined;
|
|
12
|
+
class?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
children,
|
|
17
|
+
variant = 'filled',
|
|
18
|
+
size = 'md',
|
|
19
|
+
fullWidth = false,
|
|
20
|
+
disabled = false,
|
|
21
|
+
href,
|
|
22
|
+
onclick,
|
|
23
|
+
class: className = ''
|
|
24
|
+
}: Props = $props();
|
|
25
|
+
|
|
26
|
+
const sizeStyles = {
|
|
27
|
+
sm: { padding: '8px 16px', fontSize: '0.875rem' },
|
|
28
|
+
md: { padding: '12px 24px', fontSize: '1rem' },
|
|
29
|
+
lg: { padding: '16px 32px', fontSize: '1.0625rem' }
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const styles = $derived(sizeStyles[size]);
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
{#if href}
|
|
36
|
+
<a
|
|
37
|
+
{href}
|
|
38
|
+
class="button variant-{variant} size-{size} {className}"
|
|
39
|
+
class:full-width={fullWidth}
|
|
40
|
+
class:disabled
|
|
41
|
+
onclick={onclick}
|
|
42
|
+
style="
|
|
43
|
+
--btn-padding: {styles.padding};
|
|
44
|
+
--btn-font-size: {styles.fontSize};
|
|
45
|
+
"
|
|
46
|
+
>
|
|
47
|
+
{@render children()}
|
|
48
|
+
</a>
|
|
49
|
+
{:else}
|
|
50
|
+
<button
|
|
51
|
+
class="button variant-{variant} size-{size} {className}"
|
|
52
|
+
class:full-width={fullWidth}
|
|
53
|
+
{disabled}
|
|
54
|
+
{onclick}
|
|
55
|
+
style="
|
|
56
|
+
--btn-padding: {styles.padding};
|
|
57
|
+
--btn-font-size: {styles.fontSize};
|
|
58
|
+
"
|
|
59
|
+
>
|
|
60
|
+
{@render children()}
|
|
61
|
+
</button>
|
|
62
|
+
{/if}
|
|
63
|
+
|
|
64
|
+
<style>
|
|
65
|
+
.button {
|
|
66
|
+
display: inline-flex;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
gap: 8px;
|
|
70
|
+
padding: var(--btn-padding);
|
|
71
|
+
font-size: var(--btn-font-size);
|
|
72
|
+
font-weight: 500;
|
|
73
|
+
font-family: inherit;
|
|
74
|
+
border: none;
|
|
75
|
+
border-radius: var(--glass-radius-full);
|
|
76
|
+
cursor: pointer;
|
|
77
|
+
text-decoration: none;
|
|
78
|
+
transition: all var(--transition-fast);
|
|
79
|
+
position: relative;
|
|
80
|
+
overflow: hidden;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.button.full-width {
|
|
84
|
+
width: 100%;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.button.disabled {
|
|
88
|
+
opacity: 0.5;
|
|
89
|
+
pointer-events: none;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* Filled variant */
|
|
93
|
+
.button.variant-filled {
|
|
94
|
+
background: var(--color-accent);
|
|
95
|
+
color: white;
|
|
96
|
+
box-shadow: 0 4px 16px -4px var(--color-accent-50);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.button.variant-filled:hover {
|
|
100
|
+
background: var(--color-accent-hover);
|
|
101
|
+
box-shadow: 0 8px 28px -6px var(--color-accent-50);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.button.variant-filled:active {
|
|
105
|
+
background: var(--color-accent-active);
|
|
106
|
+
box-shadow: 0 2px 10px -4px var(--color-accent-50);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* Outlined variant */
|
|
110
|
+
.button.variant-outlined {
|
|
111
|
+
background: transparent;
|
|
112
|
+
color: var(--color-accent);
|
|
113
|
+
border: 1.5px solid var(--color-accent);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.button.variant-outlined:hover {
|
|
117
|
+
background: var(--color-accent-10);
|
|
118
|
+
border-color: var(--color-accent-hover);
|
|
119
|
+
color: var(--color-accent-hover);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.button.variant-outlined:active {
|
|
123
|
+
background: var(--color-accent-15);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* Plain variant */
|
|
127
|
+
.button.variant-plain {
|
|
128
|
+
background: transparent;
|
|
129
|
+
color: var(--color-accent);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.button.variant-plain:hover {
|
|
133
|
+
color: var(--color-accent-hover);
|
|
134
|
+
text-decoration: underline;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/* Tinted variant */
|
|
138
|
+
.button.variant-tinted {
|
|
139
|
+
background: var(--color-accent-15);
|
|
140
|
+
color: var(--color-accent);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.button.variant-tinted:hover {
|
|
144
|
+
background: var(--color-accent-25);
|
|
145
|
+
color: var(--color-accent-hover);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.button.variant-tinted:active {
|
|
149
|
+
background: var(--color-accent-10);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/* Destructive variant */
|
|
153
|
+
.button.variant-destructive {
|
|
154
|
+
background: var(--color-danger);
|
|
155
|
+
color: white;
|
|
156
|
+
box-shadow: 0 4px 16px -4px color-mix(in srgb, var(--color-danger) 50%, transparent);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.button.variant-destructive:hover {
|
|
160
|
+
background: var(--color-danger-hover);
|
|
161
|
+
box-shadow: 0 8px 28px -6px color-mix(in srgb, var(--color-danger) 50%, transparent);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.button.variant-destructive:active {
|
|
165
|
+
background: var(--color-danger-active);
|
|
166
|
+
box-shadow: 0 2px 10px -4px color-mix(in srgb, var(--color-danger) 50%, transparent);
|
|
167
|
+
}
|
|
168
|
+
</style>
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
children: Snippet;
|
|
6
|
-
variant?: 'plain' | 'filled';
|
|
7
|
-
size?: 'sm' | 'md' | 'lg';
|
|
8
|
-
label?: string | undefined;
|
|
9
|
-
onclick?: ((e: MouseEvent) => void) | undefined;
|
|
10
|
-
class?: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
let {
|
|
14
|
-
children,
|
|
15
|
-
variant = 'plain',
|
|
16
|
-
size = 'md',
|
|
17
|
-
label = '',
|
|
18
|
-
onclick,
|
|
19
|
-
class: className = ''
|
|
20
|
-
}: Props = $props();
|
|
21
|
-
|
|
22
|
-
const sizeMap = {
|
|
23
|
-
sm: 32,
|
|
24
|
-
md: 40,
|
|
25
|
-
lg: 48
|
|
26
|
-
};
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<button
|
|
30
|
-
class="icon-button variant-{variant} size-{size} {className}"
|
|
31
|
-
aria-label={label}
|
|
32
|
-
title={label}
|
|
33
|
-
{onclick}
|
|
34
|
-
style="--btn-size: {sizeMap[size]}px"
|
|
35
|
-
>
|
|
36
|
-
{@render children()}
|
|
37
|
-
</button>
|
|
38
|
-
|
|
39
|
-
<style>
|
|
40
|
-
.icon-button {
|
|
41
|
-
display: flex;
|
|
42
|
-
align-items: center;
|
|
43
|
-
justify-content: center;
|
|
44
|
-
width: var(--btn-size);
|
|
45
|
-
height: var(--btn-size);
|
|
46
|
-
border: none;
|
|
47
|
-
border-radius: var(--glass-radius-full);
|
|
48
|
-
cursor: pointer;
|
|
49
|
-
transition: all var(--transition-fast);
|
|
50
|
-
background: transparent;
|
|
51
|
-
color: var(--color-text-secondary);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.icon-button:hover {
|
|
55
|
-
color: var(--color-text);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.icon-button.variant-plain {
|
|
59
|
-
background: transparent;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.icon-button.variant-plain:hover {
|
|
63
|
-
background: var(--glass-hover-subtle);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.icon-button.variant-filled {
|
|
67
|
-
background: var(--color-accent);
|
|
68
|
-
color: white;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.icon-button.variant-filled:hover {
|
|
72
|
-
background: var(--color-accent-hover);
|
|
73
|
-
}
|
|
74
|
-
</style>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
children: Snippet;
|
|
6
|
+
variant?: 'plain' | 'filled';
|
|
7
|
+
size?: 'sm' | 'md' | 'lg';
|
|
8
|
+
label?: string | undefined;
|
|
9
|
+
onclick?: ((e: MouseEvent) => void) | undefined;
|
|
10
|
+
class?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
children,
|
|
15
|
+
variant = 'plain',
|
|
16
|
+
size = 'md',
|
|
17
|
+
label = '',
|
|
18
|
+
onclick,
|
|
19
|
+
class: className = ''
|
|
20
|
+
}: Props = $props();
|
|
21
|
+
|
|
22
|
+
const sizeMap = {
|
|
23
|
+
sm: 32,
|
|
24
|
+
md: 40,
|
|
25
|
+
lg: 48
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<button
|
|
30
|
+
class="icon-button variant-{variant} size-{size} {className}"
|
|
31
|
+
aria-label={label}
|
|
32
|
+
title={label}
|
|
33
|
+
{onclick}
|
|
34
|
+
style="--btn-size: {sizeMap[size]}px"
|
|
35
|
+
>
|
|
36
|
+
{@render children()}
|
|
37
|
+
</button>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
.icon-button {
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
width: var(--btn-size);
|
|
45
|
+
height: var(--btn-size);
|
|
46
|
+
border: none;
|
|
47
|
+
border-radius: var(--glass-radius-full);
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
transition: all var(--transition-fast);
|
|
50
|
+
background: transparent;
|
|
51
|
+
color: var(--color-text-secondary);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.icon-button:hover {
|
|
55
|
+
color: var(--color-text);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.icon-button.variant-plain {
|
|
59
|
+
background: transparent;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.icon-button.variant-plain:hover {
|
|
63
|
+
background: var(--glass-hover-subtle);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.icon-button.variant-filled {
|
|
67
|
+
background: var(--color-accent);
|
|
68
|
+
color: white;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.icon-button.variant-filled:hover {
|
|
72
|
+
background: var(--color-accent-hover);
|
|
73
|
+
}
|
|
74
|
+
</style>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import { onMount } from 'svelte';
|
|
3
4
|
import { Glass } from '../glass';
|
|
4
5
|
import { HStack } from '../layout';
|
|
5
6
|
|
|
@@ -33,6 +34,40 @@
|
|
|
33
34
|
activeTab = tabId;
|
|
34
35
|
onchange?.(tabId);
|
|
35
36
|
}
|
|
37
|
+
|
|
38
|
+
let wrapperEl = $state<HTMLDivElement | undefined>();
|
|
39
|
+
let buttonEls: Record<string, HTMLButtonElement | undefined> = $state({});
|
|
40
|
+
let indicatorLeft = $state(0);
|
|
41
|
+
let indicatorWidth = $state(0);
|
|
42
|
+
let indicatorReady = $state(false);
|
|
43
|
+
|
|
44
|
+
function measure() {
|
|
45
|
+
const wrapper = wrapperEl;
|
|
46
|
+
const btn = buttonEls[activeTab];
|
|
47
|
+
if (!wrapper || !btn) {
|
|
48
|
+
indicatorReady = false;
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
indicatorLeft = btn.offsetLeft;
|
|
52
|
+
indicatorWidth = btn.offsetWidth;
|
|
53
|
+
indicatorReady = true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
$effect(() => {
|
|
57
|
+
// Re-measure whenever the active tab changes; RAF lets the DOM settle first.
|
|
58
|
+
void activeTab;
|
|
59
|
+
if (typeof requestAnimationFrame === 'undefined') return;
|
|
60
|
+
const id = requestAnimationFrame(measure);
|
|
61
|
+
return () => cancelAnimationFrame(id);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
onMount(() => {
|
|
65
|
+
measure();
|
|
66
|
+
if (typeof ResizeObserver === 'undefined' || !wrapperEl) return;
|
|
67
|
+
const ro = new ResizeObserver(() => measure());
|
|
68
|
+
ro.observe(wrapperEl);
|
|
69
|
+
return () => ro.disconnect();
|
|
70
|
+
});
|
|
36
71
|
</script>
|
|
37
72
|
|
|
38
73
|
<div
|
|
@@ -53,20 +88,29 @@
|
|
|
53
88
|
padding="xs"
|
|
54
89
|
class={inline ? 'tab-bar-container-inline' : 'tab-bar-container'}
|
|
55
90
|
>
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
91
|
+
<div class="tab-bar-wrapper" bind:this={wrapperEl}>
|
|
92
|
+
<span
|
|
93
|
+
class="tab-indicator"
|
|
94
|
+
class:ready={indicatorReady}
|
|
95
|
+
style="transform: translateX({indicatorLeft}px); width: {indicatorWidth}px;"
|
|
96
|
+
aria-hidden="true"
|
|
97
|
+
></span>
|
|
98
|
+
<HStack spacing="xs" justify="center" class="tab-bar">
|
|
99
|
+
{#each tabs as tab}
|
|
100
|
+
<button
|
|
101
|
+
class="tab-item"
|
|
102
|
+
class:active={activeTab === tab.id}
|
|
103
|
+
onclick={() => selectTab(tab.id)}
|
|
104
|
+
bind:this={buttonEls[tab.id]}
|
|
105
|
+
>
|
|
106
|
+
{#if tab.icon}
|
|
107
|
+
<span class="tab-icon">{@render tab.icon()}</span>
|
|
108
|
+
{/if}
|
|
109
|
+
<span class="tab-label">{tab.label}</span>
|
|
110
|
+
</button>
|
|
111
|
+
{/each}
|
|
112
|
+
</HStack>
|
|
113
|
+
</div>
|
|
70
114
|
</Glass>
|
|
71
115
|
</div>
|
|
72
116
|
|
|
@@ -103,11 +147,41 @@
|
|
|
103
147
|
min-height: 0;
|
|
104
148
|
}
|
|
105
149
|
|
|
150
|
+
.tab-bar-wrapper {
|
|
151
|
+
position: relative;
|
|
152
|
+
display: block;
|
|
153
|
+
}
|
|
154
|
+
|
|
106
155
|
:global(.tab-bar) {
|
|
107
156
|
min-width: 0;
|
|
157
|
+
position: relative;
|
|
158
|
+
z-index: 1;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.tab-indicator {
|
|
162
|
+
position: absolute;
|
|
163
|
+
top: 0;
|
|
164
|
+
bottom: 0;
|
|
165
|
+
left: 0;
|
|
166
|
+
width: 0;
|
|
167
|
+
border-radius: var(--glass-radius-full);
|
|
168
|
+
background: var(--glass-active-bg);
|
|
169
|
+
pointer-events: none;
|
|
170
|
+
opacity: 0;
|
|
171
|
+
z-index: 0;
|
|
172
|
+
transition:
|
|
173
|
+
transform var(--transition-spring),
|
|
174
|
+
width var(--transition-spring),
|
|
175
|
+
opacity var(--transition-fast);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.tab-indicator.ready {
|
|
179
|
+
opacity: 1;
|
|
108
180
|
}
|
|
109
181
|
|
|
110
182
|
.tab-item {
|
|
183
|
+
position: relative;
|
|
184
|
+
z-index: 1;
|
|
111
185
|
display: flex;
|
|
112
186
|
flex-direction: column;
|
|
113
187
|
align-items: center;
|
|
@@ -120,17 +194,32 @@
|
|
|
120
194
|
font-size: 0.75rem;
|
|
121
195
|
font-weight: 500;
|
|
122
196
|
cursor: pointer;
|
|
123
|
-
transition:
|
|
197
|
+
transition: color var(--transition-fast);
|
|
124
198
|
}
|
|
125
199
|
|
|
126
|
-
.tab-item:hover {
|
|
200
|
+
.tab-item:not(.active):hover {
|
|
127
201
|
color: var(--color-text);
|
|
128
|
-
background: var(--glass-hover-subtle);
|
|
129
202
|
}
|
|
130
203
|
|
|
131
204
|
.tab-item.active {
|
|
132
205
|
color: var(--color-accent);
|
|
133
|
-
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.tab-icon,
|
|
209
|
+
.tab-label {
|
|
210
|
+
display: inline-block;
|
|
211
|
+
transform-origin: center;
|
|
212
|
+
transform: scale(1);
|
|
213
|
+
transition: transform var(--transition-spring);
|
|
214
|
+
will-change: transform;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.tab-item.active .tab-icon {
|
|
218
|
+
transform: scale(1.18);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.tab-item.active .tab-label {
|
|
222
|
+
transform: scale(1.06);
|
|
134
223
|
}
|
|
135
224
|
|
|
136
225
|
.tab-icon {
|