@popp0102/nova 0.1.0 → 0.1.1

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 { useDeviceSize } from '@utils/deviceSize';
2
3
 
3
4
  const colors = {
4
5
  primary: {
@@ -6,13 +7,34 @@ const colors = {
6
7
  text: 'white',
7
8
  },
8
9
  secondary: {
9
- background: 'gray',
10
+ background: '#CCCCCC',
10
11
  text: 'black',
11
12
  },
13
+ destructive: {
14
+ background: '#FF3B30',
15
+ text: 'white',
16
+ },
17
+ };
18
+
19
+ const responsiveSizes = {
20
+ small: {
21
+ fontSize: 10,
22
+ padding: 6,
23
+ },
24
+ medium: {
25
+ fontSize: 14,
26
+ padding: 8,
27
+ },
28
+ large: {
29
+ fontSize: 16,
30
+ padding: 10,
31
+ },
12
32
  };
13
33
 
14
34
  export default function Button({ type = 'primary', style, onPress, children }) {
15
35
  const buttonColors = colors[type];
36
+ const deviceSize = useDeviceSize();
37
+ const sizes = responsiveSizes[deviceSize];
16
38
 
17
39
  return (
18
40
  <View style={[style]}>
@@ -20,11 +42,17 @@ export default function Button({ type = 'primary', style, onPress, children }) {
20
42
  onPress={onPress}
21
43
  style={({ pressed }) => [
22
44
  styles.button,
23
- { backgroundColor: buttonColors.background },
45
+ {
46
+ backgroundColor: buttonColors.background,
47
+ padding: sizes.padding,
48
+ },
24
49
  pressed && styles.pressed,
25
50
  ]}
26
51
  >
27
- <Text style={[styles.text, { color: buttonColors.text }]}>
52
+ <Text
53
+ style={[styles.text, { color: buttonColors.text, fontSize: sizes.fontSize }]}
54
+ numberOfLines={1}
55
+ >
28
56
  {children}
29
57
  </Text>
30
58
  </Pressable>
@@ -34,12 +62,14 @@ export default function Button({ type = 'primary', style, onPress, children }) {
34
62
 
35
63
  const styles = StyleSheet.create({
36
64
  button: {
37
- paddingVertical: 8,
38
- paddingHorizontal: 16,
39
- borderRadius: 16,
65
+ padding: 8,
66
+ borderRadius: 8,
67
+ shadowOffset: { width: 0, height: 1 },
68
+ shadowOpacity: 0.18,
69
+ shadowRadius: 1.0,
70
+ elevation: 2,
40
71
  },
41
72
  text: {
42
- fontSize: 24,
43
73
  textAlign: 'center',
44
74
  },
45
75
  pressed: {
@@ -1,7 +1,14 @@
1
- import { View, Text, Modal as RNModal, StyleSheet } from 'react-native';
2
- import { SafeAreaView } from 'react-native-safe-area-context';
1
+ import { View, Text, Modal as RNModal, StyleSheet } from "react-native";
2
+ import { SafeAreaView } from "react-native-safe-area-context";
3
+
4
+ import Button from "./Button";
5
+
6
+ export default function Modal({ visible, title, onConfirm, onClose, children, includeFooter = true }) {
7
+ function handleOnConfirm() {
8
+ onConfirm();
9
+ onClose();
10
+ }
3
11
 
4
- export default function Modal({ visible, title, onClose, children }) {
5
12
  return (
6
13
  <RNModal visible={visible} transparent={true} onRequestClose={onClose}>
7
14
  <SafeAreaView style={styles.backdrop}>
@@ -12,6 +19,12 @@ export default function Modal({ visible, title, onClose, children }) {
12
19
  <View style={styles.body}>
13
20
  {children}
14
21
  </View>
22
+ { includeFooter &&
23
+ <View style={styles.footer}>
24
+ <Button style={styles.button} onPress={onClose} type="secondary">Cancel</Button>
25
+ <Button style={styles.button} onPress={handleOnConfirm}>Ok</Button>
26
+ </View>
27
+ }
15
28
  </View>
16
29
  </SafeAreaView>
17
30
  </RNModal>
@@ -21,30 +34,41 @@ export default function Modal({ visible, title, onClose, children }) {
21
34
  const styles = StyleSheet.create({
22
35
  backdrop: {
23
36
  flex: 1,
24
- alignItems: 'center',
25
- justifyContent: 'center',
26
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
37
+ alignItems: "center",
38
+ justifyContent: "center",
39
+ backgroundColor: "rgba(0, 0, 0, 0.75)",
27
40
  },
28
41
  container: {
29
- paddingVertical: 16,
42
+ width: "75%",
43
+ padding: 8,
30
44
  borderRadius: 24,
31
- backgroundColor: 'yellow',
45
+ backgroundColor: "#CCCCCC",
32
46
  },
33
47
  header: {
34
48
  width: "100%",
49
+ paddingTop: 16,
35
50
  paddingHorizontal: 16,
36
- borderBottomWidth: 2,
37
- borderBottomColor: 'black',
38
51
  },
39
52
  title: {
53
+ marginTop: 16,
40
54
  fontSize: 24,
41
- fontWeight: 'bold',
42
- color: 'black',
55
+ fontWeight: "bold",
56
+ color: "black",
43
57
  },
44
58
  body: {
45
- marginTop: 8,
46
59
  paddingHorizontal: 16,
60
+ paddingVertical: 24,
47
61
  gap: 8,
48
62
  },
63
+ footer: {
64
+ flexDirection: "row",
65
+ alignItems: "center",
66
+ justifyContent: "flex-end",
67
+ gap: 8,
68
+ paddingVertical: 8,
69
+ },
70
+ button: {
71
+ flex: 0.25,
72
+ },
49
73
  });
50
74
 
@@ -0,0 +1,35 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { Dimensions } from 'react-native';
3
+
4
+ const SIZES = {
5
+ small: 375, // iPhone SE and smaller
6
+ medium: 768, // Most phones up to small tablets
7
+ };
8
+
9
+ export function getDeviceSize(width) {
10
+ if (width < SIZES.small) {
11
+ return 'small';
12
+ } else if (width < SIZES.medium) {
13
+ return 'medium';
14
+ } else {
15
+ return 'large';
16
+ }
17
+ }
18
+
19
+ export function useDeviceSize() {
20
+ const [deviceSize, setDeviceSize] = useState(() => {
21
+ const { width } = Dimensions.get('window');
22
+ return getDeviceSize(width);
23
+ });
24
+
25
+ useEffect(() => {
26
+ const subscription = Dimensions.addEventListener('change', ({ window }) => {
27
+ setDeviceSize(getDeviceSize(window.width));
28
+ });
29
+
30
+ return () => subscription?.remove();
31
+ }, []);
32
+
33
+ return deviceSize;
34
+ }
35
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popp0102/nova",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "React Native component library",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",
@@ -40,6 +40,7 @@
40
40
  "@babel/preset-flow": "^7.27.1",
41
41
  "@babel/preset-react": "^7.24.0",
42
42
  "@testing-library/react-native": "^12.4.3",
43
+ "babel-plugin-module-resolver": "^5.0.2",
43
44
  "eslint": "^8.57.0",
44
45
  "eslint-plugin-react": "^7.37.5",
45
46
  "eslint-plugin-react-hooks": "^4.6.2",