@marcosdemik/liquidglass 2.0.0 → 2.0.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.
- package/README.md +44 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/@marcosdemik/liquidglass)
|
|
5
5
|
[](https://github.com/MarcosDemik/liquidglass/blob/main/LICENSE)
|
|
6
6
|
|
|
7
|
-
A React component that creates a **Liquid Glass** UI effect
|
|
7
|
+
A React component that creates a **Liquid Glass** UI effect with real-time refraction, specular highlights, and smooth GSAP animations.
|
|
8
8
|
|
|
9
9
|
Built with SVG filters and WebGL displacement maps.
|
|
10
10
|
|
|
@@ -32,7 +32,7 @@ import { LiquidGlassButton } from "@marcosdemik/liquidglass";
|
|
|
32
32
|
|
|
33
33
|
function App() {
|
|
34
34
|
return (
|
|
35
|
-
<LiquidGlassButton width={320} height={60} radius={60}
|
|
35
|
+
<LiquidGlassButton width={320} height={60} radius={60}>
|
|
36
36
|
Click me
|
|
37
37
|
</LiquidGlassButton>
|
|
38
38
|
);
|
|
@@ -58,30 +58,28 @@ The component includes a `"use client"` directive, so it works out of the box wi
|
|
|
58
58
|
| `width` | `number` | `300` | Button width in pixels |
|
|
59
59
|
| `height` | `number` | `56` | Button height in pixels |
|
|
60
60
|
| `radius` | `number` | `60` | Border radius in pixels |
|
|
61
|
-
| `glassColor` | `string` | `"
|
|
61
|
+
| `glassColor` | `string` | `"transparent"` | Background tint color of the glass |
|
|
62
62
|
|
|
63
63
|
### Glass Effect
|
|
64
64
|
|
|
65
65
|
| Prop | Type | Default | Description |
|
|
66
66
|
|------|------|---------|-------------|
|
|
67
|
-
| `displacement` | `number` | `
|
|
68
|
-
| `blur` | `number` | `
|
|
69
|
-
| `
|
|
70
|
-
| `
|
|
71
|
-
| `
|
|
72
|
-
| `
|
|
73
|
-
| `
|
|
74
|
-
| `smoothness` | `number` | `1.0` | Blur on the displacement map (softens transitions) |
|
|
67
|
+
| `displacement` | `number` | `55` | How much the background refracts (feDisplacementMap scale) |
|
|
68
|
+
| `blur` | `number` | `1` | Gaussian blur applied to the background |
|
|
69
|
+
| `saturation` | `number` | `150` | Color saturation of the refracted result (feColorMatrix saturate value) |
|
|
70
|
+
| `brightness` | `number` | `1.1` | Brightness boost on the backdrop-filter (1 = normal) |
|
|
71
|
+
| `intensity` | `number` | `0.7` | Refraction intensity at the glass edge (0-1) |
|
|
72
|
+
| `edgeSize` | `number` | `30` | Thickness of the glass edge refraction zone in pixels |
|
|
73
|
+
| `specularWidth` | `number` | `0.02` | Specular rim thickness relative to the smallest dimension (0-1) |
|
|
75
74
|
|
|
76
75
|
### Hover Animation
|
|
77
76
|
|
|
78
77
|
| Prop | Type | Default | Description |
|
|
79
78
|
|------|------|---------|-------------|
|
|
80
|
-
| `hoverScale` | `number` | `1.
|
|
81
|
-
| `hoverDisplacement` | `number` | `
|
|
79
|
+
| `hoverScale` | `number` | `1.08` | Scale multiplier on hover |
|
|
80
|
+
| `hoverDisplacement` | `number` | `125` | Displacement scale on hover |
|
|
82
81
|
| `hoverBlur` | `number` | `4` | Blur amount on hover |
|
|
83
|
-
| `
|
|
84
|
-
| `hoverDuration` | `number` | `0.4` | Duration of hover animation in seconds |
|
|
82
|
+
| `hoverDuration` | `number` | `0.25` | Duration of hover animation in seconds |
|
|
85
83
|
| `disableAnimation` | `boolean` | `false` | Disable all GSAP animations |
|
|
86
84
|
|
|
87
85
|
### Standard HTML
|
|
@@ -112,17 +110,17 @@ All standard `<button>` HTML attributes (`onClick`, `disabled`, `aria-label`, et
|
|
|
112
110
|
</LiquidGlassButton>
|
|
113
111
|
```
|
|
114
112
|
|
|
115
|
-
### High
|
|
113
|
+
### High Refraction
|
|
116
114
|
|
|
117
115
|
```tsx
|
|
118
116
|
<LiquidGlassButton
|
|
119
117
|
width={320}
|
|
120
118
|
height={60}
|
|
121
119
|
radius={60}
|
|
122
|
-
displacement={
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
120
|
+
displacement={100}
|
|
121
|
+
intensity={1}
|
|
122
|
+
edgeSize={50}
|
|
123
|
+
saturation={200}
|
|
126
124
|
>
|
|
127
125
|
Distorted
|
|
128
126
|
</LiquidGlassButton>
|
|
@@ -135,11 +133,11 @@ All standard `<button>` HTML attributes (`onClick`, `disabled`, `aria-label`, et
|
|
|
135
133
|
width={320}
|
|
136
134
|
height={60}
|
|
137
135
|
radius={60}
|
|
138
|
-
displacement={
|
|
136
|
+
displacement={25}
|
|
139
137
|
blur={1}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
138
|
+
intensity={0.4}
|
|
139
|
+
edgeSize={15}
|
|
140
|
+
saturation={120}
|
|
143
141
|
>
|
|
144
142
|
Subtle
|
|
145
143
|
</LiquidGlassButton>
|
|
@@ -165,11 +163,10 @@ All standard `<button>` HTML attributes (`onClick`, `disabled`, `aria-label`, et
|
|
|
165
163
|
width={320}
|
|
166
164
|
height={60}
|
|
167
165
|
radius={60}
|
|
168
|
-
hoverScale={1.
|
|
169
|
-
hoverDisplacement={
|
|
166
|
+
hoverScale={1.12}
|
|
167
|
+
hoverDisplacement={150}
|
|
170
168
|
hoverBlur={6}
|
|
171
|
-
|
|
172
|
-
hoverDuration={0.6}
|
|
169
|
+
hoverDuration={0.4}
|
|
173
170
|
>
|
|
174
171
|
Strong Hover
|
|
175
172
|
</LiquidGlassButton>
|
|
@@ -192,11 +189,27 @@ All standard `<button>` HTML attributes (`onClick`, `disabled`, `aria-label`, et
|
|
|
192
189
|
|
|
193
190
|
The effect is built from three layers:
|
|
194
191
|
|
|
195
|
-
1. **WebGL Displacement
|
|
192
|
+
1. **WebGL Displacement + Specular Maps** - A GLSL fragment shader computes a displacement map and a specular highlight map from a signed distance field (SDF) of a rounded rectangle. 3D surface normals are derived from the SDF to create realistic light refraction at the edges. Both maps are rendered on an offscreen canvas and output as PNG data URLs. The WebGL context is cached as a singleton.
|
|
196
193
|
|
|
197
|
-
2. **SVG Filter Chain** - The displacement map feeds into an SVG `<filter>`
|
|
194
|
+
2. **SVG Filter Chain** - The displacement map feeds into an SVG `<filter>` with `feDisplacementMap` for background refraction, `feColorMatrix` for saturation control, and `feBlend` to composite the specular highlight layer on top. A `brightness()` function in the backdrop-filter adds a subtle glow.
|
|
198
195
|
|
|
199
|
-
3. **GSAP Animations** - Pointer events drive GSAP tweens that animate displacement scale, blur,
|
|
196
|
+
3. **GSAP Animations** - Pointer events drive GSAP tweens that animate displacement scale, blur, and button scale. Filter attributes are mutated directly each frame for maximum performance.
|
|
197
|
+
|
|
198
|
+
## Migration from v1.x
|
|
199
|
+
|
|
200
|
+
v2.0.0 replaced the chromatic aberration pipeline with a specular highlight pipeline for a more realistic glass effect. The following props were removed:
|
|
201
|
+
|
|
202
|
+
- `chroma` - removed (no more chromatic aberration)
|
|
203
|
+
- `distortion` - removed (shader normals are now computed from the SDF)
|
|
204
|
+
- `smoothness` - removed (displacement map blur is no longer needed)
|
|
205
|
+
- `hoverChromaMultiplier` - removed
|
|
206
|
+
|
|
207
|
+
New props added:
|
|
208
|
+
|
|
209
|
+
- `brightness` - controls backdrop brightness (default `1.1`)
|
|
210
|
+
- `specularWidth` - controls the specular rim thickness (default `0.02`)
|
|
211
|
+
|
|
212
|
+
Changed defaults: `displacement` (35 -> 55), `blur` (2 -> 1), `saturation` (1.2 -> 150), `hoverScale` (1.05 -> 1.08), `hoverDisplacement` (65 -> 125), `hoverDuration` (0.4 -> 0.25), `glassColor` ("rgba(255,255,255,0.05)" -> "transparent").
|
|
200
213
|
|
|
201
214
|
## Visibility Note
|
|
202
215
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marcosdemik/liquidglass",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Liquid Glass UI effect for React - glassmorphism refraction with SVG filters, WebGL and GSAP animations",
|
|
5
5
|
"author": "Marcos Demik <marcosdemik>",
|
|
6
6
|
"license": "MIT",
|