Skip to content

Commit f3b03d0

Browse files
Merge branch 'main' into app-bars
2 parents 7d84480 + b954525 commit f3b03d0

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,17 @@ export const MyComponent: React.FC = () => {
338338

339339
</details>
340340
</details>
341+
<details><summary>Badge</summary>
342+
</br>
343+
344+
**Properties**
345+
| name | description | type | default |
346+
| ------ | ------ | ------ | ----|
347+
| value | required | string | - |
348+
| valueStyle | - | TextStyle | - |
349+
350+
![badge light theme](https://ik.imagekit.io/Computools/rn-material-components/badge_light.png?updatedAt=1733926687727)
351+
![badge dark theme](https://ik.imagekit.io/Computools/rn-material-components/badge_dark.png?updatedAt=1733926687741)
341352
</details>
342353
<details><summary>Buttons</summary>
343354
<br />

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,5 +1,7 @@
11
export * from './icons';
22

3+
export {Badge, type BadgeProps} from './badge/Badge.component';
4+
35
export {Divider, type DividerProps} from './divider/Divider.component';
46

57
export {

0 commit comments

Comments
 (0)