@umituz/react-native-design-system 2.2.0 → 2.3.0

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.0",
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",
@@ -70,3 +70,12 @@ 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';
@@ -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,7 @@ export {
142
142
  AtomicProgress,
143
143
  AtomicPicker,
144
144
  AtomicDatePicker,
145
+ AtomicSkeleton,
145
146
  type IconName,
146
147
  type IconSize,
147
148
  type IconColor,
@@ -167,6 +168,10 @@ export {
167
168
  type PickerOption,
168
169
  type PickerSize,
169
170
  type AtomicDatePickerProps,
171
+ type AtomicSkeletonProps,
172
+ type SkeletonPattern,
173
+ type SkeletonConfig,
174
+ SKELETON_PATTERNS,
170
175
  } from './atoms';
171
176
 
172
177
  // =============================================================================