@vvedantb/native-ui 0.24.0 → 0.24.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.
@@ -1,8 +1,9 @@
1
- import { Pressable, View } from "react-native";
1
+ import { View } from "react-native";
2
2
  import { IconCheck } from "@tabler/icons-react-native";
3
3
  import { cn } from "./cn";
4
4
  import { touchSlop } from "./controlStyles";
5
5
  import { selectionHaptic } from "./haptics";
6
+ import { AnimatedPressable, usePressScale } from "./pressScale";
6
7
  import { withAlpha } from "./palette";
7
8
  import { useLargerText } from "./theme";
8
9
  import { tokens } from "./tokens";
@@ -91,43 +92,87 @@ export function ColorSwatches({
91
92
  const isSelected = color.toLowerCase() === selected;
92
93
  const check = isSelected ? swatchCheckColor(color) : null;
93
94
  return (
94
- <Pressable
95
+ <Swatch
95
96
  key={`${color}-${index}`}
96
97
  testID={testID ? `${testID}-${index}` : undefined}
97
- accessibilityRole="radio"
98
- accessibilityLabel={labels?.[index] ?? color}
99
- accessibilityState={{ checked: isSelected, disabled }}
100
- hitSlop={touchSlop(outer)}
98
+ label={labels?.[index] ?? color}
99
+ color={color}
100
+ selected={isSelected}
101
+ check={check}
101
102
  disabled={disabled}
103
+ diameter={diameter}
104
+ outer={outer}
102
105
  onPress={() => {
103
106
  selectionHaptic();
104
107
  onChange(color);
105
108
  }}
106
- className="items-center justify-center active:opacity-70"
107
- style={{
108
- width: outer,
109
- height: outer,
110
- borderRadius: outer / 2,
111
- borderWidth: RING,
112
- borderColor: isSelected ? tokens.color.foreground[scheme] : "transparent",
113
- }}
114
- >
115
- <View
116
- className="items-center justify-center"
117
- style={{
118
- width: diameter,
119
- height: diameter,
120
- borderRadius: diameter / 2,
121
- backgroundColor: color,
122
- borderWidth: 1,
123
- borderColor: withAlpha(tokens.color.foreground[scheme], 0.12),
124
- }}
125
- >
126
- {check ? <IconCheck size={Math.round(diameter / 2)} color={check} strokeWidth={2} /> : null}
127
- </View>
128
- </Pressable>
109
+ />
129
110
  );
130
111
  })}
131
112
  </View>
132
113
  );
133
114
  }
115
+
116
+ /** One swatch: a radio that scales a little on press. The slop does not scale. */
117
+ function Swatch({
118
+ testID,
119
+ label,
120
+ color,
121
+ selected,
122
+ check,
123
+ disabled,
124
+ diameter,
125
+ outer,
126
+ onPress,
127
+ }: {
128
+ testID?: string;
129
+ label: string;
130
+ color: string;
131
+ selected: boolean;
132
+ check: string | null;
133
+ disabled: boolean;
134
+ diameter: number;
135
+ outer: number;
136
+ onPress: () => void;
137
+ }) {
138
+ const scheme = useScheme();
139
+ const press = usePressScale({ disabled });
140
+ return (
141
+ <AnimatedPressable
142
+ testID={testID}
143
+ accessibilityRole="radio"
144
+ accessibilityLabel={label}
145
+ accessibilityState={{ checked: selected, disabled }}
146
+ hitSlop={touchSlop(outer)}
147
+ disabled={disabled}
148
+ onPress={onPress}
149
+ onPressIn={press.onPressIn}
150
+ onPressOut={press.onPressOut}
151
+ className="items-center justify-center"
152
+ style={[
153
+ {
154
+ width: outer,
155
+ height: outer,
156
+ borderRadius: outer / 2,
157
+ borderWidth: RING,
158
+ borderColor: selected ? tokens.color.foreground[scheme] : "transparent",
159
+ },
160
+ press.style,
161
+ ]}
162
+ >
163
+ <View
164
+ className="items-center justify-center"
165
+ style={{
166
+ width: diameter,
167
+ height: diameter,
168
+ borderRadius: diameter / 2,
169
+ backgroundColor: color,
170
+ borderWidth: 1,
171
+ borderColor: withAlpha(tokens.color.foreground[scheme], 0.12),
172
+ }}
173
+ >
174
+ {check ? <IconCheck size={Math.round(diameter / 2)} color={check} strokeWidth={2} /> : null}
175
+ </View>
176
+ </AnimatedPressable>
177
+ );
178
+ }
package/src/Dialog.tsx CHANGED
@@ -10,6 +10,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
10
10
  import { IconX } from "@tabler/icons-react-native";
11
11
  import { FloatingSurface } from "./FloatingSurface";
12
12
  import { cn } from "./cn";
13
+ import { AnimatedPressable, usePressScale } from "./pressScale";
13
14
  import { isCompactOverlay, textStyle, typeStyle } from "./controlStyles";
14
15
  import { DialogLayoutContext, useDialogLayout, type DialogLayout } from "./dialogLayout";
15
16
  import { palette } from "./palette";
@@ -162,14 +163,22 @@ function DialogHandle() {
162
163
  function DialogCloseButton() {
163
164
  const largerText = useLargerText();
164
165
  const scheme = useScheme();
166
+ const press = usePressScale();
167
+ // `asChild`: the close press goes into this animated `Pressable`, so the
168
+ // button scales while `overlay.tsx` stays as it is.
165
169
  return (
166
- <DialogClose
167
- testID="dialog-close"
168
- accessibilityLabel="Close"
169
- hitSlop={8}
170
- className="absolute right-2 top-2 h-11 w-11 items-center justify-center rounded-lg active:opacity-70"
171
- >
172
- <IconX size={largerText ? 26 : 16} color={tokens.color.muted[scheme]} />
170
+ <DialogClose asChild>
171
+ <AnimatedPressable
172
+ testID="dialog-close"
173
+ accessibilityLabel="Close"
174
+ hitSlop={8}
175
+ onPressIn={press.onPressIn}
176
+ onPressOut={press.onPressOut}
177
+ style={press.style}
178
+ className="absolute right-2 top-2 h-11 w-11 items-center justify-center rounded-lg"
179
+ >
180
+ <IconX size={largerText ? 26 : 16} color={tokens.color.muted[scheme]} />
181
+ </AnimatedPressable>
173
182
  </DialogClose>
174
183
  );
175
184
  }
@@ -1,5 +1,5 @@
1
1
  import * as Slot from "@rn-primitives/slot";
2
- import { createContext, useContext, useRef, useState, type ComponentType, type ReactNode } from "react";
2
+ import { createContext, useContext, useEffect, useRef, useState, type ComponentType, type ReactNode } from "react";
3
3
  import {
4
4
  Modal,
5
5
  Pressable,
@@ -12,12 +12,14 @@ import {
12
12
  type PressableProps,
13
13
  type ViewProps,
14
14
  } from "react-native";
15
+ import Animated, { runOnJS, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
15
16
  import { useSafeAreaInsets } from "react-native-safe-area-context";
16
17
  import { IconCheck, type IconProps } from "@tabler/icons-react-native";
17
18
  import { FloatingSurface } from "./FloatingSurface";
18
19
  import { cn } from "./cn";
19
20
  import { sizeStyle, typeStyle } from "./controlStyles";
20
21
  import { selectionHaptic } from "./haptics";
22
+ import { PANEL_SCALE_FROM, POPOVER_ENTER, POPOVER_EXIT } from "./motion";
21
23
  import { palette } from "./palette";
22
24
  import { useLargerText } from "./theme";
23
25
  import { tokens } from "./tokens";
@@ -195,7 +197,9 @@ export type DropdownMenuContentProps = ViewProps & {
195
197
  * `Dialog` and `Sheet` (`FloatingSurface` without blur, with the floating
196
198
  * shadow) at radius 16, at least 192 wide, `p-1.5`, scrolling when taller than
197
199
  * the room. A tap outside, Android back and the VoiceOver escape gesture close
198
- * it. With Reduce Motion on, the fade is off.
200
+ * it. The panel (not the backdrop) fades in and scales from 0.96 over 150 ms
201
+ * once it is measured, from the corner nearest the trigger, and fades out in
202
+ * 100 ms. With Reduce Motion on, it appears and leaves at once.
199
203
  */
200
204
  export function DropdownMenuContent({
201
205
  align = "start",
@@ -212,13 +216,60 @@ export function DropdownMenuContent({
212
216
  // `null` until the content is measured: only then is it known whether the
213
217
  // menu fits below the trigger or flips above, so it stays hidden till then.
214
218
  const [contentHeight, setContentHeight] = useState<number | null>(null);
219
+ // Up while open, and after a close until the panel has faded out.
220
+ const [shown, setShown] = useState(open);
221
+ if (open && !shown) setShown(true);
222
+ if (!open && shown && reduceMotion) setShown(false);
223
+ const openRef = useRef(open);
224
+ useEffect(() => {
225
+ openRef.current = open;
226
+ }, [open]);
227
+ // The panel's motion, on the UI thread. At rest (1, 1) under Reduce Motion.
228
+ const opacity = useSharedValue(reduceMotion ? 1 : 0);
229
+ const scale = useSharedValue(reduceMotion ? 1 : PANEL_SCALE_FROM);
230
+ const measured = contentHeight !== null;
231
+ const hide = () => {
232
+ // Opened again in the moment the fade ended: stay up.
233
+ if (openRef.current) return;
234
+ setShown(false);
235
+ setContentHeight(null);
236
+ scale.set(PANEL_SCALE_FROM);
237
+ };
238
+ useEffect(() => {
239
+ if (reduceMotion) {
240
+ opacity.set(1);
241
+ scale.set(1);
242
+ return;
243
+ }
244
+ if (open) {
245
+ if (!measured) return;
246
+ opacity.set(withTiming(1, POPOVER_ENTER));
247
+ scale.set(withTiming(1, POPOVER_ENTER));
248
+ } else if (shown) {
249
+ // A fade only: the scale stays where it is.
250
+ opacity.set(
251
+ withTiming(0, POPOVER_EXIT, (finished) => {
252
+ "worklet";
253
+ if (finished) runOnJS(hide)();
254
+ }),
255
+ );
256
+ }
257
+ // Only opening, measuring and closing start the motion.
258
+ }, [open, measured, reduceMotion]);
259
+ const panelStyle = useAnimatedStyle(() => ({
260
+ opacity: opacity.get(),
261
+ transform: [{ scale: scale.get() }],
262
+ }));
215
263
  const close = () => setOpen(false);
216
264
  const position = dropdownMenuPosition({ trigger, window, insets, align, sideOffset, contentHeight: contentHeight ?? 0 });
265
+ // The scale grows from the corner nearest the trigger: its edge on the
266
+ // trigger's (`align`), and the top, or the bottom when the menu flipped above.
267
+ const transformOrigin = `${align === "end" ? 100 : 0}% ${position.bottom === undefined ? 0 : 100}%`;
217
268
  return (
218
269
  <Modal
219
- visible={open}
270
+ visible={shown}
220
271
  transparent
221
- animationType={reduceMotion ? "none" : "fade"}
272
+ animationType="none"
222
273
  statusBarTranslucent
223
274
  onRequestClose={close}
224
275
  >
@@ -237,6 +288,8 @@ export function DropdownMenuContent({
237
288
  accessibilityRole="menu"
238
289
  accessibilityViewIsModal
239
290
  onAccessibilityEscape={close}
291
+ // Leaving: a late tap on a row must not select twice.
292
+ pointerEvents={open ? "auto" : "none"}
240
293
  style={{
241
294
  position: "absolute",
242
295
  ...position,
@@ -245,18 +298,20 @@ export function DropdownMenuContent({
245
298
  opacity: contentHeight === null ? 0 : 1,
246
299
  }}
247
300
  >
248
- <FloatingSurface blur={false} radius={DROPDOWN_MENU.radius} style={{ maxHeight: position.maxHeight }}>
249
- <ScrollView
250
- bounces={false}
251
- showsVerticalScrollIndicator={false}
252
- onContentSizeChange={(_width, height) => setContentHeight(height)}
253
- contentContainerStyle={{ padding: DROPDOWN_MENU.padding }}
254
- >
255
- <View className={cn(className)} style={style} {...props}>
256
- {children}
257
- </View>
258
- </ScrollView>
259
- </FloatingSurface>
301
+ <Animated.View style={[{ transformOrigin }, panelStyle]}>
302
+ <FloatingSurface blur={false} radius={DROPDOWN_MENU.radius} style={{ maxHeight: position.maxHeight }}>
303
+ <ScrollView
304
+ bounces={false}
305
+ showsVerticalScrollIndicator={false}
306
+ onContentSizeChange={(_width, height) => setContentHeight(height)}
307
+ contentContainerStyle={{ padding: DROPDOWN_MENU.padding }}
308
+ >
309
+ <View className={cn(className)} style={style} {...props}>
310
+ {children}
311
+ </View>
312
+ </ScrollView>
313
+ </FloatingSurface>
314
+ </Animated.View>
260
315
  </View>
261
316
  </View>
262
317
  </Modal>
@@ -1,8 +1,9 @@
1
1
  import type { ReactNode } from "react";
2
- import { Platform, Pressable, View } from "react-native";
2
+ import { Platform, View } from "react-native";
3
3
  import { cn } from "./cn";
4
4
  import { useSafeAreaInsets } from "react-native-safe-area-context";
5
5
  import { FloatingSurface } from "./FloatingSurface";
6
+ import { AnimatedPressable, usePressScale } from "./pressScale";
6
7
  import { useAccentColor, useLargerText } from "./theme";
7
8
  import {
8
9
  FLOATING_INSET,
@@ -24,6 +25,7 @@ export function FloatingFAB({
24
25
  const insets = useSafeAreaInsets();
25
26
  const largerText = useLargerText();
26
27
  const accentColor = useAccentColor();
28
+ const press = usePressScale({ scale: 0.95 });
27
29
  const size = largerText ? 64 : 56;
28
30
  const tabBar = largerText
29
31
  ? FLOATING_TAB_BAR_HEIGHT_LARGE
@@ -39,24 +41,29 @@ export function FloatingFAB({
39
41
  }}
40
42
  >
41
43
  <FloatingSurface radius={size / 2} blur={false}>
42
- <Pressable
44
+ <AnimatedPressable
43
45
  testID={testID}
44
46
  accessibilityRole="button"
45
47
  accessibilityLabel={label}
46
48
  onPress={onPress}
47
- // Layout in the function style and no `className`: NativeWind drops a
48
- // function `style` next to a `className`.
49
- style={({ pressed }) => ({
50
- alignItems: "center",
51
- justifyContent: "center",
52
- width: size,
53
- height: size,
54
- backgroundColor: accentColor,
55
- opacity: pressed ? 0.7 : 1,
56
- })}
49
+ onPressIn={press.onPressIn}
50
+ onPressOut={press.onPressOut}
51
+ // Layout in `style` and no `className`: NativeWind drops a function
52
+ // `style` next to a `className`, and the press scale and dim come
53
+ // from the animated style, not a function style.
54
+ style={[
55
+ {
56
+ alignItems: "center",
57
+ justifyContent: "center",
58
+ width: size,
59
+ height: size,
60
+ backgroundColor: accentColor,
61
+ },
62
+ press.style,
63
+ ]}
57
64
  >
58
65
  {children}
59
- </Pressable>
66
+ </AnimatedPressable>
60
67
  </FloatingSurface>
61
68
  </View>
62
69
  );
@@ -1,8 +1,7 @@
1
1
  import type { ComponentType } from "react";
2
- import { Pressable } from "react-native";
3
2
  import type { IconProps } from "@tabler/icons-react-native";
4
- import { cn } from "./cn";
5
3
  import { touchSlop } from "./controlStyles";
4
+ import { AnimatedPressable, usePressScale } from "./pressScale";
6
5
  import { withAlpha } from "./palette";
7
6
  import { useLargerText } from "./theme";
8
7
  import { tokens } from "./tokens";
@@ -69,8 +68,9 @@ export function IconButton({
69
68
  const largerText = useLargerText();
70
69
  const [diameter, iconSize] = METRICS[largerText ? "larger" : "regular"][size];
71
70
  const { color, ...frame } = iconButtonColors(variant, scheme);
71
+ const press = usePressScale({ restOpacity: disabled ? 0.5 : 1, disabled });
72
72
  return (
73
- <Pressable
73
+ <AnimatedPressable
74
74
  testID={testID}
75
75
  accessibilityRole="button"
76
76
  accessibilityLabel={label}
@@ -78,10 +78,12 @@ export function IconButton({
78
78
  hitSlop={touchSlop(diameter)}
79
79
  disabled={disabled}
80
80
  onPress={onPress}
81
- className={cn("items-center justify-center active:opacity-70", disabled && "opacity-50")}
82
- style={{ width: diameter, height: diameter, borderRadius: diameter / 2, borderWidth: 1, ...frame }}
81
+ onPressIn={press.onPressIn}
82
+ onPressOut={press.onPressOut}
83
+ className="items-center justify-center"
84
+ style={[{ width: diameter, height: diameter, borderRadius: diameter / 2, borderWidth: 1, ...frame }, press.style]}
83
85
  >
84
86
  <Icon size={iconSize} color={iconColor ?? color} />
85
- </Pressable>
87
+ </AnimatedPressable>
86
88
  );
87
89
  }
@@ -1,7 +1,8 @@
1
1
  import { Children, type ReactNode } from "react";
2
- import { Pressable, Text, View, type ViewProps } from "react-native";
2
+ import { Text, View, type ViewProps } from "react-native";
3
3
  import { cn } from "./cn";
4
4
  import { cardStyle, textStyle, typeStyle } from "./controlStyles";
5
+ import { AnimatedPressable, usePressScale } from "./pressScale";
5
6
  import { StatusDot } from "./StatusDot";
6
7
  import { Spinner } from "./Spinner";
7
8
  import { useLargerText } from "./theme";
@@ -31,16 +32,19 @@ export type PinnedBotTileProps = {
31
32
  export function PinnedBotTile({ title, leading, unread = false, generating = false, onPress, onLongPress, testID }: PinnedBotTileProps) {
32
33
  const scheme = useScheme();
33
34
  const largerText = useLargerText();
35
+ const press = usePressScale();
34
36
  const state = [unread ? "unread" : null, generating ? "generating" : null].filter(Boolean).join(", ");
35
37
  return (
36
- <Pressable
38
+ <AnimatedPressable
37
39
  testID={testID}
38
40
  accessibilityRole="button"
39
41
  accessibilityLabel={state ? `${title}, ${state}` : title}
40
42
  onPress={onPress}
41
43
  onLongPress={onLongPress}
42
- className={cn("min-w-0 items-center justify-center gap-2 px-3 py-4 active:opacity-70", largerText ? "min-h-36" : "min-h-28")}
43
- style={cardStyle(scheme)}
44
+ onPressIn={press.onPressIn}
45
+ onPressOut={press.onPressOut}
46
+ className={cn("min-w-0 items-center justify-center gap-2 px-3 py-4", largerText ? "min-h-36" : "min-h-28")}
47
+ style={[cardStyle(scheme), press.style]}
44
48
  >
45
49
  {leading}
46
50
  <Text
@@ -60,7 +64,7 @@ export function PinnedBotTile({ title, leading, unread = false, generating = fal
60
64
  <Spinner size="sm" decorative />
61
65
  </View>
62
66
  ) : null}
63
- </Pressable>
67
+ </AnimatedPressable>
64
68
  );
65
69
  }
66
70
 
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { Pressable, useWindowDimensions, View } from "react-native";
2
+ import { useWindowDimensions, View } from "react-native";
3
3
  import { IconSearch, IconX } from "@tabler/icons-react-native";
4
4
  import { Input as PrimitiveInput } from "./primitives/input";
5
5
  import { cn } from "./cn";
@@ -13,6 +13,7 @@ import {
13
13
  typeStyle,
14
14
  type SearchInputSize,
15
15
  } from "./controlStyles";
16
+ import { AnimatedPressable, usePressScale } from "./pressScale";
16
17
  import { palette } from "./palette";
17
18
  import { tokens } from "./tokens";
18
19
  import { useLargerText } from "./theme";
@@ -138,18 +139,13 @@ const SearchInput = React.forwardRef<
138
139
  className="absolute bottom-0 top-0 justify-center"
139
140
  style={{ right: metrics.clearRight }}
140
141
  >
141
- <Pressable
142
- testID="search-input-clear"
143
- accessibilityRole="button"
144
- accessibilityLabel={clearLabel}
145
- hitSlop={touchSlop(metrics.clear)}
142
+ <ClearButton
143
+ label={clearLabel}
144
+ size={metrics.clear}
145
+ iconSize={metrics.clearIcon}
146
+ color={muted}
146
147
  onPress={() => change("")}
147
- className="items-center justify-center rounded-md active:opacity-70"
148
- style={{ width: metrics.clear, height: metrics.clear }}
149
- >
150
- {/* `strokeWidth`, not the web `stroke`: here `stroke` is the colour. */}
151
- <IconX size={metrics.clearIcon} color={muted} strokeWidth={1.75} />
152
- </Pressable>
148
+ />
153
149
  </View>
154
150
  ) : null}
155
151
  </View>
@@ -159,5 +155,37 @@ const SearchInput = React.forwardRef<
159
155
 
160
156
  SearchInput.displayName = "SearchInput";
161
157
 
158
+ function ClearButton({
159
+ label,
160
+ size,
161
+ iconSize,
162
+ color,
163
+ onPress,
164
+ }: {
165
+ label: string;
166
+ size: number;
167
+ iconSize: number;
168
+ color: string;
169
+ onPress: () => void;
170
+ }) {
171
+ const press = usePressScale();
172
+ return (
173
+ <AnimatedPressable
174
+ testID="search-input-clear"
175
+ accessibilityRole="button"
176
+ accessibilityLabel={label}
177
+ hitSlop={touchSlop(size)}
178
+ onPress={onPress}
179
+ onPressIn={press.onPressIn}
180
+ onPressOut={press.onPressOut}
181
+ className="items-center justify-center rounded-md"
182
+ style={[{ width: size, height: size }, press.style]}
183
+ >
184
+ {/* `strokeWidth`, not the web `stroke`: here `stroke` is the colour. */}
185
+ <IconX size={iconSize} color={color} strokeWidth={1.75} />
186
+ </AnimatedPressable>
187
+ );
188
+ }
189
+
162
190
  export { SearchInput };
163
191
  export type { SearchInputProps };
@@ -1,6 +1,7 @@
1
- import { Pressable, Text } from "react-native";
1
+ import { Text } from "react-native";
2
2
  import { cn } from "../cn";
3
3
  import { buttonColors, MIN_TOUCH_TARGET, sizeStyle, touchSlop, typeStyle, type ButtonVariant } from "../controlStyles";
4
+ import { AnimatedPressable, usePressScale } from "../pressScale";
4
5
  import { useLargerText } from "../theme";
5
6
  import { useScheme } from "../useScheme";
6
7
  import { chatTextSize } from "./chat-text";
@@ -23,8 +24,9 @@ export function CardButton({ label, variant, onPress, disabled, accessibilityLab
23
24
  const largerText = useLargerText();
24
25
  const size = chatTextSize("small", largerText);
25
26
  const colors = buttonColors(variant, scheme)!;
27
+ const press = usePressScale({ restOpacity: disabled ? 0.5 : 1, disabled: !!disabled });
26
28
  return (
27
- <Pressable
29
+ <AnimatedPressable
28
30
  testID={testID}
29
31
  accessibilityRole="button"
30
32
  accessibilityLabel={accessibilityLabel ?? label}
@@ -32,18 +34,22 @@ export function CardButton({ label, variant, onPress, disabled, accessibilityLab
32
34
  disabled={disabled}
33
35
  onPress={onPress}
34
36
  hitSlop={touchSlop(MIN_TOUCH_TARGET)}
35
- className={cn("items-center justify-center rounded-full border px-4 active:opacity-70")}
36
- style={{
37
- minHeight: MIN_TOUCH_TARGET,
38
- minWidth: MIN_TOUCH_TARGET,
39
- backgroundColor: colors.backgroundColor,
40
- borderColor: colors.borderColor,
41
- opacity: disabled ? 0.5 : 1,
42
- }}
37
+ onPressIn={press.onPressIn}
38
+ onPressOut={press.onPressOut}
39
+ className="items-center justify-center rounded-full border px-4"
40
+ style={[
41
+ {
42
+ minHeight: MIN_TOUCH_TARGET,
43
+ minWidth: MIN_TOUCH_TARGET,
44
+ backgroundColor: colors.backgroundColor,
45
+ borderColor: colors.borderColor,
46
+ },
47
+ press.style,
48
+ ]}
43
49
  >
44
50
  <Text className={cn(size, "font-instrument-sans-semibold")} style={[sizeStyle(size), typeStyle("semibold"), { color: colors.color }]}>
45
51
  {label}
46
52
  </Text>
47
- </Pressable>
53
+ </AnimatedPressable>
48
54
  );
49
55
  }
@@ -1,7 +1,8 @@
1
- import { Pressable, Text, View } from "react-native";
1
+ import { Text, View } from "react-native";
2
2
  import { IconFile } from "@tabler/icons-react-native";
3
3
  import { cn } from "../cn";
4
4
  import { MIN_TOUCH_TARGET, sizeStyle, textStyle, touchSlop } from "../controlStyles";
5
+ import { AnimatedPressable, usePressScale } from "../pressScale";
5
6
  import { palette } from "../palette";
6
7
  import { useLargerText } from "../theme";
7
8
  import { tokens } from "../tokens";
@@ -51,16 +52,24 @@ export type FileChipProps = {
51
52
  */
52
53
  export function FileChip({ name, path, onOpenFile }: FileChipProps) {
53
54
  if (!path || !onOpenFile) return <FileChipLabel name={name} />;
55
+ return <FileChipButton name={name} path={path} onOpenFile={onOpenFile} />;
56
+ }
57
+
58
+ function FileChipButton({ name, path, onOpenFile }: { name: string; path: string; onOpenFile: (path: string) => void }) {
59
+ const press = usePressScale();
54
60
  return (
55
- <Pressable
61
+ <AnimatedPressable
56
62
  accessibilityRole="button"
57
63
  accessibilityLabel={name}
58
64
  accessibilityHint={path}
59
65
  hitSlop={touchSlop(MIN_TOUCH_TARGET, CHIP_HEIGHT)}
60
66
  onPress={() => onOpenFile(path)}
61
- className="min-w-0 max-w-full active:opacity-70"
67
+ onPressIn={press.onPressIn}
68
+ onPressOut={press.onPressOut}
69
+ style={press.style}
70
+ className="min-w-0 max-w-full"
62
71
  >
63
72
  <FileChipLabel name={name} />
64
- </Pressable>
73
+ </AnimatedPressable>
65
74
  );
66
75
  }