@popp0102/nova 0.2.3 → 0.3.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.
@@ -1,4 +1,5 @@
1
1
  import { View, Text, Pressable, StyleSheet } from 'react-native';
2
+ import { MaterialIcons } from '@expo/vector-icons';
2
3
  import { useDeviceSize } from '../utils/deviceSize';
3
4
 
4
5
  const colors = {
@@ -31,10 +32,20 @@ const responsiveSizes = {
31
32
  },
32
33
  };
33
34
 
34
- export default function Button({ type = 'primary', style, onPress, children }) {
35
+ export default function Button({
36
+ type = 'primary',
37
+ style,
38
+ onPress,
39
+ children,
40
+ leftIcon,
41
+ rightIcon,
42
+ iconColor
43
+ }) {
35
44
  const buttonColors = colors[type];
36
45
  const deviceSize = useDeviceSize();
37
46
  const sizes = responsiveSizes[deviceSize];
47
+ const iconSize = sizes.fontSize * 1.4;
48
+ const finalIconColor = iconColor || buttonColors.text;
38
49
 
39
50
  return (
40
51
  <View style={[style]}>
@@ -49,12 +60,20 @@ export default function Button({ type = 'primary', style, onPress, children }) {
49
60
  pressed && styles.pressed,
50
61
  ]}
51
62
  >
52
- <Text
53
- style={[styles.text, { color: buttonColors.text, fontSize: sizes.fontSize }]}
54
- numberOfLines={1}
55
- >
56
- {children}
57
- </Text>
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>
58
77
  </Pressable>
59
78
  </View>
60
79
  );
@@ -69,6 +88,12 @@ const styles = StyleSheet.create({
69
88
  shadowRadius: 1.0,
70
89
  elevation: 2,
71
90
  },
91
+ buttonContent: {
92
+ flexDirection: 'row',
93
+ alignItems: 'center',
94
+ justifyContent: 'center',
95
+ gap: 8,
96
+ },
72
97
  text: {
73
98
  textAlign: 'center',
74
99
  },
@@ -0,0 +1,33 @@
1
+ import { Animated } from 'react-native';
2
+ import { useRef, useEffect } from 'react';
3
+
4
+ const DIRECTIONS = {
5
+ IN: 'in',
6
+ OUT: 'out'
7
+ };
8
+
9
+ const VALID_DIRECTIONS = Object.values(DIRECTIONS);
10
+
11
+ export default function FadeView({ children, direction = DIRECTIONS.IN, duration = 1000 }) {
12
+ if (!VALID_DIRECTIONS.includes(direction)) {
13
+ throw new Error(`FadeView: direction must be one of ${VALID_DIRECTIONS.join(', ')}. Got: ${direction}`);
14
+ }
15
+
16
+ const fadeAnimationValue = useRef(
17
+ new Animated.Value(direction === DIRECTIONS.IN ? 0 : 1)
18
+ ).current;
19
+
20
+ useEffect(() => {
21
+ Animated.timing(fadeAnimationValue, {
22
+ toValue: direction === DIRECTIONS.IN ? 1 : 0,
23
+ duration,
24
+ useNativeDriver: true
25
+ }).start();
26
+ }, []);
27
+
28
+ return (
29
+ <Animated.View style={{ opacity: fadeAnimationValue }}>
30
+ {children}
31
+ </Animated.View>
32
+ );
33
+ }
@@ -0,0 +1,58 @@
1
+ import { Animated } from 'react-native';
2
+ import { useRef, useEffect } from 'react';
3
+
4
+ const DIRECTIONS = {
5
+ LEFT: 'left',
6
+ RIGHT: 'right',
7
+ UP: 'up',
8
+ DOWN: 'down',
9
+ };
10
+
11
+ const VALID_DIRECTIONS = Object.values(DIRECTIONS);
12
+
13
+ export default function SlideView({ children, direction = DIRECTIONS.LEFT, duration = 1000 }) {
14
+ if (!VALID_DIRECTIONS.includes(direction)) {
15
+ throw new Error(`SlideView: direction must be one of ${VALID_DIRECTIONS.join(', ')}. Got: ${direction}`);
16
+ }
17
+ let initialValue = 300;
18
+ let transformProperty = 'translateX';
19
+
20
+ switch(direction) {
21
+ case DIRECTIONS.LEFT:
22
+ initialValue = 300;
23
+ transformProperty = 'translateX';
24
+ break;
25
+ case DIRECTIONS.RIGHT:
26
+ initialValue = -300;
27
+ transformProperty = 'translateX';
28
+ break;
29
+ case DIRECTIONS.UP:
30
+ initialValue = 300;
31
+ transformProperty = 'translateY';
32
+ break;
33
+ case DIRECTIONS.DOWN:
34
+ initialValue = -300;
35
+ transformProperty = 'translateY';
36
+ break;
37
+ }
38
+
39
+ const slideAnimationValue = useRef(new Animated.Value(initialValue)).current;
40
+
41
+ const slideIn = () => {
42
+ Animated.timing(slideAnimationValue, {
43
+ toValue: 0,
44
+ duration: duration,
45
+ useNativeDriver: true,
46
+ }).start();
47
+ };
48
+
49
+ useEffect(() => {
50
+ slideIn();
51
+ }, []);
52
+
53
+ return (
54
+ <Animated.View style={{ transform: [{ [transformProperty]: slideAnimationValue }] }}>
55
+ {children}
56
+ </Animated.View>
57
+ );
58
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popp0102/nova",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "React Native component library",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",
@@ -30,10 +30,10 @@
30
30
  "prepublishOnly": "npm run lint && npm run test"
31
31
  },
32
32
  "peerDependencies": {
33
+ "@expo/vector-icons": ">=14.0.0",
33
34
  "react": ">=18.0.0",
34
35
  "react-native": ">=0.70.0",
35
- "react-native-safe-area-context": ">=4.0.0",
36
- "@expo/vector-icons": ">=14.0.0"
36
+ "react-native-safe-area-context": ">=4.0.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@babel/core": "^7.24.0",
@@ -49,7 +49,5 @@
49
49
  "react": "^18.3.1",
50
50
  "react-native": "^0.75.0",
51
51
  "react-test-renderer": "^18.3.1"
52
- },
53
- "dependencies": {
54
52
  }
55
53
  }