Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ConnectionSheetButton.tsx

99 lines2.7 KB

1import { SymbolView } from "../../components/AppSymbol";
2import { Platform, Pressable } from "react-native";
3​
4import { AppText as Text } from "../../components/AppText";
5import { cn } from "../../lib/cn";
6​
7const CARD_SHADOW = Platform.select({
8 ios: {
9 shadowColor: "rgba(23,23,23,0.08)",
10 shadowOffset: { width: 0, height: 4 },
11 shadowOpacity: 1,
12 shadowRadius: 16,
13 },
14 android: { elevation: 3 },
15});
16​
17const CARD_SHADOW_DARK = Platform.select({
18 ios: {
19 shadowColor: "#000",
20 shadowOffset: { width: 0, height: 2 },
21 shadowOpacity: 0.18,
22 shadowRadius: 8,
23 },
24 android: { elevation: 4 },
25});
26​
27export { CARD_SHADOW, CARD_SHADOW_DARK };
28​
29export function ConnectionSheetButton(props: {
30 readonly icon: React.ComponentProps<typeof SymbolView>["name"];
31 readonly label: string;
32 readonly disabled?: boolean;
33 readonly tone?: "primary" | "secondary" | "danger";
34 readonly compact?: boolean;
35 readonly onPress: () => void;
36}) {
37 const tone = props.tone ?? "secondary";
38​
39 const textColorClassName =
40 tone === "primary"
41 ? "accent-primary-foreground"
42 : tone === "danger"
43 ? "accent-danger-foreground"
44 : "accent-secondary-foreground";
45​
46 const primaryShadow =
47 tone === "primary"
48 ? Platform.select({
49 ios: {
50 shadowColor: "#000",
51 shadowOffset: { width: 0, height: 3 },
52 shadowOpacity: 0.14,
53 shadowRadius: 6,
54 },
55 android: { elevation: 3 },
56 })
57 : undefined;
58​
59 return (
60 <Pressable
61 accessibilityLabel={props.label}
62 accessibilityRole="button"
63 accessibilityState={{ disabled: props.disabled ?? false }}
64 className={cn(
65 props.compact
66 ? "min-h-[42px] flex-row items-center justify-center gap-1.5 rounded-[14px] px-3.5 py-2.5"
67 : "min-h-[48px] flex-row items-center justify-center gap-2 rounded-[16px] px-4 py-3",
68 "disabled:opacity-50",
69 tone === "primary"
70 ? "bg-primary"
71 : tone === "danger"
72 ? "border border-danger-border bg-danger"
73 : "border border-border bg-secondary",
74 )}
75 disabled={props.disabled}
76 onPress={props.onPress}
77 style={primaryShadow}
78 >
79 <SymbolView
80 name={props.icon}
81 size={props.compact ? 13 : 14}
82 tintColorClassName={textColorClassName}
83 type="monochrome"
84 />
85 <Text
86 className={cn(
87 "text-xs font-t3-bold tracking-[0.8px] uppercase",
88 tone === "primary"
89 ? "text-primary-foreground"
90 : tone === "danger"
91 ? "text-danger-foreground"
92 : "text-secondary-foreground",
93 )}
94 >
95 {props.label}
96 </Text>
97 </Pressable>
98 );