@popp0102/nova 0.6.5 → 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
|
+
});
|
|
@@ -1,39 +1,12 @@
|
|
|
1
|
-
import { View, Text, Pressable
|
|
1
|
+
import { View, Text, Pressable } from 'react-native';
|
|
2
2
|
import { MaterialIcons } from '@expo/vector-icons';
|
|
3
|
-
import {
|
|
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
|
-
};
|
|
3
|
+
import { colors, sizes, styles } from './config';
|
|
34
4
|
|
|
35
5
|
export default function Button({
|
|
36
6
|
type = 'primary',
|
|
7
|
+
size = 'medium',
|
|
8
|
+
color,
|
|
9
|
+
textColor,
|
|
37
10
|
style,
|
|
38
11
|
onPress,
|
|
39
12
|
children,
|
|
@@ -42,17 +15,18 @@ export default function Button({
|
|
|
42
15
|
iconColor
|
|
43
16
|
}) {
|
|
44
17
|
const buttonColors = colors[type];
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
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;
|
|
49
23
|
|
|
50
24
|
if (iconPosition && !['left', 'right', 'top'].includes(iconPosition)) {
|
|
51
25
|
throw new Error(`Invalid iconPosition: "${iconPosition}". Must be "left", "right", or "top".`);
|
|
52
26
|
}
|
|
53
27
|
|
|
54
28
|
const isVerticalLayout = iconPosition === 'top';
|
|
55
|
-
const verticalIconSize =
|
|
29
|
+
const verticalIconSize = buttonSizes.fontSize * 2.5;
|
|
56
30
|
|
|
57
31
|
return (
|
|
58
32
|
<Pressable
|
|
@@ -60,8 +34,8 @@ export default function Button({
|
|
|
60
34
|
style={({ pressed }) => [
|
|
61
35
|
styles.button,
|
|
62
36
|
{
|
|
63
|
-
backgroundColor:
|
|
64
|
-
padding:
|
|
37
|
+
backgroundColor: backgroundColor,
|
|
38
|
+
padding: buttonSizes.padding,
|
|
65
39
|
},
|
|
66
40
|
pressed && styles.pressed,
|
|
67
41
|
style,
|
|
@@ -77,7 +51,7 @@ export default function Button({
|
|
|
77
51
|
<MaterialIcons name={icon} size={verticalIconSize} color={finalIconColor} />
|
|
78
52
|
)}
|
|
79
53
|
<Text
|
|
80
|
-
style={[styles.text, { color:
|
|
54
|
+
style={[styles.text, { color: finalTextColor, fontSize: buttonSizes.fontSize }]}
|
|
81
55
|
numberOfLines={1}
|
|
82
56
|
>
|
|
83
57
|
{children}
|
|
@@ -89,7 +63,7 @@ export default function Button({
|
|
|
89
63
|
<MaterialIcons name={icon} size={iconSize} color={finalIconColor} />
|
|
90
64
|
)}
|
|
91
65
|
<Text
|
|
92
|
-
style={[styles.text, { color:
|
|
66
|
+
style={[styles.text, { color: finalTextColor, fontSize: buttonSizes.fontSize }]}
|
|
93
67
|
numberOfLines={1}
|
|
94
68
|
>
|
|
95
69
|
{children}
|
|
@@ -103,30 +77,3 @@ export default function Button({
|
|
|
103
77
|
</Pressable>
|
|
104
78
|
);
|
|
105
79
|
}
|
|
106
|
-
|
|
107
|
-
const styles = StyleSheet.create({
|
|
108
|
-
button: {
|
|
109
|
-
padding: 8,
|
|
110
|
-
borderRadius: 8,
|
|
111
|
-
shadowOffset: { width: 0, height: 1 },
|
|
112
|
-
shadowOpacity: 0.18,
|
|
113
|
-
shadowRadius: 1.0,
|
|
114
|
-
elevation: 2,
|
|
115
|
-
},
|
|
116
|
-
buttonContent: {
|
|
117
|
-
flexDirection: 'row',
|
|
118
|
-
alignItems: 'center',
|
|
119
|
-
justifyContent: 'center',
|
|
120
|
-
gap: 8,
|
|
121
|
-
},
|
|
122
|
-
verticalContent: {
|
|
123
|
-
flexDirection: 'column',
|
|
124
|
-
gap: 4,
|
|
125
|
-
},
|
|
126
|
-
text: {
|
|
127
|
-
textAlign: 'center',
|
|
128
|
-
},
|
|
129
|
-
pressed: {
|
|
130
|
-
opacity: 0.5,
|
|
131
|
-
},
|
|
132
|
-
});
|