@umituz/react-native-design-system 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/atoms/AtomicBadge.tsx +121 -0
- package/src/atoms/index.ts +8 -0
- package/src/index.ts +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive and safe area utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -105,4 +105,4 @@
|
|
|
105
105
|
"README.md",
|
|
106
106
|
"LICENSE"
|
|
107
107
|
]
|
|
108
|
-
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AtomicBadge Component
|
|
3
|
+
* Reusable badge for labels, status indicators, and tags
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from "react";
|
|
7
|
+
import { View, StyleSheet, type StyleProp, type ViewStyle, type TextStyle } from "react-native";
|
|
8
|
+
import { AtomicText } from "./AtomicText";
|
|
9
|
+
import { AtomicIcon, type IconName } from "./AtomicIcon";
|
|
10
|
+
import { useAppDesignTokens } from "../theme";
|
|
11
|
+
|
|
12
|
+
export type BadgeVariant = "primary" | "secondary" | "success" | "warning" | "error" | "info";
|
|
13
|
+
export type BadgeSize = "sm" | "md" | "lg";
|
|
14
|
+
|
|
15
|
+
export interface AtomicBadgeProps {
|
|
16
|
+
/** Badge text content */
|
|
17
|
+
text: string;
|
|
18
|
+
/** Visual variant */
|
|
19
|
+
variant?: BadgeVariant;
|
|
20
|
+
/** Size preset */
|
|
21
|
+
size?: BadgeSize;
|
|
22
|
+
/** Optional icon name (Ionicons) */
|
|
23
|
+
icon?: IconName;
|
|
24
|
+
/** Icon position */
|
|
25
|
+
iconPosition?: "left" | "right";
|
|
26
|
+
/** Custom container style */
|
|
27
|
+
style?: StyleProp<ViewStyle>;
|
|
28
|
+
/** Custom text style */
|
|
29
|
+
textStyle?: StyleProp<TextStyle>;
|
|
30
|
+
/** Test ID for testing */
|
|
31
|
+
testID?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const SIZE_CONFIG = {
|
|
35
|
+
sm: { paddingH: 6, paddingV: 2, fontSize: 10, iconSize: 10, gap: 3, radius: 4 },
|
|
36
|
+
md: { paddingH: 8, paddingV: 4, fontSize: 11, iconSize: 12, gap: 4, radius: 6 },
|
|
37
|
+
lg: { paddingH: 12, paddingV: 6, fontSize: 13, iconSize: 14, gap: 5, radius: 8 },
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const AtomicBadge: React.FC<AtomicBadgeProps> = React.memo(({
|
|
41
|
+
text,
|
|
42
|
+
variant = "primary",
|
|
43
|
+
size = "md",
|
|
44
|
+
icon,
|
|
45
|
+
iconPosition = "left",
|
|
46
|
+
style,
|
|
47
|
+
textStyle,
|
|
48
|
+
testID,
|
|
49
|
+
}) => {
|
|
50
|
+
const tokens = useAppDesignTokens();
|
|
51
|
+
const sizeConfig = SIZE_CONFIG[size];
|
|
52
|
+
|
|
53
|
+
const getVariantColors = () => {
|
|
54
|
+
switch (variant) {
|
|
55
|
+
case "primary":
|
|
56
|
+
return { bg: tokens.colors.primaryLight, text: tokens.colors.primary };
|
|
57
|
+
case "secondary":
|
|
58
|
+
return { bg: tokens.colors.surfaceSecondary, text: tokens.colors.textSecondary };
|
|
59
|
+
case "success":
|
|
60
|
+
return { bg: tokens.colors.successLight, text: tokens.colors.success };
|
|
61
|
+
case "warning":
|
|
62
|
+
return { bg: tokens.colors.warningLight, text: tokens.colors.warning };
|
|
63
|
+
case "error":
|
|
64
|
+
return { bg: tokens.colors.errorLight, text: tokens.colors.error };
|
|
65
|
+
case "info":
|
|
66
|
+
return { bg: tokens.colors.infoLight, text: tokens.colors.info };
|
|
67
|
+
default:
|
|
68
|
+
return { bg: tokens.colors.primaryLight, text: tokens.colors.primary };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const colors = getVariantColors();
|
|
73
|
+
|
|
74
|
+
const containerStyle: StyleProp<ViewStyle> = [
|
|
75
|
+
styles.container,
|
|
76
|
+
{
|
|
77
|
+
backgroundColor: colors.bg,
|
|
78
|
+
paddingHorizontal: sizeConfig.paddingH,
|
|
79
|
+
paddingVertical: sizeConfig.paddingV,
|
|
80
|
+
borderRadius: sizeConfig.radius,
|
|
81
|
+
gap: sizeConfig.gap,
|
|
82
|
+
flexDirection: iconPosition === "right" ? "row-reverse" : "row",
|
|
83
|
+
},
|
|
84
|
+
style,
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<View style={containerStyle} testID={testID}>
|
|
89
|
+
{icon && (
|
|
90
|
+
<AtomicIcon
|
|
91
|
+
name={icon}
|
|
92
|
+
customSize={sizeConfig.iconSize}
|
|
93
|
+
customColor={colors.text}
|
|
94
|
+
/>
|
|
95
|
+
)}
|
|
96
|
+
<AtomicText
|
|
97
|
+
type="labelSmall"
|
|
98
|
+
style={[
|
|
99
|
+
{
|
|
100
|
+
color: colors.text,
|
|
101
|
+
fontSize: sizeConfig.fontSize,
|
|
102
|
+
fontWeight: "700",
|
|
103
|
+
},
|
|
104
|
+
textStyle,
|
|
105
|
+
]}
|
|
106
|
+
>
|
|
107
|
+
{text}
|
|
108
|
+
</AtomicText>
|
|
109
|
+
</View>
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
AtomicBadge.displayName = "AtomicBadge";
|
|
114
|
+
|
|
115
|
+
const styles = StyleSheet.create({
|
|
116
|
+
container: {
|
|
117
|
+
alignSelf: "flex-start",
|
|
118
|
+
alignItems: "center",
|
|
119
|
+
justifyContent: "center",
|
|
120
|
+
},
|
|
121
|
+
});
|
package/src/atoms/index.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -143,6 +143,7 @@ export {
|
|
|
143
143
|
AtomicPicker,
|
|
144
144
|
AtomicDatePicker,
|
|
145
145
|
AtomicSkeleton,
|
|
146
|
+
AtomicBadge,
|
|
146
147
|
type IconName,
|
|
147
148
|
type IconSize,
|
|
148
149
|
type IconColor,
|
|
@@ -172,6 +173,9 @@ export {
|
|
|
172
173
|
type SkeletonPattern,
|
|
173
174
|
type SkeletonConfig,
|
|
174
175
|
SKELETON_PATTERNS,
|
|
176
|
+
type AtomicBadgeProps,
|
|
177
|
+
type BadgeVariant,
|
|
178
|
+
type BadgeSize,
|
|
175
179
|
} from './atoms';
|
|
176
180
|
|
|
177
181
|
// =============================================================================
|