@glassware/core 0.0.0-stage → 0.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 -0
- package/README.md +13 -3
- package/dist/glassware.css +124 -0
- package/dist/index.cjs +1331 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +91 -0
- package/dist/index.d.ts +91 -0
- package/dist/index.js +1297 -0
- package/dist/index.js.map +1 -0
- package/package.json +66 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Glassware contributors
|
|
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,3 +1,13 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# @glassware/core
|
|
2
|
+
|
|
3
|
+
Frosted and watery glass buttons for the web, with text color chosen
|
|
4
|
+
automatically from what sits behind them.
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
import '@glassware/core/glassware.css';
|
|
8
|
+
import { attach } from '@glassware/core';
|
|
9
|
+
|
|
10
|
+
attach(document.querySelector('button'));
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Full documentation is coming with v0.1 on the project page.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Glassware core styles.
|
|
3
|
+
* Token names and defaults follow SPEC.md §2-§4.
|
|
4
|
+
*
|
|
5
|
+
* Works with zero JavaScript as a frosted-glass button. attach() layers on:
|
|
6
|
+
* - clamping token values to the ranges in SPEC §2
|
|
7
|
+
* - data-glass-type="watery" (only after support is detected and the
|
|
8
|
+
* SVG filter has been injected, so the fallback is always frosted)
|
|
9
|
+
* - data-glass-edge="off" (when edgeReflection is false)
|
|
10
|
+
* - --glass-text-color (set inline from the sampled background)
|
|
11
|
+
* - --glass-distortion-filter (points at the per-element SVG filter)
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
.glass {
|
|
15
|
+
/* SPEC §2: visual tokens */
|
|
16
|
+
--glass-blur: 12px;
|
|
17
|
+
--glass-transparency: 0.18;
|
|
18
|
+
--glass-tint: rgba(255, 255, 255, 1);
|
|
19
|
+
--glass-radius: 12px;
|
|
20
|
+
|
|
21
|
+
/* SPEC §2: watery only. SVG filter attributes can't read CSS variables,
|
|
22
|
+
so attach() reads these two and builds the filter with matching values. */
|
|
23
|
+
--glass-distortion-scale: 40;
|
|
24
|
+
--glass-distortion-speed: 8s;
|
|
25
|
+
|
|
26
|
+
/* SPEC §3: edge reflection (layered inset box-shadows) */
|
|
27
|
+
--glass-edge-highlight: inset 1px 1px 1px rgba(255, 255, 255, 0.6);
|
|
28
|
+
--glass-edge-shadow: inset -1px -1px 1px rgba(0, 0, 0, 0.15);
|
|
29
|
+
|
|
30
|
+
/* SPEC §4: text colors, and the one that's currently in use.
|
|
31
|
+
With no JS the default is dark text, matching a light page. */
|
|
32
|
+
--glass-text-dark: #1a1a1a;
|
|
33
|
+
--glass-text-light: #f5f5f5;
|
|
34
|
+
--glass-text-color: var(--glass-text-dark);
|
|
35
|
+
|
|
36
|
+
/* Filter used by the watery type. attach() overrides this inline when
|
|
37
|
+
scale or speed differ from the defaults. */
|
|
38
|
+
--glass-distortion-filter: url(#glassware-displacement);
|
|
39
|
+
|
|
40
|
+
position: relative;
|
|
41
|
+
display: inline-flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
padding: 0.6em 1.2em;
|
|
46
|
+
border: 0;
|
|
47
|
+
border-radius: var(--glass-radius);
|
|
48
|
+
font: inherit;
|
|
49
|
+
color: var(--glass-text-color);
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
-webkit-tap-highlight-color: transparent;
|
|
52
|
+
|
|
53
|
+
/* Static fallback first for browsers without color-mix(); the tint is
|
|
54
|
+
then mixed at `transparency` alpha (SPEC §2). */
|
|
55
|
+
background: rgba(255, 255, 255, 0.18);
|
|
56
|
+
background: color-mix(
|
|
57
|
+
in srgb,
|
|
58
|
+
var(--glass-tint) calc(var(--glass-transparency) * 100%),
|
|
59
|
+
transparent
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
/* SPEC §1: frosted is the universal default */
|
|
63
|
+
-webkit-backdrop-filter: blur(var(--glass-blur));
|
|
64
|
+
backdrop-filter: blur(var(--glass-blur));
|
|
65
|
+
|
|
66
|
+
box-shadow: var(--glass-edge-highlight), var(--glass-edge-shadow);
|
|
67
|
+
transition: transform 0.15s ease, color 0.2s ease;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* SPEC §4 CSS-only fallback: the developer declares what is BEHIND the
|
|
71
|
+
element. A light background gets dark text and vice versa. */
|
|
72
|
+
.glass[data-glass-mode="light"] {
|
|
73
|
+
--glass-text-color: var(--glass-text-dark);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.glass[data-glass-mode="dark"] {
|
|
77
|
+
--glass-text-color: var(--glass-text-light);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* SPEC §3: edge reflection can be switched off */
|
|
81
|
+
.glass[data-glass-edge="off"] {
|
|
82
|
+
box-shadow: none;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/* SPEC §1: watery = blur + SVG displacement. Gated by @supports as a second
|
|
86
|
+
safety net; if the browser can't do it, the rule is ignored and the
|
|
87
|
+
element simply stays frosted.
|
|
88
|
+
|
|
89
|
+
Watery is meant to be see-through, so it starts from a lower blur and fill
|
|
90
|
+
than frosted (SPEC §2). Values set by the developer or by attach() are
|
|
91
|
+
inline and still win over these defaults. */
|
|
92
|
+
@supports (backdrop-filter: url(#x)) {
|
|
93
|
+
.glass[data-glass-type="watery"] {
|
|
94
|
+
--glass-blur: 4px;
|
|
95
|
+
--glass-transparency: 0.08;
|
|
96
|
+
|
|
97
|
+
-webkit-backdrop-filter: blur(var(--glass-blur)) var(--glass-distortion-filter);
|
|
98
|
+
backdrop-filter: blur(var(--glass-blur)) var(--glass-distortion-filter);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.glass:active {
|
|
103
|
+
transform: scale(0.97);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.glass:focus-visible {
|
|
107
|
+
outline: 2px solid var(--glass-text-color);
|
|
108
|
+
outline-offset: 2px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.glass:disabled {
|
|
112
|
+
cursor: not-allowed;
|
|
113
|
+
opacity: 0.55;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@media (prefers-reduced-motion: reduce) {
|
|
117
|
+
.glass {
|
|
118
|
+
transition: none;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.glass:active {
|
|
122
|
+
transform: none;
|
|
123
|
+
}
|
|
124
|
+
}
|