@delacour/react-native-ui 0.5.0-alpha.20261023075140 → 0.5.0-alpha.20261023075443
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/package.json +3 -3
- package/src/components/attachment/AGENTS.md +9 -2
- package/src/components/attachment/attachment-progress.tsx +11 -0
- package/src/components/attachment/attachment.variants.test.ts +17 -0
- package/src/components/attachment/attachment.variants.ts +7 -1
- package/src/components/fab/AGENTS.md +10 -0
- package/src/components/fab/fab-action.tsx +40 -26
- package/src/components/fab/fab-group.tsx +9 -3
- package/src/components/fab/fab.context.tsx +5 -0
- package/src/components/fab/fab.variants.test.ts +30 -0
- package/src/components/fab/fab.variants.ts +32 -0
- package/src/components/message/AGENTS.md +10 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delacour/react-native-ui",
|
|
3
|
-
"version": "0.5.0-alpha.
|
|
3
|
+
"version": "0.5.0-alpha.20261023075443",
|
|
4
4
|
"description": "React Native UI components — Uniwind, Reanimated, Gesture Handler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -182,8 +182,8 @@
|
|
|
182
182
|
"expo-blur": ">=15",
|
|
183
183
|
"@maplibre/maplibre-react-native": "^11.5.0",
|
|
184
184
|
"@central-icons-react-native/round-outlined-radius-1-stroke-1.5": "^1.1",
|
|
185
|
-
"@delacour/react-native-bottom-sheet": "0.3.0-alpha.
|
|
186
|
-
"@delacour/react-native-charts": "0.2.0-alpha.
|
|
185
|
+
"@delacour/react-native-bottom-sheet": "0.3.0-alpha.20261023075443",
|
|
186
|
+
"@delacour/react-native-charts": "0.2.0-alpha.20261023075443",
|
|
187
187
|
"@legendapp/list": ">=3.3",
|
|
188
188
|
"react-native-skia": ">=3.7.3",
|
|
189
189
|
"expo-linear-gradient": ">=15",
|
|
@@ -58,8 +58,10 @@ Compound root plus `Attachment.Preview`, `.Content`, `.Name`, `.Meta`, `.Progres
|
|
|
58
58
|
press target; the inner detector still claims the tap, as `Chip.CloseButton` relies on.
|
|
59
59
|
- **Only the tile root clips.** A chip or card with `overflow-hidden` would clip its remove
|
|
60
60
|
control's 44pt slop on Android, where a touch outside an `overflow: hidden` parent never lands.
|
|
61
|
-
The picture rounds itself through the `image` slot instead
|
|
62
|
-
|
|
61
|
+
The picture rounds itself through the `image` slot instead, and a chip's upload bar sits in a
|
|
62
|
+
`progressClip` layer — `absolute inset-0`, the chip's own `rounded-xl`, holding only the bar —
|
|
63
|
+
so its ends follow the corner rather than hanging below the curve wherever a theme's `--radius`
|
|
64
|
+
makes the corner wider than the bar's inset. A test pins `overflow-hidden` to the tile root.
|
|
63
65
|
- **Sizes are fixed points.** `ATTACHMENT_SIZE_POINTS` holds the preview square for chip and card,
|
|
64
66
|
and the tile's own edge, and a test pins each to its `size-*` class. A tray of mixed
|
|
65
67
|
attachments lines up whatever the reader's text size; the name and meta still scale. A chip is
|
|
@@ -85,6 +87,11 @@ Compound root plus `Attachment.Preview`, `.Content`, `.Name`, `.Meta`, `.Progres
|
|
|
85
87
|
it actually has, so the extension stays visible: `report-q3-fin…ial.pdf`. `truncateMiddle` is
|
|
86
88
|
the character-budget version for places with no layout — a notification, a log line — and
|
|
87
89
|
backs `Attachment.Name`'s `maxLength`.
|
|
90
|
+
- **A chip's press target grows, so the cross sits at the far edge.** Stretched by a column — a
|
|
91
|
+
composer tray stacked vertically — a chip is wider than its content, and a press target that only
|
|
92
|
+
shrank left the cross beside the name, mid-chip. `grow shrink` rather than `flex-1`: the basis
|
|
93
|
+
stays the content's width, so a content-sized chip in a horizontal tray is unchanged, where
|
|
94
|
+
`flex-1`'s zero basis would collapse it.
|
|
88
95
|
- **A chip is capped at `max-w-64`.** Inside a horizontal `ScrollView` a child has unbounded width,
|
|
89
96
|
so without a cap a long name would stretch the chip rather than ellipsize.
|
|
90
97
|
- **No ring.** `Progress` draws bars only, so a tile shows a short bar centred on its dimming veil
|
|
@@ -48,6 +48,17 @@ export function AttachmentProgress({ className, color = "primary" }: AttachmentP
|
|
|
48
48
|
</Progress>
|
|
49
49
|
);
|
|
50
50
|
|
|
51
|
+
// A chip's line runs along its bottom edge, so it is clipped to the chip's
|
|
52
|
+
// corner — the root itself cannot clip without clipping the remove control's
|
|
53
|
+
// slop on Android.
|
|
54
|
+
if (layout === "chip") {
|
|
55
|
+
return (
|
|
56
|
+
<View className={slots.progressClip()} pointerEvents="none">
|
|
57
|
+
{bar}
|
|
58
|
+
</View>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
51
62
|
// A tile has no edge to run a line along, so the bar sits on a veil that
|
|
52
63
|
// dims the picture until the upload lands.
|
|
53
64
|
if (layout !== "tile") return bar;
|
|
@@ -30,6 +30,7 @@ const SLOTS = [
|
|
|
30
30
|
"name",
|
|
31
31
|
"meta",
|
|
32
32
|
"progress",
|
|
33
|
+
"progressClip",
|
|
33
34
|
"progressTrack",
|
|
34
35
|
"actions",
|
|
35
36
|
"action",
|
|
@@ -106,6 +107,13 @@ describe("sizes", () => {
|
|
|
106
107
|
}
|
|
107
108
|
});
|
|
108
109
|
|
|
110
|
+
test("a stretched chip grows its press target, so the cross sits at the far edge", () => {
|
|
111
|
+
const press = attachmentVariants({ layout: "chip" }).press();
|
|
112
|
+
expect(press).toMatch(/(?:^|\s)grow(?:\s|$)/);
|
|
113
|
+
expect(press).toMatch(/(?:^|\s)shrink(?:\s|$)/);
|
|
114
|
+
expect(press).not.toMatch(/\bflex-1\b/);
|
|
115
|
+
});
|
|
116
|
+
|
|
109
117
|
test("every scale ascends", () => {
|
|
110
118
|
for (const layout of ATTACHMENT_LAYOUTS) {
|
|
111
119
|
const points = ATTACHMENT_SIZES.map((size) => ATTACHMENT_SIZE_POINTS[layout][size]);
|
|
@@ -150,6 +158,15 @@ describe("layouts", () => {
|
|
|
150
158
|
}
|
|
151
159
|
});
|
|
152
160
|
|
|
161
|
+
test("a chip's bar is clipped to the chip's own corner, without clipping the chip", () => {
|
|
162
|
+
const slots = attachmentVariants({ layout: "chip" });
|
|
163
|
+
const corner = slots.root().match(/\brounded-\S+/)?.[0] ?? "";
|
|
164
|
+
expect(corner).not.toBe("");
|
|
165
|
+
expect(slots.progressClip()).toMatch(/\babsolute inset-0\b/);
|
|
166
|
+
expect(slots.progressClip()).toContain("overflow-hidden");
|
|
167
|
+
expect(slots.progressClip().split(" ")).toContain(corner);
|
|
168
|
+
});
|
|
169
|
+
|
|
153
170
|
test("chip and card sit on a bordered card; the tile on muted", () => {
|
|
154
171
|
for (const layout of ["chip", "card"] as const) {
|
|
155
172
|
const root = attachmentVariants({ layout }).root();
|
|
@@ -106,6 +106,10 @@ export const ATTACHMENT_GROUP_FADE_MS = 180;
|
|
|
106
106
|
* - **`preview`** is the square; **`previewFallback`** the kind's tinted
|
|
107
107
|
* ground painted under the picture, so a dead URL leaves a glyph.
|
|
108
108
|
* - **`dim`** is the veil a tile draws while it uploads, holding the bar.
|
|
109
|
+
* - **`progressClip`** is the chip's bar clipped to the chip's own corner, so
|
|
110
|
+
* the bar cannot hang past a curve a theme's `--radius` made wider than its
|
|
111
|
+
* inset. A layer of its own, holding nothing but the bar, because the chip
|
|
112
|
+
* root must not clip (below).
|
|
109
113
|
* - **`badge`** is the play disc centred on a video's poster.
|
|
110
114
|
* - **`group`** is `Attachment.Group`'s content row.
|
|
111
115
|
*
|
|
@@ -126,6 +130,7 @@ export const attachmentVariants = tv({
|
|
|
126
130
|
name: "font-sans font-medium text-foreground",
|
|
127
131
|
meta: "font-sans text-muted-foreground",
|
|
128
132
|
progress: "",
|
|
133
|
+
progressClip: "absolute inset-0 overflow-hidden",
|
|
129
134
|
progressTrack: "h-0.5",
|
|
130
135
|
actions: "flex-row items-center gap-1",
|
|
131
136
|
action: "size-6 items-center justify-center rounded-full",
|
|
@@ -137,12 +142,13 @@ export const attachmentVariants = tv({
|
|
|
137
142
|
layout: {
|
|
138
143
|
chip: {
|
|
139
144
|
root: "max-w-64 flex-row items-center gap-1 rounded-xl border border-border bg-card p-1 pr-2",
|
|
140
|
-
press: "shrink flex-row items-center gap-2",
|
|
145
|
+
press: "shrink grow flex-row items-center gap-2",
|
|
141
146
|
preview: "rounded-lg",
|
|
142
147
|
previewFallback: "rounded-lg",
|
|
143
148
|
image: "rounded-lg",
|
|
144
149
|
content: "shrink",
|
|
145
150
|
progress: "absolute right-3 bottom-0 left-3",
|
|
151
|
+
progressClip: "rounded-xl",
|
|
146
152
|
},
|
|
147
153
|
tile: {
|
|
148
154
|
root: "items-center justify-center overflow-hidden rounded-xl bg-muted",
|
|
@@ -61,6 +61,16 @@ Compound root plus `Fab.Label`, `Fab.Group` and `Fab.Action`.
|
|
|
61
61
|
trigger — so there are no per-action timers, and closing halfway through
|
|
62
62
|
opening simply runs the same cascade backwards. The window is floored so a
|
|
63
63
|
stagger too wide for the count degrades to a step, never a NaN.
|
|
64
|
+
- **Each action grows out of the trigger and collapses back into it.**
|
|
65
|
+
`resolveActionMotion` takes the measured distance from the action button's
|
|
66
|
+
centre down to the trigger's (`triggerCenterY` from the trigger's layout, the
|
|
67
|
+
row's `y` and the anchor's centre from theirs) and moves the row along it
|
|
68
|
+
with `translateY` only, while the button alone scales from
|
|
69
|
+
`FAB_ACTION_START_SCALE` about its own centre. Scaling the whole row used to
|
|
70
|
+
pivot on the row's centre, which sits off to the chip's side, so the button
|
|
71
|
+
swung in from the left instead of out of the trigger. The trigger renders
|
|
72
|
+
after the actions, so a closed action sits behind it. Until the layout is
|
|
73
|
+
measured the travel is 0, and the action is still clear at that point.
|
|
64
74
|
- **Actions are unmounted while closed, not hidden.** They mount in the render
|
|
65
75
|
that opens the dial and unmount from the close animation's `finished`
|
|
66
76
|
callback, so a screen reader cannot walk into invisible buttons. A reopen
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import Animated, { useAnimatedStyle } from "react-native-reanimated";
|
|
2
|
+
import type { LayoutChangeEvent } from "react-native";
|
|
3
|
+
import Animated, { useAnimatedStyle, useSharedValue } from "react-native-reanimated";
|
|
4
4
|
import { Icon, type IconComponent } from "../icon";
|
|
5
5
|
import { Pressable } from "../pressable";
|
|
6
6
|
import { Text } from "../text";
|
|
7
7
|
import { useFabActionItem, useFabGroupPart } from "./fab.context";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
import {
|
|
9
|
+
FAB_DIAL_STAGGER,
|
|
10
|
+
FAB_FOREGROUND_TOKEN,
|
|
11
|
+
fabVariants,
|
|
12
|
+
resolveActionMotion,
|
|
13
|
+
resolveDialProgress,
|
|
14
|
+
} from "./fab.variants";
|
|
15
15
|
|
|
16
16
|
export type FabActionProps = {
|
|
17
17
|
icon: IconComponent;
|
|
@@ -40,7 +40,10 @@ export type FabActionProps = {
|
|
|
40
40
|
* screen reader meets each action once.
|
|
41
41
|
*
|
|
42
42
|
* Its stagger window comes from its place in the dial, read on the UI thread
|
|
43
|
-
* from the dial's one spring.
|
|
43
|
+
* from the dial's one spring. It grows out of the trigger and collapses back
|
|
44
|
+
* into it: the row travels down the centre line to the trigger's centre while
|
|
45
|
+
* the button alone scales about its own centre, so nothing swings in from the
|
|
46
|
+
* chip's side. Under reduced motion it fades in place.
|
|
44
47
|
*/
|
|
45
48
|
export function FabAction({
|
|
46
49
|
icon,
|
|
@@ -52,26 +55,37 @@ export function FabAction({
|
|
|
52
55
|
labelClassName,
|
|
53
56
|
testID,
|
|
54
57
|
}: FabActionProps): ReactElement {
|
|
55
|
-
const { progress, count, labelSide, size, haptic, isReducedMotion, close } =
|
|
58
|
+
const { progress, triggerCenterY, count, labelSide, size, haptic, isReducedMotion, close } =
|
|
59
|
+
useFabGroupPart("Fab.Action");
|
|
56
60
|
const { index } = useFabActionItem("Fab.Action");
|
|
57
61
|
const slots = fabVariants({ size, labelSide, isDisabled });
|
|
62
|
+
const rowY = useSharedValue(0);
|
|
63
|
+
const anchorCenterY = useSharedValue(0);
|
|
64
|
+
|
|
65
|
+
const handleRowLayout = (event: LayoutChangeEvent) => {
|
|
66
|
+
rowY.value = event.nativeEvent.layout.y;
|
|
67
|
+
};
|
|
68
|
+
const handleAnchorLayout = (event: LayoutChangeEvent) => {
|
|
69
|
+
const { y, height } = event.nativeEvent.layout;
|
|
70
|
+
anchorCenterY.value = y + height / 2;
|
|
71
|
+
};
|
|
58
72
|
|
|
59
|
-
const
|
|
73
|
+
const rowStyle = useAnimatedStyle(() => {
|
|
60
74
|
if (isReducedMotion) {
|
|
61
75
|
const value = progress.value;
|
|
62
|
-
return {
|
|
63
|
-
opacity: value < 0 ? 0 : value > 1 ? 1 : value,
|
|
64
|
-
transform: [{ translateY: 0 }, { scale: 1 }],
|
|
65
|
-
};
|
|
76
|
+
return { opacity: value < 0 ? 0 : value > 1 ? 1 : value, transform: [{ translateY: 0 }] };
|
|
66
77
|
}
|
|
67
78
|
const local = resolveDialProgress({ open: progress.value, index, count, stagger: FAB_DIAL_STAGGER });
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
const measured = triggerCenterY.value > 0 && anchorCenterY.value > 0;
|
|
80
|
+
const travel = measured ? triggerCenterY.value - (rowY.value + anchorCenterY.value) : 0;
|
|
81
|
+
const motion = resolveActionMotion({ local, travel });
|
|
82
|
+
return { opacity: motion.opacity, transform: [{ translateY: motion.translateY }] };
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const anchorStyle = useAnimatedStyle(() => {
|
|
86
|
+
if (isReducedMotion) return { transform: [{ scale: 1 }] };
|
|
87
|
+
const local = resolveDialProgress({ open: progress.value, index, count, stagger: FAB_DIAL_STAGGER });
|
|
88
|
+
return { transform: [{ scale: resolveActionMotion({ local, travel: 0 }).scale }] };
|
|
75
89
|
});
|
|
76
90
|
|
|
77
91
|
const handlePress = () => {
|
|
@@ -80,7 +94,7 @@ export function FabAction({
|
|
|
80
94
|
};
|
|
81
95
|
|
|
82
96
|
return (
|
|
83
|
-
<Animated.View className={slots.action({ className })} style={
|
|
97
|
+
<Animated.View className={slots.action({ className })} onLayout={handleRowLayout} style={rowStyle}>
|
|
84
98
|
<Pressable
|
|
85
99
|
accessibilityElementsHidden
|
|
86
100
|
accessible={false}
|
|
@@ -94,7 +108,7 @@ export function FabAction({
|
|
|
94
108
|
{label}
|
|
95
109
|
</Text>
|
|
96
110
|
</Pressable>
|
|
97
|
-
<View className={slots.actionAnchor()}>
|
|
111
|
+
<Animated.View className={slots.actionAnchor()} onLayout={handleAnchorLayout} style={anchorStyle}>
|
|
98
112
|
<Pressable
|
|
99
113
|
accessibilityLabel={label}
|
|
100
114
|
accessibilityRole="button"
|
|
@@ -111,7 +125,7 @@ export function FabAction({
|
|
|
111
125
|
icon={icon}
|
|
112
126
|
/>
|
|
113
127
|
</Pressable>
|
|
114
|
-
</View>
|
|
128
|
+
</Animated.View>
|
|
115
129
|
</Animated.View>
|
|
116
130
|
);
|
|
117
131
|
}
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
useMemo,
|
|
10
10
|
useState,
|
|
11
11
|
} from "react";
|
|
12
|
-
import { BackHandler, View, type ViewProps } from "react-native";
|
|
12
|
+
import { BackHandler, type LayoutChangeEvent, View, type ViewProps } from "react-native";
|
|
13
13
|
import Animated, {
|
|
14
14
|
useAnimatedStyle,
|
|
15
15
|
useReducedMotion,
|
|
@@ -102,6 +102,7 @@ export function FabGroup({
|
|
|
102
102
|
const isReducedMotion = useReducedMotion();
|
|
103
103
|
const insets = use(SafeAreaInsetsContext);
|
|
104
104
|
const progress = useSharedValue(isOpen ? 1 : 0);
|
|
105
|
+
const triggerCenterY = useSharedValue(0);
|
|
105
106
|
const [isMounted, setIsMounted] = useState(isOpen);
|
|
106
107
|
|
|
107
108
|
// Mount before the open spring starts, in the same render that opened it,
|
|
@@ -134,10 +135,14 @@ export function FabGroup({
|
|
|
134
135
|
|
|
135
136
|
const close = useCallback(() => setIsOpen(false), [setIsOpen]);
|
|
136
137
|
const toggle = () => setIsOpen(!isOpen);
|
|
138
|
+
const handleTriggerLayout = (event: LayoutChangeEvent) => {
|
|
139
|
+
const { y, height } = event.nativeEvent.layout;
|
|
140
|
+
triggerCenterY.value = y + height / 2;
|
|
141
|
+
};
|
|
137
142
|
|
|
138
143
|
const context = useMemo<FabGroupContextValue>(
|
|
139
|
-
() => ({ progress, isOpen, count, labelSide, size, haptic, isReducedMotion, close }),
|
|
140
|
-
[progress, isOpen, count, labelSide, size, haptic, isReducedMotion, close]
|
|
144
|
+
() => ({ progress, triggerCenterY, isOpen, count, labelSide, size, haptic, isReducedMotion, close }),
|
|
145
|
+
[progress, triggerCenterY, isOpen, count, labelSide, size, haptic, isReducedMotion, close]
|
|
141
146
|
);
|
|
142
147
|
|
|
143
148
|
const isExtended = label !== undefined && !isOpen;
|
|
@@ -194,6 +199,7 @@ export function FabGroup({
|
|
|
194
199
|
disabled={isDisabled}
|
|
195
200
|
feedback="scale"
|
|
196
201
|
haptic={haptic}
|
|
202
|
+
onLayout={handleTriggerLayout}
|
|
197
203
|
onPress={toggle}
|
|
198
204
|
testID={testID}
|
|
199
205
|
>
|
|
@@ -47,6 +47,11 @@ export function useFabPart(component: string): FabContextValue {
|
|
|
47
47
|
export type FabGroupContextValue = {
|
|
48
48
|
/** The dial's one spring, 0 closed → 1 open. It overshoots; readers clamp. */
|
|
49
49
|
progress: SharedValue<number>;
|
|
50
|
+
/**
|
|
51
|
+
* The trigger's vertical centre in the dial's own coordinates, from its
|
|
52
|
+
* layout. Each action collapses onto it. 0 until measured.
|
|
53
|
+
*/
|
|
54
|
+
triggerCenterY: SharedValue<number>;
|
|
50
55
|
isOpen: boolean;
|
|
51
56
|
/** How many actions the dial holds — each action's stagger window depends on it. */
|
|
52
57
|
count: number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { describe, expect, test } from "bun:test";
|
|
2
2
|
import { ICON_SIZES } from "../icon/icon.variants";
|
|
3
3
|
import {
|
|
4
|
+
FAB_ACTION_START_SCALE,
|
|
4
5
|
FAB_DIAL_STAGGER,
|
|
5
6
|
FAB_FOREGROUND_TOKEN,
|
|
6
7
|
FAB_ICON_SIZE,
|
|
@@ -8,6 +9,7 @@ import {
|
|
|
8
9
|
FAB_SIZES,
|
|
9
10
|
FAB_VARIANTS,
|
|
10
11
|
fabVariants,
|
|
12
|
+
resolveActionMotion,
|
|
11
13
|
resolveDialProgress,
|
|
12
14
|
resolveFabIconSize,
|
|
13
15
|
resolveFabPlacementStyle,
|
|
@@ -272,3 +274,31 @@ describe("fabVariants", () => {
|
|
|
272
274
|
expect(classes(fabVariants({ labelSide: "top" }).dial())).toContain("items-center");
|
|
273
275
|
});
|
|
274
276
|
});
|
|
277
|
+
|
|
278
|
+
describe("resolveActionMotion", () => {
|
|
279
|
+
test("a closed action sits on the trigger's centre, shrunk and clear", () => {
|
|
280
|
+
const motion = resolveActionMotion({ local: 0, travel: 120 });
|
|
281
|
+
expect(motion.opacity).toBe(0);
|
|
282
|
+
expect(motion.translateY).toBe(120);
|
|
283
|
+
expect(motion.scale).toBe(FAB_ACTION_START_SCALE);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test("an open action rests where it was laid out, at full size", () => {
|
|
287
|
+
expect(resolveActionMotion({ local: 1, travel: 120 })).toEqual({ opacity: 1, translateY: 0, scale: 1 });
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
test("it travels straight down the centre line as it closes, never sideways", () => {
|
|
291
|
+
let previous = -1;
|
|
292
|
+
for (let step = 100; step >= 0; step--) {
|
|
293
|
+
const { translateY, scale } = resolveActionMotion({ local: step / 100, travel: 80 });
|
|
294
|
+
expect(translateY).toBeGreaterThanOrEqual(previous);
|
|
295
|
+
expect(scale).toBeLessThanOrEqual(1);
|
|
296
|
+
expect(scale).toBeGreaterThanOrEqual(FAB_ACTION_START_SCALE);
|
|
297
|
+
previous = translateY;
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
test("an unmeasured action does not move", () => {
|
|
302
|
+
expect(resolveActionMotion({ local: 0.5, travel: 0 }).translateY).toBe(0);
|
|
303
|
+
});
|
|
304
|
+
});
|
|
@@ -154,6 +154,38 @@ export function resolveDialProgress({
|
|
|
154
154
|
return local < 0 ? 0 : local > 1 ? 1 : local;
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
/** An action button's scale at the start of its window, tucked behind the trigger. */
|
|
158
|
+
export const FAB_ACTION_START_SCALE = 0.4;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Where one action is at `local` (its own 0–1 share of the dial's spring).
|
|
162
|
+
*
|
|
163
|
+
* `travel` is the measured distance, in points, from the action button's centre
|
|
164
|
+
* down to the trigger's. Closed, the action sits on the trigger's centre at
|
|
165
|
+
* {@link FAB_ACTION_START_SCALE}, behind it; open, it rests where it was laid
|
|
166
|
+
* out. Only `translateY` moves, so the action grows out of and collapses into
|
|
167
|
+
* the trigger along its centre line, never sideways. The caller scales the
|
|
168
|
+
* button alone, about its own centre — the whole row's centre sits off to the
|
|
169
|
+
* chip's side, and scaling about it drags the button in from there.
|
|
170
|
+
*
|
|
171
|
+
* `travel` is 0 until the layout is measured, and the action stays clear until
|
|
172
|
+
* its window opens, so the unmeasured frame shows nothing.
|
|
173
|
+
*
|
|
174
|
+
* A worklet, so the action's animated style calls it on the UI thread.
|
|
175
|
+
*/
|
|
176
|
+
export function resolveActionMotion({ local, travel }: { local: number; travel: number }): {
|
|
177
|
+
opacity: number;
|
|
178
|
+
translateY: number;
|
|
179
|
+
scale: number;
|
|
180
|
+
} {
|
|
181
|
+
"worklet";
|
|
182
|
+
return {
|
|
183
|
+
opacity: local,
|
|
184
|
+
translateY: (1 - local) * travel,
|
|
185
|
+
scale: FAB_ACTION_START_SCALE + (1 - FAB_ACTION_START_SCALE) * local,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
157
189
|
/**
|
|
158
190
|
* Styling for every part of a fab and its dial.
|
|
159
191
|
*
|
|
@@ -48,7 +48,7 @@ Compound root plus `Message.Avatar`, `.Header`, `.Author`, `.Bubble`, `.Text`,
|
|
|
48
48
|
property without remapping it, giving `borderStartStartRadius`, which React
|
|
49
49
|
Native (≥ 0.71) supports and flips under RTL. No `style` fallback is needed,
|
|
50
50
|
so `resolveMessageCornerStyle` from the spec was not written. The `rtl` demo
|
|
51
|
-
is the visual check.
|
|
51
|
+
is the visual check, and the `runs` clip flips one live.
|
|
52
52
|
- **Run spacing is the message's.** `first`/`middle` sit `mb-0.5`, `last`/`single`
|
|
53
53
|
`mb-2`, through the `position` variant, so a list needs no separator logic.
|
|
54
54
|
- **Fill and foreground are a pair.** Outgoing `bg-primary` /
|
|
@@ -132,8 +132,13 @@ an image viewer, text selection by default (`selectable` steals the long press).
|
|
|
132
132
|
|
|
133
133
|
## Previews
|
|
134
134
|
|
|
135
|
-
Five demos are captured: `
|
|
135
|
+
Five demos are captured: `runs` (**hero**, a clip — the run is sent one message
|
|
136
|
+
at a time, each arrival tightening the corners it shares with the one above, then
|
|
137
|
+
flips to right to left and back), `status` (a clip — the receipt walks sending →
|
|
136
138
|
read, the failed one retries and fails again), `typing` (a clip of the dots),
|
|
137
|
-
and stills of `directions
|
|
138
|
-
`align: "stretch"`. The Retry control carries no `testID`, so
|
|
139
|
-
|
|
139
|
+
and stills of `directions` and `reactions`, all but `typing` at
|
|
140
|
+
`align: "stretch"`. The Retry control carries no `testID`, so the preview
|
|
141
|
+
capture<!-- registry:omit --> (`apps/playground/e2e/previews/message.e2e.ts`)<!-- /registry:omit --> taps it by its text — which only
|
|
142
|
+
works because the failed message in `status` is `isCompound`: without it the
|
|
143
|
+
message is one accessibility element, its Retry an accessibility action that
|
|
144
|
+
never reaches the tree.
|