@phreshos/react-ui 0.1.52 → 0.1.53
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/dist/main.d.ts +1 -1
- package/dist/main.js +1 -1
- package/dist/surface/surface.d.ts +9 -0
- package/dist/surface/surface.js +18 -1
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export { useDirection, useDocumentDirection, type Direction } from "./foundation
|
|
|
13
13
|
export type { Preferences, PreferencesUpdate, Theme } from "./foundation/preferences.js";
|
|
14
14
|
export { Flex, type FlexProps } from "./flex.js";
|
|
15
15
|
export { Grid, type GridProps } from "./grid.js";
|
|
16
|
-
export { Surface, type MaterialMode, type MaterialOptions, type ShadowOptions, type SurfaceComponent, type SurfaceDepth, type SurfaceHost, type SurfaceHostProps, type SurfaceOwnProps, type SurfaceProps } from "./surface/surface.js";
|
|
16
|
+
export { Surface, useSurfaceColor, type MaterialMode, type MaterialOptions, type ShadowOptions, type SurfaceComponent, type SurfaceDepth, type SurfaceHost, type SurfaceHostProps, type SurfaceOwnProps, type SurfaceProps } from "./surface/surface.js";
|
|
17
17
|
export { resolveColor, useColor, useContrastingColor, type Color, type ColorLevel, type ColorScale } from "./foundation/color.js";
|
|
18
18
|
export { Panel, type PanelProps, type PanelHeaderProps, type PanelContentProps } from "./panel.js";
|
|
19
19
|
export { Window, type WindowProps, type WindowContentProps, type WindowHeaderProps, type WindowIdentityProps, type WindowCenterProps, type WindowActionsProps, type WindowActionProps, type WindowControlProps, type WindowMaximizeProps, type WindowCloseProps, type WindowMoveCaptureProps } from "./window.js";
|
package/dist/main.js
CHANGED
|
@@ -12,7 +12,7 @@ export { timing } from "./foundation/timing.js";
|
|
|
12
12
|
export { useDirection, useDocumentDirection } from "./foundation/direction.js";
|
|
13
13
|
export { Flex } from "./flex.js";
|
|
14
14
|
export { Grid } from "./grid.js";
|
|
15
|
-
export { Surface } from "./surface/surface.js";
|
|
15
|
+
export { Surface, useSurfaceColor } from "./surface/surface.js";
|
|
16
16
|
export { resolveColor, useColor, useContrastingColor } from "./foundation/color.js";
|
|
17
17
|
// Context-dependent parts are public only through their owning component family.
|
|
18
18
|
export { Panel } from "./panel.js";
|
|
@@ -71,6 +71,15 @@ export declare const interactionShift: Readonly<{
|
|
|
71
71
|
}>;
|
|
72
72
|
/** A clear Surface has no paint to move, so it shows the same shift as a slightly stronger veil. */
|
|
73
73
|
export declare const clearVeil = 1.3;
|
|
74
|
+
/**
|
|
75
|
+
* The color a Surface of this color and depth is painted with at rest, before its material: a recess
|
|
76
|
+
* sinks below the color it is given; a clear Surface, with no depth or a transparent color, paints
|
|
77
|
+
* nothing. Whatever draws on a Surface and must match it, such as a terminal telling its programs
|
|
78
|
+
* what it stands on, takes this color.
|
|
79
|
+
*/
|
|
80
|
+
export declare function surfaceColor(color: Color, depth: SurfaceDepth, colors: Visual["colors"]): string;
|
|
81
|
+
/** The color a Surface of this color and depth is painted with at rest, in the active Appearance. */
|
|
82
|
+
export declare function useSurfaceColor(color?: Color, depth?: SurfaceDepth): string;
|
|
74
83
|
/** Resolves every visual value of one Surface. Pure over its inputs. */
|
|
75
84
|
export declare function surfacePaint(visual: Visual, color: Color, depth: SurfaceDepth, options: MaterialMode | MaterialOptions | undefined, shadowOptions: ShadowOverrides["shadow"], interaction: SurfaceInteraction | undefined): {
|
|
76
85
|
fill: string;
|
package/dist/surface/surface.js
CHANGED
|
@@ -67,6 +67,23 @@ const materialLevel = Object.freeze({ none: 0, basic: 1, extended: 2, full: 3 })
|
|
|
67
67
|
export const interactionShift = Object.freeze({ hovered: 0.05, pressed: 0.1 });
|
|
68
68
|
/** A clear Surface has no paint to move, so it shows the same shift as a slightly stronger veil. */
|
|
69
69
|
export const clearVeil = 1.3;
|
|
70
|
+
/**
|
|
71
|
+
* The color a Surface of this color and depth is painted with at rest, before its material: a recess
|
|
72
|
+
* sinks below the color it is given; a clear Surface, with no depth or a transparent color, paints
|
|
73
|
+
* nothing. Whatever draws on a Surface and must match it, such as a terminal telling its programs
|
|
74
|
+
* what it stands on, takes this color.
|
|
75
|
+
*/
|
|
76
|
+
export function surfaceColor(color, depth, colors) {
|
|
77
|
+
const base = resolveColor(color, colors);
|
|
78
|
+
if (depth === "none" || base === "transparent")
|
|
79
|
+
return "transparent";
|
|
80
|
+
return depth === "recessed" ? recessColor(base) : base;
|
|
81
|
+
}
|
|
82
|
+
/** The color a Surface of this color and depth is painted with at rest, in the active Appearance. */
|
|
83
|
+
export function useSurfaceColor(color = "background", depth = "raised") {
|
|
84
|
+
const { colors } = useVisual();
|
|
85
|
+
return surfaceColor(color, depth, colors);
|
|
86
|
+
}
|
|
70
87
|
/** Resolves every visual value of one Surface. Pure over its inputs. */
|
|
71
88
|
export function surfacePaint(visual, color, depth, options, shadowOptions, interaction) {
|
|
72
89
|
const { colors } = visual;
|
|
@@ -78,7 +95,7 @@ export function surfacePaint(visual, color, depth, options, shadowOptions, inter
|
|
|
78
95
|
const darkness = canvasDarkness(colors);
|
|
79
96
|
// A recess moves away from its surroundings toward whichever extreme has
|
|
80
97
|
// room, by one constant perceptual difference on any canvas.
|
|
81
|
-
const rest = depth === "recessed" ?
|
|
98
|
+
const rest = depth === "recessed" ? surfaceColor(color, depth, colors) : base;
|
|
82
99
|
// A clear Surface, with no depth or a transparent color, has no substance of
|
|
83
100
|
// its own: it paints nothing at rest, takes the content color of whatever it
|
|
84
101
|
// sits on, and only reveals interaction as a veil. With no depth, a color
|