@umituz/react-native-design-system 2.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-design-system",
3
- "version": "2.2.0",
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
+ });
@@ -70,3 +70,20 @@ export {
70
70
 
71
71
  // DatePicker
72
72
  export { AtomicDatePicker, type AtomicDatePickerProps } from './AtomicDatePicker';
73
+
74
+ // Skeleton
75
+ export {
76
+ AtomicSkeleton,
77
+ type AtomicSkeletonProps,
78
+ type SkeletonPattern,
79
+ type SkeletonConfig,
80
+ SKELETON_PATTERNS,
81
+ } from './skeleton';
82
+
83
+ // Badge
84
+ export {
85
+ AtomicBadge,
86
+ type AtomicBadgeProps,
87
+ type BadgeVariant,
88
+ type BadgeSize,
89
+ } from './AtomicBadge';
@@ -0,0 +1,143 @@
1
+ /**
2
+ * AtomicSkeleton - Skeleton Loader Component
3
+ *
4
+ * Skeleton placeholder loader with shimmer animation for loading states.
5
+ *
6
+ * @example
7
+ * ```tsx
8
+ * // List skeleton
9
+ * <AtomicSkeleton pattern="list" count={5} />
10
+ *
11
+ * // Card skeleton
12
+ * <AtomicSkeleton pattern="card" count={3} />
13
+ *
14
+ * // Custom skeleton
15
+ * <AtomicSkeleton
16
+ * pattern="custom"
17
+ * custom={[
18
+ * { width: '100%', height: 200, borderRadius: 12 },
19
+ * { width: '80%', height: 20, borderRadius: 4 }
20
+ * ]}
21
+ * />
22
+ * ```
23
+ */
24
+
25
+ import React, { useEffect, useRef } from 'react';
26
+ import { View, StyleSheet, Animated, type StyleProp, type ViewStyle } from 'react-native';
27
+ import { useAppDesignTokens } from '../../theme';
28
+ import type { SkeletonPattern, SkeletonConfig } from './AtomicSkeleton.types';
29
+ import { SKELETON_PATTERNS } from './AtomicSkeleton.types';
30
+
31
+ const SHIMMER_DURATION = 1200;
32
+
33
+ export interface AtomicSkeletonProps {
34
+ /** Skeleton pattern preset */
35
+ pattern?: SkeletonPattern;
36
+ /** Custom skeleton configurations */
37
+ custom?: SkeletonConfig[];
38
+ /** Number of skeleton items to render */
39
+ count?: number;
40
+ /** Custom container style */
41
+ style?: StyleProp<ViewStyle>;
42
+ /** Disable shimmer animation */
43
+ disableAnimation?: boolean;
44
+ /** Test ID for testing */
45
+ testID?: string;
46
+ }
47
+
48
+ /**
49
+ * Skeleton loader component with shimmer animation
50
+ *
51
+ * Provides visual feedback during content loading with customizable patterns
52
+ */
53
+ export const AtomicSkeleton: React.FC<AtomicSkeletonProps> = ({
54
+ pattern = 'list',
55
+ custom,
56
+ count = 1,
57
+ style,
58
+ disableAnimation = false,
59
+ testID,
60
+ }) => {
61
+ const tokens = useAppDesignTokens();
62
+ const skeletonConfigs = pattern === 'custom' && custom
63
+ ? custom
64
+ : SKELETON_PATTERNS[pattern];
65
+
66
+ const shimmerAnim = useRef(new Animated.Value(0)).current;
67
+
68
+ useEffect(() => {
69
+ if (disableAnimation) return;
70
+
71
+ const shimmerAnimation = Animated.loop(
72
+ Animated.sequence([
73
+ Animated.timing(shimmerAnim, {
74
+ toValue: 1,
75
+ duration: SHIMMER_DURATION,
76
+ useNativeDriver: false,
77
+ }),
78
+ Animated.timing(shimmerAnim, {
79
+ toValue: 0,
80
+ duration: 0,
81
+ useNativeDriver: false,
82
+ }),
83
+ ])
84
+ );
85
+
86
+ shimmerAnimation.start();
87
+
88
+ return () => {
89
+ shimmerAnimation.stop();
90
+ };
91
+ }, [shimmerAnim, disableAnimation]);
92
+
93
+ const backgroundColor = shimmerAnim.interpolate({
94
+ inputRange: [0, 0.5, 1],
95
+ outputRange: [
96
+ tokens.colors.surfaceSecondary,
97
+ tokens.colors.border,
98
+ tokens.colors.surfaceSecondary,
99
+ ],
100
+ });
101
+
102
+ const renderSkeletonItem = (index: number) => (
103
+ <View key={`skeleton-group-${index}`} style={styles.skeletonGroup}>
104
+ {skeletonConfigs.map((config, configIndex) => (
105
+ <Animated.View
106
+ key={`skeleton-${index}-${configIndex}`}
107
+ style={[
108
+ styles.skeleton,
109
+ {
110
+ width: config.width as number | `${number}%` | undefined,
111
+ height: config.height,
112
+ borderRadius: config.borderRadius,
113
+ marginBottom: config.marginBottom,
114
+ backgroundColor: disableAnimation
115
+ ? tokens.colors.surfaceSecondary
116
+ : backgroundColor,
117
+ } as any,
118
+ ]}
119
+ />
120
+ ))}
121
+ </View>
122
+ );
123
+
124
+ return (
125
+ <View style={[styles.container, style]} testID={testID}>
126
+ {Array.from({ length: count }).map((_, index) => renderSkeletonItem(index))}
127
+ </View>
128
+ );
129
+ };
130
+
131
+ AtomicSkeleton.displayName = 'AtomicSkeleton';
132
+
133
+ const styles = StyleSheet.create({
134
+ container: {
135
+ width: '100%',
136
+ },
137
+ skeletonGroup: {
138
+ width: '100%',
139
+ },
140
+ skeleton: {
141
+ overflow: 'hidden',
142
+ },
143
+ });
@@ -0,0 +1,55 @@
1
+ /**
2
+ * AtomicSkeleton Types
3
+ *
4
+ * Type definitions and configurations for skeleton loading states.
5
+ */
6
+
7
+ /**
8
+ * Skeleton loader pattern presets
9
+ */
10
+ export type SkeletonPattern = 'list' | 'card' | 'profile' | 'text' | 'custom';
11
+
12
+ /**
13
+ * Skeleton loader configuration for individual skeleton elements
14
+ */
15
+ export interface SkeletonConfig {
16
+ /** Width of skeleton element (number in pixels or percentage string) */
17
+ width?: number | string;
18
+ /** Height of skeleton element in pixels */
19
+ height?: number;
20
+ /** Border radius in pixels */
21
+ borderRadius?: number;
22
+ /** Bottom margin in pixels */
23
+ marginBottom?: number;
24
+ }
25
+
26
+ /**
27
+ * Predefined skeleton pattern configurations
28
+ *
29
+ * - **list**: Single row skeleton for list items
30
+ * - **card**: Card-style skeleton with image and text placeholders
31
+ * - **profile**: Profile skeleton with avatar and text
32
+ * - **text**: Multiple text line skeletons
33
+ * - **custom**: Use custom configuration
34
+ */
35
+ export const SKELETON_PATTERNS: Record<SkeletonPattern, SkeletonConfig[]> = {
36
+ list: [
37
+ { width: '100%', height: 60, borderRadius: 8, marginBottom: 12 },
38
+ ],
39
+ card: [
40
+ { width: '100%', height: 200, borderRadius: 12, marginBottom: 16 },
41
+ { width: '80%', height: 20, borderRadius: 4, marginBottom: 8 },
42
+ { width: '60%', height: 16, borderRadius: 4, marginBottom: 0 },
43
+ ],
44
+ profile: [
45
+ { width: 80, height: 80, borderRadius: 40, marginBottom: 16 },
46
+ { width: '60%', height: 24, borderRadius: 4, marginBottom: 8 },
47
+ { width: '40%', height: 16, borderRadius: 4, marginBottom: 0 },
48
+ ],
49
+ text: [
50
+ { width: '100%', height: 16, borderRadius: 4, marginBottom: 8 },
51
+ { width: '90%', height: 16, borderRadius: 4, marginBottom: 8 },
52
+ { width: '95%', height: 16, borderRadius: 4, marginBottom: 0 },
53
+ ],
54
+ custom: [],
55
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * AtomicSkeleton - Skeleton Loader
3
+ *
4
+ * Exports skeleton loader component and types
5
+ */
6
+
7
+ export { AtomicSkeleton, type AtomicSkeletonProps } from './AtomicSkeleton';
8
+ export type { SkeletonPattern, SkeletonConfig } from './AtomicSkeleton.types';
9
+ export { SKELETON_PATTERNS } from './AtomicSkeleton.types';
package/src/index.ts CHANGED
@@ -142,6 +142,8 @@ export {
142
142
  AtomicProgress,
143
143
  AtomicPicker,
144
144
  AtomicDatePicker,
145
+ AtomicSkeleton,
146
+ AtomicBadge,
145
147
  type IconName,
146
148
  type IconSize,
147
149
  type IconColor,
@@ -167,6 +169,13 @@ export {
167
169
  type PickerOption,
168
170
  type PickerSize,
169
171
  type AtomicDatePickerProps,
172
+ type AtomicSkeletonProps,
173
+ type SkeletonPattern,
174
+ type SkeletonConfig,
175
+ SKELETON_PATTERNS,
176
+ type AtomicBadgeProps,
177
+ type BadgeVariant,
178
+ type BadgeSize,
170
179
  } from './atoms';
171
180
 
172
181
  // =============================================================================