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

sidebar-header-actions.tsx

56 lines1.8 KB

1import { SymbolView } from "../../components/AppSymbol";
2import { Pressable, StyleSheet, View } from "react-native";
3​
4import { useThemeColor } from "../../lib/useThemeColor";
5​
6export interface SidebarHeaderActionsProps {
7 readonly onOpenSettings: () => void;
8 /** Rendered inside a shared capsule group — buttons drop their own chrome. */
9 readonly grouped?: boolean;
11​
12function FallbackHeaderButton(props: {
13 readonly accessibilityLabel: string;
14 readonly icon: "gearshape" | "square.and.pencil";
15 readonly grouped?: boolean;
16 readonly onPress: () => void;
17}) {
18 const iconColor = useThemeColor("--color-foreground");
19 const pressedBackgroundColor = useThemeColor("--color-subtle");
20 const idleBackgroundColor = useThemeColor("--color-glass-surface");
21 const borderColor = useThemeColor("--color-header-border");
22​
23 return (
24 <Pressable
25 className="h-11 w-[50px] items-center justify-center rounded-[22px]"
26 accessibilityLabel={props.accessibilityLabel}
27 accessibilityRole="button"
28 hitSlop={4}
29 onPress={props.onPress}
30 style={({ pressed }) => [
31 props.grouped
32 ? { backgroundColor: pressed ? pressedBackgroundColor : "transparent", borderWidth: 0 }
33 : {
34 backgroundColor: pressed ? pressedBackgroundColor : idleBackgroundColor,
35 borderColor,
36 borderWidth: StyleSheet.hairlineWidth,
37 },
38 ]}
39 >
40 <SymbolView name={props.icon} size={20} tintColor={iconColor} type="monochrome" />
41 </Pressable>
42 );
44​
45export function SidebarHeaderActions(props: SidebarHeaderActionsProps) {
46 return (
47 <View className="flex-row items-center gap-0.5">
48 <FallbackHeaderButton
49 accessibilityLabel="Open settings"
50 grouped={props.grouped}
51 icon="gearshape"
52 onPress={props.onOpenSettings}
53 />
54 </View>
55 );