@umituz/react-native-design-system 2.0.0 → 2.0.2
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 +1 -1
- package/src/atoms/AtomicCard.tsx +84 -0
- package/src/atoms/index.ts +30 -30
- package/src/index.ts +4 -0
- package/src/molecules/Divider/Divider.tsx +187 -0
- package/src/molecules/Divider/index.ts +2 -0
- package/src/molecules/Divider/types.ts +88 -0
- package/src/molecules/index.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/react-native-design-system",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography and responsive utilities",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AtomicCard Component
|
|
3
|
+
*
|
|
4
|
+
* A simple, styled card container component
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { View, StyleSheet, type ViewStyle, type StyleProp } from 'react-native';
|
|
9
|
+
import { useAppDesignTokens } from '../theme';
|
|
10
|
+
|
|
11
|
+
export type AtomicCardVariant = 'elevated' | 'outlined' | 'filled';
|
|
12
|
+
export type AtomicCardPadding = 'none' | 'sm' | 'md' | 'lg';
|
|
13
|
+
|
|
14
|
+
export interface AtomicCardProps {
|
|
15
|
+
children: React.ReactNode;
|
|
16
|
+
variant?: AtomicCardVariant;
|
|
17
|
+
padding?: AtomicCardPadding;
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
testID?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const AtomicCard: React.FC<AtomicCardProps> = ({
|
|
23
|
+
children,
|
|
24
|
+
variant = 'elevated',
|
|
25
|
+
padding = 'md',
|
|
26
|
+
style,
|
|
27
|
+
testID,
|
|
28
|
+
}) => {
|
|
29
|
+
const tokens = useAppDesignTokens();
|
|
30
|
+
|
|
31
|
+
const paddingValues: Record<AtomicCardPadding, number> = {
|
|
32
|
+
none: 0,
|
|
33
|
+
sm: tokens.spacing.sm,
|
|
34
|
+
md: tokens.spacing.md,
|
|
35
|
+
lg: tokens.spacing.lg,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const getVariantStyle = (): ViewStyle => {
|
|
39
|
+
switch (variant) {
|
|
40
|
+
case 'elevated':
|
|
41
|
+
return {
|
|
42
|
+
backgroundColor: tokens.colors.surface,
|
|
43
|
+
shadowColor: '#000',
|
|
44
|
+
shadowOffset: { width: 0, height: 2 },
|
|
45
|
+
shadowOpacity: 0.1,
|
|
46
|
+
shadowRadius: 4,
|
|
47
|
+
elevation: 2,
|
|
48
|
+
};
|
|
49
|
+
case 'outlined':
|
|
50
|
+
return {
|
|
51
|
+
backgroundColor: tokens.colors.surface,
|
|
52
|
+
borderWidth: 1,
|
|
53
|
+
borderColor: tokens.colors.outline,
|
|
54
|
+
};
|
|
55
|
+
case 'filled':
|
|
56
|
+
return {
|
|
57
|
+
backgroundColor: tokens.colors.surfaceVariant,
|
|
58
|
+
};
|
|
59
|
+
default:
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<View
|
|
66
|
+
style={[
|
|
67
|
+
styles.card,
|
|
68
|
+
{ borderRadius: tokens.borders.radius.md },
|
|
69
|
+
{ padding: paddingValues[padding] },
|
|
70
|
+
getVariantStyle(),
|
|
71
|
+
style,
|
|
72
|
+
]}
|
|
73
|
+
testID={testID}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
</View>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const styles = StyleSheet.create({
|
|
81
|
+
card: {
|
|
82
|
+
overflow: 'hidden',
|
|
83
|
+
},
|
|
84
|
+
});
|
package/src/atoms/index.ts
CHANGED
|
@@ -5,39 +5,39 @@
|
|
|
5
5
|
|
|
6
6
|
// Button
|
|
7
7
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
AtomicButton,
|
|
9
|
+
type AtomicButtonProps,
|
|
10
|
+
type ButtonVariant,
|
|
11
|
+
type ButtonSize,
|
|
12
12
|
} from './AtomicButton';
|
|
13
13
|
|
|
14
14
|
// Text
|
|
15
15
|
export { AtomicText, type AtomicTextProps } from './AtomicText';
|
|
16
16
|
|
|
17
|
-
// Card
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
// Card
|
|
18
|
+
export {
|
|
19
|
+
AtomicCard,
|
|
20
|
+
type AtomicCardProps,
|
|
21
|
+
type AtomicCardVariant,
|
|
22
|
+
type AtomicCardPadding,
|
|
23
|
+
} from './AtomicCard';
|
|
24
24
|
|
|
25
25
|
// Input
|
|
26
26
|
export {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
AtomicInput,
|
|
28
|
+
type AtomicInputProps,
|
|
29
|
+
type AtomicInputVariant,
|
|
30
|
+
type AtomicInputState,
|
|
31
|
+
type AtomicInputSize,
|
|
32
32
|
} from './AtomicInput';
|
|
33
33
|
|
|
34
34
|
// Icon
|
|
35
35
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
AtomicIcon,
|
|
37
|
+
type AtomicIconProps,
|
|
38
|
+
type IconSize,
|
|
39
|
+
type IconColor,
|
|
40
|
+
type IconName,
|
|
41
41
|
} from './AtomicIcon';
|
|
42
42
|
|
|
43
43
|
// Avatar
|
|
@@ -51,19 +51,19 @@ export { AtomicProgress, type AtomicProgressProps } from './AtomicProgress';
|
|
|
51
51
|
|
|
52
52
|
// Fab
|
|
53
53
|
export {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
AtomicFab,
|
|
55
|
+
type AtomicFabProps,
|
|
56
|
+
type FabSize,
|
|
57
|
+
type FabVariant,
|
|
58
|
+
getFabVariants,
|
|
59
59
|
} from './AtomicFab';
|
|
60
60
|
|
|
61
61
|
// Picker
|
|
62
62
|
export {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
AtomicPicker,
|
|
64
|
+
type AtomicPickerProps,
|
|
65
|
+
type PickerOption,
|
|
66
|
+
type PickerSize,
|
|
67
67
|
} from './AtomicPicker';
|
|
68
68
|
|
|
69
69
|
// DatePicker
|
package/src/index.ts
CHANGED
|
@@ -116,6 +116,7 @@ export {
|
|
|
116
116
|
AtomicIcon,
|
|
117
117
|
AtomicButton,
|
|
118
118
|
AtomicInput,
|
|
119
|
+
AtomicCard,
|
|
119
120
|
AtomicFab,
|
|
120
121
|
AtomicAvatar,
|
|
121
122
|
AtomicChip,
|
|
@@ -134,6 +135,9 @@ export {
|
|
|
134
135
|
type AtomicInputVariant,
|
|
135
136
|
type AtomicInputState,
|
|
136
137
|
type AtomicInputSize,
|
|
138
|
+
type AtomicCardProps,
|
|
139
|
+
type AtomicCardVariant,
|
|
140
|
+
type AtomicCardPadding,
|
|
137
141
|
type AtomicFabProps,
|
|
138
142
|
type FabSize,
|
|
139
143
|
type FabVariant,
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divider Domain - Divider Component
|
|
3
|
+
*
|
|
4
|
+
* Universal divider component for visual separation.
|
|
5
|
+
* Supports horizontal, vertical, and text dividers.
|
|
6
|
+
*
|
|
7
|
+
* @domain divider
|
|
8
|
+
* @layer presentation/components
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import { View, StyleSheet, type StyleProp, type ViewStyle } from 'react-native';
|
|
13
|
+
import { useAppDesignTokens } from '../../theme/hooks/useAppDesignTokens';
|
|
14
|
+
import { AtomicText } from '../../atoms/AtomicText';
|
|
15
|
+
import type { DividerOrientation, DividerStyle, DividerSpacing } from './types';
|
|
16
|
+
import {
|
|
17
|
+
DividerUtils,
|
|
18
|
+
DIVIDER_CONSTANTS,
|
|
19
|
+
} from './types';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Divider component props
|
|
23
|
+
*/
|
|
24
|
+
export interface DividerProps {
|
|
25
|
+
/** Orientation (horizontal or vertical) */
|
|
26
|
+
orientation?: DividerOrientation;
|
|
27
|
+
/** Line style (solid, dashed, dotted) */
|
|
28
|
+
lineStyle?: DividerStyle;
|
|
29
|
+
/** Spacing (margin) */
|
|
30
|
+
spacing?: DividerSpacing;
|
|
31
|
+
/** Custom color */
|
|
32
|
+
color?: string;
|
|
33
|
+
/** Custom thickness */
|
|
34
|
+
thickness?: number;
|
|
35
|
+
/** Text label (for text divider) */
|
|
36
|
+
text?: string;
|
|
37
|
+
/** Custom container style */
|
|
38
|
+
style?: StyleProp<ViewStyle>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Divider Component
|
|
43
|
+
*
|
|
44
|
+
* Visual separator for content sections.
|
|
45
|
+
* Supports horizontal, vertical, and text variants.
|
|
46
|
+
*
|
|
47
|
+
* USAGE:
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Horizontal divider (default)
|
|
50
|
+
* <Divider />
|
|
51
|
+
*
|
|
52
|
+
* // Vertical divider
|
|
53
|
+
* <Divider orientation="vertical" />
|
|
54
|
+
*
|
|
55
|
+
* // Text divider (OR separator)
|
|
56
|
+
* <Divider text="OR" />
|
|
57
|
+
*
|
|
58
|
+
* // Custom spacing
|
|
59
|
+
* <Divider spacing="large" />
|
|
60
|
+
*
|
|
61
|
+
* // Dashed style
|
|
62
|
+
* <Divider lineStyle="dashed" />
|
|
63
|
+
*
|
|
64
|
+
* // Custom color
|
|
65
|
+
* <Divider color="#FF0000" />
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export const Divider: React.FC<DividerProps> = ({
|
|
69
|
+
orientation = DIVIDER_CONSTANTS.DEFAULT_ORIENTATION,
|
|
70
|
+
lineStyle = DIVIDER_CONSTANTS.DEFAULT_STYLE,
|
|
71
|
+
spacing = DIVIDER_CONSTANTS.DEFAULT_SPACING,
|
|
72
|
+
color,
|
|
73
|
+
thickness = DIVIDER_CONSTANTS.DEFAULT_THICKNESS,
|
|
74
|
+
text,
|
|
75
|
+
style,
|
|
76
|
+
}) => {
|
|
77
|
+
const tokens = useAppDesignTokens();
|
|
78
|
+
const spacingValue = DividerUtils.getSpacing(spacing);
|
|
79
|
+
const borderColor = color || tokens.colors.border;
|
|
80
|
+
|
|
81
|
+
// Determine border style based on lineStyle
|
|
82
|
+
const getBorderStyle = (): 'solid' | 'dashed' | 'dotted' => {
|
|
83
|
+
return lineStyle;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Horizontal divider
|
|
87
|
+
if (orientation === 'horizontal' && !text) {
|
|
88
|
+
return (
|
|
89
|
+
<View
|
|
90
|
+
style={[
|
|
91
|
+
styles.horizontal,
|
|
92
|
+
{
|
|
93
|
+
marginVertical: spacingValue,
|
|
94
|
+
borderBottomWidth: thickness,
|
|
95
|
+
borderBottomColor: borderColor,
|
|
96
|
+
borderStyle: getBorderStyle(),
|
|
97
|
+
},
|
|
98
|
+
style,
|
|
99
|
+
]}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Vertical divider
|
|
105
|
+
if (orientation === 'vertical') {
|
|
106
|
+
return (
|
|
107
|
+
<View
|
|
108
|
+
style={[
|
|
109
|
+
styles.vertical,
|
|
110
|
+
{
|
|
111
|
+
marginHorizontal: spacingValue,
|
|
112
|
+
borderLeftWidth: thickness,
|
|
113
|
+
borderLeftColor: borderColor,
|
|
114
|
+
borderStyle: getBorderStyle(),
|
|
115
|
+
},
|
|
116
|
+
style,
|
|
117
|
+
]}
|
|
118
|
+
/>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Text divider (horizontal with text label)
|
|
123
|
+
if (text) {
|
|
124
|
+
return (
|
|
125
|
+
<View
|
|
126
|
+
style={[
|
|
127
|
+
styles.textContainer,
|
|
128
|
+
{
|
|
129
|
+
marginVertical: spacingValue,
|
|
130
|
+
},
|
|
131
|
+
style,
|
|
132
|
+
]}
|
|
133
|
+
>
|
|
134
|
+
<View
|
|
135
|
+
style={[
|
|
136
|
+
styles.textLine,
|
|
137
|
+
{
|
|
138
|
+
borderBottomWidth: thickness,
|
|
139
|
+
borderBottomColor: borderColor,
|
|
140
|
+
borderStyle: getBorderStyle(),
|
|
141
|
+
},
|
|
142
|
+
]}
|
|
143
|
+
/>
|
|
144
|
+
<AtomicText
|
|
145
|
+
type="bodySmall"
|
|
146
|
+
color="secondary"
|
|
147
|
+
style={styles.textLabel}
|
|
148
|
+
>
|
|
149
|
+
{text}
|
|
150
|
+
</AtomicText>
|
|
151
|
+
<View
|
|
152
|
+
style={[
|
|
153
|
+
styles.textLine,
|
|
154
|
+
{
|
|
155
|
+
borderBottomWidth: thickness,
|
|
156
|
+
borderBottomColor: borderColor,
|
|
157
|
+
borderStyle: getBorderStyle(),
|
|
158
|
+
},
|
|
159
|
+
]}
|
|
160
|
+
/>
|
|
161
|
+
</View>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
return null;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const styles = StyleSheet.create({
|
|
169
|
+
horizontal: {
|
|
170
|
+
width: '100%',
|
|
171
|
+
},
|
|
172
|
+
vertical: {
|
|
173
|
+
height: '100%',
|
|
174
|
+
},
|
|
175
|
+
textContainer: {
|
|
176
|
+
flexDirection: 'row',
|
|
177
|
+
alignItems: 'center',
|
|
178
|
+
width: '100%',
|
|
179
|
+
},
|
|
180
|
+
textLine: {
|
|
181
|
+
flex: 1,
|
|
182
|
+
},
|
|
183
|
+
textLabel: {
|
|
184
|
+
marginHorizontal: 12,
|
|
185
|
+
fontWeight: '500',
|
|
186
|
+
},
|
|
187
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divider Domain - Entity Definitions
|
|
3
|
+
*
|
|
4
|
+
* Core types and interfaces for dividers and separators.
|
|
5
|
+
* Simple visual separators for content sections.
|
|
6
|
+
*
|
|
7
|
+
* @domain divider
|
|
8
|
+
* @layer domain/entities
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Divider orientation
|
|
13
|
+
*/
|
|
14
|
+
export type DividerOrientation = 'horizontal' | 'vertical';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Divider style
|
|
18
|
+
*/
|
|
19
|
+
export type DividerStyle = 'solid' | 'dashed' | 'dotted';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Divider spacing
|
|
23
|
+
*/
|
|
24
|
+
export type DividerSpacing = 'none' | 'small' | 'medium' | 'large';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Divider configuration
|
|
28
|
+
*/
|
|
29
|
+
export interface DividerConfig {
|
|
30
|
+
/** Orientation */
|
|
31
|
+
orientation: DividerOrientation;
|
|
32
|
+
/** Line style */
|
|
33
|
+
style: DividerStyle;
|
|
34
|
+
/** Spacing (margin) */
|
|
35
|
+
spacing: DividerSpacing;
|
|
36
|
+
/** Custom color */
|
|
37
|
+
color?: string;
|
|
38
|
+
/** Custom thickness */
|
|
39
|
+
thickness?: number;
|
|
40
|
+
/** Text label (for text divider) */
|
|
41
|
+
text?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Spacing configurations (px)
|
|
46
|
+
*/
|
|
47
|
+
export const SPACING_CONFIGS: Record<DividerSpacing, number> = {
|
|
48
|
+
none: 0,
|
|
49
|
+
small: 8,
|
|
50
|
+
medium: 16,
|
|
51
|
+
large: 24,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Divider utility class
|
|
56
|
+
*/
|
|
57
|
+
export class DividerUtils {
|
|
58
|
+
/**
|
|
59
|
+
* Get spacing value
|
|
60
|
+
*/
|
|
61
|
+
static getSpacing(spacing: DividerSpacing): number {
|
|
62
|
+
return SPACING_CONFIGS[spacing];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Validate divider config
|
|
67
|
+
*/
|
|
68
|
+
static validateConfig(config: Partial<DividerConfig>): DividerConfig {
|
|
69
|
+
return {
|
|
70
|
+
orientation: config.orientation || 'horizontal',
|
|
71
|
+
style: config.style || 'solid',
|
|
72
|
+
spacing: config.spacing || 'medium',
|
|
73
|
+
color: config.color,
|
|
74
|
+
thickness: config.thickness || 1,
|
|
75
|
+
text: config.text,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Divider constants
|
|
82
|
+
*/
|
|
83
|
+
export const DIVIDER_CONSTANTS = {
|
|
84
|
+
DEFAULT_ORIENTATION: 'horizontal' as DividerOrientation,
|
|
85
|
+
DEFAULT_STYLE: 'solid' as DividerStyle,
|
|
86
|
+
DEFAULT_SPACING: 'medium' as DividerSpacing,
|
|
87
|
+
DEFAULT_THICKNESS: 1,
|
|
88
|
+
} as const;
|