Skip to content

Commit 6e50871

Browse files
committed
feat: add TopBar component with Bar and AppBar exports; refactor Txt component for skeleton support
1 parent a79402e commit 6e50871

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/components/Text.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Medium } from '@utils/fonts'
2-
import type { TextProps } from 'react-native'
2+
import { useMemo } from 'react'
3+
import { View, type TextProps } from 'react-native'
34

45
export function TxtAcc({ children, size, style, ...rest }: TextProps & { size?: number }) {
56
return (
@@ -9,10 +10,21 @@ export function TxtAcc({ children, size, style, ...rest }: TextProps & { size?:
910
)
1011
}
1112

12-
export function Txt({ children, size, style, ...rest }: TextProps & { size?: number }) {
13+
type TxtProps = TextProps & {
14+
size?: number
15+
skeleton?: boolean | string | number | object | undefined | null
16+
}
17+
18+
export function Txt({ children, size, style, skeleton = true, ...rest }: TxtProps) {
19+
if (skeleton === undefined) return <TxtSkeleton />
1320
return (
1421
<Medium className='text-zinc-500' style={[{ fontSize: size || 11.5 }, style]} {...rest}>
1522
{children}
1623
</Medium>
1724
)
1825
}
26+
27+
export function TxtSkeleton() {
28+
const width = useMemo(() => Math.random() * 50 + 30, [])
29+
return <View className='rounded-md bg-zinc-200 dark:bg-zinc-800' style={{ height: 16, width: width }} />
30+
}

src/components/TopBar.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { View } from 'react-native'
2+
3+
export const Bar = () => (
4+
<View className='mx-auto h-1.5 w-28 justify-between rounded-full bg-zinc-200 dark:bg-zinc-800' />
5+
)
6+
7+
export const AppBar = () => (
8+
<View className='pb-3.5 pt-4'>
9+
<Bar />
10+
</View>
11+
)

0 commit comments

Comments
 (0)