Skip to content

Commit 7d8f032

Browse files
feat: implemented badge
1 parent 1a4746e commit 7d8f032

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/badge/Badge.component.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
import {View, Text, type ViewProps, type StyleProp, type TextStyle} from 'react-native';
3+
4+
import {styles} from './badge.styles';
5+
import {useTheme} from '../theme/useTheme.hook';
6+
import {useTypography} from '../typography/useTypography.component';
7+
8+
export interface BadgeProps extends ViewProps {
9+
value: string;
10+
11+
valueStyle?: StyleProp<TextStyle>;
12+
}
13+
14+
export const Badge: React.FC<BadgeProps> = ({value, style, valueStyle, ...props}) => {
15+
const {error} = useTheme();
16+
const {labelSmall} = useTypography();
17+
18+
return (
19+
<View style={[styles.container, {backgroundColor: error.background}, style]} {...props}>
20+
<Text style={[labelSmall, {color: error.text}, valueStyle]}>{value}</Text>
21+
</View>
22+
);
23+
};

src/badge/badge.styles.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import {StyleSheet} from 'react-native';
2+
3+
export const styles = StyleSheet.create({
4+
container: {
5+
alignItems: 'center',
6+
justifyContent: 'center',
7+
8+
paddingHorizontal: 4,
9+
minWidth: 16,
10+
height: 16,
11+
borderRadius: 100,
12+
},
13+
});

src/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export {Badge, type BadgeProps} from './badge/Badge.component';
2+
13
export {Divider, type DividerProps} from './divider/Divider.component';
24

35
export {BottomSheet, type BottomSheetProps, type BottomSheetRef} from './sheets/bottom-sheet/BottomSheet.component';

0 commit comments

Comments
 (0)