@popp0102/nova 0.6.2 → 0.6.4
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/lib/components/Badge.js +11 -2
- package/lib/components/Button.js +44 -14
- package/package.json +1 -1
package/lib/components/Badge.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { View, Text, StyleSheet } from 'react-native';
|
|
2
2
|
import { MaterialIcons } from '@expo/vector-icons';
|
|
3
3
|
|
|
4
|
+
const SIZES = {
|
|
5
|
+
small: 12,
|
|
6
|
+
medium: 14,
|
|
7
|
+
large: 16,
|
|
8
|
+
};
|
|
9
|
+
|
|
4
10
|
export default function Badge({
|
|
5
11
|
children,
|
|
6
12
|
leftIcon,
|
|
@@ -8,13 +14,16 @@ export default function Badge({
|
|
|
8
14
|
iconSize = 20,
|
|
9
15
|
color = 'white',
|
|
10
16
|
backgroundColor = 'blue',
|
|
17
|
+
size = 'large',
|
|
11
18
|
style
|
|
12
19
|
}) {
|
|
20
|
+
const fontSize = SIZES[size] || SIZES.large;
|
|
21
|
+
|
|
13
22
|
return (
|
|
14
23
|
<View style={style}>
|
|
15
24
|
<View style={[styles.container, { backgroundColor }]}>
|
|
16
25
|
{leftIcon && <MaterialIcons name={leftIcon} size={iconSize} color={color} />}
|
|
17
|
-
<Text style={[styles.text, { color }]}>{children}</Text>
|
|
26
|
+
<Text style={[styles.text, { color, fontSize }]}>{children}</Text>
|
|
18
27
|
{rightIcon && <MaterialIcons name={rightIcon} size={iconSize} color={color} />}
|
|
19
28
|
</View>
|
|
20
29
|
</View>
|
|
@@ -31,6 +40,6 @@ const styles = StyleSheet.create({
|
|
|
31
40
|
alignSelf: "flex-start",
|
|
32
41
|
},
|
|
33
42
|
text: {
|
|
34
|
-
|
|
43
|
+
fontWeight: '600',
|
|
35
44
|
},
|
|
36
45
|
});
|
package/lib/components/Button.js
CHANGED
|
@@ -37,8 +37,8 @@ export default function Button({
|
|
|
37
37
|
style,
|
|
38
38
|
onPress,
|
|
39
39
|
children,
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
icon,
|
|
41
|
+
iconPosition,
|
|
42
42
|
iconColor
|
|
43
43
|
}) {
|
|
44
44
|
const buttonColors = colors[type];
|
|
@@ -47,6 +47,13 @@ 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
58
|
<View style={[style]}>
|
|
52
59
|
<Pressable
|
|
@@ -60,18 +67,37 @@ export default function Button({
|
|
|
60
67
|
pressed && styles.pressed,
|
|
61
68
|
]}
|
|
62
69
|
>
|
|
63
|
-
<View style={
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
+
</>
|
|
75
101
|
)}
|
|
76
102
|
</View>
|
|
77
103
|
</Pressable>
|
|
@@ -94,6 +120,10 @@ const styles = StyleSheet.create({
|
|
|
94
120
|
justifyContent: 'center',
|
|
95
121
|
gap: 8,
|
|
96
122
|
},
|
|
123
|
+
verticalContent: {
|
|
124
|
+
flexDirection: 'column',
|
|
125
|
+
gap: 4,
|
|
126
|
+
},
|
|
97
127
|
text: {
|
|
98
128
|
textAlign: 'center',
|
|
99
129
|
},
|