@phreshos/react-ui 0.1.5 → 0.1.7
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 +4 -2
- package/dist/surface-material.d.ts +2 -2
- package/dist/surface-material.js +4 -4
- package/dist/surface.d.ts +2 -2
- package/dist/surface.js +9 -13
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -94,17 +94,19 @@ texture:
|
|
|
94
94
|
</Surface>
|
|
95
95
|
|
|
96
96
|
<Surface color="strong" grain="large">...</Surface>
|
|
97
|
-
<Surface color="#101114" grain={0.2}
|
|
97
|
+
<Surface color="#101114" grain={0.2} grainAnimation={8} backdrop={4} opacity={0.9}>...</Surface>
|
|
98
98
|
<Surface distortion={70} waves={8} ripples={4} saturation={1.4} brightness={1.04}>...</Surface>
|
|
99
99
|
```
|
|
100
100
|
|
|
101
101
|
`color` resolves from `Theme.background`; its semantic levels derive from that
|
|
102
102
|
same source and a direct color remains an explicit local override. `grain`,
|
|
103
|
-
`grainAmount`, `
|
|
103
|
+
`grainAmount`, `grainAnimation`, `backdrop`, `opacity`, `distortion`, `waves`,
|
|
104
104
|
`ripples`, `saturation`, and `brightness` resolve from `Theme.surface`, accept
|
|
105
105
|
their semantic levels or direct values, and remain bounded by Core's Theme
|
|
106
106
|
limits. Radius and foreground remain ordinary Theme styles. Grain intensity
|
|
107
107
|
controls tonal distance while grain amount controls retained cell density.
|
|
108
|
+
Each Surface owns one uniform one-pixel inset edge derived from its resolved
|
|
109
|
+
material color; consumers supply only their radius and do not redraw the edge.
|
|
108
110
|
When either is zero, Surface creates no grain pattern or paths. Refraction and
|
|
109
111
|
native frost use independent backdrop layers so blur does not soften the
|
|
110
112
|
displaced image. Enabled organic, wave, and ripple fields are combined
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
interface SurfaceMaterialProps {
|
|
2
|
-
readonly
|
|
2
|
+
readonly grainAnimation: number;
|
|
3
3
|
readonly color: string;
|
|
4
4
|
readonly distortion: number;
|
|
5
5
|
readonly grain: number;
|
|
@@ -10,5 +10,5 @@ interface SurfaceMaterialProps {
|
|
|
10
10
|
readonly waves: number;
|
|
11
11
|
}
|
|
12
12
|
/** The locally owned SVG paint layer inside one Surface. */
|
|
13
|
-
export declare function SurfaceMaterial({
|
|
13
|
+
export declare function SurfaceMaterial({ color, distortion, grain, grainAmount, grainAnimation, identity, opacity, ripples, waves }: SurfaceMaterialProps): import("react").JSX.Element | null;
|
|
14
14
|
export {};
|
package/dist/surface-material.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
/** The locally owned SVG paint layer inside one Surface. */
|
|
4
|
-
export function SurfaceMaterial({
|
|
4
|
+
export function SurfaceMaterial({ color, distortion, grain, grainAmount, grainAnimation, identity, opacity, ripples, waves }) {
|
|
5
5
|
const seed = useMemo(() => seedFrom(identity), [identity]);
|
|
6
6
|
const hasPaint = opacity > 0;
|
|
7
7
|
const hasGrain = hasPaint && grain > 0 && grainAmount > 0;
|
|
@@ -11,14 +11,14 @@ export function SurfaceMaterial({ animation, color, distortion, grain, grainAmou
|
|
|
11
11
|
const paths = useRef([]);
|
|
12
12
|
useEffect(() => {
|
|
13
13
|
paths.current.forEach((path, tone) => path?.setAttribute("d", initial[tone] ?? ""));
|
|
14
|
-
if (
|
|
14
|
+
if (grainAnimation === 0 || !hasGrain || !svg.current)
|
|
15
15
|
return;
|
|
16
16
|
const paint = (frame) => {
|
|
17
17
|
const values = grainPaths(seed, frame, grainAmount);
|
|
18
18
|
paths.current.forEach((path, tone) => path?.setAttribute("d", values[tone] ?? ""));
|
|
19
19
|
};
|
|
20
|
-
return animate(svg.current,
|
|
21
|
-
}, [
|
|
20
|
+
return animate(svg.current, grainAnimation, paint);
|
|
21
|
+
}, [grainAnimation, grainAmount, hasGrain, initial, seed]);
|
|
22
22
|
if (!hasPaint && !hasDistortion)
|
|
23
23
|
return null;
|
|
24
24
|
return _jsxs("svg", { ref: svg, "data-surface-material": "", "aria-hidden": "true", focusable: "false", style: {
|
package/dist/surface.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export type SurfaceProps = Omit<ComponentPropsWithoutRef<"div">, "color" | "opac
|
|
|
11
11
|
/** Theme-derived level or direct retained grain amount from zero to one. */
|
|
12
12
|
grainAmount?: ScaleLevel | number;
|
|
13
13
|
/** Theme-derived level or direct grain changes per second from zero to 16. */
|
|
14
|
-
|
|
14
|
+
grainAnimation?: ScaleLevel | number;
|
|
15
15
|
/** Theme-derived level or direct backdrop blur from zero to 24 CSS pixels. */
|
|
16
16
|
backdrop?: ScaleLevel | number;
|
|
17
17
|
/** Theme-derived level or direct material opacity from zero to one. */
|
|
@@ -36,7 +36,7 @@ export declare const Surface: import("react").ForwardRefExoticComponent<Omit<Omi
|
|
|
36
36
|
/** Theme-derived level or direct retained grain amount from zero to one. */
|
|
37
37
|
grainAmount?: ScaleLevel | number;
|
|
38
38
|
/** Theme-derived level or direct grain changes per second from zero to 16. */
|
|
39
|
-
|
|
39
|
+
grainAnimation?: ScaleLevel | number;
|
|
40
40
|
/** Theme-derived level or direct backdrop blur from zero to 24 CSS pixels. */
|
|
41
41
|
backdrop?: ScaleLevel | number;
|
|
42
42
|
/** Theme-derived level or direct material opacity from zero to one. */
|
package/dist/surface.js
CHANGED
|
@@ -9,9 +9,8 @@ const layerStyle = {
|
|
|
9
9
|
borderRadius: "inherit",
|
|
10
10
|
pointerEvents: "none"
|
|
11
11
|
};
|
|
12
|
-
const borderOpacity = 0.3;
|
|
13
12
|
/** Contains content above locally owned Surface material layers. */
|
|
14
|
-
export const Surface = forwardRef(function Surface({
|
|
13
|
+
export const Surface = forwardRef(function Surface({ backdrop, brightness, children, color, distortion, grain, grainAmount, grainAnimation, opacity, ripples, saturation, style, waves, ...properties }, forwardedRef) {
|
|
15
14
|
const theme = useTheme();
|
|
16
15
|
const identity = `phresh-surface-${useId().replaceAll(":", "")}`;
|
|
17
16
|
const element = useRef(null);
|
|
@@ -22,7 +21,7 @@ export const Surface = forwardRef(function Surface({ animation, backdrop, bright
|
|
|
22
21
|
else if (forwardedRef)
|
|
23
22
|
forwardedRef.current = node;
|
|
24
23
|
}, [forwardedRef]);
|
|
25
|
-
const resolved = resolveSurface({
|
|
24
|
+
const resolved = resolveSurface({ backdrop, brightness, color, distortion, grain, grainAmount, grainAnimation, opacity, ripples, saturation, waves }, theme);
|
|
26
25
|
useLayoutEffect(() => {
|
|
27
26
|
const surface = element.current;
|
|
28
27
|
if (surface)
|
|
@@ -32,20 +31,17 @@ export const Surface = forwardRef(function Surface({ animation, backdrop, bright
|
|
|
32
31
|
borderRadius: theme.radius,
|
|
33
32
|
color: theme.foreground,
|
|
34
33
|
...style
|
|
35
|
-
}, children: [resolved.refracts && _jsx(BackdropLayer, { name: "refraction", filter: `url("#${identity}-distortion")`, zIndex: -3 }), resolved.frost && _jsx(BackdropLayer, { name: "frost", filter: resolved.frost, zIndex: -2 }), _jsx(SurfaceBorder, { color: resolved.material.color }), _jsx(SurfaceMaterial, { identity: identity, ...resolved.material }), children] });
|
|
34
|
+
}, children: [resolved.refracts && _jsx(BackdropLayer, { name: "refraction", filter: `url("#${identity}-distortion")`, zIndex: -3 }), resolved.frost && _jsx(BackdropLayer, { name: "frost", filter: resolved.frost, zIndex: -2 }), _jsx(SurfaceBorder, { color: resolved.material.color, opacity: resolveScale("large", resolved.material.opacity, themeLimits.surface.opacity) }), _jsx(SurfaceMaterial, { identity: identity, ...resolved.material }), children] });
|
|
36
35
|
});
|
|
37
|
-
/** Draws one
|
|
38
|
-
function SurfaceBorder({ color }) {
|
|
39
|
-
const
|
|
40
|
-
const shade = `color-mix(in oklch, ${color} 94%, black)`;
|
|
36
|
+
/** Draws one uniform inset edge from the same color as the Surface material. */
|
|
37
|
+
function SurfaceBorder({ color, opacity }) {
|
|
38
|
+
const edge = `color-mix(in oklch, ${color} 94%, black)`;
|
|
41
39
|
return _jsx("div", { "data-surface-border": "", "aria-hidden": "true", style: {
|
|
42
40
|
...layerStyle,
|
|
43
41
|
zIndex: 0,
|
|
44
|
-
borderStyle: "solid",
|
|
45
|
-
borderWidth: 1,
|
|
46
|
-
borderColor: `${highlight} ${shade} ${shade} ${highlight}`,
|
|
47
42
|
boxSizing: "border-box",
|
|
48
|
-
|
|
43
|
+
boxShadow: `inset 0 0 0 1px ${edge}`,
|
|
44
|
+
opacity
|
|
49
45
|
} });
|
|
50
46
|
}
|
|
51
47
|
/** Keeps refraction and native frost in independent compositor passes. */
|
|
@@ -59,7 +55,7 @@ function BackdropLayer({ filter, name, zIndex }) {
|
|
|
59
55
|
}
|
|
60
56
|
function resolveSurface(values, theme) {
|
|
61
57
|
const material = {
|
|
62
|
-
|
|
58
|
+
grainAnimation: resolveScale(values.grainAnimation, theme.surface.grainAnimation, themeLimits.surface.grainAnimation),
|
|
63
59
|
color: resolveColor(values.color, theme.background),
|
|
64
60
|
distortion: resolveScale(values.distortion, theme.surface.distortion, themeLimits.surface.distortion),
|
|
65
61
|
grain: resolveScale(values.grain, theme.surface.grain, themeLimits.surface.grain),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phreshos/react-ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "React components for coherent PhreshOS Program interfaces.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"prepack": "node --run test && node --run build"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@phreshos/core": "^0.1.
|
|
55
|
+
"@phreshos/core": "^0.1.15",
|
|
56
56
|
"react": "^19.2.0",
|
|
57
57
|
"react-dom": "^19.2.0"
|
|
58
58
|
},
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@base-ui/react": "^1.7.0",
|
|
64
|
-
"@phreshos/core": "^0.1.
|
|
64
|
+
"@phreshos/core": "^0.1.15",
|
|
65
65
|
"@testing-library/dom": "^10.4.1",
|
|
66
66
|
"@testing-library/react": "^16.3.0",
|
|
67
67
|
"@testing-library/user-event": "^14.6.1",
|