mirror of
https://github.com/DocNR/POWR.git
synced 2025-04-19 10:51:19 +00:00
25 lines
778 B
TypeScript
25 lines
778 B
TypeScript
import * as Slot from '@rn-primitives/slot';
|
|
import type { SlottableTextProps, TextRef } from '@rn-primitives/types';
|
|
import * as React from 'react';
|
|
import { Text as RNText } from 'react-native';
|
|
import { cn } from '~/lib/utils';
|
|
|
|
const TextClassContext = React.createContext<string | undefined>(undefined);
|
|
|
|
const Text = React.forwardRef<TextRef, SlottableTextProps>(
|
|
({ className, asChild = false, ...props }, ref) => {
|
|
const textClass = React.useContext(TextClassContext);
|
|
const Component = asChild ? Slot.Text : RNText;
|
|
return (
|
|
<Component
|
|
className={cn('text-base text-foreground web:select-text', textClass, className)}
|
|
ref={ref}
|
|
{...props}
|
|
/>
|
|
);
|
|
}
|
|
);
|
|
Text.displayName = 'Text';
|
|
|
|
export { Text, TextClassContext };
|