@utilitywarehouse/hearth-react-native 0.6.0 → 0.8.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.
- package/.storybook/main.ts +12 -6
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +18 -0
- package/build/components/Banner/Banner.d.ts +6 -0
- package/build/components/Banner/Banner.js +161 -0
- package/build/components/Banner/Banner.props.d.ts +82 -0
- package/build/components/Banner/Banner.props.js +1 -0
- package/build/components/Banner/index.d.ts +2 -0
- package/build/components/Banner/index.js +1 -0
- package/build/components/BottomSheet/BottomSheetBackdrop.js +1 -5
- package/build/components/BottomSheet/BottomSheetFlatList.js +1 -5
- package/build/components/BottomSheet/BottomSheetHandle.js +1 -5
- package/build/components/BottomSheet/useBottomSheetLogic.d.ts +1 -1
- package/build/components/Button/ButtonIcon.js +2 -1
- package/build/components/Button/ButtonRoot.js +2 -6
- package/build/components/Button/ButtonText.js +4 -1
- package/build/components/Card/Card.context.d.ts +7 -0
- package/build/components/Card/CardAction/CardAction.context.d.ts +9 -0
- package/build/components/Card/{CardAction.context.js → CardAction/CardAction.context.js} +7 -1
- package/build/components/Card/CardAction/CardAction.d.ts +18 -0
- package/build/components/Card/CardAction/CardAction.js +7 -0
- package/build/components/Card/CardAction/CardAction.props.d.ts +63 -0
- package/build/components/Card/CardAction/CardAction.props.js +1 -0
- package/build/components/Card/CardAction/CardActionContent.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionContent.js +13 -0
- package/build/components/Card/CardAction/CardActionHelperText.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionHelperText.js +13 -0
- package/build/components/Card/CardAction/CardActionIcon.d.ts +9 -0
- package/build/components/Card/CardAction/CardActionIcon.js +19 -0
- package/build/components/Card/CardAction/CardActionLeadingContent.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionLeadingContent.js +5 -0
- package/build/components/Card/CardAction/CardActionRoot.d.ts +12 -0
- package/build/components/Card/CardAction/CardActionRoot.js +155 -0
- package/build/components/Card/CardAction/CardActionText.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionText.js +9 -0
- package/build/components/Card/CardAction/CardActionTrailingContent.d.ts +6 -0
- package/build/components/Card/CardAction/CardActionTrailingContent.js +5 -0
- package/build/components/Card/CardAction/CardActionTrailingIcon.d.ts +9 -0
- package/build/components/Card/CardAction/CardActionTrailingIcon.js +19 -0
- package/build/components/Card/CardAction/index.d.ts +10 -0
- package/build/components/Card/CardAction/index.js +9 -0
- package/build/components/Card/CardContent.d.ts +6 -0
- package/build/components/Card/CardContent.js +33 -0
- package/build/components/Card/CardPressHandler.context.d.ts +6 -0
- package/build/components/Card/CardPressHandler.context.js +6 -0
- package/build/components/Card/{CardAction.d.ts → CardPressHandler.d.ts} +3 -3
- package/build/components/Card/CardPressHandler.js +13 -0
- package/build/components/Card/CardRoot.js +103 -11
- package/build/components/Card/index.d.ts +3 -2
- package/build/components/Card/index.js +3 -2
- package/build/components/Checkbox/CheckboxIcon.js +2 -1
- package/build/components/Container/Container.js +3 -3
- package/build/components/CurrencyInput/CurrencyInput.js +1 -1
- package/build/components/Expandable/Expandable.d.ts +6 -0
- package/build/components/Expandable/Expandable.js +44 -0
- package/build/components/Expandable/Expandable.props.d.ts +38 -0
- package/build/components/Expandable/Expandable.props.js +1 -0
- package/build/components/Expandable/index.d.ts +2 -0
- package/build/components/Expandable/index.js +1 -0
- package/build/components/ExpandableCard/ExpandableCard.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCard.js +23 -0
- package/build/components/ExpandableCard/ExpandableCard.props.d.ts +69 -0
- package/build/components/ExpandableCard/ExpandableCard.props.js +1 -0
- package/build/components/ExpandableCard/ExpandableCardContent.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardContent.js +14 -0
- package/build/components/ExpandableCard/ExpandableCardExpandedContent.d.ts +11 -0
- package/build/components/ExpandableCard/ExpandableCardExpandedContent.js +18 -0
- package/build/components/ExpandableCard/ExpandableCardGroup.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardGroup.js +17 -0
- package/build/components/ExpandableCard/ExpandableCardGroup.props.d.ts +25 -0
- package/build/components/ExpandableCard/ExpandableCardGroup.props.js +1 -0
- package/build/components/ExpandableCard/ExpandableCardHelperText.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardHelperText.js +13 -0
- package/build/components/ExpandableCard/ExpandableCardIcon.d.ts +9 -0
- package/build/components/ExpandableCard/ExpandableCardIcon.js +19 -0
- package/build/components/ExpandableCard/ExpandableCardLeadingContent.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardLeadingContent.js +5 -0
- package/build/components/ExpandableCard/ExpandableCardText.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardText.js +7 -0
- package/build/components/ExpandableCard/ExpandableCardTrailingContent.d.ts +6 -0
- package/build/components/ExpandableCard/ExpandableCardTrailingContent.js +5 -0
- package/build/components/ExpandableCard/ExpandableCardTrailingIcon.d.ts +9 -0
- package/build/components/ExpandableCard/ExpandableCardTrailingIcon.js +17 -0
- package/build/components/ExpandableCard/ExpandableCardTrigger.d.ts +17 -0
- package/build/components/ExpandableCard/ExpandableCardTrigger.js +7 -0
- package/build/components/ExpandableCard/ExpandableCardTrigger.props.d.ts +44 -0
- package/build/components/ExpandableCard/ExpandableCardTrigger.props.js +1 -0
- package/build/components/ExpandableCard/ExpandableCardTriggerRoot.d.ts +11 -0
- package/build/components/ExpandableCard/ExpandableCardTriggerRoot.js +91 -0
- package/build/components/ExpandableCard/index.d.ts +14 -0
- package/build/components/ExpandableCard/index.js +11 -0
- package/build/components/Helper/HelperIcon.js +2 -1
- package/build/components/HighlightBanner/HighlightBanner.d.ts +6 -0
- package/build/components/HighlightBanner/HighlightBanner.js +86 -0
- package/build/components/HighlightBanner/HighlightBanner.props.d.ts +14 -0
- package/build/components/HighlightBanner/HighlightBanner.props.js +1 -0
- package/build/components/HighlightBanner/index.d.ts +2 -0
- package/build/components/HighlightBanner/index.js +1 -0
- package/build/components/Icon/Icon.d.ts +2 -6
- package/build/components/IconButton/IconButtonIcon.js +2 -1
- package/build/components/IconContainer/IconContainer.d.ts +4 -3
- package/build/components/IconContainer/IconContainer.js +3 -3
- package/build/components/Input/InputField.js +4 -2
- package/build/components/Input/InputIcon.js +2 -1
- package/build/components/Link/LinkIcon.js +3 -2
- package/build/components/List/ListAction/ListActionTrailingIcon.js +2 -1
- package/build/components/List/ListItem/ListItemIcon.js +2 -1
- package/build/components/List/ListItem/ListItemTrailingIcon.js +2 -3
- package/build/components/Radio/RadioIcon.js +7 -2
- package/build/components/RadioCard/RadioCardIcon.js +3 -2
- package/build/components/Spinner/Spinner.web.d.ts +2 -1
- package/build/components/Switch/Switch.js +5 -3
- package/build/components/Textarea/TextareaField.js +1 -1
- package/build/components/ToggleButton/ToggleButtonIcon.js +2 -1
- package/build/components/ToggleButton/ToggleButtonRoot.js +2 -2
- package/build/components/UnstyledIconButton/UnstyledIconButtonIcon.js +2 -1
- package/build/components/index.d.ts +5 -1
- package/build/components/index.js +5 -1
- package/build/core/index.d.ts +3 -3
- package/build/core/index.js +3 -3
- package/build/core/themes.d.ts +24 -12
- package/build/hooks/useColorMode.d.ts +1 -1
- package/build/hooks/useColorMode.js +7 -8
- package/build/tokens/components/dark/banner.d.ts +19 -0
- package/build/tokens/components/dark/banner.js +19 -0
- package/build/tokens/components/dark/card-action.d.ts +11 -0
- package/build/tokens/components/dark/card-action.js +10 -0
- package/build/tokens/components/dark/card-content.d.ts +25 -0
- package/build/tokens/components/dark/card-content.js +24 -0
- package/build/tokens/components/dark/drawer.d.ts +29 -0
- package/build/tokens/components/dark/drawer.js +28 -0
- package/build/tokens/components/dark/illustrations.d.ts +0 -1
- package/build/tokens/components/dark/illustrations.js +0 -1
- package/build/tokens/components/dark/index.d.ts +3 -0
- package/build/tokens/components/dark/index.js +3 -0
- package/build/tokens/components/light/banner.d.ts +19 -0
- package/build/tokens/components/light/banner.js +19 -0
- package/build/tokens/components/light/card-action.d.ts +11 -0
- package/build/tokens/components/light/card-action.js +10 -0
- package/build/tokens/components/light/card-content.d.ts +25 -0
- package/build/tokens/components/light/card-content.js +24 -0
- package/build/tokens/components/light/drawer.d.ts +29 -0
- package/build/tokens/components/light/drawer.js +28 -0
- package/build/tokens/components/light/illustrations.d.ts +0 -1
- package/build/tokens/components/light/illustrations.js +0 -1
- package/build/tokens/components/light/index.d.ts +3 -0
- package/build/tokens/components/light/index.js +3 -0
- package/build/tokens/layout.d.ts +6 -6
- package/build/tokens/layout.js +3 -3
- package/build/tokens/typography.d.ts +6 -0
- package/build/tokens/typography.js +3 -0
- package/docs/components/AllComponents.web.tsx +75 -4
- package/docs/components/NextPrevPage.tsx +5 -5
- package/docs/components/VariantTitle.tsx +17 -7
- package/package.json +16 -14
- package/src/components/Banner/Banner.docs.mdx +402 -0
- package/src/components/Banner/Banner.props.ts +106 -0
- package/src/components/Banner/Banner.stories.tsx +494 -0
- package/src/components/Banner/Banner.tsx +264 -0
- package/src/components/Banner/index.ts +2 -0
- package/src/components/BottomSheet/BottomSheetBackdrop.tsx +1 -2
- package/src/components/BottomSheet/BottomSheetFlatList.tsx +1 -3
- package/src/components/BottomSheet/BottomSheetHandle.tsx +0 -1
- package/src/components/Button/ButtonIcon.tsx +2 -1
- package/src/components/Button/ButtonRoot.tsx +2 -6
- package/src/components/Button/ButtonText.tsx +4 -1
- package/src/components/Card/Card.context.ts +7 -0
- package/src/components/Card/Card.docs.mdx +221 -15
- package/src/components/Card/Card.stories.tsx +50 -3
- package/src/components/Card/CardAction/CardAction.context.ts +22 -0
- package/src/components/Card/CardAction/CardAction.props.ts +87 -0
- package/src/components/Card/CardAction/CardAction.stories.tsx +265 -0
- package/src/components/Card/CardAction/CardAction.tsx +10 -0
- package/src/components/Card/CardAction/CardActionContent.tsx +20 -0
- package/src/components/Card/CardAction/CardActionHelperText.tsx +21 -0
- package/src/components/Card/CardAction/CardActionIcon.tsx +32 -0
- package/src/components/Card/CardAction/CardActionLeadingContent.tsx +9 -0
- package/src/components/Card/CardAction/CardActionRoot.tsx +258 -0
- package/src/components/Card/CardAction/CardActionText.tsx +17 -0
- package/src/components/Card/CardAction/CardActionTrailingContent.tsx +9 -0
- package/src/components/Card/CardAction/CardActionTrailingIcon.tsx +32 -0
- package/src/components/Card/CardAction/index.ts +10 -0
- package/src/components/Card/CardContent.tsx +40 -0
- package/src/components/Card/CardPressHandler.context.ts +12 -0
- package/src/components/Card/CardPressHandler.tsx +20 -0
- package/src/components/Card/CardRoot.tsx +128 -13
- package/src/components/Card/index.ts +3 -2
- package/src/components/Checkbox/CheckboxIcon.tsx +2 -1
- package/src/components/Container/Container.tsx +3 -3
- package/src/components/CurrencyInput/CurrencyInput.tsx +1 -1
- package/src/components/Expandable/Expandable.docs.mdx +201 -0
- package/src/components/Expandable/Expandable.props.ts +46 -0
- package/src/components/Expandable/Expandable.stories.tsx +284 -0
- package/src/components/Expandable/Expandable.tsx +92 -0
- package/src/components/Expandable/index.ts +2 -0
- package/src/components/ExpandableCard/ExpandableCard.docs.mdx +312 -0
- package/src/components/ExpandableCard/ExpandableCard.props.ts +85 -0
- package/src/components/ExpandableCard/ExpandableCard.stories.tsx +326 -0
- package/src/components/ExpandableCard/ExpandableCard.tsx +76 -0
- package/src/components/ExpandableCard/ExpandableCardContent.tsx +21 -0
- package/src/components/ExpandableCard/ExpandableCardExpandedContent.tsx +42 -0
- package/src/components/ExpandableCard/ExpandableCardGroup.props.ts +31 -0
- package/src/components/ExpandableCard/ExpandableCardGroup.tsx +40 -0
- package/src/components/ExpandableCard/ExpandableCardHelperText.tsx +21 -0
- package/src/components/ExpandableCard/ExpandableCardIcon.tsx +32 -0
- package/src/components/ExpandableCard/ExpandableCardLeadingContent.tsx +9 -0
- package/src/components/ExpandableCard/ExpandableCardText.tsx +14 -0
- package/src/components/ExpandableCard/ExpandableCardTrailingContent.tsx +9 -0
- package/src/components/ExpandableCard/ExpandableCardTrailingIcon.tsx +30 -0
- package/src/components/ExpandableCard/ExpandableCardTrigger.props.ts +47 -0
- package/src/components/ExpandableCard/ExpandableCardTrigger.tsx +10 -0
- package/src/components/ExpandableCard/ExpandableCardTriggerRoot.tsx +154 -0
- package/src/components/ExpandableCard/index.ts +14 -0
- package/src/components/Helper/HelperIcon.tsx +2 -1
- package/src/components/HighlightBanner/HighlightBanner.docs.mdx +277 -0
- package/src/components/HighlightBanner/HighlightBanner.props.ts +29 -0
- package/src/components/HighlightBanner/HighlightBanner.stories.tsx +259 -0
- package/src/components/HighlightBanner/HighlightBanner.tsx +122 -0
- package/src/components/HighlightBanner/index.ts +2 -0
- package/src/components/Icon/Icon.tsx +4 -3
- package/src/components/IconButton/IconButtonIcon.tsx +2 -1
- package/src/components/IconContainer/IconContainer.tsx +17 -19
- package/src/components/Input/InputField.tsx +2 -1
- package/src/components/Input/InputIcon.tsx +2 -1
- package/src/components/Link/LinkIcon.tsx +3 -2
- package/src/components/List/ListAction/ListActionTrailingIcon.tsx +2 -1
- package/src/components/List/ListItem/ListItemIcon.tsx +2 -1
- package/src/components/List/ListItem/ListItemTrailingIcon.tsx +2 -3
- package/src/components/Radio/RadioIcon.tsx +8 -3
- package/src/components/RadioCard/RadioCardIcon.tsx +4 -3
- package/src/components/Switch/Switch.tsx +10 -5
- package/src/components/Switch/Switch.web.tsx +1 -0
- package/src/components/Textarea/TextareaField.tsx +1 -1
- package/src/components/ToggleButton/ToggleButtonIcon.tsx +2 -1
- package/src/components/ToggleButton/ToggleButtonRoot.tsx +2 -2
- package/src/components/UnstyledIconButton/UnstyledIconButtonIcon.tsx +2 -1
- package/src/components/index.ts +5 -9
- package/src/core/index.ts +14 -11
- package/src/hooks/useColorMode.ts +9 -12
- package/src/tokens/components/dark/banner.ts +19 -0
- package/src/tokens/components/dark/card-action.ts +11 -0
- package/src/tokens/components/dark/card-content.ts +25 -0
- package/src/tokens/components/dark/drawer.ts +29 -0
- package/src/tokens/components/dark/illustrations.ts +0 -1
- package/src/tokens/components/dark/index.ts +3 -0
- package/src/tokens/components/light/banner.ts +19 -0
- package/src/tokens/components/light/card-action.ts +11 -0
- package/src/tokens/components/light/card-content.ts +25 -0
- package/src/tokens/components/light/drawer.ts +29 -0
- package/src/tokens/components/light/illustrations.ts +0 -1
- package/src/tokens/components/light/index.ts +3 -0
- package/src/tokens/layout.ts +3 -3
- package/src/tokens/typography.ts +3 -0
- package/build/components/Card/CardAction.context.d.ts +0 -6
- package/build/components/Card/CardAction.js +0 -13
- package/src/components/Card/CardAction.context.ts +0 -12
- package/src/components/Card/CardAction.tsx +0 -18
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import { ChevronRightSmallIcon, CloseSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
2
|
+
import { Pressable, View } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
+
import { BodyText } from '../BodyText';
|
|
5
|
+
import { Card } from '../Card';
|
|
6
|
+
import { Heading } from '../Heading';
|
|
7
|
+
import { IconContainer } from '../IconContainer';
|
|
8
|
+
import { ThemedImage } from '../ThemedImage';
|
|
9
|
+
import { UnstyledIconButton } from '../UnstyledIconButton';
|
|
10
|
+
import type BannerProps from './Banner.props';
|
|
11
|
+
|
|
12
|
+
const Banner = ({
|
|
13
|
+
icon,
|
|
14
|
+
iconContainerVariant = 'subtle',
|
|
15
|
+
iconContainerSize = 'md',
|
|
16
|
+
iconContainerColor = 'pig',
|
|
17
|
+
illustration,
|
|
18
|
+
image,
|
|
19
|
+
heading,
|
|
20
|
+
description,
|
|
21
|
+
direction = 'horizontal',
|
|
22
|
+
link,
|
|
23
|
+
button,
|
|
24
|
+
onPress,
|
|
25
|
+
onClose,
|
|
26
|
+
variant = 'subtle',
|
|
27
|
+
colorScheme = 'pig',
|
|
28
|
+
style,
|
|
29
|
+
...props
|
|
30
|
+
}: BannerProps) => {
|
|
31
|
+
const hasIllustration = Boolean(illustration);
|
|
32
|
+
styles.useVariants({ direction, hasIllustration });
|
|
33
|
+
|
|
34
|
+
const renderIconOrImage = () => {
|
|
35
|
+
if (icon) {
|
|
36
|
+
return (
|
|
37
|
+
<IconContainer
|
|
38
|
+
icon={icon}
|
|
39
|
+
variant={iconContainerVariant}
|
|
40
|
+
size={iconContainerSize}
|
|
41
|
+
color={iconContainerColor}
|
|
42
|
+
style={styles.media}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
if (illustration) {
|
|
47
|
+
return (
|
|
48
|
+
<ThemedImage
|
|
49
|
+
light={illustration.light}
|
|
50
|
+
dark={illustration.dark}
|
|
51
|
+
style={styles.image}
|
|
52
|
+
accessible
|
|
53
|
+
accessibilityLabel={heading}
|
|
54
|
+
/>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
if (image) {
|
|
58
|
+
return (
|
|
59
|
+
<View style={[styles.media, styles.imageWrapper]}>
|
|
60
|
+
<ThemedImage
|
|
61
|
+
light={image.light}
|
|
62
|
+
dark={image.dark}
|
|
63
|
+
style={styles.image}
|
|
64
|
+
accessible
|
|
65
|
+
accessibilityLabel={heading}
|
|
66
|
+
/>
|
|
67
|
+
</View>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const renderAction = () => {
|
|
74
|
+
if (link) {
|
|
75
|
+
return <View style={styles.action}>{link}</View>;
|
|
76
|
+
}
|
|
77
|
+
if (button) {
|
|
78
|
+
return <View style={styles.action}>{button}</View>;
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const content = (
|
|
84
|
+
<View style={styles.container}>
|
|
85
|
+
{renderIconOrImage()}
|
|
86
|
+
<View style={styles.contentContainer}>
|
|
87
|
+
<View style={styles.textContainer}>
|
|
88
|
+
<Heading
|
|
89
|
+
size="sm"
|
|
90
|
+
style={styles.heading}
|
|
91
|
+
textAlign={hasIllustration && direction === 'vertical' ? 'center' : 'left'}
|
|
92
|
+
>
|
|
93
|
+
{heading}
|
|
94
|
+
</Heading>
|
|
95
|
+
<BodyText
|
|
96
|
+
size="md"
|
|
97
|
+
style={styles.description}
|
|
98
|
+
textAlign={hasIllustration && direction === 'vertical' ? 'center' : 'left'}
|
|
99
|
+
>
|
|
100
|
+
{description}
|
|
101
|
+
</BodyText>
|
|
102
|
+
{renderAction()}
|
|
103
|
+
</View>
|
|
104
|
+
{onPress && (
|
|
105
|
+
<UnstyledIconButton
|
|
106
|
+
icon={ChevronRightSmallIcon}
|
|
107
|
+
size="sm"
|
|
108
|
+
onPress={onPress}
|
|
109
|
+
style={styles.chevron}
|
|
110
|
+
/>
|
|
111
|
+
)}
|
|
112
|
+
{onClose && (
|
|
113
|
+
<UnstyledIconButton
|
|
114
|
+
icon={CloseSmallIcon}
|
|
115
|
+
size="sm"
|
|
116
|
+
onPress={onClose}
|
|
117
|
+
style={styles.closeButton}
|
|
118
|
+
accessibilityLabel="Close banner"
|
|
119
|
+
/>
|
|
120
|
+
)}
|
|
121
|
+
</View>
|
|
122
|
+
</View>
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
if (onPress) {
|
|
126
|
+
return (
|
|
127
|
+
<Card variant={variant} style={[styles.card, style]} {...props}>
|
|
128
|
+
<Pressable onPress={onPress} accessibilityRole="button" style={styles.pressable}>
|
|
129
|
+
{content}
|
|
130
|
+
</Pressable>
|
|
131
|
+
</Card>
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<Card variant={variant} style={[styles.card, style]} {...props}>
|
|
137
|
+
{content}
|
|
138
|
+
</Card>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
Banner.displayName = 'Banner';
|
|
143
|
+
|
|
144
|
+
const styles = StyleSheet.create(theme => ({
|
|
145
|
+
card: {},
|
|
146
|
+
pressable: {
|
|
147
|
+
width: '100%',
|
|
148
|
+
},
|
|
149
|
+
container: {
|
|
150
|
+
flexDirection: 'row',
|
|
151
|
+
gap: theme.space.lg,
|
|
152
|
+
variants: {
|
|
153
|
+
direction: {
|
|
154
|
+
horizontal: {
|
|
155
|
+
flexDirection: 'row',
|
|
156
|
+
alignItems: 'flex-start',
|
|
157
|
+
},
|
|
158
|
+
vertical: {
|
|
159
|
+
flexDirection: 'column',
|
|
160
|
+
alignItems: 'stretch',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
hasIllustration: {
|
|
164
|
+
true: {},
|
|
165
|
+
false: {},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
compoundVariants: [
|
|
169
|
+
{
|
|
170
|
+
direction: 'vertical',
|
|
171
|
+
hasIllustration: false,
|
|
172
|
+
styles: {
|
|
173
|
+
alignItems: 'flex-start',
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
direction: 'vertical',
|
|
178
|
+
hasIllustration: true,
|
|
179
|
+
styles: {
|
|
180
|
+
alignItems: 'center',
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
media: {
|
|
186
|
+
flexShrink: 0,
|
|
187
|
+
variants: {
|
|
188
|
+
direction: {
|
|
189
|
+
horizontal: {},
|
|
190
|
+
vertical: {
|
|
191
|
+
alignSelf: 'flex-start',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
imageWrapper: {
|
|
197
|
+
variants: {
|
|
198
|
+
direction: {
|
|
199
|
+
horizontal: {},
|
|
200
|
+
vertical: {
|
|
201
|
+
width: '100%',
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
image: {
|
|
207
|
+
borderRadius: theme.borderRadius.md,
|
|
208
|
+
borderWidth: theme.borderWidth[1],
|
|
209
|
+
borderColor: theme.color.border.strong,
|
|
210
|
+
variants: {
|
|
211
|
+
direction: {
|
|
212
|
+
horizontal: { width: 160, height: 95 },
|
|
213
|
+
vertical: {
|
|
214
|
+
width: '100%',
|
|
215
|
+
height: 160,
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
contentContainer: {
|
|
221
|
+
flex: 1,
|
|
222
|
+
flexDirection: 'row',
|
|
223
|
+
alignItems: 'flex-start',
|
|
224
|
+
justifyContent: 'space-between',
|
|
225
|
+
gap: theme.space.lg,
|
|
226
|
+
},
|
|
227
|
+
textContainer: {
|
|
228
|
+
flex: 1,
|
|
229
|
+
gap: theme.space.lg,
|
|
230
|
+
},
|
|
231
|
+
heading: {
|
|
232
|
+
compoundVariants: [
|
|
233
|
+
{
|
|
234
|
+
direction: 'vertical',
|
|
235
|
+
hasIllustration: true,
|
|
236
|
+
styles: {
|
|
237
|
+
textAlign: 'center',
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
},
|
|
242
|
+
description: {
|
|
243
|
+
compoundVariants: [
|
|
244
|
+
{
|
|
245
|
+
direction: 'vertical',
|
|
246
|
+
hasIllustration: true,
|
|
247
|
+
styles: {
|
|
248
|
+
textAlign: 'center',
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
action: {
|
|
254
|
+
alignSelf: 'flex-start',
|
|
255
|
+
},
|
|
256
|
+
chevron: {
|
|
257
|
+
alignSelf: 'center',
|
|
258
|
+
},
|
|
259
|
+
closeButton: {
|
|
260
|
+
alignSelf: 'flex-start',
|
|
261
|
+
},
|
|
262
|
+
}));
|
|
263
|
+
|
|
264
|
+
export default Banner;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BottomSheetBackdrop as Backdrop } from '@gorhom/bottom-sheet';
|
|
2
|
+
import { BottomSheetDefaultBackdropProps } from '@gorhom/bottom-sheet/lib/typescript/components/bottomSheetBackdrop/types';
|
|
2
3
|
import { StyleSheet, withUnistyles } from 'react-native-unistyles';
|
|
3
4
|
import { useTheme } from '../../hooks';
|
|
4
|
-
import { BottomSheetDefaultBackdropProps } from '@gorhom/bottom-sheet/lib/typescript/components/bottomSheetBackdrop/types';
|
|
5
5
|
|
|
6
6
|
const StyledBottomSheetBackdrop = withUnistyles(Backdrop);
|
|
7
7
|
|
|
@@ -9,7 +9,6 @@ const BottomSheetBackdrop = ({ style, ...props }: BottomSheetDefaultBackdropProp
|
|
|
9
9
|
const theme = useTheme();
|
|
10
10
|
return (
|
|
11
11
|
<StyledBottomSheetBackdrop
|
|
12
|
-
// @ts-expect-error - style unistyles error
|
|
13
12
|
style={[styles.backdrop, style]}
|
|
14
13
|
opacity={theme.components.overlay.opacity / 100}
|
|
15
14
|
appearsOnIndex={0}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
1
|
import { BottomSheetFlatList as FlatList } from '@gorhom/bottom-sheet';
|
|
2
|
+
import { BottomSheetFlatListProps } from '@gorhom/bottom-sheet/lib/typescript/components/bottomSheetScrollable/types';
|
|
3
3
|
import { StyleSheet, withUnistyles } from 'react-native-unistyles';
|
|
4
4
|
import { useBottomSheetContext } from './BottomSheet.context';
|
|
5
|
-
import { BottomSheetFlatListProps } from '@gorhom/bottom-sheet/lib/typescript/components/bottomSheetScrollable/types';
|
|
6
5
|
|
|
7
6
|
const StyledBottomSheetFlatList = withUnistyles(FlatList);
|
|
8
7
|
|
|
@@ -20,7 +19,6 @@ const BottomSheetFlatList = ({
|
|
|
20
19
|
|
|
21
20
|
return (
|
|
22
21
|
<StyledBottomSheetFlatList
|
|
23
|
-
// @ts-expect-error - style
|
|
24
22
|
style={[styles.container, style]}
|
|
25
23
|
contentContainerStyle={[styles.contentContainer, contentContainerStyle]}
|
|
26
24
|
{...props}
|
|
@@ -7,7 +7,6 @@ const StyledBottomSheetHandle = withUnistyles(Handle);
|
|
|
7
7
|
const BottomSheetHandle = ({ style, indicatorStyle, ...props }: BottomSheetDefaultHandleProps) => {
|
|
8
8
|
return (
|
|
9
9
|
<StyledBottomSheetHandle
|
|
10
|
-
// @ts-expect-error - style
|
|
11
10
|
style={[styles.handle, style]}
|
|
12
11
|
indicatorStyle={[styles.indicator, indicatorStyle]}
|
|
13
12
|
{...props}
|
|
@@ -13,7 +13,8 @@ const ButtonIcon = ({ children, ...props }: IconProps) => {
|
|
|
13
13
|
{...props}
|
|
14
14
|
style={
|
|
15
15
|
Platform.OS === 'web'
|
|
16
|
-
?
|
|
16
|
+
? // @ts-expect-error - style prop type issue
|
|
17
|
+
{ ...(styles.icon as StyleProp<ViewStyle>), ...props.style }
|
|
17
18
|
: [styles.icon as StyleProp<ViewStyle>, props.style]
|
|
18
19
|
}
|
|
19
20
|
>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { Pressable, ViewStyle } from 'react-native';
|
|
3
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
-
import {
|
|
4
|
+
import { useCardPressHandlerContext } from '../Card';
|
|
5
5
|
import { ButtonContext } from './Button.context';
|
|
6
6
|
import type { BaseButtonProps } from './Button.props';
|
|
7
7
|
|
|
@@ -17,7 +17,7 @@ const ButtonRoot = ({
|
|
|
17
17
|
...props
|
|
18
18
|
}: BaseButtonProps & { states?: { active?: boolean; disabled?: boolean } }) => {
|
|
19
19
|
const { active, disabled = false } = states || {};
|
|
20
|
-
const { pressed } =
|
|
20
|
+
const { pressed } = useCardPressHandlerContext();
|
|
21
21
|
|
|
22
22
|
styles.useVariants({
|
|
23
23
|
variant,
|
|
@@ -103,7 +103,6 @@ const styles = StyleSheet.create(theme => ({
|
|
|
103
103
|
ghost: {
|
|
104
104
|
backgroundColor: 'transparent',
|
|
105
105
|
borderWidth: 0,
|
|
106
|
-
textDecoration: 'underline',
|
|
107
106
|
},
|
|
108
107
|
},
|
|
109
108
|
size: {
|
|
@@ -349,7 +348,6 @@ const styles = StyleSheet.create(theme => ({
|
|
|
349
348
|
variant: 'ghost',
|
|
350
349
|
colorScheme: 'functional',
|
|
351
350
|
styles: {
|
|
352
|
-
textDecorationColor: theme.color.interactive.functional.foreground.subtle,
|
|
353
351
|
_web: {
|
|
354
352
|
_hover: {
|
|
355
353
|
backgroundColor: theme.color.interactive.functional.surface.subtle.hover,
|
|
@@ -397,7 +395,6 @@ const styles = StyleSheet.create(theme => ({
|
|
|
397
395
|
variant: 'ghost',
|
|
398
396
|
colorScheme: 'affirmative',
|
|
399
397
|
styles: {
|
|
400
|
-
textDecorationColor: theme.color.interactive.affirmative.foreground.subtle,
|
|
401
398
|
_web: {
|
|
402
399
|
_hover: {
|
|
403
400
|
backgroundColor: theme.color.interactive.affirmative.surface.subtle.hover,
|
|
@@ -421,7 +418,6 @@ const styles = StyleSheet.create(theme => ({
|
|
|
421
418
|
variant: 'ghost',
|
|
422
419
|
colorScheme: 'destructive',
|
|
423
420
|
styles: {
|
|
424
|
-
textDecorationColor: theme.color.interactive.destructive.foreground.subtle,
|
|
425
421
|
_web: {
|
|
426
422
|
_hover: {
|
|
427
423
|
backgroundColor: theme.color.interactive.destructive.surface.subtle.hover,
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { createContext, useContext } from 'react';
|
|
2
|
+
import CardProps from './Card.props';
|
|
2
3
|
|
|
3
4
|
interface CardContextProps {
|
|
4
5
|
pressed?: boolean;
|
|
6
|
+
noPadding?: boolean;
|
|
7
|
+
hasActions?: boolean;
|
|
8
|
+
hasContent?: boolean;
|
|
9
|
+
hasOnlyActions?: boolean;
|
|
10
|
+
space?: CardProps['space'];
|
|
11
|
+
variant?: CardProps['variant'];
|
|
5
12
|
}
|
|
6
13
|
|
|
7
14
|
export const CardContext = createContext<CardContextProps>({});
|
|
@@ -2,6 +2,7 @@ import { Canvas, Controls, Meta, Primary, Story } from '@storybook/addon-docs/bl
|
|
|
2
2
|
import { BodyText, Card, Center, DetailText } from '../../';
|
|
3
3
|
import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
4
4
|
import * as Stories from './Card.stories';
|
|
5
|
+
import * as ActionStories from './CardAction/CardAction.stories';
|
|
5
6
|
|
|
6
7
|
<Meta title="Components / Card" />
|
|
7
8
|
|
|
@@ -16,8 +17,18 @@ A Card component serves as a visual container that groups related content and ac
|
|
|
16
17
|
- [Playground](#playground)
|
|
17
18
|
- [Usage](#usage)
|
|
18
19
|
- [Props](#props)
|
|
20
|
+
- [`CardPressHandler` Props](#cardpresshandler-props)
|
|
21
|
+
- [`CardAction` Props](#cardaction-props)
|
|
19
22
|
- [Variants](#variants)
|
|
20
|
-
- [
|
|
23
|
+
- [Examples](#examples)
|
|
24
|
+
- [Interactive](#interactive)
|
|
25
|
+
- [With `CardAction`](#with-cardaction)
|
|
26
|
+
- [`CardAction` Playground](#cardaction-playground)
|
|
27
|
+
- [`CardAction` With Badge](#cardaction-with-badge)
|
|
28
|
+
- [`CardAction` Size Variants](#cardaction-size-variants)
|
|
29
|
+
- [`CardAction` Advanced Usage with Children](#cardaction-advanced-usage-with-children)
|
|
30
|
+
- [`CardAction` Component Parts](#cardaction-component-parts)
|
|
31
|
+
- [`CardAction` Accessibility](#cardaction-accessibility)
|
|
21
32
|
|
|
22
33
|
## Playground
|
|
23
34
|
|
|
@@ -55,7 +66,7 @@ const MyComponent = () => (
|
|
|
55
66
|
| colorScheme | `'neutralStrong' \| 'neutralSubtle' \| 'purple' \| 'energy'` <br /> `'broadband' \| 'mobile' \| 'insurance' \| 'cashback' \|` <br /> `'pig'` | The color scheme of the card. | `'neutralStrong'` |
|
|
56
67
|
| noPadding | `boolean` | Wether or not the card has padding. | `false` |
|
|
57
68
|
| selected | `boolean` | Whether the card is selected. | `false` |
|
|
58
|
-
| onPress | `() => void` | Callback function to be called. |
|
|
69
|
+
| onPress | `() => void` | Callback function to be called. | `-` |
|
|
59
70
|
| disabled | `boolean` | Whether the card is disabled. | `false` |
|
|
60
71
|
| space | `'none' \| '2xs' \| 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| '2xl'` | The space between the content. | `none` |
|
|
61
72
|
| alignItems | `'flex-start' \| 'flex-end' \| `<br />`'center' \| 'stretch' \| 'baseline'` | The align items of the flex container. | `flex-start` |
|
|
@@ -66,42 +77,237 @@ const MyComponent = () => (
|
|
|
66
77
|
| rowGap | `number` | The row gap between the content. | `0` |
|
|
67
78
|
| columnGap | `number` | The column gap between the content. | `0` |
|
|
68
79
|
|
|
69
|
-
### `
|
|
80
|
+
### `CardPressHandler` Props
|
|
70
81
|
|
|
71
|
-
| Property
|
|
72
|
-
|
|
|
73
|
-
|
|
|
82
|
+
| Property | Type | Description | Default |
|
|
83
|
+
| ---------------- | -------- | --------------------------------------------------------------------------- | --------- |
|
|
84
|
+
| handlerToInherit | `string` | The handler to inherit from the child component when the `Card` is pressed. | `onPress` |
|
|
85
|
+
|
|
86
|
+
### `CardAction` Props
|
|
87
|
+
|
|
88
|
+
| Property | Type | Description | Default |
|
|
89
|
+
| -------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------- | ---------- |
|
|
90
|
+
| loading | `boolean` | Show loading skeleton state | `false` |
|
|
91
|
+
| disabled | `boolean` | Disable interactions | `false` |
|
|
92
|
+
| size | `'md' \| 'lg'` | Size of the heading text | `'md'` |
|
|
93
|
+
| onPress | `() => void` | Callback when the action is pressed | `-` |
|
|
94
|
+
| heading | `string` | The main heading text (required when not using children) | `-` |
|
|
95
|
+
| helperText | `string` | Optional secondary text below the heading | `-` |
|
|
96
|
+
| leadingIcon | `ReactNode` | The leading icon. | `-` |
|
|
97
|
+
| trailingIcon | `ReactNode` | The trailing icon. | `-` |
|
|
98
|
+
| leadingContent | `ReactNode` | Content to display on the left (typically an icon) | `-` |
|
|
99
|
+
| trailingContent | `ReactNode` | Content to display on the right (typically an icon) | `-` |
|
|
100
|
+
| iconContainer | `boolean` | Whether to show the icon container | `false` |
|
|
101
|
+
| iconContainerVariant | `'subtle' \| 'emphasis'` | Variant of the icon container | `'subtle'` |
|
|
102
|
+
| iconContainerColor | `'pig' \| 'energy' \| 'broadband' \| 'mobile' \|` <br />`'insurance' \| 'cashback' \| 'highlight'` | Semantic colour family for surface tokens | `pig` |
|
|
103
|
+
| badge | `BadgeProps` | Badge configuration object | |
|
|
104
|
+
| badgePosition | `'bottom' \| 'middle' \| 'right' \| 'top'` | Position of the badge | `'bottom'` |
|
|
74
105
|
|
|
75
106
|
## Variants
|
|
76
107
|
|
|
77
108
|
<Canvas of={Stories.Variants} />
|
|
78
109
|
|
|
79
|
-
##
|
|
110
|
+
## Examples
|
|
111
|
+
|
|
112
|
+
### Interactive
|
|
80
113
|
|
|
81
114
|
You can make the card interactive by adding an `onPress` prop. You can also toggle the `selected` prop
|
|
82
115
|
to change the card's appearance.
|
|
83
116
|
|
|
84
|
-
Alternatively to make the card inherit an
|
|
85
|
-
This will by default inherit the `onPress`
|
|
86
|
-
by passing the `
|
|
117
|
+
Alternatively to make the card inherit an event handler from a child component, you can use the `CardPressHandler` component.
|
|
118
|
+
This will by default inherit the `onPress` handler from the child component. You can specify a different action
|
|
119
|
+
by passing the `handlerToInherit` prop e.g `onChange`. Wrapping a component in a `CardPressHandler` component will
|
|
87
120
|
make the card interactive and also show the `active` state of the child component when the `Card` is pressed.
|
|
88
121
|
|
|
89
122
|
<Canvas of={Stories.Interactive} />
|
|
90
123
|
|
|
91
|
-
See example below for how to use the `
|
|
124
|
+
See example below for how to use the `CardPressHandler` component:
|
|
92
125
|
|
|
93
126
|
```jsx
|
|
94
|
-
import {
|
|
127
|
+
import {
|
|
128
|
+
Card,
|
|
129
|
+
CardPressHandler,
|
|
130
|
+
BodyText,
|
|
131
|
+
Heading,
|
|
132
|
+
Flex,
|
|
133
|
+
Button,
|
|
134
|
+
} from '@utilitywarehouse/hearth-react-native';
|
|
95
135
|
|
|
96
136
|
const MyComponent = () => (
|
|
97
137
|
<Card variant="emphasis" colorScheme="neutralSubtle">
|
|
98
138
|
<Flex space="md" direction="column" align="stretch">
|
|
99
139
|
<Heading size="md">Heading</Heading>
|
|
100
|
-
<BodyText>
|
|
101
|
-
<
|
|
140
|
+
<BodyText>Content</BodyText>
|
|
141
|
+
<CardPressHandler>
|
|
102
142
|
<Button onPress={() => console.log('pressed')}>Press me</Button>
|
|
103
|
-
</
|
|
143
|
+
</CardPressHandler>
|
|
104
144
|
</Flex>
|
|
105
145
|
</Card>
|
|
106
146
|
);
|
|
107
147
|
```
|
|
148
|
+
|
|
149
|
+
### With `CardAction`
|
|
150
|
+
|
|
151
|
+
You can use the `CardAction` component within a `Card` to create actionable items with consistent styling.
|
|
152
|
+
|
|
153
|
+
<Canvas of={Stories.WithActions} />
|
|
154
|
+
|
|
155
|
+
```jsx
|
|
156
|
+
import { Card, CardAction, BodyText, Heading, Flex } from '@utilitywarehouse/hearth-react-native';
|
|
157
|
+
|
|
158
|
+
const MyComponent = () => (
|
|
159
|
+
<Card variant="emphasis">
|
|
160
|
+
<BodyText>Content</BodyText>
|
|
161
|
+
<CardAction
|
|
162
|
+
onPress={() => console.log('Card action pressed')}
|
|
163
|
+
heading="Card Action Head"
|
|
164
|
+
helperText="Some helper text"
|
|
165
|
+
leadingIcon={BellMediumIcon}
|
|
166
|
+
/>
|
|
167
|
+
<CardAction
|
|
168
|
+
onPress={() => console.log('Card action pressed')}
|
|
169
|
+
heading="Card Action Head"
|
|
170
|
+
leadingIcon={BellMediumIcon}
|
|
171
|
+
/>
|
|
172
|
+
<CardAction
|
|
173
|
+
onPress={() => console.log('Card action pressed')}
|
|
174
|
+
heading="Card Action Head"
|
|
175
|
+
helperText="Testing"
|
|
176
|
+
leadingIcon={BellMediumIcon}
|
|
177
|
+
iconContainer={false}
|
|
178
|
+
/>
|
|
179
|
+
</Card>
|
|
180
|
+
);
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
#### `CardAction` Playground
|
|
184
|
+
|
|
185
|
+
<Canvas of={ActionStories.Playground} />
|
|
186
|
+
<Controls of={ActionStories.Playground} />
|
|
187
|
+
|
|
188
|
+
#### `CardAction` With Badge
|
|
189
|
+
|
|
190
|
+
The badge can be positioned in three different locations:
|
|
191
|
+
|
|
192
|
+
```tsx
|
|
193
|
+
import { Card, CardAction } from '@utilitywarehouse/hearth-react-native';
|
|
194
|
+
|
|
195
|
+
const MyComponent = () => (
|
|
196
|
+
<>
|
|
197
|
+
{/* Badge at bottom (default) */}
|
|
198
|
+
<Card>
|
|
199
|
+
<CardAction
|
|
200
|
+
heading="Action"
|
|
201
|
+
helperText="Helper text"
|
|
202
|
+
badge={{ text: 'New' }}
|
|
203
|
+
badgePosition="bottom"
|
|
204
|
+
onPress={() => console.log('pressed')}
|
|
205
|
+
/>
|
|
206
|
+
</Card>
|
|
207
|
+
|
|
208
|
+
{/* Badge in middle (between heading and helper text) */}
|
|
209
|
+
<Card>
|
|
210
|
+
<CardAction
|
|
211
|
+
heading="Action"
|
|
212
|
+
helperText="Helper text"
|
|
213
|
+
badge={{ text: 'New' }}
|
|
214
|
+
badgePosition="middle"
|
|
215
|
+
onPress={() => console.log('pressed')}
|
|
216
|
+
/>
|
|
217
|
+
</Card>
|
|
218
|
+
|
|
219
|
+
{/* Badge on the right */}
|
|
220
|
+
<Card>
|
|
221
|
+
<CardAction
|
|
222
|
+
heading="Action"
|
|
223
|
+
helperText="Helper text"
|
|
224
|
+
badge={{ text: 'New' }}
|
|
225
|
+
badgePosition="right"
|
|
226
|
+
onPress={() => console.log('pressed')}
|
|
227
|
+
/>
|
|
228
|
+
</Card>
|
|
229
|
+
</>
|
|
230
|
+
);
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### `CardAction` Size Variants
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
import { Card, CardAction } from '@utilitywarehouse/hearth-react-native';
|
|
237
|
+
|
|
238
|
+
const MyComponent = () => (
|
|
239
|
+
<>
|
|
240
|
+
<Card>
|
|
241
|
+
<CardAction
|
|
242
|
+
heading="Medium heading"
|
|
243
|
+
helperText="Default md size"
|
|
244
|
+
size="md"
|
|
245
|
+
onPress={() => console.log('pressed')}
|
|
246
|
+
/>
|
|
247
|
+
</Card>
|
|
248
|
+
|
|
249
|
+
<Card>
|
|
250
|
+
<CardAction
|
|
251
|
+
heading="Large heading"
|
|
252
|
+
helperText="Larger lg size"
|
|
253
|
+
size="lg"
|
|
254
|
+
onPress={() => console.log('pressed')}
|
|
255
|
+
/>
|
|
256
|
+
</Card>
|
|
257
|
+
</>
|
|
258
|
+
);
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
#### `CardAction` Advanced Usage with Children
|
|
262
|
+
|
|
263
|
+
For more complex layouts, you can use the component parts directly:
|
|
264
|
+
|
|
265
|
+
```tsx
|
|
266
|
+
import {
|
|
267
|
+
Card,
|
|
268
|
+
CardAction,
|
|
269
|
+
CardActionLeadingContent,
|
|
270
|
+
CardActionContent,
|
|
271
|
+
CardActionText,
|
|
272
|
+
CardActionHelperText,
|
|
273
|
+
CardActionTrailingContent,
|
|
274
|
+
CardActionIcon,
|
|
275
|
+
CardActionTrailingIcon,
|
|
276
|
+
} from '@utilitywarehouse/hearth-react-native';
|
|
277
|
+
import {
|
|
278
|
+
ElectricityMediumIcon,
|
|
279
|
+
ChevronRightSmallIcon,
|
|
280
|
+
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
281
|
+
|
|
282
|
+
const MyComponent = () => (
|
|
283
|
+
<Card>
|
|
284
|
+
<CardAction onPress={() => console.log('pressed')}>
|
|
285
|
+
<CardActionLeadingContent>
|
|
286
|
+
<CardActionIcon as={ElectricityMediumIcon} />
|
|
287
|
+
</CardActionLeadingContent>
|
|
288
|
+
<CardActionContent>
|
|
289
|
+
<CardActionText>Custom Layout</CardActionText>
|
|
290
|
+
<CardActionHelperText>With complete control</CardActionHelperText>
|
|
291
|
+
</CardActionContent>
|
|
292
|
+
<CardActionTrailingContent>
|
|
293
|
+
<CardActionTrailingIcon as={ChevronRightSmallIcon} />
|
|
294
|
+
</CardActionTrailingContent>
|
|
295
|
+
</CardAction>
|
|
296
|
+
</Card>
|
|
297
|
+
);
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
#### `CardAction` Component Parts
|
|
301
|
+
|
|
302
|
+
- `CardAction` - Main component wrapper
|
|
303
|
+
- `CardActionContent` - Container for text content
|
|
304
|
+
- `CardActionText` - Heading text
|
|
305
|
+
- `CardActionHelperText` - Secondary helper text
|
|
306
|
+
- `CardActionLeadingContent` - Container for leading content
|
|
307
|
+
- `CardActionTrailingContent` - Container for trailing content
|
|
308
|
+
- `CardActionIcon` - Styled icon for leading content
|
|
309
|
+
- `CardActionTrailingIcon` - Styled icon for trailing content
|
|
310
|
+
|
|
311
|
+
#### `CardAction` Accessibility
|
|
312
|
+
|
|
313
|
+
The component automatically sets `accessibilityRole="button"` when an `onPress` handler is provided, ensuring proper screen reader announcements.
|