@popp0102/nova 0.6.4 → 0.6.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.
@@ -0,0 +1,70 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export const colors = {
4
+ primary: {
5
+ background: 'blue',
6
+ text: 'white',
7
+ },
8
+ secondary: {
9
+ background: '#CCCCCC',
10
+ text: 'black',
11
+ },
12
+ destructive: {
13
+ background: '#FF3B30',
14
+ text: 'white',
15
+ },
16
+ };
17
+
18
+ export const sizes = {
19
+ tiny: {
20
+ fontSize: 12,
21
+ padding: 6,
22
+ },
23
+ small: {
24
+ fontSize: 14,
25
+ padding: 8,
26
+ },
27
+ medium: {
28
+ fontSize: 16,
29
+ padding: 12,
30
+ },
31
+ large: {
32
+ fontSize: 20,
33
+ padding: 16,
34
+ },
35
+ xlarge: {
36
+ fontSize: 24,
37
+ padding: 20,
38
+ },
39
+ xxlarge: {
40
+ fontSize: 28,
41
+ padding: 24,
42
+ },
43
+ };
44
+
45
+ export const styles = StyleSheet.create({
46
+ button: {
47
+ padding: 8,
48
+ borderRadius: 8,
49
+ shadowOffset: { width: 0, height: 1 },
50
+ shadowOpacity: 0.18,
51
+ shadowRadius: 1.0,
52
+ elevation: 2,
53
+ },
54
+ buttonContent: {
55
+ flexDirection: 'row',
56
+ alignItems: 'center',
57
+ justifyContent: 'center',
58
+ gap: 8,
59
+ },
60
+ verticalContent: {
61
+ flexDirection: 'column',
62
+ gap: 4,
63
+ },
64
+ text: {
65
+ textAlign: 'center',
66
+ },
67
+ pressed: {
68
+ opacity: 0.5,
69
+ },
70
+ });
@@ -0,0 +1,79 @@
1
+ import { View, Text, Pressable } from 'react-native';
2
+ import { MaterialIcons } from '@expo/vector-icons';
3
+ import { colors, sizes, styles } from './config';
4
+
5
+ export default function Button({
6
+ type = 'primary',
7
+ size = 'medium',
8
+ color,
9
+ textColor,
10
+ style,
11
+ onPress,
12
+ children,
13
+ icon,
14
+ iconPosition,
15
+ iconColor
16
+ }) {
17
+ const buttonColors = colors[type];
18
+ const buttonSizes = sizes[size];
19
+ const backgroundColor = color || buttonColors.background;
20
+ const finalTextColor = textColor || buttonColors.text;
21
+ const iconSize = buttonSizes.fontSize * 1.4;
22
+ const finalIconColor = iconColor || finalTextColor;
23
+
24
+ if (iconPosition && !['left', 'right', 'top'].includes(iconPosition)) {
25
+ throw new Error(`Invalid iconPosition: "${iconPosition}". Must be "left", "right", or "top".`);
26
+ }
27
+
28
+ const isVerticalLayout = iconPosition === 'top';
29
+ const verticalIconSize = buttonSizes.fontSize * 2.5;
30
+
31
+ return (
32
+ <Pressable
33
+ onPress={onPress}
34
+ style={({ pressed }) => [
35
+ styles.button,
36
+ {
37
+ backgroundColor: backgroundColor,
38
+ padding: buttonSizes.padding,
39
+ },
40
+ pressed && styles.pressed,
41
+ style,
42
+ ]}
43
+ >
44
+ <View style={[
45
+ styles.buttonContent,
46
+ isVerticalLayout && styles.verticalContent
47
+ ]}>
48
+ {isVerticalLayout ? (
49
+ <>
50
+ {icon && (
51
+ <MaterialIcons name={icon} size={verticalIconSize} color={finalIconColor} />
52
+ )}
53
+ <Text
54
+ style={[styles.text, { color: finalTextColor, fontSize: buttonSizes.fontSize }]}
55
+ numberOfLines={1}
56
+ >
57
+ {children}
58
+ </Text>
59
+ </>
60
+ ) : (
61
+ <>
62
+ {icon && iconPosition === 'left' && (
63
+ <MaterialIcons name={icon} size={iconSize} color={finalIconColor} />
64
+ )}
65
+ <Text
66
+ style={[styles.text, { color: finalTextColor, fontSize: buttonSizes.fontSize }]}
67
+ numberOfLines={1}
68
+ >
69
+ {children}
70
+ </Text>
71
+ {icon && iconPosition === 'right' && (
72
+ <MaterialIcons name={icon} size={iconSize} color={finalIconColor} />
73
+ )}
74
+ </>
75
+ )}
76
+ </View>
77
+ </Pressable>
78
+ );
79
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popp0102/nova",
3
- "version": "0.6.4",
3
+ "version": "0.6.6",
4
4
  "description": "React Native component library",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",
@@ -1,133 +0,0 @@
1
- import { View, Text, Pressable, StyleSheet } from 'react-native';
2
- import { MaterialIcons } from '@expo/vector-icons';
3
- import { useDeviceSize } from '../utils/deviceSize';
4
-
5
- const colors = {
6
- primary: {
7
- background: 'blue',
8
- text: 'white',
9
- },
10
- secondary: {
11
- background: '#CCCCCC',
12
- text: 'black',
13
- },
14
- destructive: {
15
- background: '#FF3B30',
16
- text: 'white',
17
- },
18
- };
19
-
20
- const responsiveSizes = {
21
- small: {
22
- fontSize: 10,
23
- padding: 6,
24
- },
25
- medium: {
26
- fontSize: 14,
27
- padding: 8,
28
- },
29
- large: {
30
- fontSize: 16,
31
- padding: 10,
32
- },
33
- };
34
-
35
- export default function Button({
36
- type = 'primary',
37
- style,
38
- onPress,
39
- children,
40
- icon,
41
- iconPosition,
42
- iconColor
43
- }) {
44
- const buttonColors = colors[type];
45
- const deviceSize = useDeviceSize();
46
- const sizes = responsiveSizes[deviceSize];
47
- const iconSize = sizes.fontSize * 1.4;
48
- const finalIconColor = iconColor || buttonColors.text;
49
-
50
- if (iconPosition && !['left', 'right', 'top'].includes(iconPosition)) {
51
- throw new Error(`Invalid iconPosition: "${iconPosition}". Must be "left", "right", or "top".`);
52
- }
53
-
54
- const isVerticalLayout = iconPosition === 'top';
55
- const verticalIconSize = sizes.fontSize * 2.5;
56
-
57
- return (
58
- <View style={[style]}>
59
- <Pressable
60
- onPress={onPress}
61
- style={({ pressed }) => [
62
- styles.button,
63
- {
64
- backgroundColor: buttonColors.background,
65
- padding: sizes.padding,
66
- },
67
- pressed && styles.pressed,
68
- ]}
69
- >
70
- <View style={[
71
- styles.buttonContent,
72
- isVerticalLayout && styles.verticalContent
73
- ]}>
74
- {isVerticalLayout ? (
75
- <>
76
- {icon && (
77
- <MaterialIcons name={icon} size={verticalIconSize} color={finalIconColor} />
78
- )}
79
- <Text
80
- style={[styles.text, { color: buttonColors.text, fontSize: sizes.fontSize }]}
81
- numberOfLines={1}
82
- >
83
- {children}
84
- </Text>
85
- </>
86
- ) : (
87
- <>
88
- {icon && iconPosition === 'left' && (
89
- <MaterialIcons name={icon} size={iconSize} color={finalIconColor} />
90
- )}
91
- <Text
92
- style={[styles.text, { color: buttonColors.text, fontSize: sizes.fontSize }]}
93
- numberOfLines={1}
94
- >
95
- {children}
96
- </Text>
97
- {icon && iconPosition === 'right' && (
98
- <MaterialIcons name={icon} size={iconSize} color={finalIconColor} />
99
- )}
100
- </>
101
- )}
102
- </View>
103
- </Pressable>
104
- </View>
105
- );
106
- }
107
-
108
- const styles = StyleSheet.create({
109
- button: {
110
- padding: 8,
111
- borderRadius: 8,
112
- shadowOffset: { width: 0, height: 1 },
113
- shadowOpacity: 0.18,
114
- shadowRadius: 1.0,
115
- elevation: 2,
116
- },
117
- buttonContent: {
118
- flexDirection: 'row',
119
- alignItems: 'center',
120
- justifyContent: 'center',
121
- gap: 8,
122
- },
123
- verticalContent: {
124
- flexDirection: 'column',
125
- gap: 4,
126
- },
127
- text: {
128
- textAlign: 'center',
129
- },
130
- pressed: {
131
- opacity: 0.5,
132
- },
133
- });