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

AppText.tsx

57 lines1.6 KB

1import {
2 Platform,
3 Text as RNText,
4 TextInput as RNTextInput,
5 type TextInputInstance,
6 type TextInputProps as RNTextInputProps,
7 type TextProps as RNTextProps,
8} from "react-native";
9​
10import { MOBILE_TEXT_CLASSES } from "../../lib/typography";
11​
12import { cn } from "../../lib/cn";
13​
14export type AppTextProps = RNTextProps & {
15 readonly className?: string;
16 readonly textRole?: keyof typeof MOBILE_TEXT_CLASSES;
17};
18​
19/**
20 * Thin wrapper around RN Text with default font-family and foreground color.
21 * Uses Uniwind className — no manual style parsing.
22 */
23export function AppText({ className, textRole, ...props }: AppTextProps) {
24 return (
25 <RNText
26 className={cn(
27 "font-sans text-foreground",
28 textRole && MOBILE_TEXT_CLASSES[textRole],
29 className,
30 )}
31 selectionColorClassName={Platform.OS === "android" ? "accent-focus/32" : undefined}
32 {...props}
33 />
34 );
36​
37export type AppTextInputProps = Omit<RNTextInputProps, "placeholderTextColor"> & {
38 readonly className?: string;
39 readonly ref?: React.Ref<TextInputInstance>;
40};
41​
42export function AppTextInput({ className, ref, ...props }: AppTextInputProps) {
43 return (
44 <RNTextInput
45 ref={ref}
46 className={cn(
47 "min-h-13.5 rounded-2xl border border-input-border bg-input px-3.5 py-3 font-sans text-base text-foreground",
48 className,
49 )}
50 placeholderTextColorClassName="accent-placeholder"
51 selectionColorClassName={"accent-focus/32"}
52 cursorColorClassName={"accent-focus"}
53 selectionHandleColorClassName={Platform.OS === "android" ? "accent-focus" : undefined}
54 {...props}
55 />
56 );