@cruxgarden/plasma-ui 0.1.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/CHANGELOG.md +13 -0
- package/LICENSE +21 -0
- package/README.md +232 -0
- package/dist/Plasma.d.ts +41 -0
- package/dist/PlasmaProvider.d.ts +79 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +1522 -0
- package/dist/moods.d.ts +40 -0
- package/dist/renderer.d.ts +143 -0
- package/dist/shaders.d.ts +14 -0
- package/dist/snap.d.ts +27 -0
- package/dist/spring.d.ts +25 -0
- package/package.json +74 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
Initial release.
|
|
6
|
+
|
|
7
|
+
- `PlasmaProvider`: shared WebGL material with moods, theme, tint/opacity/frost, rim (color, width, highlight, edge line), viscosity/stretch/flow, blend, smoothness, refraction, dispersion, grid/magnet, quality.
|
|
8
|
+
- `Plasma`: any element as a glass surface, with per-surface radius, lean, tint/opacity/frost/elevation, join-aware `padding`, drag with edge/grid snapping, controlled offsets, join events.
|
|
9
|
+
- `usePlasma`: pulse, bump, capability and spring info.
|
|
10
|
+
- CSS frosted fallback when WebGL2 is unavailable; `prefers-reduced-motion` support.
|
|
11
|
+
- `fuse={false}`: surfaces that never blend, bridge, or join - for bars, docks, and fixed chrome.
|
|
12
|
+
- `background`: any CSS color, image URL, or live img/canvas/video source; images refract with a slow swirl, colors get subtle luminance drift, canvas and video re-upload per frame. Dynamic.
|
|
13
|
+
- No runtime dependencies beyond React.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Crux Garden
|
|
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
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
# Plasma UI
|
|
2
|
+
|
|
3
|
+
A liquid glass workspace for React. Every `<Plasma>` panel joins one WebGL material: surfaces fuse on contact, refract what's behind them, and snap to a grid when dragged. Built for workspace and canvas UIs - tool panels, dashboards, launchers - by [Crux Garden](https://github.com/cruxgarden).
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
[**Try it**](https://cruxgarden.github.io/plasma-ui/) · [workspace example](https://cruxgarden.github.io/plasma-ui/examples/workspace/)
|
|
8
|
+
|
|
9
|
+
**Status: 0.1.0.** The core material is stable and tested; the API may change between minor versions before 1.0.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @cruxgarden/plasma-ui
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Zero dependencies beyond React.
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { PlasmaProvider, Plasma } from "@cruxgarden/plasma-ui";
|
|
19
|
+
|
|
20
|
+
export function App() {
|
|
21
|
+
return (
|
|
22
|
+
<PlasmaProvider mood="tidal">
|
|
23
|
+
<Plasma as="header" lean={false}>
|
|
24
|
+
My App
|
|
25
|
+
</Plasma>
|
|
26
|
+
<Plasma draggable>
|
|
27
|
+
<h3>Inbox</h3>
|
|
28
|
+
</Plasma>
|
|
29
|
+
</PlasmaProvider>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Example
|
|
35
|
+
|
|
36
|
+
[`examples/workspace`](examples/workspace) is a small working app - inbox, reader, tasks, and a player as draggable fused panels, with focus-driven elevation and layout persisted to localStorage. `node examples/workspace/build.mjs` builds it to a single html file.
|
|
37
|
+
|
|
38
|
+
## Not yet
|
|
39
|
+
|
|
40
|
+
Plasma UI 0.1 is a workspace library, not a full UI system. Know these before adopting:
|
|
41
|
+
|
|
42
|
+
- **No layers.** Overlapping surfaces fuse. Dialogs, menus, toasts, and fixed bars must be plain CSS for now (the docs site's own nav shows the pattern).
|
|
43
|
+
- **No clipping in scroll containers.** Plasma inside a scrollable list draws past its edges. Scrolling _inside_ one panel is fine.
|
|
44
|
+
- **No drag or resize handles.** `draggable` moves the whole surface; mark interactive children `data-plasma-nodrag`.
|
|
45
|
+
- **Draws its own background.** Browsers don't let WebGL read the rendered page, so the glass refracts its background layer - the procedural mood field, or any color, image, canvas, or video you pass via `background` - rather than your live DOM. Custom background shaders aren't supported yet.
|
|
46
|
+
- **Rounded rectangles only.** No rotation or arbitrary shapes.
|
|
47
|
+
|
|
48
|
+
All of these are on the roadmap below.
|
|
49
|
+
|
|
50
|
+
## How it works
|
|
51
|
+
|
|
52
|
+
Markup stays ordinary HTML. `PlasmaProvider` renders one fixed canvas behind the page. Each frame:
|
|
53
|
+
|
|
54
|
+
1. **Silhouette.** Every registered element reports its box; one shader draws them as a single shape. Corners against a neighbor square off, and blending applies only where surfaces face different ways, so flush panels share a clean outline while gaps and steps get rounded fillets.
|
|
55
|
+
2. **Smoothing.** The silhouette is blurred and traced at its halfway contour, evening out curvature.
|
|
56
|
+
3. **Height.** A heavier blur becomes a height map; its slope drives refraction, so joined panels act as one lens.
|
|
57
|
+
4. **Tint and frost.** Color and translucency spread across the material with the same blur, so different values flow into each other across joins. The background renders once to a texture; two blurred copies serve frosted glass.
|
|
58
|
+
5. **Light.** The final pass refracts the background, splits color at the edges, and adds a rim and a pointer highlight.
|
|
59
|
+
|
|
60
|
+
Without WebGL2, `Plasma` falls back to a CSS frosted panel.
|
|
61
|
+
|
|
62
|
+
## `<PlasmaProvider>`
|
|
63
|
+
|
|
64
|
+
| Prop | Type | Default | Description |
|
|
65
|
+
| -------------------------- | ---------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
66
|
+
| `mood` | `"tidal" \| "aurora" \| "ember" \| Mood` | `"tidal"` | Colors, blend distance, and spring feel |
|
|
67
|
+
| `theme` | `"auto" \| "light" \| "dark"` | `"auto"` | Auto follows the OS and `<html data-theme>` |
|
|
68
|
+
| `radius` | `number` | `26` | Default corner radius (px) for every surface |
|
|
69
|
+
| `background` | `BackgroundSource` | | Any CSS color (luminance drift), image URL (refracted, slow swirl), or an `img`/`canvas`/`video` element - canvas and video update live. Dynamic. Omit for the procedural mood field |
|
|
70
|
+
| `blend` | `number` | mood | Distance (px) at which surfaces start to fuse |
|
|
71
|
+
| `viscosity` | `number` | `0.5` | `0` is watery and bouncy, `1` is slow like syrup; also scales drag and snap springs |
|
|
72
|
+
| `stretch` | `number` | `1` | How far the glass trails behind moving panels; `0` turns it off |
|
|
73
|
+
| `flow` | `number` | `0` | Slow ripple along the edges |
|
|
74
|
+
| `tint` | `string` | `"#ffffff"` | Plasma color (hex) |
|
|
75
|
+
| `opacity` | `number` | `0` | Tint strength, 0 (clear) to 1 (solid color) |
|
|
76
|
+
| `frost` | `number` | `0` | Translucency, 0 (clear) to 1 (frosted) |
|
|
77
|
+
| `elevation` | `number` | `0.35` | Shadow depth, 0 (flat) to 1 (floating); dragged surfaces raise automatically |
|
|
78
|
+
| `smoothness` | `number` | `1` | Outline smoothing strength |
|
|
79
|
+
| `refraction`, `dispersion` | `number` | `1` | Lens strength, color splitting |
|
|
80
|
+
| `rim` | `number` | `1` | Colored rim strength; `0` turns it off |
|
|
81
|
+
| `rimColor` | `"iridescent" \| "tint" \| string` | `"iridescent"` | Rainbow sheen, each surface's tint, or a hex color |
|
|
82
|
+
| `rimWidth` | `number` | `1` | How far the rim reaches in from the edge |
|
|
83
|
+
| `highlight` | `number` | `1` | Pointer-facing highlight; `0` turns it off |
|
|
84
|
+
| `edgeLine` | `number` | `1` | Thin line along the outline; `0` turns it off |
|
|
85
|
+
| `pointerDrop` | `boolean` | `true` | Liquid drop that follows the pointer |
|
|
86
|
+
| `ambientDrops` | `boolean` | `false` | Decorative orbiting drops |
|
|
87
|
+
| `grid`, `magnet` | `number` | `24`, `40` | Snap grid size and edge latch distance |
|
|
88
|
+
| `quality` | `number` | `1.25` | Maximum canvas pixel ratio |
|
|
89
|
+
| `maxSurfaces` | `number` | `16` | Visible surface budget, compiled into the shaders (fixed at mount); higher costs GPU time |
|
|
90
|
+
| `zIndex` | `number` | `-1` | Canvas stacking order |
|
|
91
|
+
|
|
92
|
+
## `<Plasma>`
|
|
93
|
+
|
|
94
|
+
Accepts all HTML attributes plus:
|
|
95
|
+
|
|
96
|
+
| Prop | Type | Default | Description |
|
|
97
|
+
| --------------------------------------- | ------------------------ | -------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
98
|
+
| `as` | `ElementType` | `"div"` | Element to render |
|
|
99
|
+
| `radius` | `number` | provider | Corner radius (px) for this surface |
|
|
100
|
+
| `lean` | `number \| false` | `10` | Lean toward the pointer while standalone |
|
|
101
|
+
| `tint`, `opacity`, `frost`, `elevation` | `string`, `number` | provider | Color, translucency, and shadow depth for this surface; joined surfaces with different values blend into each other |
|
|
102
|
+
| `padding` | `number` | | Inner padding (px); halves on joined edges so gutters between fused panels equal the free-edge inset |
|
|
103
|
+
| `fuse` | `boolean` | `true` | `false`: this surface never blends, bridges, or joins with others - for bars, docks, and fixed chrome |
|
|
104
|
+
| `draggable` | `boolean` | `false` | Move freely, snap on release; arrow keys move one grid step |
|
|
105
|
+
| `snap` | `boolean` | `true` | Latch to neighbor edges, otherwise the grid |
|
|
106
|
+
| `bounds` | `RefObject<HTMLElement>` | viewport | Drag area and grid origin |
|
|
107
|
+
| `offset` / `defaultOffset` | `{ x, y }` | | Controlled or initial offset; changes spring into place |
|
|
108
|
+
| `onDragStart`, `onDragEnd(offset)` | | | Drag lifecycle; `onDragEnd` gets the settled offset |
|
|
109
|
+
| `onJoinChange(joined)` | | | Fires when the surface fuses with or separates from a neighbor |
|
|
110
|
+
|
|
111
|
+
Drag ignores presses on buttons, links, inputs, and anything marked `data-plasma-nodrag`.
|
|
112
|
+
|
|
113
|
+
## `usePlasma()`
|
|
114
|
+
|
|
115
|
+
Returns `pulse(x, y, strength?)`, `bump(energy)`, `supported`, `grid`, `magnet`, `spring`, and `reducedMotion`.
|
|
116
|
+
|
|
117
|
+
## Custom moods
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
import type { Mood } from "@cruxgarden/plasma-ui";
|
|
121
|
+
|
|
122
|
+
const dusk: Mood = {
|
|
123
|
+
colors: ["#0b0816", "#3b2a6b", "#f0a868"],
|
|
124
|
+
blend: 40,
|
|
125
|
+
spring: { stiffness: 150, damping: 14 },
|
|
126
|
+
};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Motion feel
|
|
130
|
+
|
|
131
|
+
Each surface is a spring chasing its element, and the drawn glass always covers the element. Moving panels leave a trailing stretch; stopping ones overshoot before settling. Scrolling doesn't count as motion.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
<PlasmaProvider viscosity={0.1} stretch={1.3} flow={0.6} /> // water
|
|
135
|
+
<PlasmaProvider viscosity={0.85} stretch={1.8} /> // honey
|
|
136
|
+
<PlasmaProvider stretch={0} /> // glass tracks panels exactly
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`flow` ripples the outline, so leave it at `0` where flush edges should stay perfectly straight.
|
|
140
|
+
|
|
141
|
+
## Styling the rim
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
// solid cyan rim, a bit wider, no pointer highlight
|
|
145
|
+
<PlasmaProvider rimColor="#5fd4ff" rimWidth={1.6} highlight={0} />
|
|
146
|
+
|
|
147
|
+
// each panel's rim follows its own tint
|
|
148
|
+
<PlasmaProvider rimColor="tint">
|
|
149
|
+
<Plasma tint="#ff5fa2" opacity={0.3} />
|
|
150
|
+
</PlasmaProvider>
|
|
151
|
+
|
|
152
|
+
// plain glass: no colored rim, just the edge line
|
|
153
|
+
<PlasmaProvider rim={0} />
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Guidelines
|
|
157
|
+
|
|
158
|
+
- Use glass for containers: panels, docks, cards, dialogs. Small controls read better as regular HTML on top.
|
|
159
|
+
- Place surfaces either flush (they become one piece) or further apart than the blend distance. Smaller gaps render as liquid bridging.
|
|
160
|
+
- Up to `maxSurfaces` (default 16) draw at once; offscreen ones are skipped first. Two render passes loop over every slot per pixel, so raise it only as far as you need.
|
|
161
|
+
- Lean and pulses use the CSS `translate` and `scale` properties, and drag uses `transform`, so they compose with each other. Avoid setting those on `Plasma` elements yourself.
|
|
162
|
+
- `prefers-reduced-motion` disables lean, pulses, the pointer drop, and springs.
|
|
163
|
+
|
|
164
|
+
## Roadmap
|
|
165
|
+
|
|
166
|
+
In priority order. Not a schedule.
|
|
167
|
+
|
|
168
|
+
1. **Layers** - independent materials that stack instead of fusing, for dialogs, menus, and fixed chrome over glass.
|
|
169
|
+
2. **Drag handles and resize** - `handle` prop so panel content stays fully interactive; edge resize with grid snapping.
|
|
170
|
+
3. **Scroll clipping** - glass confined to scrollable containers.
|
|
171
|
+
4. **Pluggable backgrounds** - colors, images, and live canvas/video shipped in 0.1 (`background` prop); custom shaders next.
|
|
172
|
+
5. **Shapes** - rotation and non-rectangular outlines.
|
|
173
|
+
|
|
174
|
+
Contributions welcome on any of these - see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
175
|
+
|
|
176
|
+
## Browser support
|
|
177
|
+
|
|
178
|
+
Chrome, Edge, Firefox, and Safari 16.4+ (WebGL2). Elsewhere, `Plasma` renders as a CSS frosted panel and all layout, drag, and snap behavior still works.
|
|
179
|
+
|
|
180
|
+
## Development
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
npm install
|
|
184
|
+
npm run build # library → dist/
|
|
185
|
+
npm run build:site # docs + playground → site/dist/index.html
|
|
186
|
+
npm run build:example # workspace example → examples/workspace/dist/index.html
|
|
187
|
+
npm run build:pages # both, in the layout GitHub Pages serves → site/dist/
|
|
188
|
+
npm test # snap-logic tests
|
|
189
|
+
npm run verify # typecheck + tests + build, the gate CI runs
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Every page is a single self-contained HTML file, so you can open one straight
|
|
193
|
+
from disk. `scripts/build-page.mjs` is the one builder they share.
|
|
194
|
+
|
|
195
|
+
Pushing to `main` deploys `npm run build:pages` to GitHub Pages:
|
|
196
|
+
|
|
197
|
+
- Site: https://cruxgarden.github.io/plasma-ui/
|
|
198
|
+
- Workspace example: https://cruxgarden.github.io/plasma-ui/examples/workspace/
|
|
199
|
+
|
|
200
|
+
Releases go to npm from a local machine, the same way the Crux Garden CLI
|
|
201
|
+
does — see [PUBLISH.md](PUBLISH.md).
|
|
202
|
+
|
|
203
|
+
## Used by
|
|
204
|
+
|
|
205
|
+
- [Crux Garden](https://github.com/cruxgarden) - the workspace Plasma UI was built for.
|
|
206
|
+
|
|
207
|
+
Using it in something? Add yours in a PR.
|
|
208
|
+
|
|
209
|
+
## Contributing
|
|
210
|
+
|
|
211
|
+
Contributions are welcome - bug reports, fixes, and roadmap features alike.
|
|
212
|
+
|
|
213
|
+
1. Fork the repo and create a branch from `main`.
|
|
214
|
+
2. `npm install`, make your change, and keep `npm test` and `npm run typecheck` green.
|
|
215
|
+
3. Rebuild the docs site (`npm run build:site`) and click through the five nav configurations - it's the integration test.
|
|
216
|
+
4. For visual changes, include before/after screenshots in the PR.
|
|
217
|
+
5. Open a pull request with a short description of what changed and why.
|
|
218
|
+
|
|
219
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the code layout and a list of known gaps that make good first projects. By contributing, you agree that your contributions will be licensed under the MIT license.
|
|
220
|
+
|
|
221
|
+
## Acknowledgements
|
|
222
|
+
|
|
223
|
+
Plasma UI is built on well-known graphics and simulation techniques:
|
|
224
|
+
|
|
225
|
+
- **Blobby surfaces / metaballs** - the fuse-on-contact behavior descends from Jim Blinn's [_A Generalization of Algebraic Surface Drawing_](https://dl.acm.org/doi/10.1145/357306.357310) (1982).
|
|
226
|
+
- **Signed distance fields** - the material is drawn with 2D SDFs combined by smooth minimum, per Inigo Quilez's [2D distance functions](https://iquilezles.org/articles/distfunctions2d/) and [smooth minimum](https://iquilezles.org/articles/smin/) articles; the procedural background uses his [fBM](https://iquilezles.org/articles/fbm/) construction.
|
|
227
|
+
- **Spring integration** - panel motion uses semi-implicit Euler with fixed substeps, in the spirit of Glenn Fiedler's [_Integration Basics_](https://gafferongames.com/post/integration_basics/).
|
|
228
|
+
- **Liquid glass** - the optical treatment (refraction, dispersion, frost) is an original WebGL take on the direction popularized by Apple's [Liquid Glass](https://developer.apple.com/design/human-interface-guidelines/materials) material.
|
|
229
|
+
|
|
230
|
+
## License
|
|
231
|
+
|
|
232
|
+
[MIT](LICENSE)
|
package/dist/Plasma.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface Offset {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
export interface PlasmaProps extends Omit<React.HTMLAttributes<HTMLElement>, "onDragStart" | "onDragEnd"> {
|
|
7
|
+
/** Element to render. Default "div". */
|
|
8
|
+
as?: React.ElementType;
|
|
9
|
+
/** Corner radius in px. Defaults to the provider's radius. */
|
|
10
|
+
radius?: number;
|
|
11
|
+
/** How far (px) the surface leans toward the pointer while standalone. 0 or false disables. Default 10. */
|
|
12
|
+
lean?: number | false;
|
|
13
|
+
/** Tint color (hex) for this surface. Defaults to the provider's tint. */
|
|
14
|
+
tint?: string;
|
|
15
|
+
/** Tint strength, 0 (clear) to 1 (solid color). Defaults to the provider's opacity. */
|
|
16
|
+
opacity?: number;
|
|
17
|
+
/** Translucency, 0 (clear) to 1 (frosted). Defaults to the provider's frost. */
|
|
18
|
+
frost?: number;
|
|
19
|
+
/** Elevation, 0 (flat) to 1 (floating). Defaults to the provider's elevation; raises automatically while dragging. */
|
|
20
|
+
elevation?: number;
|
|
21
|
+
/** When false, this surface never blends, bridges, or joins with others - for bars, docks, and other fixed chrome. Default true. */
|
|
22
|
+
fuse?: boolean;
|
|
23
|
+
/** Inner padding in px. Halves on any edge joined to a neighbor, so gutters between fused panels equal the free-edge inset. */
|
|
24
|
+
padding?: number;
|
|
25
|
+
/** Let the user drag the surface. It moves freely and snaps on release. */
|
|
26
|
+
draggable?: boolean;
|
|
27
|
+
/** Snap on release (edges latch to neighbors, otherwise the grid). Default true. */
|
|
28
|
+
snap?: boolean;
|
|
29
|
+
/** Keep dragging inside this element. Defaults to the viewport. Also sets the grid origin. */
|
|
30
|
+
bounds?: React.RefObject<HTMLElement>;
|
|
31
|
+
/** Controlled offset from the element's layout position. Changes spring into place. */
|
|
32
|
+
offset?: Offset;
|
|
33
|
+
/** Starting offset when uncontrolled. */
|
|
34
|
+
defaultOffset?: Offset;
|
|
35
|
+
onDragStart?: () => void;
|
|
36
|
+
/** Reports the offset the surface is settling into. */
|
|
37
|
+
onDragEnd?: (offset: Offset) => void;
|
|
38
|
+
/** Fires when the surface fuses with or separates from a neighbor. */
|
|
39
|
+
onJoinChange?: (joined: boolean) => void;
|
|
40
|
+
}
|
|
41
|
+
export declare const Plasma: React.ForwardRefExoticComponent<PlasmaProps & React.RefAttributes<HTMLElement>>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BackgroundSource, PlasmaRenderer } from "./renderer";
|
|
3
|
+
import { Mood, MoodName } from "./moods";
|
|
4
|
+
export interface PlasmaProviderProps {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
/** Preset name or a custom mood. */
|
|
7
|
+
mood?: MoodName | Mood;
|
|
8
|
+
/** "auto" follows prefers-color-scheme and a data-theme attribute on <html>. */
|
|
9
|
+
theme?: "auto" | "light" | "dark";
|
|
10
|
+
/** Override the mood's fuse distance in px. */
|
|
11
|
+
blend?: number;
|
|
12
|
+
/** Lens strength multiplier. Default 1. */
|
|
13
|
+
refraction?: number;
|
|
14
|
+
/** Color-splitting multiplier. Default 1. */
|
|
15
|
+
dispersion?: number;
|
|
16
|
+
/** Colored rim strength. 0 turns it off. Default 1. */
|
|
17
|
+
rim?: number;
|
|
18
|
+
/** Rim color: "iridescent", "tint" (follows each surface's tint), or a hex color. Default "iridescent". */
|
|
19
|
+
rimColor?: "iridescent" | "tint" | (string & {});
|
|
20
|
+
/** Rim width multiplier. Default 1. */
|
|
21
|
+
rimWidth?: number;
|
|
22
|
+
/** Strength of the highlight that faces the pointer. 0 turns it off. Default 1. */
|
|
23
|
+
highlight?: number;
|
|
24
|
+
/** Strength of the thin line along the outline. 0 turns it off. Default 1. */
|
|
25
|
+
edgeLine?: number;
|
|
26
|
+
/** How thick the material feels: 0 is watery and bouncy, 1 is slow like syrup. Also scales drag and snap springs. Default 0.5. */
|
|
27
|
+
viscosity?: number;
|
|
28
|
+
/** How far the glass trails and stretches behind moving panels. 0 turns it off. Default 1. */
|
|
29
|
+
stretch?: number;
|
|
30
|
+
/** Slow ripple along the edges. Default 0 (still edges). */
|
|
31
|
+
flow?: number;
|
|
32
|
+
/** Background: any CSS color (subtle luminance drift), an image URL or data URI (refracted, slow swirl), or an img/canvas/video element - canvas and video update live. Change it any time. Omit for the procedural mood field. */
|
|
33
|
+
background?: BackgroundSource;
|
|
34
|
+
/** Default corner radius (px) for every surface. Default 26. */
|
|
35
|
+
radius?: number;
|
|
36
|
+
/** Plasma tint color (hex). Default "#ffffff". */
|
|
37
|
+
tint?: string;
|
|
38
|
+
/** Tint strength from 0 (clear glass) to 1 (solid color). Default 0. */
|
|
39
|
+
opacity?: number;
|
|
40
|
+
/** Translucency from 0 (clear glass) to 1 (frosted). Default 0. */
|
|
41
|
+
frost?: number;
|
|
42
|
+
/** How high surfaces float: 0 sits flat with no shadow, 1 floats high with a deep soft shadow. Dragged surfaces raise automatically. Default 0.35. */
|
|
43
|
+
elevation?: number;
|
|
44
|
+
/** Outline smoothing multiplier. Default 1. */
|
|
45
|
+
smoothness?: number;
|
|
46
|
+
/** Show a liquid drop that follows the pointer. Default true. */
|
|
47
|
+
pointerDrop?: boolean;
|
|
48
|
+
/** Decorative drops orbiting near the bottom right. Default false. */
|
|
49
|
+
ambientDrops?: boolean;
|
|
50
|
+
/** Grid cell size used when draggable glass snaps. Default 24. */
|
|
51
|
+
grid?: number;
|
|
52
|
+
/** Edge latch distance for snapping. Default 40. */
|
|
53
|
+
magnet?: number;
|
|
54
|
+
/** Maximum device pixel ratio for the canvas. Default 1.25. */
|
|
55
|
+
quality?: number;
|
|
56
|
+
/** Maximum visible glass surfaces. Compiled into the shaders, so it is fixed for the provider's lifetime; more surfaces cost GPU time. Default 16. */
|
|
57
|
+
maxSurfaces?: number;
|
|
58
|
+
/** z-index of the fixed canvas. Default -1 (behind content). */
|
|
59
|
+
zIndex?: number;
|
|
60
|
+
}
|
|
61
|
+
export interface PlasmaContextValue {
|
|
62
|
+
renderer: PlasmaRenderer | null;
|
|
63
|
+
/** Provider-level tint and opacity, used by the CSS fallback. */
|
|
64
|
+
tint: string;
|
|
65
|
+
opacity: number;
|
|
66
|
+
frost: number;
|
|
67
|
+
/** Provider-level default corner radius. */
|
|
68
|
+
radius: number;
|
|
69
|
+
/** False when WebGL2 is unavailable; <Plasma> falls back to CSS glass. */
|
|
70
|
+
supported: boolean;
|
|
71
|
+
grid: number;
|
|
72
|
+
magnet: number;
|
|
73
|
+
spring: Mood["spring"];
|
|
74
|
+
reducedMotion: boolean;
|
|
75
|
+
pulse: (x: number, y: number, strength?: number) => void;
|
|
76
|
+
bump: (energy: number) => void;
|
|
77
|
+
}
|
|
78
|
+
export declare const usePlasma: () => PlasmaContextValue;
|
|
79
|
+
export declare function PlasmaProvider({ children, mood, theme, blend, refraction, dispersion, rim, smoothness, background, radius, tint, opacity, frost, elevation, viscosity, stretch, flow, rimColor, rimWidth, highlight, edgeLine, pointerDrop, ambientDrops, grid, magnet, quality, maxSurfaces, zIndex, }: PlasmaProviderProps): React.JSX.Element;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { PlasmaProvider, usePlasma } from "./PlasmaProvider";
|
|
2
|
+
export type { PlasmaProviderProps, PlasmaContextValue } from "./PlasmaProvider";
|
|
3
|
+
export { Plasma } from "./Plasma";
|
|
4
|
+
export type { PlasmaProps, Offset } from "./Plasma";
|
|
5
|
+
export { moods, resolveMood } from "./moods";
|
|
6
|
+
export type { Mood, MoodName } from "./moods";
|
|
7
|
+
export { snapBox, boxGap } from "./snap";
|
|
8
|
+
export type { Box, SnapOptions } from "./snap";
|
|
9
|
+
export { PlasmaRenderer } from "./renderer";
|
|
10
|
+
export { makeShaders, DEFAULT_MAX_SHAPES } from "./shaders";
|
|
11
|
+
export type { BackgroundSource, JoinedSides, RendererSettings, ShapeHandle, ShapeOptions } from "./renderer";
|