glasslikeui 0.2.2 → 1.0.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 +214 -0
- package/dist/actions/a11ySync.d.ts +9 -0
- package/dist/actions/a11ySync.js +49 -0
- package/dist/actions/deviceMotion.d.ts +31 -0
- package/dist/actions/deviceMotion.js +142 -0
- package/dist/actions/dragSnap.d.ts +47 -0
- package/dist/actions/dragSnap.js +222 -0
- package/dist/actions/index.d.ts +5 -0
- package/dist/actions/index.js +5 -0
- package/dist/actions/scrollEdge.d.ts +21 -0
- package/dist/actions/scrollEdge.js +61 -0
- package/dist/actions/viewTransition.d.ts +23 -0
- package/dist/actions/viewTransition.js +34 -0
- package/dist/components/glass/Glass.svelte +164 -0
- package/dist/components/glass/Glass.svelte.d.ts +19 -0
- package/dist/components/glass/GlassCard.svelte +12 -5
- package/dist/components/glass/GlassCard.svelte.d.ts +4 -2
- package/dist/components/glass/GlassDimLayer.svelte +37 -0
- package/dist/components/glass/GlassDimLayer.svelte.d.ts +8 -0
- package/dist/components/glass/GlassEffectContainer.svelte +58 -0
- package/dist/components/glass/GlassEffectContainer.svelte.d.ts +12 -0
- package/dist/components/glass/GlassMorph.svelte +42 -0
- package/dist/components/glass/GlassMorph.svelte.d.ts +10 -0
- package/dist/components/glass/GlassSection.svelte +11 -5
- package/dist/components/glass/GlassSection.svelte.d.ts +4 -2
- package/dist/components/glass/LensFilters.svelte +41 -0
- package/dist/components/glass/LensFilters.svelte.d.ts +18 -0
- package/dist/components/glass/Sheet.svelte +70 -40
- package/dist/components/glass/Sheet.svelte.d.ts +6 -2
- package/dist/components/glass/index.d.ts +5 -5
- package/dist/components/glass/index.js +5 -5
- package/dist/components/index.d.ts +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/interactive/Badge.svelte +3 -11
- package/dist/components/interactive/Badge.svelte.d.ts +2 -2
- package/dist/components/interactive/Button.svelte +9 -32
- package/dist/components/interactive/Button.svelte.d.ts +4 -4
- package/dist/components/interactive/IconButton.svelte +3 -14
- package/dist/components/interactive/IconButton.svelte.d.ts +4 -4
- package/dist/components/interactive/TabView.svelte +5 -4
- package/dist/components/interactive/TabView.svelte.d.ts +1 -1
- package/dist/components/layout/Divider.svelte.d.ts +1 -1
- package/dist/components/layout/Grid.svelte.d.ts +1 -1
- package/dist/components/layout/HStack.svelte.d.ts +1 -1
- package/dist/components/layout/ScrollView.svelte +27 -4
- package/dist/components/layout/ScrollView.svelte.d.ts +5 -1
- package/dist/components/layout/Spacer.svelte.d.ts +1 -1
- package/dist/components/layout/VStack.svelte.d.ts +1 -1
- package/dist/components/layout/ZStack.svelte.d.ts +1 -1
- package/dist/components/list/List.svelte +3 -3
- package/dist/components/list/List.svelte.d.ts +1 -1
- package/dist/components/list/ListRow.svelte.d.ts +1 -1
- package/dist/components/media/SymbolImage.svelte.d.ts +1 -1
- package/dist/components/navigation/NavigationBar.svelte +113 -24
- package/dist/components/navigation/NavigationBar.svelte.d.ts +2 -1
- package/dist/components/navigation/NavigationLink.svelte.d.ts +1 -1
- package/dist/components/typography/Text.svelte +3 -2
- package/dist/components/typography/Text.svelte.d.ts +2 -2
- package/dist/constants/colors.js +2 -2
- package/dist/constants/index.d.ts +1 -5
- package/dist/constants/index.js +1 -5
- package/dist/constants/sizes.js +4 -4
- package/dist/constants/variants.d.ts +23 -0
- package/dist/constants/variants.js +18 -0
- package/dist/icons/index.js +10 -7
- package/dist/index.d.ts +2 -4
- package/dist/index.js +2 -7
- package/dist/styles/glasslikeui.css +192 -0
- package/dist/styles/lens.css +93 -0
- package/dist/styles/squircle.css +17 -0
- package/dist/styles/typography.css +27 -0
- package/dist/test-setup.d.ts +1 -0
- package/dist/test-setup.js +6 -0
- package/package.json +19 -7
- package/dist/components/glass/LiquidGlass.svelte +0 -123
- package/dist/components/glass/LiquidGlass.svelte.d.ts +0 -17
- package/dist/constants/materials.d.ts +0 -13
- package/dist/constants/materials.js +0 -43
- package/dist/styles/liquidglass.css +0 -139
package/dist/icons/index.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* Extensibility: Consumers may call `registerIcons(...)` at app startup to
|
|
9
9
|
* add project-specific icons without forking the library.
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export var ICONS = {
|
|
12
12
|
// Navigation
|
|
13
13
|
'chevron.left': '<polyline points="15 18 9 12 15 6"></polyline>',
|
|
14
14
|
'chevron.right': '<polyline points="9 18 15 12 9 6"></polyline>',
|
|
@@ -78,7 +78,7 @@ export const ICONS = {
|
|
|
78
78
|
'error': '<circle cx="12" cy="12" r="10"></circle><line x1="15" y1="9" x2="9" y2="15"></line><line x1="9" y1="9" x2="15" y2="15"></line>'
|
|
79
79
|
};
|
|
80
80
|
/** Default fallback icon name */
|
|
81
|
-
export
|
|
81
|
+
export var DEFAULT_ICON = 'star';
|
|
82
82
|
/**
|
|
83
83
|
* Register additional icons at runtime. Use for app-specific icons that
|
|
84
84
|
* don't belong in the shared library.
|
|
@@ -87,20 +87,23 @@ export const DEFAULT_ICON = 'star';
|
|
|
87
87
|
* is trusted, hardcoded, and does not include scripts or event handlers.
|
|
88
88
|
*/
|
|
89
89
|
export function registerIcons(icons) {
|
|
90
|
-
for (
|
|
90
|
+
for (var _i = 0, _a = Object.entries(icons); _i < _a.length; _i++) {
|
|
91
|
+
var _b = _a[_i], name = _b[0], path = _b[1];
|
|
91
92
|
ICONS[name] = path;
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
/** Get icon path by name with fallback. Warns in dev when falling back. */
|
|
95
96
|
export function getIconPath(name) {
|
|
96
|
-
|
|
97
|
+
var _a, _b;
|
|
98
|
+
var path = ICONS[name];
|
|
97
99
|
if (path !== undefined) {
|
|
98
100
|
return path;
|
|
99
101
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
var env = (_a = globalThis.process) === null || _a === void 0 ? void 0 : _a.env;
|
|
103
|
+
if (!env || env.NODE_ENV !== 'production') {
|
|
104
|
+
console.warn("[glasslikeui] unknown icon \"".concat(name, "\", falling back to \"").concat(DEFAULT_ICON, "\". Register it via registerIcons({ \"").concat(name, "\": \"<svg...>\" })."));
|
|
102
105
|
}
|
|
103
|
-
return ICONS[DEFAULT_ICON];
|
|
106
|
+
return (_b = ICONS[DEFAULT_ICON]) !== null && _b !== void 0 ? _b : '';
|
|
104
107
|
}
|
|
105
108
|
/** Check if icon exists */
|
|
106
109
|
export function hasIcon(name) {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Component library for Svelte with liquid glass effects
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
2
|
+
* GlassLikeUI -- Svelte component library with frosted glass materials.
|
|
6
3
|
*/
|
|
7
4
|
export * from './components';
|
|
8
5
|
export * from './constants';
|
|
9
6
|
export * from './icons';
|
|
7
|
+
export * from './actions';
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
* Component library for Svelte with liquid glass effects
|
|
4
|
-
*
|
|
5
|
-
* @packageDocumentation
|
|
2
|
+
* GlassLikeUI -- Svelte component library with frosted glass materials.
|
|
6
3
|
*/
|
|
7
|
-
// Components
|
|
8
4
|
export * from './components';
|
|
9
|
-
// Design Tokens
|
|
10
5
|
export * from './constants';
|
|
11
|
-
// Icons
|
|
12
6
|
export * from './icons';
|
|
7
|
+
export * from './actions';
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/* GlassLikeUI v1 design tokens.
|
|
2
|
+
* Import in your global styles. Mount <LensFilters /> once at app root
|
|
3
|
+
* for SVG filter defs.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
:root {
|
|
7
|
+
/* ========================================
|
|
8
|
+
Glass surface tokens (dark mode default)
|
|
9
|
+
======================================== */
|
|
10
|
+
|
|
11
|
+
/* Base surface color — variant-driven opacity applied at runtime */
|
|
12
|
+
--glass-surface-color: 28, 28, 30;
|
|
13
|
+
--glass-opacity: 0.30;
|
|
14
|
+
--glass-surface-bg: rgba(var(--glass-surface-color), var(--glass-opacity));
|
|
15
|
+
|
|
16
|
+
/* Core effect parameters (intensity-driven) */
|
|
17
|
+
--glass-blur: 20px;
|
|
18
|
+
--glass-displacement-scale: 8;
|
|
19
|
+
--glass-saturation: 1.8;
|
|
20
|
+
|
|
21
|
+
/* Edge + highlight tokens */
|
|
22
|
+
--glass-border: rgba(255, 255, 255, 0.12);
|
|
23
|
+
--glass-border-width: 0.5px;
|
|
24
|
+
--glass-highlight: rgba(255, 255, 255, 0.08);
|
|
25
|
+
--glass-shadow: rgba(0, 0, 0, 0.5);
|
|
26
|
+
--glass-shadow-inner: rgba(0, 0, 0, 0.2);
|
|
27
|
+
--glass-divider: rgba(255, 255, 255, 0.08);
|
|
28
|
+
--glass-handle: rgba(255, 255, 255, 0.3);
|
|
29
|
+
--glass-highlight-angle: 135deg;
|
|
30
|
+
--glass-motion-enabled: 1;
|
|
31
|
+
|
|
32
|
+
/* Interaction states */
|
|
33
|
+
--glass-hover-bg: rgba(255, 255, 255, 0.08);
|
|
34
|
+
--glass-hover-subtle: rgba(255, 255, 255, 0.04);
|
|
35
|
+
--glass-active-bg: rgba(255, 255, 255, 0.12);
|
|
36
|
+
--glass-active-subtle: rgba(255, 255, 255, 0.06);
|
|
37
|
+
|
|
38
|
+
/* Component helpers */
|
|
39
|
+
--glass-button-bg: rgba(255, 255, 255, 0.1);
|
|
40
|
+
--glass-button-hover: rgba(255, 255, 255, 0.15);
|
|
41
|
+
--glass-badge-bg: rgba(255, 255, 255, 0.08);
|
|
42
|
+
|
|
43
|
+
/* Navigation chrome */
|
|
44
|
+
--glass-nav-bg: rgba(0, 0, 0, 0.7);
|
|
45
|
+
--glass-blur-nav: 24px;
|
|
46
|
+
|
|
47
|
+
/* Sheet chrome */
|
|
48
|
+
--glass-sheet-bg: rgba(28, 28, 30, 0.80);
|
|
49
|
+
|
|
50
|
+
/* ========================================
|
|
51
|
+
Accent system
|
|
52
|
+
======================================== */
|
|
53
|
+
--color-accent: #0071e3;
|
|
54
|
+
--color-accent-hover: color-mix(in srgb, var(--color-accent) 85%, white);
|
|
55
|
+
--color-accent-active: color-mix(in srgb, var(--color-accent) 85%, black);
|
|
56
|
+
--color-accent-10: color-mix(in srgb, var(--color-accent) 10%, transparent);
|
|
57
|
+
--color-accent-15: color-mix(in srgb, var(--color-accent) 15%, transparent);
|
|
58
|
+
--color-accent-25: color-mix(in srgb, var(--color-accent) 25%, transparent);
|
|
59
|
+
--color-accent-50: color-mix(in srgb, var(--color-accent) 50%, transparent);
|
|
60
|
+
|
|
61
|
+
/* Semantic danger — adapts to light/dark via color-mix */
|
|
62
|
+
--color-danger: #ef4444;
|
|
63
|
+
--color-danger-hover: color-mix(in srgb, var(--color-danger) 85%, white);
|
|
64
|
+
--color-danger-active: color-mix(in srgb, var(--color-danger) 85%, black);
|
|
65
|
+
|
|
66
|
+
/* ========================================
|
|
67
|
+
Radius system
|
|
68
|
+
======================================== */
|
|
69
|
+
--glass-radius-sm: 12px;
|
|
70
|
+
--glass-radius-md: 18px;
|
|
71
|
+
--glass-radius-lg: 24px;
|
|
72
|
+
--glass-radius-xl: 32px;
|
|
73
|
+
--glass-radius-2xl: 44px;
|
|
74
|
+
--glass-radius-full: 9999px;
|
|
75
|
+
|
|
76
|
+
/* ========================================
|
|
77
|
+
Spacing system
|
|
78
|
+
======================================== */
|
|
79
|
+
--spacing-xs: 0.5rem;
|
|
80
|
+
--spacing-sm: 1rem;
|
|
81
|
+
--spacing-md: 1.5rem;
|
|
82
|
+
--spacing-lg: 2.5rem;
|
|
83
|
+
--spacing-xl: 4rem;
|
|
84
|
+
--spacing-2xl: 6rem;
|
|
85
|
+
|
|
86
|
+
/* ========================================
|
|
87
|
+
Transitions
|
|
88
|
+
======================================== */
|
|
89
|
+
--transition: 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
90
|
+
--transition-fast: 0.15s cubic-bezier(0.25, 0.1, 0.25, 1);
|
|
91
|
+
--transition-spring: 0.4s cubic-bezier(0.32, 0.72, 0, 1);
|
|
92
|
+
|
|
93
|
+
/* ========================================
|
|
94
|
+
Layout caps
|
|
95
|
+
======================================== */
|
|
96
|
+
--max-width: 1200px;
|
|
97
|
+
--max-width-wide: 1440px;
|
|
98
|
+
|
|
99
|
+
/* Typography tokens are defined in styles/typography.css. */
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* ========================================
|
|
103
|
+
Light mode overrides
|
|
104
|
+
======================================== */
|
|
105
|
+
:root[data-theme='light'] {
|
|
106
|
+
--glass-surface-color: 255, 255, 255;
|
|
107
|
+
--glass-opacity: 0.22;
|
|
108
|
+
|
|
109
|
+
--glass-border: rgba(0, 0, 0, 0.06);
|
|
110
|
+
--glass-highlight: rgba(255, 255, 255, 0.8);
|
|
111
|
+
--glass-shadow: rgba(0, 0, 0, 0.12);
|
|
112
|
+
--glass-shadow-inner: rgba(0, 0, 0, 0.04);
|
|
113
|
+
--glass-divider: rgba(0, 0, 0, 0.06);
|
|
114
|
+
--glass-handle: rgba(0, 0, 0, 0.2);
|
|
115
|
+
|
|
116
|
+
--glass-hover-bg: rgba(0, 0, 0, 0.04);
|
|
117
|
+
--glass-hover-subtle: rgba(0, 0, 0, 0.02);
|
|
118
|
+
--glass-active-bg: rgba(0, 0, 0, 0.08);
|
|
119
|
+
--glass-active-subtle: rgba(0, 0, 0, 0.04);
|
|
120
|
+
|
|
121
|
+
--glass-button-bg: rgba(0, 0, 0, 0.05);
|
|
122
|
+
--glass-button-hover: rgba(0, 0, 0, 0.08);
|
|
123
|
+
--glass-badge-bg: rgba(0, 0, 0, 0.04);
|
|
124
|
+
|
|
125
|
+
--glass-nav-bg: rgba(255, 255, 255, 0.85);
|
|
126
|
+
--glass-sheet-bg: rgba(255, 255, 255, 0.88);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/* ========================================
|
|
130
|
+
Accessibility — dual path
|
|
131
|
+
Native media queries (Safari) + data-attribute fallback (cross-browser)
|
|
132
|
+
Consumers on Chrome/Firefox can wire matchMedia into data-attrs manually.
|
|
133
|
+
======================================== */
|
|
134
|
+
|
|
135
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
136
|
+
:root {
|
|
137
|
+
--glass-opacity: 0.95;
|
|
138
|
+
--glass-blur: 0px;
|
|
139
|
+
--glass-displacement-scale: 0;
|
|
140
|
+
--glass-saturation: 1;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
:root[data-reduced-transparency='true'] {
|
|
144
|
+
--glass-opacity: 0.95;
|
|
145
|
+
--glass-blur: 0px;
|
|
146
|
+
--glass-displacement-scale: 0;
|
|
147
|
+
--glass-saturation: 1;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@media (prefers-contrast: more) {
|
|
151
|
+
:root {
|
|
152
|
+
--glass-border-width: 1.5px;
|
|
153
|
+
--glass-opacity: 0.98;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
:root[data-contrast='more'] {
|
|
157
|
+
--glass-border-width: 1.5px;
|
|
158
|
+
--glass-opacity: 0.98;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@media (prefers-reduced-motion: reduce) {
|
|
162
|
+
:root {
|
|
163
|
+
--transition: 0s;
|
|
164
|
+
--transition-fast: 0s;
|
|
165
|
+
--transition-spring: 0s;
|
|
166
|
+
--glass-motion-enabled: 0;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
:root[data-reduced-motion='true'] {
|
|
170
|
+
--transition: 0s;
|
|
171
|
+
--transition-fast: 0s;
|
|
172
|
+
--transition-spring: 0s;
|
|
173
|
+
--glass-motion-enabled: 0;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* ========================================
|
|
177
|
+
No backdrop-filter support — opaque fallback
|
|
178
|
+
======================================== */
|
|
179
|
+
@supports not (backdrop-filter: blur(1px)) {
|
|
180
|
+
:root {
|
|
181
|
+
--glass-opacity: 0.92;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/* ========================================
|
|
186
|
+
Performance — reduce effect cost on small viewports
|
|
187
|
+
======================================== */
|
|
188
|
+
@media (max-width: 768px) {
|
|
189
|
+
:root {
|
|
190
|
+
--glass-blur-nav: 16px;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* Glass lens layer.
|
|
2
|
+
* Pseudo-element strategy: ::before captures backdrop via backdrop-filter,
|
|
3
|
+
* then an SVG filter displaces those pixels to produce edge refraction.
|
|
4
|
+
* Requires <LensFilters /> mounted once for the SVG defs.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
.glass-surface {
|
|
8
|
+
position: relative;
|
|
9
|
+
isolation: isolate;
|
|
10
|
+
background: var(--glass-surface-bg);
|
|
11
|
+
border-radius: var(--glass-radius, var(--glass-radius-lg));
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
color: inherit;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.glass-surface::before {
|
|
17
|
+
content: '';
|
|
18
|
+
position: absolute;
|
|
19
|
+
inset: 0;
|
|
20
|
+
z-index: 0;
|
|
21
|
+
border-radius: inherit;
|
|
22
|
+
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
|
23
|
+
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
|
24
|
+
pointer-events: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.glass-surface.has-lensing::before {
|
|
28
|
+
filter: url(#glass-lens-refract);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.glass-surface::after {
|
|
32
|
+
content: '';
|
|
33
|
+
position: absolute;
|
|
34
|
+
inset: 0;
|
|
35
|
+
z-index: 1;
|
|
36
|
+
border-radius: inherit;
|
|
37
|
+
pointer-events: none;
|
|
38
|
+
border: var(--glass-border-width) solid var(--glass-border);
|
|
39
|
+
box-shadow:
|
|
40
|
+
inset 0 1px 0 0 var(--glass-highlight),
|
|
41
|
+
inset 0 -1px 0 0 var(--glass-shadow-inner);
|
|
42
|
+
background: linear-gradient(
|
|
43
|
+
var(--glass-highlight-angle),
|
|
44
|
+
rgba(255, 255, 255, calc(0.08 * var(--glass-motion-enabled))) 0%,
|
|
45
|
+
transparent 40%,
|
|
46
|
+
transparent 60%,
|
|
47
|
+
rgba(0, 0, 0, calc(0.04 * var(--glass-motion-enabled))) 100%
|
|
48
|
+
);
|
|
49
|
+
mix-blend-mode: overlay;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.glass-content {
|
|
53
|
+
position: relative;
|
|
54
|
+
z-index: 2;
|
|
55
|
+
height: 100%;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.glass-content > :where(h1, h2, h3, h4, h5, h6, p, span, label, a, button) {
|
|
59
|
+
font-family: var(--font-system);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.glass-surface.has-shadow {
|
|
63
|
+
box-shadow:
|
|
64
|
+
0 8px 32px -8px var(--glass-shadow),
|
|
65
|
+
0 2px 8px -2px var(--glass-shadow);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.glass-surface.is-interactive {
|
|
69
|
+
cursor: pointer;
|
|
70
|
+
transition: transform var(--transition-fast), box-shadow var(--transition-fast);
|
|
71
|
+
}
|
|
72
|
+
.glass-surface.is-interactive:hover {
|
|
73
|
+
transform: scale(calc(1 + 0.01 * var(--glass-motion-enabled)));
|
|
74
|
+
box-shadow:
|
|
75
|
+
0 12px 40px -8px var(--glass-shadow),
|
|
76
|
+
0 4px 12px -2px var(--glass-shadow),
|
|
77
|
+
0 0 0 1px var(--glass-highlight);
|
|
78
|
+
}
|
|
79
|
+
.glass-surface.is-interactive:active {
|
|
80
|
+
transform: scale(calc(1 - 0.005 * var(--glass-motion-enabled)));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.glass-dim-layer {
|
|
84
|
+
position: absolute;
|
|
85
|
+
inset: 0;
|
|
86
|
+
background: linear-gradient(
|
|
87
|
+
to bottom,
|
|
88
|
+
rgba(0, 0, 0, 0.2) 0%,
|
|
89
|
+
rgba(0, 0, 0, 0.45) 100%
|
|
90
|
+
);
|
|
91
|
+
pointer-events: none;
|
|
92
|
+
z-index: -1;
|
|
93
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/* Squircle corner utility.
|
|
2
|
+
* Uses clip-path with a normalized (objectBoundingBox) path so the shape
|
|
3
|
+
* scales correctly with element dimensions. Apply .glass-squircle to any
|
|
4
|
+
* element that should have continuous-curve corners instead of circular.
|
|
5
|
+
* Falls back to CSS border-radius where the clip-path is unsupported.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
.glass-squircle {
|
|
9
|
+
clip-path: url(#glass-squircle-path);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
@supports (corner-shape: superellipse(2)) {
|
|
13
|
+
.glass-squircle {
|
|
14
|
+
clip-path: none;
|
|
15
|
+
corner-shape: superellipse(2.5);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/* Typography tokens.
|
|
2
|
+
* SF Pro where available, then Segoe UI (Windows), Roboto (Linux/Android),
|
|
3
|
+
* Helvetica/Arial, and finally the system sans-serif fallback.
|
|
4
|
+
*
|
|
5
|
+
* Tokens are exposed as CSS custom properties but are NOT applied to :root
|
|
6
|
+
* so that they don't override the consumer's own body font. Library
|
|
7
|
+
* components opt in via `font-family: var(--font-system)`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
:root {
|
|
11
|
+
--font-system: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro',
|
|
12
|
+
'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
13
|
+
--font-system-mono: ui-monospace, 'SF Mono', Menlo, 'Cascadia Mono',
|
|
14
|
+
'Roboto Mono', 'Courier New', monospace;
|
|
15
|
+
--dynamic-type-scale: 1;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Consumer can opt in globally like this:
|
|
19
|
+
* body { font-family: var(--font-system); }
|
|
20
|
+
* or use these utility classes on specific elements:
|
|
21
|
+
*/
|
|
22
|
+
.font-system {
|
|
23
|
+
font-family: var(--font-system);
|
|
24
|
+
}
|
|
25
|
+
.font-system-mono {
|
|
26
|
+
font-family: var(--font-system-mono);
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glasslikeui",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Svelte component library with frosted glass materials",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"svelte": "./dist/index.js",
|
|
@@ -12,14 +12,20 @@
|
|
|
12
12
|
"svelte": "./dist/index.js",
|
|
13
13
|
"default": "./dist/index.js"
|
|
14
14
|
},
|
|
15
|
-
"./
|
|
15
|
+
"./glasslikeui.css": "./dist/styles/glasslikeui.css",
|
|
16
|
+
"./lens.css": "./dist/styles/lens.css",
|
|
17
|
+
"./squircle.css": "./dist/styles/squircle.css",
|
|
18
|
+
"./typography.css": "./dist/styles/typography.css"
|
|
16
19
|
},
|
|
17
20
|
"files": [
|
|
18
21
|
"dist"
|
|
19
22
|
],
|
|
20
23
|
"scripts": {
|
|
21
24
|
"package": "svelte-package",
|
|
22
|
-
"prepublishOnly": "npm run package"
|
|
25
|
+
"prepublishOnly": "npm run package",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest",
|
|
28
|
+
"test:coverage": "vitest run --coverage"
|
|
23
29
|
},
|
|
24
30
|
"peerDependencies": {
|
|
25
31
|
"svelte": "^5.0.0"
|
|
@@ -31,8 +37,14 @@
|
|
|
31
37
|
"devDependencies": {
|
|
32
38
|
"@sveltejs/package": "^2.5.7",
|
|
33
39
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
40
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
41
|
+
"@testing-library/svelte": "^5.3.1",
|
|
42
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
43
|
+
"jsdom": "^29.0.2",
|
|
44
|
+
"svelte": "^5.55.4",
|
|
45
|
+
"svelte-check": "^4.4.6",
|
|
46
|
+
"typescript": "^6.0.3",
|
|
47
|
+
"vite": "^8.0.10",
|
|
48
|
+
"vitest": "^4.1.5"
|
|
37
49
|
}
|
|
38
50
|
}
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
|
-
import { MATERIAL_CONFIG, CORNER_RADIUS, PADDING } from '../../constants';
|
|
4
|
-
import type { MaterialType, CornerRadius, Padding } from '../../constants';
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
children: Snippet;
|
|
8
|
-
material?: MaterialType;
|
|
9
|
-
tint?: string;
|
|
10
|
-
cornerRadius?: CornerRadius;
|
|
11
|
-
padding?: Padding;
|
|
12
|
-
border?: boolean;
|
|
13
|
-
shadow?: boolean;
|
|
14
|
-
interactive?: boolean;
|
|
15
|
-
class?: string;
|
|
16
|
-
style?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
let {
|
|
20
|
-
children,
|
|
21
|
-
material = 'regular',
|
|
22
|
-
tint = '',
|
|
23
|
-
cornerRadius = 'lg',
|
|
24
|
-
padding = 'md',
|
|
25
|
-
border = true,
|
|
26
|
-
shadow = true,
|
|
27
|
-
interactive = false,
|
|
28
|
-
class: className = '',
|
|
29
|
-
style: customStyle = ''
|
|
30
|
-
}: Props = $props();
|
|
31
|
-
|
|
32
|
-
const config = $derived(MATERIAL_CONFIG[material]);
|
|
33
|
-
</script>
|
|
34
|
-
|
|
35
|
-
<div
|
|
36
|
-
class="liquid-glass {className}"
|
|
37
|
-
class:interactive
|
|
38
|
-
class:has-border={border}
|
|
39
|
-
class:has-shadow={shadow}
|
|
40
|
-
class:chrome={material === 'chrome'}
|
|
41
|
-
style="
|
|
42
|
-
--glass-blur: {config.blur}px;
|
|
43
|
-
--glass-saturation: {config.saturation};
|
|
44
|
-
--glass-bg-opacity: {config.bgOpacity};
|
|
45
|
-
--glass-border-opacity: {config.borderOpacity};
|
|
46
|
-
--glass-radius: {CORNER_RADIUS[cornerRadius]};
|
|
47
|
-
--glass-padding: {PADDING[padding]};
|
|
48
|
-
{tint ? `--glass-tint: ${tint};` : ''}
|
|
49
|
-
{customStyle}
|
|
50
|
-
"
|
|
51
|
-
>
|
|
52
|
-
<div class="glass-content">
|
|
53
|
-
{@render children()}
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
|
-
<style>
|
|
58
|
-
.liquid-glass {
|
|
59
|
-
position: relative;
|
|
60
|
-
border-radius: var(--glass-radius);
|
|
61
|
-
padding: var(--glass-padding);
|
|
62
|
-
overflow: hidden;
|
|
63
|
-
isolation: isolate;
|
|
64
|
-
background: var(--glass-tint, var(--glass-bg));
|
|
65
|
-
backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
|
66
|
-
-webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturation));
|
|
67
|
-
transition: all var(--transition);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.liquid-glass.has-border {
|
|
71
|
-
border: 1px solid var(--glass-border);
|
|
72
|
-
box-shadow:
|
|
73
|
-
inset 0 1px 0 0 var(--glass-highlight),
|
|
74
|
-
inset 0 -1px 0 0 var(--glass-shadow-inner);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
.liquid-glass.has-shadow {
|
|
78
|
-
box-shadow:
|
|
79
|
-
0 8px 32px -8px var(--glass-shadow),
|
|
80
|
-
0 2px 8px -2px var(--glass-shadow),
|
|
81
|
-
inset 0 1px 0 0 var(--glass-highlight),
|
|
82
|
-
inset 0 -1px 0 0 var(--glass-shadow-inner);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.liquid-glass.chrome {
|
|
86
|
-
background: linear-gradient(
|
|
87
|
-
135deg,
|
|
88
|
-
rgba(255, 255, 255, 0.15) 0%,
|
|
89
|
-
rgba(255, 255, 255, 0.05) 50%,
|
|
90
|
-
rgba(255, 255, 255, 0.1) 100%
|
|
91
|
-
);
|
|
92
|
-
border: 1px solid var(--glass-chrome-border);
|
|
93
|
-
box-shadow:
|
|
94
|
-
0 0 0 1px var(--glass-chrome-outer),
|
|
95
|
-
inset 0 1px 2px 0 rgba(255, 255, 255, 0.3),
|
|
96
|
-
0 8px 40px -8px var(--glass-shadow),
|
|
97
|
-
0 20px 60px -20px var(--glass-shadow);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
.liquid-glass.interactive {
|
|
101
|
-
cursor: pointer;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.liquid-glass.interactive:hover {
|
|
105
|
-
background: var(--glass-hover-bg);
|
|
106
|
-
transform: translateY(-2px);
|
|
107
|
-
box-shadow:
|
|
108
|
-
0 12px 40px -8px var(--glass-shadow),
|
|
109
|
-
0 4px 12px -2px var(--glass-shadow),
|
|
110
|
-
inset 0 1px 0 0 var(--glass-highlight);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.liquid-glass.interactive:active {
|
|
114
|
-
transform: translateY(0);
|
|
115
|
-
background: var(--glass-active-bg);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.glass-content {
|
|
119
|
-
position: relative;
|
|
120
|
-
z-index: 1;
|
|
121
|
-
height: 100%;
|
|
122
|
-
}
|
|
123
|
-
</style>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { MaterialType, CornerRadius, Padding } from '../../constants';
|
|
3
|
-
interface Props {
|
|
4
|
-
children: Snippet;
|
|
5
|
-
material?: MaterialType;
|
|
6
|
-
tint?: string;
|
|
7
|
-
cornerRadius?: CornerRadius;
|
|
8
|
-
padding?: Padding;
|
|
9
|
-
border?: boolean;
|
|
10
|
-
shadow?: boolean;
|
|
11
|
-
interactive?: boolean;
|
|
12
|
-
class?: string;
|
|
13
|
-
style?: string;
|
|
14
|
-
}
|
|
15
|
-
declare const LiquidGlass: import("svelte").Component<Props, {}, "">;
|
|
16
|
-
type LiquidGlass = ReturnType<typeof LiquidGlass>;
|
|
17
|
-
export default LiquidGlass;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Glass material design tokens
|
|
3
|
-
* Configurations for LiquidGlass component materials
|
|
4
|
-
*/
|
|
5
|
-
export interface MaterialConfig {
|
|
6
|
-
blur: number;
|
|
7
|
-
saturation: number;
|
|
8
|
-
bgOpacity: number;
|
|
9
|
-
borderOpacity: number;
|
|
10
|
-
}
|
|
11
|
-
/** Glass material presets */
|
|
12
|
-
export declare const MATERIAL_CONFIG: Record<string, MaterialConfig>;
|
|
13
|
-
export type MaterialType = keyof typeof MATERIAL_CONFIG;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Glass material design tokens
|
|
3
|
-
* Configurations for LiquidGlass component materials
|
|
4
|
-
*/
|
|
5
|
-
/** Glass material presets */
|
|
6
|
-
export const MATERIAL_CONFIG = {
|
|
7
|
-
ultraThin: {
|
|
8
|
-
blur: 8,
|
|
9
|
-
saturation: 1.2,
|
|
10
|
-
bgOpacity: 0.15,
|
|
11
|
-
borderOpacity: 0.08
|
|
12
|
-
},
|
|
13
|
-
thin: {
|
|
14
|
-
blur: 16,
|
|
15
|
-
saturation: 1.4,
|
|
16
|
-
bgOpacity: 0.25,
|
|
17
|
-
borderOpacity: 0.12
|
|
18
|
-
},
|
|
19
|
-
regular: {
|
|
20
|
-
blur: 24,
|
|
21
|
-
saturation: 1.8,
|
|
22
|
-
bgOpacity: 0.4,
|
|
23
|
-
borderOpacity: 0.18
|
|
24
|
-
},
|
|
25
|
-
thick: {
|
|
26
|
-
blur: 40,
|
|
27
|
-
saturation: 2.0,
|
|
28
|
-
bgOpacity: 0.55,
|
|
29
|
-
borderOpacity: 0.25
|
|
30
|
-
},
|
|
31
|
-
ultraThick: {
|
|
32
|
-
blur: 60,
|
|
33
|
-
saturation: 2.2,
|
|
34
|
-
bgOpacity: 0.7,
|
|
35
|
-
borderOpacity: 0.3
|
|
36
|
-
},
|
|
37
|
-
chrome: {
|
|
38
|
-
blur: 30,
|
|
39
|
-
saturation: 2.5,
|
|
40
|
-
bgOpacity: 0.3,
|
|
41
|
-
borderOpacity: 0.4
|
|
42
|
-
}
|
|
43
|
-
};
|