@popp0102/nova 0.6.3 → 0.6.5

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.
@@ -37,8 +37,8 @@ export default function Button({
37
37
  style,
38
38
  onPress,
39
39
  children,
40
- leftIcon,
41
- rightIcon,
40
+ icon,
41
+ iconPosition,
42
42
  iconColor
43
43
  }) {
44
44
  const buttonColors = colors[type];
@@ -47,35 +47,60 @@ export default function Button({
47
47
  const iconSize = sizes.fontSize * 1.4;
48
48
  const finalIconColor = iconColor || buttonColors.text;
49
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
+
50
57
  return (
51
- <View style={[style]}>
52
- <Pressable
53
- onPress={onPress}
54
- style={({ pressed }) => [
55
- styles.button,
56
- {
57
- backgroundColor: buttonColors.background,
58
- padding: sizes.padding,
59
- },
60
- pressed && styles.pressed,
61
- ]}
62
- >
63
- <View style={styles.buttonContent}>
64
- {leftIcon && (
65
- <MaterialIcons name={leftIcon} size={iconSize} color={finalIconColor} />
66
- )}
67
- <Text
68
- style={[styles.text, { color: buttonColors.text, fontSize: sizes.fontSize }]}
69
- numberOfLines={1}
70
- >
71
- {children}
72
- </Text>
73
- {rightIcon && (
74
- <MaterialIcons name={rightIcon} size={iconSize} color={finalIconColor} />
75
- )}
76
- </View>
77
- </Pressable>
78
- </View>
58
+ <Pressable
59
+ onPress={onPress}
60
+ style={({ pressed }) => [
61
+ styles.button,
62
+ {
63
+ backgroundColor: buttonColors.background,
64
+ padding: sizes.padding,
65
+ },
66
+ pressed && styles.pressed,
67
+ style,
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>
79
104
  );
80
105
  }
81
106
 
@@ -94,6 +119,10 @@ const styles = StyleSheet.create({
94
119
  justifyContent: 'center',
95
120
  gap: 8,
96
121
  },
122
+ verticalContent: {
123
+ flexDirection: 'column',
124
+ gap: 4,
125
+ },
97
126
  text: {
98
127
  textAlign: 'center',
99
128
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popp0102/nova",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "description": "React Native component library",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",