@umituz/react-native-design-system 2.4.4 → 2.4.6

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.4.4",
3
+ "version": "2.4.6",
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",
@@ -1,30 +1,41 @@
1
1
  /**
2
2
  * AtomicCard Component
3
- *
3
+ *
4
4
  * A simple, styled card container component
5
5
  */
6
6
 
7
7
  import React from 'react';
8
- import { View, StyleSheet, type ViewStyle, type StyleProp } from 'react-native';
8
+ import {
9
+ View,
10
+ Pressable,
11
+ StyleSheet,
12
+ type ViewStyle,
13
+ type StyleProp,
14
+ type GestureResponderEvent,
15
+ } from 'react-native';
9
16
  import { useAppDesignTokens } from '../theme';
10
17
 
11
18
  export type AtomicCardVariant = 'elevated' | 'outlined' | 'filled';
12
19
  export type AtomicCardPadding = 'none' | 'sm' | 'md' | 'lg';
13
20
 
14
21
  export interface AtomicCardProps {
15
- children: React.ReactNode;
16
- variant?: AtomicCardVariant;
17
- padding?: AtomicCardPadding;
18
- style?: StyleProp<ViewStyle>;
19
- testID?: string;
22
+ children: React.ReactNode;
23
+ variant?: AtomicCardVariant;
24
+ padding?: AtomicCardPadding;
25
+ style?: StyleProp<ViewStyle>;
26
+ testID?: string;
27
+ onPress?: (event: GestureResponderEvent) => void;
28
+ disabled?: boolean;
20
29
  }
21
30
 
22
31
  export const AtomicCard: React.FC<AtomicCardProps> = ({
23
- children,
24
- variant = 'elevated',
25
- padding = 'md',
26
- style,
27
- testID,
32
+ children,
33
+ variant = 'elevated',
34
+ padding = 'md',
35
+ style,
36
+ testID,
37
+ onPress,
38
+ disabled,
28
39
  }) => {
29
40
  const tokens = useAppDesignTokens();
30
41
 
@@ -58,24 +69,36 @@ export const AtomicCard: React.FC<AtomicCardProps> = ({
58
69
  }
59
70
  };
60
71
 
72
+ const cardStyle = [
73
+ styles.card,
74
+ { borderRadius: tokens.borders.radius.md },
75
+ { padding: paddingValues[padding] },
76
+ getVariantStyle(),
77
+ style,
78
+ ];
79
+
80
+ if (onPress) {
61
81
  return (
62
- <View
63
- style={[
64
- styles.card,
65
- { borderRadius: tokens.borders.radius.md },
66
- { padding: paddingValues[padding] },
67
- getVariantStyle(),
68
- style,
69
- ]}
70
- testID={testID}
71
- >
72
- {children}
73
- </View>
82
+ <Pressable
83
+ style={cardStyle}
84
+ testID={testID}
85
+ onPress={onPress}
86
+ disabled={disabled}
87
+ >
88
+ {children}
89
+ </Pressable>
74
90
  );
91
+ }
92
+
93
+ return (
94
+ <View style={cardStyle} testID={testID}>
95
+ {children}
96
+ </View>
97
+ );
75
98
  };
76
99
 
77
100
  const styles = StyleSheet.create({
78
- card: {
79
- overflow: 'hidden',
80
- },
101
+ card: {
102
+ overflow: 'hidden',
103
+ },
81
104
  });
@@ -22,8 +22,17 @@
22
22
  * ```
23
23
  */
24
24
 
25
- import React, { useEffect, useRef } from 'react';
26
- import { View, StyleSheet, Animated, type StyleProp, type ViewStyle } from 'react-native';
25
+ import React, { useEffect } from 'react';
26
+ import { View, StyleSheet, type StyleProp, type ViewStyle } from 'react-native';
27
+ import {
28
+ useSharedValue,
29
+ useAnimatedStyle,
30
+ withRepeat,
31
+ withSequence,
32
+ withTiming,
33
+ Easing,
34
+ } from 'react-native-reanimated';
35
+ import Animated from 'react-native-reanimated';
27
36
  import { useAppDesignTokens } from '../../theme';
28
37
  import type { SkeletonPattern, SkeletonConfig } from './AtomicSkeleton.types';
29
38
  import { SKELETON_PATTERNS } from './AtomicSkeleton.types';
@@ -50,6 +59,53 @@ export interface AtomicSkeletonProps {
50
59
  *
51
60
  * Provides visual feedback during content loading with customizable patterns
52
61
  */
62
+ const SkeletonItem: React.FC<{
63
+ config: SkeletonConfig;
64
+ baseColor: string;
65
+ highlightColor: string;
66
+ disableAnimation: boolean;
67
+ }> = ({ config, baseColor, highlightColor, disableAnimation }) => {
68
+ const opacity = useSharedValue(0);
69
+
70
+ useEffect(() => {
71
+ if (disableAnimation) return;
72
+
73
+ opacity.value = withRepeat(
74
+ withSequence(
75
+ withTiming(1, { duration: SHIMMER_DURATION / 2, easing: Easing.ease }),
76
+ withTiming(0, { duration: SHIMMER_DURATION / 2, easing: Easing.ease })
77
+ ),
78
+ -1,
79
+ false
80
+ );
81
+ }, [opacity, disableAnimation]);
82
+
83
+ const animatedStyle = useAnimatedStyle(() => ({
84
+ backgroundColor: disableAnimation
85
+ ? baseColor
86
+ : opacity.value === 0
87
+ ? baseColor
88
+ : highlightColor,
89
+ opacity: disableAnimation ? 1 : 0.5 + opacity.value * 0.5,
90
+ }));
91
+
92
+ return (
93
+ <Animated.View
94
+ style={[
95
+ styles.skeleton,
96
+ {
97
+ width: config.width as number | `${number}%` | undefined,
98
+ height: config.height,
99
+ borderRadius: config.borderRadius,
100
+ marginBottom: config.marginBottom,
101
+ backgroundColor: baseColor,
102
+ },
103
+ animatedStyle,
104
+ ]}
105
+ />
106
+ );
107
+ };
108
+
53
109
  export const AtomicSkeleton: React.FC<AtomicSkeletonProps> = ({
54
110
  pattern = 'list',
55
111
  custom,
@@ -63,59 +119,15 @@ export const AtomicSkeleton: React.FC<AtomicSkeletonProps> = ({
63
119
  ? custom
64
120
  : SKELETON_PATTERNS[pattern];
65
121
 
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
122
  const renderSkeletonItem = (index: number) => (
103
123
  <View key={`skeleton-group-${index}`} style={styles.skeletonGroup}>
104
124
  {skeletonConfigs.map((config, configIndex) => (
105
- <Animated.View
125
+ <SkeletonItem
106
126
  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
- ]}
127
+ config={config}
128
+ baseColor={tokens.colors.surfaceSecondary}
129
+ highlightColor={tokens.colors.border}
130
+ disableAnimation={disableAnimation}
119
131
  />
120
132
  ))}
121
133
  </View>