glacia-native 0.5.1 → 0.5.2
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 +29 -4
- package/README.md +27 -0
- package/lib/module/Bars.js +10 -9
- package/lib/module/Button.js +11 -8
- package/lib/module/Card.js +2 -2
- package/lib/module/Dialog.js +16 -17
- package/lib/module/Display.js +8 -7
- package/lib/module/Feedback.js +24 -15
- package/lib/module/Form.js +29 -33
- package/lib/module/Forms2.js +38 -21
- package/lib/module/Glass.js +2 -2
- package/lib/module/Input.js +12 -10
- package/lib/module/Message.js +11 -15
- package/lib/module/Overlays.js +22 -6
- package/lib/module/Pickers.js +16 -16
- package/lib/module/SegmentedControl.js +19 -10
- package/lib/module/Slider.js +18 -9
- package/lib/module/Switch.js +21 -9
- package/lib/module/TabBar.js +18 -12
- package/lib/module/Table.js +4 -3
- package/lib/module/Tabs.js +3 -2
- package/lib/module/ai.js +18 -15
- package/lib/module/charts/BarChart.js +11 -3
- package/lib/module/internal/GlassView.js +2 -2
- package/lib/module/internal/blur.js +78 -0
- package/lib/module/internal/fallback.js +110 -20
- package/lib/module/internal/glow.js +36 -0
- package/lib/module/internal/lens.js +70 -0
- package/lib/module/internal/material.js +64 -0
- package/lib/module/internal/primitives.js +1 -0
- package/lib/module/internal/rim.js +35 -0
- package/lib/module/internal/tokens.js +34 -2
- package/lib/typescript/Message.d.ts +5 -9
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/internal/GlassView.d.ts +13 -0
- package/lib/typescript/internal/blur.d.ts +24 -0
- package/lib/typescript/internal/fallback.d.ts +27 -2
- package/lib/typescript/internal/glow.d.ts +11 -0
- package/lib/typescript/internal/lens.d.ts +47 -0
- package/lib/typescript/internal/material.d.ts +27 -0
- package/lib/typescript/internal/primitives.d.ts +2 -0
- package/lib/typescript/internal/rim.d.ts +16 -0
- package/lib/typescript/internal/tokens.d.ts +36 -0
- package/package.json +12 -3
- package/src/Bars.tsx +12 -2
- package/src/Button.tsx +16 -9
- package/src/Card.tsx +2 -2
- package/src/Dialog.tsx +37 -26
- package/src/Display.tsx +8 -5
- package/src/Feedback.tsx +36 -13
- package/src/Form.tsx +60 -40
- package/src/Forms2.tsx +65 -24
- package/src/Glass.tsx +4 -0
- package/src/Input.tsx +15 -11
- package/src/Message.tsx +15 -16
- package/src/Overlays.tsx +25 -6
- package/src/Pickers.tsx +11 -6
- package/src/SegmentedControl.tsx +33 -9
- package/src/Slider.tsx +19 -10
- package/src/Switch.tsx +24 -10
- package/src/TabBar.tsx +33 -12
- package/src/Table.tsx +4 -3
- package/src/Tabs.tsx +5 -0
- package/src/ai.tsx +28 -20
- package/src/charts/BarChart.tsx +41 -3
- package/src/index.ts +1 -0
- package/src/internal/GlassView.tsx +17 -0
- package/src/internal/blur.ts +90 -0
- package/src/internal/fallback.tsx +158 -20
- package/src/internal/glow.tsx +62 -0
- package/src/internal/lens.tsx +105 -0
- package/src/internal/material.ts +92 -0
- package/src/internal/primitives.ts +3 -0
- package/src/internal/rim.tsx +79 -0
- package/src/internal/tokens.ts +34 -1
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lensFill = void 0;
|
|
4
|
+
exports.lensShadow = lensShadow;
|
|
5
|
+
exports.LensRim = LensRim;
|
|
6
|
+
exports.SelectedLens = SelectedLens;
|
|
7
|
+
exports.rowLensStyle = rowLensStyle;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const tokens_1 = require("./tokens");
|
|
10
|
+
const primitives_1 = require("./primitives");
|
|
11
|
+
const rim_1 = require("./rim");
|
|
12
|
+
const fill = { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 };
|
|
13
|
+
/**
|
|
14
|
+
* How far a lens sits above its row.
|
|
15
|
+
*
|
|
16
|
+
* Shallower than a panel's shadow: a lens is inside a surface that already
|
|
17
|
+
* floats, so it needs contact, not altitude.
|
|
18
|
+
*/
|
|
19
|
+
function lensShadow(isDark) {
|
|
20
|
+
return {
|
|
21
|
+
shadowColor: tokens_1.material.shadowColor,
|
|
22
|
+
shadowOpacity: isDark ? 0 : 0.1,
|
|
23
|
+
shadowRadius: 8,
|
|
24
|
+
shadowOffset: { width: 0, height: 2 },
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The rim of a lens, on its own.
|
|
29
|
+
*
|
|
30
|
+
* For indicators that are already animated views and cannot become a
|
|
31
|
+
* `SelectedLens`: they keep their own transform, and this paints the light on
|
|
32
|
+
* top of whatever tint they already have.
|
|
33
|
+
*/
|
|
34
|
+
function LensRim({ radius, isDark }) {
|
|
35
|
+
const { View } = (0, primitives_1.primitives)();
|
|
36
|
+
const rim = (isDark ? tokens_1.material.rim.dark : tokens_1.material.rim.light) * 0.66;
|
|
37
|
+
return ((0, jsx_runtime_1.jsx)(View, { style: { ...fill, overflow: "hidden", borderRadius: radius }, pointerEvents: "none", children: (0, jsx_runtime_1.jsx)(rim_1.GlassRim, { radius: radius, rim: rim, highlight: tokens_1.material.highlight * 0.7 }) }));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* A selected state, drawn as the web's lens.
|
|
41
|
+
*
|
|
42
|
+
* Rendered as an absolutely positioned overlay so it never changes the layout
|
|
43
|
+
* of the row it marks: parents keep their padding and press handling, and the
|
|
44
|
+
* content paints above it by sibling order.
|
|
45
|
+
*/
|
|
46
|
+
function SelectedLens({ radius, isDark, style, children, testID }) {
|
|
47
|
+
const { View } = (0, primitives_1.primitives)();
|
|
48
|
+
const theme = isDark ? tokens_1.colors.dark : tokens_1.colors.light;
|
|
49
|
+
return ((0, jsx_runtime_1.jsxs)(View, { testID: testID, pointerEvents: "none", style: [
|
|
50
|
+
{
|
|
51
|
+
borderRadius: radius,
|
|
52
|
+
backgroundColor: theme.glassActive,
|
|
53
|
+
...lensShadow(isDark),
|
|
54
|
+
},
|
|
55
|
+
style,
|
|
56
|
+
], children: [(0, jsx_runtime_1.jsx)(LensRim, { radius: radius, isDark: isDark }), children] }));
|
|
57
|
+
}
|
|
58
|
+
/** The lens overlay for a row: inset from the panel's edges, full width inside. */
|
|
59
|
+
function rowLensStyle(radius, inset = 6) {
|
|
60
|
+
return {
|
|
61
|
+
position: "absolute",
|
|
62
|
+
top: 2,
|
|
63
|
+
bottom: 2,
|
|
64
|
+
left: inset,
|
|
65
|
+
right: inset,
|
|
66
|
+
borderRadius: radius,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** A pill lens filling its own box, for indicators pinned to a control. */
|
|
70
|
+
exports.lensFill = { ...fill, borderRadius: tokens_1.radii.pill };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// The fallback's material recipe — the web engine's surface profiles, in
|
|
3
|
+
// React Native terms.
|
|
4
|
+
//
|
|
5
|
+
// The web fits a different lens per component family (panel, control, field,
|
|
6
|
+
// overlay, hint, rail). The fallback had a single flat surface for all of
|
|
7
|
+
// them, which is why a dialog and a badge looked identical. This module turns
|
|
8
|
+
// each profile into the numbers the layered fallback needs: how strongly the
|
|
9
|
+
// backdrop is blurred, how bright the rim is, how much light sits inside the
|
|
10
|
+
// top edge, and whether the surface is lifted by a shadow.
|
|
11
|
+
//
|
|
12
|
+
// Nothing here renders. It is a table plus one resolver, so the fallback
|
|
13
|
+
// component stays a layout and the profiles stay reviewable against the web.
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.materialFor = materialFor;
|
|
16
|
+
exports.isFlatProfile = isFlatProfile;
|
|
17
|
+
const tokens_1 = require("./tokens");
|
|
18
|
+
/**
|
|
19
|
+
* The web profile values this mapping is derived from.
|
|
20
|
+
*
|
|
21
|
+
* Kept in the same order and with the same names as the engine's table so the
|
|
22
|
+
* two can be diffed by eye: bend drives the blur strength, depth the inner
|
|
23
|
+
* highlight, and dome the rim brightness (the dome is the part of the lens
|
|
24
|
+
* that catches the light).
|
|
25
|
+
*/
|
|
26
|
+
const webProfiles = {
|
|
27
|
+
panel: { bend: 0.45, depth: 0.25, dome: 0.5 },
|
|
28
|
+
control: { bend: 0.55, depth: 0.3, dome: 0.6 },
|
|
29
|
+
field: { bend: 0.35, depth: 0.2, dome: 0.34 },
|
|
30
|
+
overlay: { bend: 0.5, depth: 0.34, dome: 0.66 },
|
|
31
|
+
hint: { bend: 0.28, depth: 0.22, dome: 0.3 },
|
|
32
|
+
rail: { bend: 0.4, depth: 0.22, dome: 0.4 },
|
|
33
|
+
};
|
|
34
|
+
/** The reference profile: the panel is the base lens the others scale from. */
|
|
35
|
+
const BASE_BLUR = 24;
|
|
36
|
+
const BASE_DOME = webProfiles.panel.dome;
|
|
37
|
+
const BASE_DEPTH = webProfiles.panel.depth;
|
|
38
|
+
/**
|
|
39
|
+
* The material for one surface.
|
|
40
|
+
*
|
|
41
|
+
* The `clear` effect is the same stack with a thinner lens — less blur and a
|
|
42
|
+
* fainter rim — which is what the web means by clear. Reduce Transparency is
|
|
43
|
+
* handled before this call: it replaces the whole stack with a solid colour.
|
|
44
|
+
*/
|
|
45
|
+
function materialFor(profile = "panel", effect = "regular", isDark = false) {
|
|
46
|
+
const lens = webProfiles[profile];
|
|
47
|
+
const thin = effect === "clear" ? 0.55 : 1;
|
|
48
|
+
const rimBase = isDark ? tokens_1.material.rim.dark : tokens_1.material.rim.light;
|
|
49
|
+
return {
|
|
50
|
+
blur: Math.round(BASE_BLUR * (lens.bend / webProfiles.panel.bend) * thin),
|
|
51
|
+
rim: rimBase * (lens.dome / BASE_DOME) * thin,
|
|
52
|
+
highlight: tokens_1.material.highlight * (lens.depth / BASE_DEPTH) * thin,
|
|
53
|
+
// The web drops every surface by 1px; overlays carry their own, deeper
|
|
54
|
+
// shadow from the component's style, which the fallback prefers when set.
|
|
55
|
+
shadowOpacity: isDark ? 0 : tokens_1.material.shadowOpacity.light,
|
|
56
|
+
shadowRadius: 3,
|
|
57
|
+
shadowOffsetY: 1,
|
|
58
|
+
elevation: isDark ? 0 : 1,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/** Whether a surface is a shadowed one at all (the hint family sits flat). */
|
|
62
|
+
function isFlatProfile(profile) {
|
|
63
|
+
return profile === "hint";
|
|
64
|
+
}
|
|
@@ -215,6 +215,7 @@ function resolve() {
|
|
|
215
215
|
Polygon: svg?.Polygon ?? fallback("polygon"),
|
|
216
216
|
Defs: svg?.Defs ?? fallback("defs"),
|
|
217
217
|
LinearGradient: svg?.LinearGradient ?? fallback("linearGradient"),
|
|
218
|
+
RadialGradient: svg?.RadialGradient ?? fallback("radialGradient"),
|
|
218
219
|
Stop: svg?.Stop ?? fallback("stop"),
|
|
219
220
|
ClipPath: svg?.ClipPath ?? fallback("clipPath"),
|
|
220
221
|
// TextInput is not an SVG primitive, but resolving it here keeps every
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GlassRim = GlassRim;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
// The painted rim: light caught on the curved edge of a glass surface.
|
|
6
|
+
//
|
|
7
|
+
// This is the layer that makes a rounded corner *read* as rounded. The web
|
|
8
|
+
// engine paints a rim gradient into every glass element (brightest along the
|
|
9
|
+
// top edge, fading down the sides, nearly gone at the bottom), plus a soft
|
|
10
|
+
// highlight just inside the top. The fallback only had a uniform 8% edge line,
|
|
11
|
+
// which is why the owner described the corners as "not fully curved".
|
|
12
|
+
//
|
|
13
|
+
// Drawn in SVG because that is what the package already uses for its charts
|
|
14
|
+
// and share the same resolver: no new native dependency, and it works
|
|
15
|
+
// identically on iOS and Android.
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const primitives_1 = require("./primitives");
|
|
18
|
+
const tokens_1 = require("./tokens");
|
|
19
|
+
const fill = { position: "absolute", top: 0, left: 0, right: 0, bottom: 0 };
|
|
20
|
+
/**
|
|
21
|
+
* The rim light and top highlight of one surface.
|
|
22
|
+
*
|
|
23
|
+
* Both are stacked stops of a vertical gradient in the same colour: the eye
|
|
24
|
+
* reads the brightest edge as a lit curve and the falloff as the curve turning
|
|
25
|
+
* away from the light.
|
|
26
|
+
*/
|
|
27
|
+
function GlassRim({ radius, rim, highlight }) {
|
|
28
|
+
const { Svg, Defs, Rect, LinearGradient, Stop } = (0, primitives_1.primitives)();
|
|
29
|
+
const key = (0, react_1.useId)().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
30
|
+
const rimId = `rim-${key}`;
|
|
31
|
+
const highlightId = `top-${key}`;
|
|
32
|
+
// SVG clamps rx/ry to half the side, so a pill radius simply becomes a pill.
|
|
33
|
+
const rx = Math.max(0, radius - 0.5);
|
|
34
|
+
return ((0, jsx_runtime_1.jsxs)(Svg, { width: "100%", height: "100%", style: fill, pointerEvents: "none", children: [(0, jsx_runtime_1.jsxs)(Defs, { children: [(0, jsx_runtime_1.jsxs)(LinearGradient, { id: rimId, x1: "0", y1: "0", x2: "0", y2: "1", children: [(0, jsx_runtime_1.jsx)(Stop, { offset: "0", stopColor: tokens_1.material.rimColor, stopOpacity: rim }), (0, jsx_runtime_1.jsx)(Stop, { offset: "0.55", stopColor: tokens_1.material.rimColor, stopOpacity: rim * 0.35 }), (0, jsx_runtime_1.jsx)(Stop, { offset: "1", stopColor: tokens_1.material.rimColor, stopOpacity: rim * 0.08 })] }), (0, jsx_runtime_1.jsxs)(LinearGradient, { id: highlightId, x1: "0", y1: "0", x2: "0", y2: "1", children: [(0, jsx_runtime_1.jsx)(Stop, { offset: "0", stopColor: tokens_1.material.rimColor, stopOpacity: highlight }), (0, jsx_runtime_1.jsx)(Stop, { offset: "1", stopColor: tokens_1.material.rimColor, stopOpacity: 0 })] })] }), (0, jsx_runtime_1.jsx)(Rect, { x: 0.5, y: 0.5, width: "99%", height: "99%", rx: rx, ry: rx, fill: "none", stroke: `url(#${rimId})`, strokeWidth: 1 }), (0, jsx_runtime_1.jsx)(Rect, { x: 1, y: 1, width: "98%", height: "40%", rx: Math.max(0, rx - 1), ry: Math.max(0, rx - 1), fill: `url(#${highlightId})` })] }));
|
|
35
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.colors = exports.controlSizes = exports.palette = exports.typeScale = exports.springs = exports.radii = void 0;
|
|
3
|
+
exports.material = exports.colors = exports.controlSizes = exports.palette = exports.typeScale = exports.springs = exports.radii = void 0;
|
|
4
4
|
exports.toneColor = toneColor;
|
|
5
5
|
const glacia_tokens_1 = require("glacia-tokens");
|
|
6
6
|
exports.radii = {
|
|
@@ -8,6 +8,7 @@ exports.radii = {
|
|
|
8
8
|
md: glacia_tokens_1.radii.md.number,
|
|
9
9
|
lg: glacia_tokens_1.radii.lg.number,
|
|
10
10
|
xl: glacia_tokens_1.radii.xl.number,
|
|
11
|
+
stack: glacia_tokens_1.radii.stack.number,
|
|
11
12
|
pill: glacia_tokens_1.radii.pill.number,
|
|
12
13
|
};
|
|
13
14
|
exports.springs = {
|
|
@@ -69,8 +70,16 @@ exports.colors = {
|
|
|
69
70
|
muted: "#3C3C4399",
|
|
70
71
|
glass: "rgba(255, 255, 255, 0.6)",
|
|
71
72
|
glassActive: "rgba(236, 236, 240, 0.85)",
|
|
73
|
+
/**
|
|
74
|
+
* The near-solid surface the web uses where legibility beats translucency:
|
|
75
|
+
* menus and toggle groups. A glass surface underneath text that must be
|
|
76
|
+
* read at a glance is the one place the web deliberately goes opaque-ish.
|
|
77
|
+
*/
|
|
78
|
+
surface: "rgba(255, 255, 255, 0.86)",
|
|
72
79
|
edge: "rgba(0, 0, 0, 0.08)",
|
|
73
|
-
separator:
|
|
80
|
+
// The agreed separator value: the web CSS one (0.15 / 0.16 dark), so the
|
|
81
|
+
// three files that carried three different light values now agree.
|
|
82
|
+
separator: "rgba(60, 60, 67, 0.15)",
|
|
74
83
|
fill: "#0088FF",
|
|
75
84
|
destructive: "#FF3B30",
|
|
76
85
|
on: "#34C759",
|
|
@@ -103,6 +112,7 @@ exports.colors = {
|
|
|
103
112
|
muted: "#EBEBF599",
|
|
104
113
|
glass: "rgba(40, 40, 40, 0.62)",
|
|
105
114
|
glassActive: "rgba(70, 70, 70, 0.62)",
|
|
115
|
+
surface: "rgba(40, 40, 40, 0.86)",
|
|
106
116
|
edge: "rgba(255, 255, 255, 0.08)",
|
|
107
117
|
separator: "rgba(235, 235, 245, 0.16)",
|
|
108
118
|
fill: "#0091FF",
|
|
@@ -121,6 +131,28 @@ exports.colors = {
|
|
|
121
131
|
axis: "#EBEBF5",
|
|
122
132
|
},
|
|
123
133
|
};
|
|
134
|
+
/**
|
|
135
|
+
* The values the fallback's material layers are built from.
|
|
136
|
+
*
|
|
137
|
+
* These are the web engine's numbers, not new inventions: the rim shine is the
|
|
138
|
+
* web's `--gl-rim` brightness (0.30 light / 0.13 dark), the top highlight and
|
|
139
|
+
* press glow are the web overlay alphas, and the drop shadow is the web's
|
|
140
|
+
* `0 1px 3px` black 0.06. They live here, next to the colours, so no component
|
|
141
|
+
* carries a material literal of its own.
|
|
142
|
+
*/
|
|
143
|
+
exports.material = {
|
|
144
|
+
/** Maximum alpha of the painted rim light, per theme (web: shine). */
|
|
145
|
+
rim: { light: 0.3, dark: 0.13 },
|
|
146
|
+
/** Alpha of the soft highlight drawn inside the top edge. */
|
|
147
|
+
highlight: 0.1,
|
|
148
|
+
/** Alpha of the radial glow that fades in while a surface is held. */
|
|
149
|
+
glow: 0.035,
|
|
150
|
+
/** Shadow colour; the web drops surfaces by 1px with 6% black in light. */
|
|
151
|
+
shadowColor: "#000000",
|
|
152
|
+
shadowOpacity: { light: 0.06, dark: 0 },
|
|
153
|
+
/** The colour the rim light and the top highlight are painted in. */
|
|
154
|
+
rimColor: "#FFFFFF",
|
|
155
|
+
};
|
|
124
156
|
/** Resolves a tone to its theme colour. */
|
|
125
157
|
function toneColor(theme, tone) {
|
|
126
158
|
switch (tone) {
|
|
@@ -11,15 +11,11 @@ export interface MessageBubbleProps {
|
|
|
11
11
|
/**
|
|
12
12
|
* One message's bubble.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* Incoming messages take the theme's wash; outgoing take `glassActive`, the
|
|
21
|
-
* same tint the library uses for any selected surface, so a transcript reads
|
|
22
|
-
* consistently with the rest of Glacia.
|
|
14
|
+
* The bubble is a glass surface like the rest of the library (panel profile),
|
|
15
|
+
* so it carries the same blurred backdrop, lit rim and shadow as a card. The
|
|
16
|
+
* outgoing direction is tinted with `glassActive` — the theme's selected
|
|
17
|
+
* tint — and the incoming one uses the plain glass token, which is what keeps
|
|
18
|
+
* the two directions distinguishable without a second material.
|
|
23
19
|
*/
|
|
24
20
|
export declare const MessageBubble: import("react").ForwardRefExoticComponent<MessageBubbleProps & import("react").RefAttributes<any>>;
|
|
25
21
|
export interface MessageAttachmentProps {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Glass, type GlassProps } from "./Glass";
|
|
2
|
+
export type { SurfaceProfile } from "./internal/material";
|
|
2
3
|
export { Button, type ButtonProps } from "./Button";
|
|
3
4
|
export { Switch, type SwitchProps } from "./Switch";
|
|
4
5
|
export { Slider, type SliderProps } from "./Slider";
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
import type { SurfaceProfile } from "./material";
|
|
3
4
|
export interface NativeGlassProps {
|
|
4
5
|
effect?: "clear" | "regular" | "none";
|
|
5
6
|
tintColor?: string;
|
|
6
7
|
interactive?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Which web surface profile this is (panel, control, field, overlay, hint,
|
|
10
|
+
* rail). The fallback uses it to pick blur, rim brightness and highlight —
|
|
11
|
+
* read by the fallback branch only; Apple's material replaces the stack on
|
|
12
|
+
* iOS 26, so the prop is not forwarded there.
|
|
13
|
+
*/
|
|
14
|
+
surface?: SurfaceProfile;
|
|
15
|
+
/**
|
|
16
|
+
* True while the surface is held, so the fallback can fade its specular glow
|
|
17
|
+
* in. Not forwarded to Apple's view, which draws its own press effect.
|
|
18
|
+
*/
|
|
19
|
+
pressed?: boolean;
|
|
7
20
|
/** Passed to whichever surface renders, so tests can find the glass itself. */
|
|
8
21
|
testID?: string;
|
|
9
22
|
style?: StyleProp<ViewStyle>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export type BlurKind = "expo" | "community";
|
|
2
|
+
interface ResolvedBlur {
|
|
3
|
+
kind: BlurKind;
|
|
4
|
+
View: any;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The installed blur backend, or null when neither is available.
|
|
8
|
+
*
|
|
9
|
+
* Memoised: the answer is a property of the installed modules, not of the
|
|
10
|
+
* render, so resolving once keeps every surface on the same backend.
|
|
11
|
+
*/
|
|
12
|
+
export declare function resolveBlurView(): ResolvedBlur | null;
|
|
13
|
+
/** Clears the memoised backend. Only tests call this. */
|
|
14
|
+
export declare function resetBlurResolver(): void;
|
|
15
|
+
/**
|
|
16
|
+
* The props one backend needs to blur a surface.
|
|
17
|
+
*
|
|
18
|
+
* The two libraries name the same idea differently — expo-blur takes a 0–100
|
|
19
|
+
* intensity and a tint, community-blur a 0–100 amount and a blur type — so the
|
|
20
|
+
* mapping lives here rather than in the fallback's render. Android needs an
|
|
21
|
+
* explicit method on expo-blur; Dimezis is its own real-time backdrop blur.
|
|
22
|
+
*/
|
|
23
|
+
export declare function blurProps(kind: BlurKind, intensity: number, isDark: boolean): Record<string, any>;
|
|
24
|
+
export {};
|
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
import { type SurfaceProfile } from "./material";
|
|
3
4
|
export interface FallbackGlassProps {
|
|
4
5
|
effect?: "clear" | "regular" | "none";
|
|
6
|
+
/**
|
|
7
|
+
* Which of the web's six lenses this surface is. The profile decides the
|
|
8
|
+
* blur strength, rim brightness and top highlight, so a dialog and a badge
|
|
9
|
+
* no longer share one flat recipe.
|
|
10
|
+
*/
|
|
11
|
+
surface?: SurfaceProfile;
|
|
5
12
|
tintColor?: string;
|
|
13
|
+
/** True while the surface is held; fades the specular glow in. */
|
|
14
|
+
pressed?: boolean;
|
|
6
15
|
testID?: string;
|
|
7
16
|
style?: StyleProp<ViewStyle>;
|
|
8
17
|
children?: ReactNode;
|
|
@@ -17,7 +26,23 @@ export interface FallbackGlassProps {
|
|
|
17
26
|
* Glacia's own glass surface for every platform where Apple's material is not
|
|
18
27
|
* available: Android, iOS before 26, and Expo Go.
|
|
19
28
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
29
|
+
* The material is the web one, rebuilt in layers, because a single flat View
|
|
30
|
+
* could never read as glass:
|
|
31
|
+
*
|
|
32
|
+
* 1. backdrop blur (`expo-blur` / `@react-native-community/blur` when either
|
|
33
|
+
* is installed — a real `UIVisualEffectView` on iOS 17),
|
|
34
|
+
* 2. the tint token on top of the blurred backdrop,
|
|
35
|
+
* 3. a painted rim light, brightest on the top edge, so corners read as curved,
|
|
36
|
+
* 4. a soft highlight just inside the top edge,
|
|
37
|
+
* 5. the 0.5px edge line, and
|
|
38
|
+
* 6. a drop shadow on the surface itself (outside the clipped layer).
|
|
39
|
+
*
|
|
40
|
+
* All of that lives in an absolutely-positioned, clipped layer behind the
|
|
41
|
+
* children. The caller's style stays on the outer View, so heights, padding and
|
|
42
|
+
* flex behaviour are byte-identical to the old flat implementation and
|
|
43
|
+
* switching branches never shifts the layout.
|
|
44
|
+
*
|
|
45
|
+
* Reduce Transparency still replaces the whole thing with a solid colour: the
|
|
46
|
+
* preference exists precisely to remove see-through surfaces.
|
|
22
47
|
*/
|
|
23
48
|
export declare const FallbackGlassView: import("react").ForwardRefExoticComponent<FallbackGlassProps & import("react").RefAttributes<any>>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface SurfaceGlowProps {
|
|
2
|
+
/** True while the surface is held. */
|
|
3
|
+
active: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* A radial highlight that fades in while `active`.
|
|
7
|
+
*
|
|
8
|
+
* Motion uses the package's spring tokens and respects Reduce Motion: with the
|
|
9
|
+
* preference on, the glow appears at its end state rather than fading.
|
|
10
|
+
*/
|
|
11
|
+
export declare function SurfaceGlow({ active }: SurfaceGlowProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
3
|
+
/**
|
|
4
|
+
* How far a lens sits above its row.
|
|
5
|
+
*
|
|
6
|
+
* Shallower than a panel's shadow: a lens is inside a surface that already
|
|
7
|
+
* floats, so it needs contact, not altitude.
|
|
8
|
+
*/
|
|
9
|
+
export declare function lensShadow(isDark?: boolean): ViewStyle;
|
|
10
|
+
/**
|
|
11
|
+
* The rim of a lens, on its own.
|
|
12
|
+
*
|
|
13
|
+
* For indicators that are already animated views and cannot become a
|
|
14
|
+
* `SelectedLens`: they keep their own transform, and this paints the light on
|
|
15
|
+
* top of whatever tint they already have.
|
|
16
|
+
*/
|
|
17
|
+
export declare function LensRim({ radius, isDark }: {
|
|
18
|
+
radius: number;
|
|
19
|
+
isDark?: boolean;
|
|
20
|
+
}): import("react").JSX.Element;
|
|
21
|
+
export interface SelectedLensProps {
|
|
22
|
+
/** The lens shape. A circle is simply a radius of half the side. */
|
|
23
|
+
radius: number;
|
|
24
|
+
isDark?: boolean;
|
|
25
|
+
style?: StyleProp<ViewStyle>;
|
|
26
|
+
children?: ReactNode;
|
|
27
|
+
testID?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A selected state, drawn as the web's lens.
|
|
31
|
+
*
|
|
32
|
+
* Rendered as an absolutely positioned overlay so it never changes the layout
|
|
33
|
+
* of the row it marks: parents keep their padding and press handling, and the
|
|
34
|
+
* content paints above it by sibling order.
|
|
35
|
+
*/
|
|
36
|
+
export declare function SelectedLens({ radius, isDark, style, children, testID }: SelectedLensProps): import("react").JSX.Element;
|
|
37
|
+
/** The lens overlay for a row: inset from the panel's edges, full width inside. */
|
|
38
|
+
export declare function rowLensStyle(radius: number, inset?: number): ViewStyle;
|
|
39
|
+
/** A pill lens filling its own box, for indicators pinned to a control. */
|
|
40
|
+
export declare const lensFill: {
|
|
41
|
+
readonly borderRadius: 9999;
|
|
42
|
+
readonly position: "absolute";
|
|
43
|
+
readonly top: 0;
|
|
44
|
+
readonly left: 0;
|
|
45
|
+
readonly right: 0;
|
|
46
|
+
readonly bottom: 0;
|
|
47
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** The six surfaces the web engine distinguishes. */
|
|
2
|
+
export type SurfaceProfile = "panel" | "control" | "field" | "overlay" | "hint" | "rail";
|
|
3
|
+
/** A resolved material for one surface, in the units React Native accepts. */
|
|
4
|
+
export interface ResolvedMaterial {
|
|
5
|
+
/** Backdrop blur intensity on expo-blur's 0–100 scale. */
|
|
6
|
+
blur: number;
|
|
7
|
+
/** Alpha of the rim's brightest (top) stop. */
|
|
8
|
+
rim: number;
|
|
9
|
+
/** Alpha of the highlight inside the top edge. */
|
|
10
|
+
highlight: number;
|
|
11
|
+
/** How far the surface is lifted, from the theme's shadow tokens. */
|
|
12
|
+
shadowOpacity: number;
|
|
13
|
+
shadowRadius: number;
|
|
14
|
+
shadowOffsetY: number;
|
|
15
|
+
/** Android's equivalent of the iOS shadow. */
|
|
16
|
+
elevation: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The material for one surface.
|
|
20
|
+
*
|
|
21
|
+
* The `clear` effect is the same stack with a thinner lens — less blur and a
|
|
22
|
+
* fainter rim — which is what the web means by clear. Reduce Transparency is
|
|
23
|
+
* handled before this call: it replaces the whole stack with a solid colour.
|
|
24
|
+
*/
|
|
25
|
+
export declare function materialFor(profile?: SurfaceProfile, effect?: "clear" | "regular" | "none", isDark?: boolean): ResolvedMaterial;
|
|
26
|
+
/** Whether a surface is a shadowed one at all (the hint family sits flat). */
|
|
27
|
+
export declare function isFlatProfile(profile: SurfaceProfile): boolean;
|
|
@@ -13,6 +13,8 @@ export interface RNPrimitives {
|
|
|
13
13
|
/** Gradient and clipping nodes, for the colour picker's hue track. */
|
|
14
14
|
Defs: any;
|
|
15
15
|
LinearGradient: any;
|
|
16
|
+
/** The radial gradient the press glow is painted with. */
|
|
17
|
+
RadialGradient: any;
|
|
16
18
|
Stop: any;
|
|
17
19
|
ClipPath: any;
|
|
18
20
|
SvgText: any;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface GlassRimProps {
|
|
2
|
+
/** The surface's corner radius, so the rim follows the shape. */
|
|
3
|
+
radius: number;
|
|
4
|
+
/** Alpha of the brightest (top) part of the rim. */
|
|
5
|
+
rim: number;
|
|
6
|
+
/** Alpha of the highlight inside the top edge. */
|
|
7
|
+
highlight: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The rim light and top highlight of one surface.
|
|
11
|
+
*
|
|
12
|
+
* Both are stacked stops of a vertical gradient in the same colour: the eye
|
|
13
|
+
* reads the brightest edge as a lit curve and the falloff as the curve turning
|
|
14
|
+
* away from the light.
|
|
15
|
+
*/
|
|
16
|
+
export declare function GlassRim({ radius, rim, highlight }: GlassRimProps): import("react").JSX.Element;
|
|
@@ -3,6 +3,7 @@ export declare const radii: {
|
|
|
3
3
|
md: 14;
|
|
4
4
|
lg: 20;
|
|
5
5
|
xl: 28;
|
|
6
|
+
stack: 26;
|
|
6
7
|
pill: 9999;
|
|
7
8
|
};
|
|
8
9
|
export declare const springs: {
|
|
@@ -103,6 +104,12 @@ export declare const colors: {
|
|
|
103
104
|
muted: string;
|
|
104
105
|
glass: string;
|
|
105
106
|
glassActive: string;
|
|
107
|
+
/**
|
|
108
|
+
* The near-solid surface the web uses where legibility beats translucency:
|
|
109
|
+
* menus and toggle groups. A glass surface underneath text that must be
|
|
110
|
+
* read at a glance is the one place the web deliberately goes opaque-ish.
|
|
111
|
+
*/
|
|
112
|
+
surface: string;
|
|
106
113
|
edge: string;
|
|
107
114
|
separator: string;
|
|
108
115
|
fill: string;
|
|
@@ -134,6 +141,7 @@ export declare const colors: {
|
|
|
134
141
|
muted: string;
|
|
135
142
|
glass: string;
|
|
136
143
|
glassActive: string;
|
|
144
|
+
surface: string;
|
|
137
145
|
edge: string;
|
|
138
146
|
separator: string;
|
|
139
147
|
fill: string;
|
|
@@ -154,6 +162,34 @@ export declare const colors: {
|
|
|
154
162
|
};
|
|
155
163
|
/** Keeps the shared token file honest if a colour is added there first. */
|
|
156
164
|
export type ThemeColors = typeof colors.light;
|
|
165
|
+
/**
|
|
166
|
+
* The values the fallback's material layers are built from.
|
|
167
|
+
*
|
|
168
|
+
* These are the web engine's numbers, not new inventions: the rim shine is the
|
|
169
|
+
* web's `--gl-rim` brightness (0.30 light / 0.13 dark), the top highlight and
|
|
170
|
+
* press glow are the web overlay alphas, and the drop shadow is the web's
|
|
171
|
+
* `0 1px 3px` black 0.06. They live here, next to the colours, so no component
|
|
172
|
+
* carries a material literal of its own.
|
|
173
|
+
*/
|
|
174
|
+
export declare const material: {
|
|
175
|
+
/** Maximum alpha of the painted rim light, per theme (web: shine). */
|
|
176
|
+
rim: {
|
|
177
|
+
light: number;
|
|
178
|
+
dark: number;
|
|
179
|
+
};
|
|
180
|
+
/** Alpha of the soft highlight drawn inside the top edge. */
|
|
181
|
+
highlight: number;
|
|
182
|
+
/** Alpha of the radial glow that fades in while a surface is held. */
|
|
183
|
+
glow: number;
|
|
184
|
+
/** Shadow colour; the web drops surfaces by 1px with 6% black in light. */
|
|
185
|
+
shadowColor: string;
|
|
186
|
+
shadowOpacity: {
|
|
187
|
+
light: number;
|
|
188
|
+
dark: number;
|
|
189
|
+
};
|
|
190
|
+
/** The colour the rim light and the top highlight are painted in. */
|
|
191
|
+
rimColor: string;
|
|
192
|
+
};
|
|
157
193
|
/** The semantic tone of a feedback component (Banner, Toast). */
|
|
158
194
|
export type Tone = "info" | "success" | "warning" | "error";
|
|
159
195
|
/** Resolves a tone to its theme colour. */
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "glacia-native",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Liquid Glass UI components for React Native — real iOS 26 glass, with a clean fallback on Android and older iOS.",
|
|
5
|
+
"author": "Binyam Feyissa (https://github.com/binyamfeyissa)",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"repository": {
|
|
7
8
|
"type": "git",
|
|
@@ -24,10 +25,12 @@
|
|
|
24
25
|
"@callstack/liquid-glass": ">=0.7.0",
|
|
25
26
|
"react": ">=18",
|
|
26
27
|
"react-native": ">=0.80",
|
|
27
|
-
"react-native-svg": ">=13"
|
|
28
|
+
"react-native-svg": ">=13",
|
|
29
|
+
"expo-blur": ">=12",
|
|
30
|
+
"@react-native-community/blur": ">=4"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"glacia-tokens": "0.5.
|
|
33
|
+
"glacia-tokens": "0.5.2"
|
|
31
34
|
},
|
|
32
35
|
"devDependencies": {
|
|
33
36
|
"@testing-library/react": "^16.3.3",
|
|
@@ -41,6 +44,12 @@
|
|
|
41
44
|
"peerDependenciesMeta": {
|
|
42
45
|
"react-native-svg": {
|
|
43
46
|
"optional": true
|
|
47
|
+
},
|
|
48
|
+
"expo-blur": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
51
|
+
"@react-native-community/blur": {
|
|
52
|
+
"optional": true
|
|
44
53
|
}
|
|
45
54
|
},
|
|
46
55
|
"scripts": {
|