argentui 0.3.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 +160 -0
- package/dist/index.cjs +838 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +306 -0
- package/dist/index.d.ts +306 -0
- package/dist/index.js +794 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +289 -0
- package/package.json +63 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { LiquidMetalParams } from '@paper-design/shaders-react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Argent's own liquid-metal shader — a clean-room WebGL2 implementation of the
|
|
6
|
+
* classic recipe: hard light→dark reflection banding, curvature-warped UVs,
|
|
7
|
+
* time-driven simplex-noise flow, per-channel chromatic dispersion, and a rim
|
|
8
|
+
* lift. No third-party shader code beyond the public-domain-style simplex
|
|
9
|
+
* noise (Ashima Arts / Stefan Gustavson, MIT).
|
|
10
|
+
*
|
|
11
|
+
* Used when a surface sets `engine="native"`; removes the need for
|
|
12
|
+
* @paper-design/shaders-react entirely.
|
|
13
|
+
*/
|
|
14
|
+
interface NativeMetalParams {
|
|
15
|
+
/** Highlight band colour (hex). */
|
|
16
|
+
light: string;
|
|
17
|
+
/** Shadow band colour (hex). */
|
|
18
|
+
dark: string;
|
|
19
|
+
/** Stripe density. */
|
|
20
|
+
repetition: number;
|
|
21
|
+
/** Band direction in degrees. */
|
|
22
|
+
angle: number;
|
|
23
|
+
/** Band edge softness 0–1. */
|
|
24
|
+
softness: number;
|
|
25
|
+
/** Per-channel band offset (chromatic dispersion). */
|
|
26
|
+
dispersion: number;
|
|
27
|
+
/** Noise warp amount. */
|
|
28
|
+
distortion: number;
|
|
29
|
+
/** Animation speed (0 = still). */
|
|
30
|
+
speed: number;
|
|
31
|
+
/** Pattern scale — higher spreads the bands out. */
|
|
32
|
+
scale: number;
|
|
33
|
+
}
|
|
34
|
+
type MetalEngine = "paper" | "native";
|
|
35
|
+
declare const NATIVE_TONES: Record<string, Omit<NativeMetalParams, "speed" | "scale">>;
|
|
36
|
+
interface MetalMount {
|
|
37
|
+
update(params: Partial<NativeMetalParams>): void;
|
|
38
|
+
destroy(): void;
|
|
39
|
+
}
|
|
40
|
+
/** Mount the native liquid-metal shader on a canvas. Returns null without WebGL2. */
|
|
41
|
+
declare function mountMetal(canvas: HTMLCanvasElement, params: NativeMetalParams): MetalMount | null;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The liquid-metal surface is Paper's `LiquidMetal` WebGL shader
|
|
45
|
+
* (@paper-design/shaders) run with `shape="none"` so it fills the whole element
|
|
46
|
+
* instead of painting a blob. Each tone is a tuned set of shader params; the
|
|
47
|
+
* canvas sits behind the content and is clipped to the surface's radius.
|
|
48
|
+
*
|
|
49
|
+
* `@paper-design/shaders-react` is a peer dependency — install it alongside
|
|
50
|
+
* `argentui`. It is licensed under PolyForm Shield by Paper.
|
|
51
|
+
*/
|
|
52
|
+
type MetalTone = "silver" | "gold" | "gunmetal" | "obsidian";
|
|
53
|
+
type Tuned = Pick<LiquidMetalParams, "colorBack" | "colorTint" | "repetition" | "softness" | "shiftRed" | "shiftBlue" | "distortion" | "contour" | "angle">;
|
|
54
|
+
declare const TONE_PARAMS: Record<MetalTone, Tuned>;
|
|
55
|
+
/** True once mounted on the client — the WebGL canvas can't render during SSR. */
|
|
56
|
+
declare function useMounted(): boolean;
|
|
57
|
+
/** True when the user prefers reduced motion — the metal freezes (speed 0). */
|
|
58
|
+
declare function useReducedMotion(): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Reports whether `ref` is on/near screen. Each metal surface is a WebGL
|
|
61
|
+
* canvas, and browsers cap concurrent contexts (~16) — so we only mount the
|
|
62
|
+
* shader while it's visible and release the context when it scrolls away.
|
|
63
|
+
*/
|
|
64
|
+
declare function useInView(ref: React.RefObject<Element | null>, margin?: string): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Finishes — shader presets tuned to the shape and size of the element. One
|
|
67
|
+
* pattern does not fit all: a card wants broad flowing bands, a thin progress
|
|
68
|
+
* bar wants many stripes crossing it, a 22px toggle thumb wants one soft
|
|
69
|
+
* highlight like a ball bearing, and a hairline badge rim wants dense bands so
|
|
70
|
+
* a tiny visible slice always catches some light.
|
|
71
|
+
*/
|
|
72
|
+
type MetalFinish = "surface" | "button" | "bar" | "orb" | "rim";
|
|
73
|
+
interface FinishTuning {
|
|
74
|
+
/** Band direction override (deg). */
|
|
75
|
+
angle?: number;
|
|
76
|
+
/** Random per-mount angle variation (±deg) so identical elements don't look cloned. */
|
|
77
|
+
angleJitter?: number;
|
|
78
|
+
repetition?: number;
|
|
79
|
+
softness?: number;
|
|
80
|
+
distortion?: number;
|
|
81
|
+
/** Multiplier on the tone's chromatic shift. */
|
|
82
|
+
shift?: number;
|
|
83
|
+
/** Default pattern scale. */
|
|
84
|
+
scale?: number;
|
|
85
|
+
/** Multiplier on the animation speed. */
|
|
86
|
+
speed?: number;
|
|
87
|
+
}
|
|
88
|
+
declare const FINISHES: Record<MetalFinish, FinishTuning>;
|
|
89
|
+
/**
|
|
90
|
+
* Effects — the character of the liquid's motion, independent of tone and
|
|
91
|
+
* finish: how soft the bands are, how hard the noise churns them, how fast
|
|
92
|
+
* everything moves.
|
|
93
|
+
*/
|
|
94
|
+
type MetalEffect = "flow" | "molten" | "ripple" | "chrome" | "wave";
|
|
95
|
+
interface EffectTuning {
|
|
96
|
+
angle?: number;
|
|
97
|
+
repetition?: number;
|
|
98
|
+
softness?: number;
|
|
99
|
+
distortion?: number;
|
|
100
|
+
/** Multiplier on chromatic shift. */
|
|
101
|
+
shift?: number;
|
|
102
|
+
/** Multiplier on animation speed. */
|
|
103
|
+
speed?: number;
|
|
104
|
+
}
|
|
105
|
+
declare const EFFECTS: Record<MetalEffect, EffectTuning>;
|
|
106
|
+
interface MetalFillProps {
|
|
107
|
+
tone: MetalTone;
|
|
108
|
+
/** Shader animation speed (0 pauses). */
|
|
109
|
+
speed?: number;
|
|
110
|
+
/** Pattern scale — higher spreads the bands out. Defaults per finish. */
|
|
111
|
+
scale?: number;
|
|
112
|
+
/** `"paper"` (Paper's LiquidMetal, default) or `"native"` (Argent's own shader). */
|
|
113
|
+
engine?: MetalEngine;
|
|
114
|
+
/** Shape-tuned shader preset. Defaults to `"surface"`. */
|
|
115
|
+
finish?: MetalFinish;
|
|
116
|
+
/** Motion character preset. Defaults to `"flow"`. */
|
|
117
|
+
effect?: MetalEffect;
|
|
118
|
+
/** Band direction in degrees — overrides the tone/finish default. */
|
|
119
|
+
angle?: number;
|
|
120
|
+
}
|
|
121
|
+
/** The shader canvas, absolutely filling its positioned parent (when in view). */
|
|
122
|
+
declare function MetalFill({ tone, speed, scale, engine, finish, effect, angle }: MetalFillProps): react.JSX.Element;
|
|
123
|
+
|
|
124
|
+
/** Where the liquid metal shows: just the edge, or the whole surface. */
|
|
125
|
+
type MetalVariant = "border" | "fill";
|
|
126
|
+
/** Border framing: a single rim, or a rim plus an inner hairline frame. */
|
|
127
|
+
type MetalFrame = "single" | "double";
|
|
128
|
+
interface MetalProps extends React.HTMLAttributes<HTMLElement> {
|
|
129
|
+
/** Element/component to render. Defaults to `div`. */
|
|
130
|
+
as?: React.ElementType;
|
|
131
|
+
/** Metal finish. */
|
|
132
|
+
tone?: MetalTone;
|
|
133
|
+
/** `"border"` (metal edge only, default) or `"fill"` (metal fills the surface). */
|
|
134
|
+
variant?: MetalVariant;
|
|
135
|
+
/** `"single"` rim (default) or `"double"` — rim plus an inner hairline frame. */
|
|
136
|
+
frame?: MetalFrame;
|
|
137
|
+
/** Let the metal show faintly through the interior panel (border variant). */
|
|
138
|
+
tint?: boolean;
|
|
139
|
+
/** Border thickness in px (border variant). */
|
|
140
|
+
borderWidth?: number;
|
|
141
|
+
/** Fill the whole surface with metal on hover (border variant). */
|
|
142
|
+
revealOnHover?: boolean;
|
|
143
|
+
/** Corner radius in px. */
|
|
144
|
+
radius?: number;
|
|
145
|
+
/** Shader animation speed (0 pauses the metal). */
|
|
146
|
+
speed?: number;
|
|
147
|
+
/** Pattern scale — higher spreads the reflection bands out. */
|
|
148
|
+
metalScale?: number;
|
|
149
|
+
/** Shader engine: Paper's LiquidMetal (default) or Argent's own. */
|
|
150
|
+
engine?: MetalEngine;
|
|
151
|
+
/** Shape-tuned shader preset. Defaults to `"surface"`. */
|
|
152
|
+
finish?: MetalFinish;
|
|
153
|
+
/** Motion character: flow, molten, ripple, chrome, or wave. */
|
|
154
|
+
effect?: MetalEffect;
|
|
155
|
+
/** Band direction in degrees — overrides the tone/finish default. */
|
|
156
|
+
angle?: number;
|
|
157
|
+
/** A specular streak that sweeps across on hover. */
|
|
158
|
+
sheen?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* A frosted standoff ring outside the metal — a few px of backdrop blur
|
|
161
|
+
* finished with a ~5% hairline. `true` for 8px, or a number for the ring
|
|
162
|
+
* width. Theme the line with `--argent-halo-line`.
|
|
163
|
+
*/
|
|
164
|
+
halo?: boolean | number;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* A liquid-metal surface powered by Paper's `LiquidMetal` shader. By default the
|
|
168
|
+
* metal is just the edge; pass `variant="fill"` for a full metal surface, or
|
|
169
|
+
* `revealOnHover` to fill in on interaction. The base for every Argent component.
|
|
170
|
+
*/
|
|
171
|
+
declare const Metal: react.ForwardRefExoticComponent<MetalProps & react.RefAttributes<HTMLElement>>;
|
|
172
|
+
interface MetalCardProps extends MetalProps {
|
|
173
|
+
}
|
|
174
|
+
/** A padded liquid-metal container. Metal edge by default. */
|
|
175
|
+
declare const MetalCard: react.ForwardRefExoticComponent<MetalCardProps & react.RefAttributes<HTMLElement>>;
|
|
176
|
+
interface MetalButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
177
|
+
tone?: MetalTone;
|
|
178
|
+
size?: "sm" | "md" | "lg";
|
|
179
|
+
/** `"border"` (default — readable, fills on hover) or `"fill"` (full chrome). */
|
|
180
|
+
variant?: MetalVariant;
|
|
181
|
+
/** Corner radius in px. */
|
|
182
|
+
radius?: number;
|
|
183
|
+
borderWidth?: number;
|
|
184
|
+
/** Fill with metal on hover (border variant). Defaults to `true`. */
|
|
185
|
+
revealOnHover?: boolean;
|
|
186
|
+
/** Vibrate on press where supported. Defaults to `true`. */
|
|
187
|
+
haptics?: boolean;
|
|
188
|
+
speed?: number;
|
|
189
|
+
engine?: MetalEngine;
|
|
190
|
+
finish?: MetalFinish;
|
|
191
|
+
effect?: MetalEffect;
|
|
192
|
+
angle?: number;
|
|
193
|
+
halo?: boolean | number;
|
|
194
|
+
}
|
|
195
|
+
/** A liquid-metal button — readable at rest, molten on hover, with a stamped press. */
|
|
196
|
+
declare const MetalButton: react.ForwardRefExoticComponent<MetalButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
197
|
+
|
|
198
|
+
interface MetalToggleProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onChange"> {
|
|
199
|
+
tone?: MetalTone;
|
|
200
|
+
checked?: boolean;
|
|
201
|
+
defaultChecked?: boolean;
|
|
202
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
203
|
+
/** Vibrate on toggle where supported. Defaults to `true`. */
|
|
204
|
+
haptics?: boolean;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* A mercury switch — the thumb is a drop of liquid metal that slides (and
|
|
208
|
+
* squishes) across a dark channel.
|
|
209
|
+
*/
|
|
210
|
+
declare const MetalToggle: react.ForwardRefExoticComponent<MetalToggleProps & react.RefAttributes<HTMLButtonElement>>;
|
|
211
|
+
interface MetalProgressProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
212
|
+
tone?: MetalTone;
|
|
213
|
+
/** 0–100. Omit for an indeterminate molten sweep. */
|
|
214
|
+
value?: number;
|
|
215
|
+
/** Track height in px. */
|
|
216
|
+
height?: number;
|
|
217
|
+
}
|
|
218
|
+
/** A molten progress bar — liquid metal rising in a dark channel. */
|
|
219
|
+
declare const MetalProgress: react.ForwardRefExoticComponent<MetalProgressProps & react.RefAttributes<HTMLDivElement>>;
|
|
220
|
+
interface MetalBadgeProps extends Omit<MetalProps, "as" | "variant"> {
|
|
221
|
+
}
|
|
222
|
+
/** A small liquid-metal pill — a metal rim around a quiet label. */
|
|
223
|
+
declare const MetalBadge: react.ForwardRefExoticComponent<MetalBadgeProps & react.RefAttributes<HTMLElement>>;
|
|
224
|
+
|
|
225
|
+
/** Where the metal lives in shader text: the whole glyph, or just its edge. */
|
|
226
|
+
type MetalTextVariant = "fill" | "outline";
|
|
227
|
+
interface MetalTextProps extends React.HTMLAttributes<HTMLElement> {
|
|
228
|
+
/** Element to render. Defaults to `span`. */
|
|
229
|
+
as?: React.ElementType;
|
|
230
|
+
tone?: MetalTone;
|
|
231
|
+
/** Animate the highlight band across the glyphs (CSS mode). Defaults to `true`. */
|
|
232
|
+
shimmer?: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Pour the real liquid-metal shader into the glyphs — flowing bands, liquid
|
|
235
|
+
* edges, chromatic fringe. Costs a WebGL canvas; the CSS gradient renders as
|
|
236
|
+
* a placeholder until the shader is ready, and stands in wherever WebGL
|
|
237
|
+
* isn't. Children must be a plain string in this mode.
|
|
238
|
+
*/
|
|
239
|
+
shader?: boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Shader mode: `"fill"` (metal fills the glyphs, default) or `"outline"` —
|
|
242
|
+
* the metal runs around the edge of each letterform and the interior takes
|
|
243
|
+
* `fill` / `fillGradient`.
|
|
244
|
+
*/
|
|
245
|
+
variant?: MetalTextVariant;
|
|
246
|
+
/** Interior colour for `variant="outline"`. */
|
|
247
|
+
fill?: string;
|
|
248
|
+
/** Interior vertical gradient `[top, bottom]` for `variant="outline"` — wins over `fill`. */
|
|
249
|
+
fillGradient?: [string, string];
|
|
250
|
+
/** Metal edge thickness in px for `variant="outline"`. Defaults to ~5% of the font size. */
|
|
251
|
+
outlineWidth?: number;
|
|
252
|
+
/** Type size in px (shader mode). Defaults to `64`. */
|
|
253
|
+
fontSize?: number;
|
|
254
|
+
/** Weight for the glyph silhouette (shader mode). Defaults to `800`. */
|
|
255
|
+
fontWeight?: number;
|
|
256
|
+
/**
|
|
257
|
+
* Font for the silhouette (shader mode). Rendered inside an SVG image, which
|
|
258
|
+
* sees system fonts only — to use a webfont, pass `fontCss` with a
|
|
259
|
+
* data-URI @font-face for the same family.
|
|
260
|
+
*/
|
|
261
|
+
fontFamily?: string;
|
|
262
|
+
/**
|
|
263
|
+
* Raw CSS embedded in the glyph SVG (shader mode) — typically a @font-face
|
|
264
|
+
* whose `src` is a data: URI, which lets webfonts (e.g. Google Fonts) render
|
|
265
|
+
* inside the silhouette. Load the same face into `document.fonts` so the
|
|
266
|
+
* width measurement matches.
|
|
267
|
+
*/
|
|
268
|
+
fontCss?: string;
|
|
269
|
+
/** Shader animation speed (0 pauses). */
|
|
270
|
+
speed?: number;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Metal type. By default a chrome gradient clipped to the glyphs with a flowing
|
|
274
|
+
* shimmer — pure CSS, use it freely at any scale. Pass `shader` to pour the
|
|
275
|
+
* real liquid-metal shader into the letterforms — `variant="fill"` floods the
|
|
276
|
+
* glyphs; `variant="outline"` runs the metal around their edges over a dark or
|
|
277
|
+
* gradient interior.
|
|
278
|
+
*/
|
|
279
|
+
declare const MetalText: react.ForwardRefExoticComponent<MetalTextProps & react.RefAttributes<HTMLElement>>;
|
|
280
|
+
|
|
281
|
+
interface MetalLogoProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
282
|
+
/** Image URL (or data URI) with a transparent background — the metal flows inside its silhouette. */
|
|
283
|
+
src: string;
|
|
284
|
+
tone?: MetalTone;
|
|
285
|
+
/** Rendered size in px (square by default). */
|
|
286
|
+
size?: number;
|
|
287
|
+
width?: number;
|
|
288
|
+
height?: number;
|
|
289
|
+
/** Shader animation speed (0 pauses). */
|
|
290
|
+
speed?: number;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Liquid metal poured into a logo — pass any image with a transparent
|
|
294
|
+
* background and the metal flows inside its silhouette. The classic
|
|
295
|
+
* liquid-metal treatment for marks, monograms, and icons.
|
|
296
|
+
*/
|
|
297
|
+
declare function MetalLogo({ src, tone, size, width, height, speed, style, ...rest }: MetalLogoProps): react.JSX.Element;
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Tiny haptics for metal presses — `navigator.vibrate` where available
|
|
301
|
+
* (Android Chrome; iOS Safari ignores it). On by default, like Glacé.
|
|
302
|
+
*/
|
|
303
|
+
/** Globally enable/disable Argent haptics. */
|
|
304
|
+
declare function setHaptics(on: boolean): void;
|
|
305
|
+
|
|
306
|
+
export { EFFECTS, FINISHES, Metal, MetalBadge, type MetalBadgeProps, MetalButton, type MetalButtonProps, MetalCard, type MetalCardProps, type MetalEffect, type MetalEngine, MetalFill, type MetalFillProps, type MetalFinish, type MetalFrame, MetalLogo, type MetalLogoProps, type MetalMount, MetalProgress, type MetalProgressProps, type MetalProps, MetalText, type MetalTextProps, type MetalTextVariant, MetalToggle, type MetalToggleProps, type MetalTone, type MetalVariant, NATIVE_TONES, type NativeMetalParams, TONE_PARAMS, mountMetal, setHaptics, useInView, useMounted, useReducedMotion };
|