@boostdev/design-system-react-native 0.2.6 → 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.
@@ -5,9 +5,13 @@ import { useTheme } from '../../../native/ThemeContext';
5
5
 
6
6
  type BannerVariant = 'info' | 'success' | 'warning' | 'error';
7
7
 
8
+ /** Function form of children: receives the variant's resolved text color so
9
+ * custom content can match the banner's theme. */
10
+ type BannerContentRenderProp = (props: { color: string }) => ReactNode;
11
+
8
12
  interface NotificationBannerProps {
9
13
  variant?: BannerVariant;
10
- children: ReactNode;
14
+ children: ReactNode | BannerContentRenderProp;
11
15
  action?: ReactNode;
12
16
  onDismiss?: () => void;
13
17
  style?: StyleProp<ViewStyle>;
@@ -21,8 +25,10 @@ const styles = StyleSheet.create({
21
25
  paddingHorizontal: spacing.m,
22
26
  gap: spacing.xs,
23
27
  },
24
- content: {
28
+ body: {
25
29
  flex: 1,
30
+ },
31
+ content: {
26
32
  fontSize: font.size.bodyS,
27
33
  fontFamily: font.family.body,
28
34
  lineHeight: lineHeight.bodyS,
@@ -51,6 +57,7 @@ export function NotificationBanner({
51
57
  };
52
58
 
53
59
  const { bg, text, border: borderColor } = variantColors[variant];
60
+ const resolvedChildren = typeof children === 'function' ? children({ color: text }) : children;
54
61
 
55
62
  return (
56
63
  <View
@@ -58,7 +65,13 @@ export function NotificationBanner({
58
65
  accessibilityLiveRegion={isUrgent ? 'assertive' : 'polite'}
59
66
  style={[styles.banner, { backgroundColor: bg, borderBottomWidth: 3, borderBottomColor: borderColor }, style]}
60
67
  >
61
- <Text style={[styles.content, { color: text }]}>{children}</Text>
68
+ <View style={styles.body}>
69
+ {typeof resolvedChildren === 'string' || typeof resolvedChildren === 'number' ? (
70
+ <Text style={[styles.content, { color: text }]}>{resolvedChildren}</Text>
71
+ ) : (
72
+ resolvedChildren
73
+ )}
74
+ </View>
62
75
  {action}
63
76
  {onDismiss && (
64
77
  <Pressable