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

work-log-layout.tsx

82 lines2.2 KB

1import { AppText as Text } from "../../components/ui/AppText";
2import { cn } from "../../lib/cn";
3import type { ComponentProps, ReactNode } from "react";
4import { Pressable, View } from "react-native";
5import { THREAD_WORK_ROW_MIN_HEIGHT, type deriveThreadWorkLogSizing } from "../../lib/layout";
6​
7export function WorkLogBlock({
8 children,
9 layout = "standalone",
10 continues = false,
11}: {
12 children: ReactNode;
13 layout?: "standalone" | "group-header";
14 continues?: boolean | undefined;
15}) {
16 return (
17 <View className={continues || layout === "group-header" ? "-mx-1 px-1" : "-mx-1 mb-1 px-1"}>
18 {children}
19 </View>
20 );
22​
23export function WorkLogRows({ children }: { children: ReactNode }) {
24 return <View className="gap-px">{children}</View>;
26​
27export function WorkLogIconSlot({ children }: { children: ReactNode }) {
28 return <View className="relative h-6 w-6 shrink-0 items-center justify-center">{children}</View>;
30​
31export function WorkLogPressable({
32 children,
33 rowSizing,
34 trailing,
35 ...props
36}: Omit<ComponentProps<typeof Pressable>, "children" | "className" | "style" | "hitSlop"> & {
37 children: ReactNode;
38 rowSizing?: ReturnType<typeof deriveThreadWorkLogSizing>;
39 trailing?: ReactNode;
40}) {
41 const pressable = (
42 <Pressable {...props} hitSlop={4} className="rounded-md px-0.5 py-0 active:bg-subtle">
43 <View
44 className="flex-row items-center gap-1.5"
45 style={{ minHeight: rowSizing?.estimatedRowHeight ?? THREAD_WORK_ROW_MIN_HEIGHT }}
46 >
47 {children}
48 </View>
49 </Pressable>
50 );
51 return trailing ? (
52 <View className="flex-row items-center gap-2">
53 <View className="min-w-0 flex-1">{pressable}</View>
54 {trailing}
55 </View>
56 ) : (
57 pressable
58 );
60​
61export function WorkLogLabel({
62 children,
63 tone = "default",
64}: {
65 children: ReactNode;
66 tone?: "default" | "danger" | "warning";
67}) {
68 return (
69 <Text
70 selectable={false}
71 numberOfLines={1}
72 ellipsizeMode="tail"
73 className={cn(
74 "min-w-0 flex-1 text-sm text-foreground-muted",
75 tone === "danger" && "font-t3-medium text-adaptive-rose-600-400",
76 tone === "warning" && "font-t3-medium text-warning-foreground",
77 )}
78 >
79 {children}
80 </Text>
81 );