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

AppText.tsx

53 lines1.5 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​
19export function AppText({ className, textRole, ...props }: AppTextProps) {
20 return (
21 <RNText
22 className={cn(
23 "font-sans text-foreground",
24 textRole && MOBILE_TEXT_CLASSES[textRole],
25 className,
26 )}
27 selectionColorClassName={Platform.OS === "android" ? "accent-focus/32" : undefined}
28 {...props}
29 />
30 );
32​
33export type AppTextInputProps = Omit<RNTextInputProps, "placeholderTextColor"> & {
34 readonly className?: string;
35 readonly ref?: React.Ref<TextInputInstance>;
36};
37​
38export function AppTextInput({ className, ref, ...props }: AppTextInputProps) {
39 return (
40 <RNTextInput
41 ref={ref}
42 className={cn(
43 "min-h-13.5 rounded-2xl border border-input-border bg-input px-3.5 py-3 font-sans text-base text-foreground",
44 className,
45 )}
46 placeholderTextColorClassName="accent-placeholder"
47 selectionColorClassName={"accent-focus/32"}
48 cursorColorClassName={"accent-focus"}
49 selectionHandleColorClassName={Platform.OS === "android" ? "accent-focus" : undefined}
50 {...props}
51 />
52 );