mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 23:59:08 +00:00
30 lines
808 B
TypeScript
30 lines
808 B
TypeScript
import { Platform, Text as RNText, type TextProps } from "react-native";
|
|
|
|
interface CustomTextProps extends TextProps {
|
|
className?: string;
|
|
}
|
|
|
|
export function Text({ className, ...props }: CustomTextProps) {
|
|
if (Platform.isTV)
|
|
return (
|
|
<RNText allowFontScaling={false} className={clsx(className)} {...props} />
|
|
);
|
|
|
|
return (
|
|
<RNText allowFontScaling={false} className={clsx(className)} {...props} />
|
|
);
|
|
}
|
|
|
|
const clsx = (className?: string) => {
|
|
const colorClassRegex = /\btext-[a-z]+-\d+\b/;
|
|
const hasColorClass = className ? colorClassRegex.test(className) : false;
|
|
const defaultClassName = "text-white";
|
|
const classes = [
|
|
...(hasColorClass ? [] : [defaultClassName]),
|
|
...(className ? [className] : []),
|
|
]
|
|
.filter(Boolean)
|
|
.join(" ");
|
|
return classes;
|
|
};
|