@popp0102/nova 0.6.7 → 0.7.0

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.
@@ -19,26 +19,32 @@ export const sizes = {
19
19
  tiny: {
20
20
  fontSize: 12,
21
21
  padding: 6,
22
+ fontWeight: '400',
22
23
  },
23
24
  small: {
24
25
  fontSize: 14,
25
26
  padding: 8,
27
+ fontWeight: '500',
26
28
  },
27
29
  medium: {
28
- fontSize: 16,
30
+ fontSize: 18,
29
31
  padding: 12,
32
+ fontWeight: '600',
30
33
  },
31
34
  large: {
32
- fontSize: 20,
35
+ fontSize: 22,
33
36
  padding: 16,
37
+ fontWeight: '700',
34
38
  },
35
39
  xlarge: {
36
- fontSize: 24,
40
+ fontSize: 26,
37
41
  padding: 20,
42
+ fontWeight: '800',
38
43
  },
39
44
  xxlarge: {
40
- fontSize: 28,
45
+ fontSize: 30,
41
46
  padding: 24,
47
+ fontWeight: '900',
42
48
  },
43
49
  };
44
50
 
@@ -46,10 +52,13 @@ export const styles = StyleSheet.create({
46
52
  button: {
47
53
  padding: 8,
48
54
  borderRadius: 8,
49
- shadowOffset: { width: 0, height: 1 },
50
- shadowOpacity: 0.18,
51
- shadowRadius: 1.0,
52
- elevation: 2,
55
+ borderWidth: 2,
56
+ borderColor: 'rgba(0, 0, 0, 0.3)',
57
+ shadowColor: '#000',
58
+ shadowOffset: { width: 0, height: 4 },
59
+ shadowOpacity: 0.3,
60
+ shadowRadius: 6,
61
+ elevation: 8,
53
62
  },
54
63
  buttonContent: {
55
64
  flexDirection: 'row',
@@ -1,4 +1,5 @@
1
1
  import { View, Text, Pressable } from 'react-native';
2
+ import { LinearGradient } from 'expo-linear-gradient';
2
3
  import { MaterialIcons } from '@expo/vector-icons';
3
4
  import { colors, sizes, styles } from './config';
4
5
 
@@ -10,70 +11,62 @@ export default function Button({
10
11
  style,
11
12
  onPress,
12
13
  children,
13
- icon,
14
- iconPosition,
15
- iconColor
14
+ icon
16
15
  }) {
17
16
  const buttonColors = colors[type];
18
17
  const buttonSizes = sizes[size];
19
- const backgroundColor = color || buttonColors.background;
18
+ const isGradient = Array.isArray(color);
19
+ const backgroundColor = isGradient ? null : (color || buttonColors.background);
20
20
  const finalTextColor = textColor || buttonColors.text;
21
- const iconSize = buttonSizes.fontSize * 1.4;
22
- const finalIconColor = iconColor || finalTextColor;
21
+
22
+ const iconName = icon?.name;
23
+ const iconPosition = icon?.position;
24
+ const iconColor = icon?.color || finalTextColor;
23
25
 
24
26
  if (iconPosition && !['left', 'right', 'top'].includes(iconPosition)) {
25
- throw new Error(`Invalid iconPosition: "${iconPosition}". Must be "left", "right", or "top".`);
27
+ throw new Error(`Invalid icon.position: "${iconPosition}". Must be "left", "right", or "top".`);
26
28
  }
27
29
 
28
30
  const isVerticalLayout = iconPosition === 'top';
31
+ const baseIconSize = buttonSizes.fontSize * 1.4;
29
32
  const verticalIconSize = buttonSizes.fontSize * 2.5;
33
+ const iconSize = isVerticalLayout ? verticalIconSize : baseIconSize;
34
+
35
+ const textElement = (
36
+ <Text
37
+ style={[styles.text, { color: finalTextColor, fontSize: buttonSizes.fontSize, fontWeight: buttonSizes.fontWeight }]}
38
+ numberOfLines={1}
39
+ >
40
+ {children}
41
+ </Text>
42
+ );
43
+
44
+ const iconElement = iconName && (
45
+ <MaterialIcons name={iconName} size={iconSize} color={iconColor} />
46
+ );
47
+
48
+ const content = (
49
+ <View style={[styles.buttonContent, isVerticalLayout && styles.verticalContent]}>
50
+ {iconName && (iconPosition === 'left' || iconPosition === 'top') && iconElement}
51
+ {textElement}
52
+ {iconName && iconPosition === 'right' && iconElement}
53
+ </View>
54
+ );
55
+
56
+ const backgroundStyle = isGradient
57
+ ? { overflow: 'hidden', padding: 0 }
58
+ : { backgroundColor, padding: buttonSizes.padding };
30
59
 
31
60
  return (
32
61
  <Pressable
33
62
  onPress={onPress}
34
- style={({ pressed }) => [
35
- styles.button,
36
- {
37
- backgroundColor: backgroundColor,
38
- padding: buttonSizes.padding,
39
- },
40
- pressed && styles.pressed,
41
- style,
42
- ]}
63
+ style={({ pressed }) => [styles.button, backgroundStyle, pressed && styles.pressed, style]}
43
64
  >
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>
65
+ {isGradient ? (
66
+ <LinearGradient colors={color} style={{ padding: buttonSizes.padding }}>
67
+ {content}
68
+ </LinearGradient>
69
+ ) : content}
77
70
  </Pressable>
78
71
  );
79
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popp0102/nova",
3
- "version": "0.6.7",
3
+ "version": "0.7.0",
4
4
  "description": "React Native component library",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",
@@ -31,6 +31,7 @@
31
31
  },
32
32
  "peerDependencies": {
33
33
  "@expo/vector-icons": ">=14.0.0",
34
+ "expo-linear-gradient": ">=14.0.0",
34
35
  "react": ">=18.0.0",
35
36
  "react-native": ">=0.70.0",
36
37
  "react-native-safe-area-context": ">=4.0.0"
@@ -42,7 +43,7 @@
42
43
  "@babel/preset-react": "^7.24.0",
43
44
  "@testing-library/react-native": "^12.4.3",
44
45
  "babel-plugin-module-resolver": "^5.0.2",
45
- "eslint": "^8.57.0",
46
+ "eslint": "^8.57.1",
46
47
  "eslint-plugin-react": "^7.37.5",
47
48
  "eslint-plugin-react-hooks": "^4.6.2",
48
49
  "jest": "^30.2.0",