@popp0102/nova 0.9.5 → 0.10.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.
@@ -3,7 +3,7 @@ import { StyleSheet } from 'react-native';
3
3
  export const sizes = {
4
4
  h1: 64,
5
5
  h2: 48,
6
- h3: 28,
6
+ h3: 36,
7
7
  h4: 24,
8
8
  h5: 20,
9
9
  h6: 16,
@@ -1,12 +1,21 @@
1
1
  import { Text } from "react-native";
2
2
  import { sizes, styles } from './config';
3
3
 
4
- export default function Heading({ children, color = 'black', size = 'h4', fontFamily }) {
4
+ export default function Heading({ children, color = 'black', size = 'h4', fontFamily, textAlign = 'left', numberOfLines, ellipsizeMode = 'tail' }) {
5
5
  const fontSize = sizes[size] || sizes.h4;
6
6
  const fontWeight = fontFamily ? 'normal' : 'bold';
7
7
 
8
+ const dynamicStyle = { color, fontSize, fontWeight, textAlign };
9
+ if (fontFamily) {
10
+ dynamicStyle.fontFamily = fontFamily;
11
+ }
12
+
8
13
  return (
9
- <Text style={[styles.heading, { color, fontSize, fontFamily, fontWeight }]}>
14
+ <Text
15
+ style={[styles.heading, dynamicStyle]}
16
+ numberOfLines={numberOfLines}
17
+ ellipsizeMode={ellipsizeMode}
18
+ >
10
19
  {children}
11
20
  </Text>
12
21
  );
@@ -7,19 +7,31 @@ export const styles = StyleSheet.create({
7
7
  width: "100%",
8
8
  },
9
9
  topRow: {
10
- flexDirection: "row",
11
- alignItems: "center",
10
+ position: 'relative',
12
11
  width: "100%",
12
+ minHeight: 48,
13
+ justifyContent: 'center',
13
14
  },
14
15
  backButton: {
16
+ position: 'absolute',
17
+ left: 0,
18
+ top: 0,
19
+ bottom: 0,
15
20
  width: 48,
21
+ justifyContent: 'center',
16
22
  },
17
23
  titleContainer: {
18
- flex: 1,
24
+ width: "100%",
25
+ paddingLeft: 48,
26
+ paddingRight: 40,
19
27
  alignItems: 'center',
20
28
  },
21
29
  rightContent: {
22
- width: 80,
30
+ position: 'absolute',
31
+ right: 0,
32
+ top: 0,
33
+ bottom: 0,
23
34
  alignItems: "flex-end",
35
+ justifyContent: 'center',
24
36
  },
25
37
  });
@@ -6,31 +6,77 @@ import { styles } from './config';
6
6
 
7
7
  export default function ScreenHeader({
8
8
  title,
9
- onBack,
10
- rightContent,
9
+ leftIcon,
10
+ rightIcon,
11
11
  titleFontFamily,
12
- titleColor = "#4A2C0A",
13
- backIconColor = "#4A2C0A"
12
+ titleColor = "#4A2C0A"
14
13
  }) {
15
14
  const deviceSize = useDeviceSize();
16
- const titleSize = deviceSize === 'small' ? 'h3' : 'h2';
15
+ const titleSize = deviceSize === 'small' ? 'h4' : 'h3';
16
+
17
+ const leftIconColor = leftIcon?.color || "#4A2C0A";
18
+ const leftIconName = leftIcon?.name || "arrow-back";
19
+ const onLeftIconPress = leftIcon?.onSelect;
20
+
21
+ const rightIconColor = rightIcon?.color || "#4A2C0A";
22
+ const rightIconName = rightIcon?.name;
23
+ const onRightIconPress = rightIcon?.onSelect;
24
+
25
+ const renderLeftIcon = () => {
26
+ if (!leftIcon) return null;
27
+
28
+ const icon = <MaterialIcons name={leftIconName} size={32} color={leftIconColor} />;
29
+
30
+ if (onLeftIconPress) {
31
+ return (
32
+ <Pressable onPress={onLeftIconPress} style={styles.backButton} testID="screen-header-left-icon">
33
+ {icon}
34
+ </Pressable>
35
+ );
36
+ }
37
+
38
+ return (
39
+ <View style={styles.backButton} testID="screen-header-left-icon">
40
+ {icon}
41
+ </View>
42
+ );
43
+ };
44
+
45
+ const renderRightIcon = () => {
46
+ if (!rightIconName) return null;
47
+
48
+ const icon = <MaterialIcons name={rightIconName} size={28} color={rightIconColor} />;
49
+
50
+ if (onRightIconPress) {
51
+ return (
52
+ <Pressable onPress={onRightIconPress} style={styles.rightContent} testID="screen-header-right-icon">
53
+ {icon}
54
+ </Pressable>
55
+ );
56
+ }
57
+
58
+ return (
59
+ <View style={styles.rightContent} testID="screen-header-right-icon">
60
+ {icon}
61
+ </View>
62
+ );
63
+ };
17
64
 
18
65
  return (
19
66
  <View style={styles.header}>
20
67
  <View style={styles.topRow}>
21
- {onBack && (
22
- <Pressable onPress={onBack} style={styles.backButton} testID="screen-header-back-button">
23
- <MaterialIcons name="arrow-back" size={32} color={backIconColor} />
24
- </Pressable>
25
- )}
68
+ {renderLeftIcon()}
26
69
  <View style={styles.titleContainer}>
27
- <Heading size={titleSize} fontFamily={titleFontFamily} color={titleColor}>{title}</Heading>
70
+ <Heading
71
+ size={titleSize}
72
+ fontFamily={titleFontFamily}
73
+ color={titleColor}
74
+ numberOfLines={1}
75
+ >
76
+ {title}
77
+ </Heading>
28
78
  </View>
29
- {rightContent && (
30
- <View style={styles.rightContent}>
31
- {rightContent}
32
- </View>
33
- )}
79
+ {renderRightIcon()}
34
80
  </View>
35
81
  </View>
36
82
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@popp0102/nova",
3
- "version": "0.9.5",
3
+ "version": "0.10.0",
4
4
  "description": "React Native component library",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.js",