mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2import {Text as RNText, TextProps} from 'react-native'
3import {s, lh} from 'lib/styles'
4import {useTheme, TypographyVariant} from 'lib/ThemeContext'
5
6export type CustomTextProps = TextProps & {
7 type?: TypographyVariant
8 lineHeight?: number
9 title?: string
10 dataSet?: Record<string, string | number>
11}
12
13export function Text({
14 type = 'md',
15 children,
16 lineHeight,
17 style,
18 title,
19 dataSet,
20 ...props
21}: React.PropsWithChildren<CustomTextProps>) {
22 const theme = useTheme()
23 const typography = theme.typography[type]
24 const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined
25 return (
26 <RNText
27 style={[s.black, typography, lineHeightStyle, style]}
28 // @ts-ignore web only -esb
29 dataSet={Object.assign({tooltip: title}, dataSet || {})}
30 {...props}>
31 {children}
32 </RNText>
33 )
34}