@utilitywarehouse/hearth-react-native 0.4.2 → 0.6.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 +21 -1
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +52 -0
- package/build/components/Alert/AlertTitle.js +6 -6
- package/build/components/Badge/Badge.js +3 -3
- package/build/components/Badge/Badge.props.d.ts +1 -0
- package/build/components/Button/ButtonRoot.js +4 -0
- package/build/components/Button/ButtonText.js +2 -2
- package/build/components/Card/CardRoot.js +1 -1
- package/build/components/Carousel/Carousel.context.d.ts +4 -0
- package/build/components/Carousel/Carousel.context.js +4 -0
- package/build/components/Carousel/Carousel.d.ts +6 -0
- package/build/components/Carousel/Carousel.js +278 -0
- package/build/components/Carousel/Carousel.props.d.ts +65 -0
- package/build/components/Carousel/Carousel.props.js +1 -0
- package/build/components/Carousel/CarouselControlItem.d.ts +24 -0
- package/build/components/Carousel/CarouselControlItem.js +64 -0
- package/build/components/Carousel/CarouselControls.d.ts +4 -0
- package/build/components/Carousel/CarouselControls.js +74 -0
- package/build/components/Carousel/CarouselItem.d.ts +6 -0
- package/build/components/Carousel/CarouselItem.js +38 -0
- package/build/components/Carousel/index.d.ts +5 -0
- package/build/components/Carousel/index.js +5 -0
- package/build/components/Container/Container.d.ts +6 -0
- package/build/components/Container/Container.js +40 -0
- package/build/components/Container/Container.props.d.ts +85 -0
- package/build/components/Container/Container.props.js +1 -0
- package/build/components/Container/index.d.ts +2 -0
- package/build/components/Container/index.js +1 -0
- package/build/components/DescriptionList/DescriptionList.d.ts +1 -1
- package/build/components/DescriptionList/DescriptionList.js +2 -2
- package/build/components/DescriptionList/DescriptionList.props.d.ts +1 -8
- package/build/components/DescriptionList/DescriptionListItem.d.ts +1 -1
- package/build/components/DescriptionList/DescriptionListItem.js +4 -3
- package/build/components/DescriptionList/DescriptionListItem.props.d.ts +3 -8
- package/build/components/IndicatorIconButton/IndicatorIconButton.d.ts +6 -0
- package/build/components/IndicatorIconButton/IndicatorIconButton.js +26 -0
- package/build/components/IndicatorIconButton/IndicatorIconButton.props.d.ts +8 -0
- package/build/components/IndicatorIconButton/IndicatorIconButton.props.js +1 -0
- package/build/components/IndicatorIconButton/index.d.ts +2 -0
- package/build/components/IndicatorIconButton/index.js +1 -0
- package/build/components/Link/LinkText.js +3 -3
- package/build/components/List/List.context.d.ts +0 -2
- package/build/components/List/List.d.ts +1 -1
- package/build/components/List/List.js +5 -5
- package/build/components/List/List.props.d.ts +1 -9
- package/build/components/List/ListAction/ListAction.d.ts +18 -0
- package/build/components/List/ListAction/ListAction.js +103 -0
- package/build/components/List/ListAction/ListAction.props.d.ts +8 -0
- package/build/components/List/ListAction/ListAction.props.js +1 -0
- package/build/components/List/ListAction/ListActionContent.d.ts +6 -0
- package/build/components/List/ListAction/ListActionContent.js +14 -0
- package/build/components/List/ListAction/ListActionText.d.ts +6 -0
- package/build/components/List/ListAction/ListActionText.js +7 -0
- package/build/components/List/ListAction/ListActionTrailingContent.d.ts +6 -0
- package/build/components/List/ListAction/ListActionTrailingContent.js +5 -0
- package/build/components/List/ListAction/ListActionTrailingIcon.d.ts +9 -0
- package/build/components/List/ListAction/ListActionTrailingIcon.js +18 -0
- package/build/components/List/ListAction/index.d.ts +6 -0
- package/build/components/List/ListAction/index.js +5 -0
- package/build/components/List/ListItem/ListItem.context.d.ts +1 -1
- package/build/components/List/ListItem/ListItem.props.d.ts +9 -5
- package/build/components/List/ListItem/ListItemRoot.d.ts +1 -1
- package/build/components/List/ListItem/ListItemRoot.js +10 -12
- package/build/components/List/ListItem/index.d.ts +4 -4
- package/build/components/List/ListItem/index.js +3 -3
- package/build/components/List/index.d.ts +1 -0
- package/build/components/List/index.js +1 -0
- package/build/components/ProgressStepper/ProgressStep.d.ts +10 -0
- package/build/components/ProgressStepper/ProgressStep.js +100 -0
- package/build/components/ProgressStepper/ProgressStepper.d.ts +6 -0
- package/build/components/ProgressStepper/ProgressStepper.js +22 -0
- package/build/components/ProgressStepper/ProgressStepper.props.d.ts +22 -0
- package/build/components/ProgressStepper/ProgressStepper.props.js +1 -0
- package/build/components/ProgressStepper/ProgressStepperRoot.d.ts +6 -0
- package/build/components/ProgressStepper/ProgressStepperRoot.js +16 -0
- package/build/components/ProgressStepper/index.d.ts +3 -0
- package/build/components/ProgressStepper/index.js +2 -0
- package/build/components/SectionHeader/SectionHeader.d.ts +1 -1
- package/build/components/SectionHeader/SectionHeader.js +6 -3
- package/build/components/SectionHeader/SectionHeader.props.d.ts +9 -16
- package/build/components/SectionHeader/SectionHeaderTrailingContent.d.ts +6 -0
- package/build/components/SectionHeader/SectionHeaderTrailingContent.js +13 -0
- package/build/components/SectionHeader/index.d.ts +1 -0
- package/build/components/SectionHeader/index.js +1 -0
- package/build/components/Tabs/Tab.js +2 -2
- package/build/components/ThemedImage/ThemedImage.d.ts +12 -0
- package/build/components/ThemedImage/ThemedImage.js +27 -0
- package/build/components/ThemedImage/ThemedImage.props.d.ts +13 -0
- package/build/components/ThemedImage/ThemedImage.props.js +1 -0
- package/build/components/ThemedImage/index.d.ts +2 -0
- package/build/components/ThemedImage/index.js +1 -0
- package/build/components/ToggleButton/ToggleButtonText.js +2 -2
- package/build/components/UnstyledIconButton/UnstyledIconButton.props.d.ts +4 -1
- package/build/components/index.d.ts +5 -0
- package/build/components/index.js +5 -0
- package/build/core/themes.d.ts +12 -24
- package/build/hooks/useStyleProps.js +1 -1
- package/build/tokens/components/dark/button.d.ts +1 -1
- package/build/tokens/components/dark/button.js +1 -1
- package/build/tokens/components/dark/dialog.d.ts +1 -0
- package/build/tokens/components/dark/dialog.js +1 -0
- package/build/tokens/components/dark/illustrations.d.ts +1 -0
- package/build/tokens/components/dark/illustrations.js +1 -0
- package/build/tokens/components/dark/toast.d.ts +4 -1
- package/build/tokens/components/dark/toast.js +4 -1
- package/build/tokens/components/light/button.d.ts +1 -1
- package/build/tokens/components/light/button.js +1 -1
- package/build/tokens/components/light/dialog.d.ts +1 -0
- package/build/tokens/components/light/dialog.js +1 -0
- package/build/tokens/components/light/illustrations.d.ts +1 -0
- package/build/tokens/components/light/illustrations.js +1 -0
- package/build/tokens/components/light/toast.d.ts +4 -1
- package/build/tokens/components/light/toast.js +4 -1
- package/build/tokens/layout.d.ts +6 -12
- package/build/tokens/layout.js +3 -6
- package/docs/components/AllComponents.web.tsx +122 -5
- package/docs/components/BadgeList.tsx +20 -56
- package/docs/components/SwitchList.tsx +4 -8
- package/docs/getting-started.mdx +30 -14
- package/docs/introduction.mdx +1 -1
- package/docs/layout-components.docs.mdx +30 -0
- package/package.json +6 -4
- package/src/components/Alert/AlertTitle.tsx +7 -7
- package/src/components/Badge/Badge.props.ts +1 -0
- package/src/components/Badge/Badge.tsx +3 -2
- package/src/components/Button/ButtonRoot.tsx +4 -0
- package/src/components/Button/ButtonText.tsx +3 -3
- package/src/components/Card/CardRoot.tsx +2 -0
- package/src/components/Carousel/Carousel.context.tsx +8 -0
- package/src/components/Carousel/Carousel.docs.mdx +389 -0
- package/src/components/Carousel/Carousel.props.ts +89 -0
- package/src/components/Carousel/Carousel.stories.tsx +317 -0
- package/src/components/Carousel/Carousel.tsx +444 -0
- package/src/components/Carousel/CarouselControlItem.tsx +87 -0
- package/src/components/Carousel/CarouselControls.tsx +150 -0
- package/src/components/Carousel/CarouselItem.tsx +68 -0
- package/src/components/Carousel/index.ts +6 -0
- package/src/components/Container/Container.docs.mdx +168 -0
- package/src/components/Container/Container.props.ts +89 -0
- package/src/components/Container/Container.stories.tsx +274 -0
- package/src/components/Container/Container.tsx +52 -0
- package/src/components/Container/index.tsx +2 -0
- package/src/components/DescriptionList/DescriptionList.docs.mdx +24 -27
- package/src/components/DescriptionList/DescriptionList.props.ts +1 -8
- package/src/components/DescriptionList/DescriptionList.stories.tsx +13 -19
- package/src/components/DescriptionList/DescriptionList.tsx +2 -14
- package/src/components/DescriptionList/DescriptionListItem.props.ts +3 -8
- package/src/components/DescriptionList/DescriptionListItem.tsx +13 -21
- package/src/components/IndicatorIconButton/IndicatorIconButton.docs.mdx +85 -0
- package/src/components/IndicatorIconButton/IndicatorIconButton.props.ts +12 -0
- package/src/components/IndicatorIconButton/IndicatorIconButton.stories.tsx +142 -0
- package/src/components/IndicatorIconButton/IndicatorIconButton.tsx +36 -0
- package/src/components/IndicatorIconButton/index.tsx +2 -0
- package/src/components/Link/LinkText.tsx +4 -4
- package/src/components/List/List.context.ts +0 -1
- package/src/components/List/List.docs.mdx +376 -179
- package/src/components/List/List.props.ts +1 -9
- package/src/components/List/List.stories.tsx +289 -38
- package/src/components/List/List.tsx +5 -26
- package/src/components/List/ListAction/ListAction.props.ts +10 -0
- package/src/components/List/ListAction/ListAction.tsx +133 -0
- package/src/components/List/ListAction/ListActionContent.tsx +21 -0
- package/src/components/List/ListAction/ListActionText.tsx +14 -0
- package/src/components/List/ListAction/ListActionTrailingContent.tsx +9 -0
- package/src/components/List/ListAction/ListActionTrailingIcon.tsx +32 -0
- package/src/components/List/ListAction/index.ts +6 -0
- package/src/components/List/ListItem/ListItem.context.ts +1 -1
- package/src/components/List/ListItem/ListItem.props.ts +9 -5
- package/src/components/List/ListItem/ListItemRoot.tsx +18 -14
- package/src/components/List/ListItem/index.ts +4 -4
- package/src/components/List/index.ts +1 -0
- package/src/components/ProgressStepper/ProgressStep.tsx +134 -0
- package/src/components/ProgressStepper/ProgressStepper.docs.mdx +87 -0
- package/src/components/ProgressStepper/ProgressStepper.props.ts +27 -0
- package/src/components/ProgressStepper/ProgressStepper.stories.tsx +108 -0
- package/src/components/ProgressStepper/ProgressStepper.tsx +26 -0
- package/src/components/ProgressStepper/ProgressStepperRoot.tsx +32 -0
- package/src/components/ProgressStepper/index.ts +3 -0
- package/src/components/SectionHeader/SectionHeader.props.ts +9 -16
- package/src/components/SectionHeader/SectionHeader.stories.tsx +28 -18
- package/src/components/SectionHeader/SectionHeader.tsx +18 -19
- package/src/components/SectionHeader/SectionHeaderTrailingContent.tsx +20 -0
- package/src/components/SectionHeader/Sectionheader.docs.mdx +9 -24
- package/src/components/SectionHeader/index.ts +1 -0
- package/src/components/Switch/Switch.docs.mdx +0 -4
- package/src/components/Tabs/Tab.tsx +4 -2
- package/src/components/ThemedImage/ThemedImage.docs.mdx +208 -0
- package/src/components/ThemedImage/ThemedImage.props.ts +15 -0
- package/src/components/ThemedImage/ThemedImage.stories.tsx +175 -0
- package/src/components/ThemedImage/ThemedImage.tsx +34 -0
- package/src/components/ThemedImage/index.tsx +2 -0
- package/src/components/ToggleButton/ToggleButtonText.tsx +3 -3
- package/src/components/UnstyledIconButton/UnstyledIconButton.props.ts +2 -1
- package/src/components/index.ts +5 -0
- package/src/hooks/useStyleProps.ts +1 -1
- package/src/tokens/components/dark/button.ts +1 -1
- package/src/tokens/components/dark/dialog.ts +1 -0
- package/src/tokens/components/dark/illustrations.ts +1 -0
- package/src/tokens/components/dark/toast.ts +4 -1
- package/src/tokens/components/light/button.ts +1 -1
- package/src/tokens/components/light/dialog.ts +1 -0
- package/src/tokens/components/light/illustrations.ts +1 -0
- package/src/tokens/components/light/toast.ts +4 -1
- package/src/tokens/layout.ts +3 -6
- package/src/vite-env.d.ts +6 -0
|
@@ -25,6 +25,10 @@ import {
|
|
|
25
25
|
ListItemTrailingContent,
|
|
26
26
|
ListItemTrailingIcon,
|
|
27
27
|
SectionHeader,
|
|
28
|
+
Switch,
|
|
29
|
+
Link,
|
|
30
|
+
ListAction,
|
|
31
|
+
BodyText,
|
|
28
32
|
} from '../../';
|
|
29
33
|
import { BackToTopButton, BadgeList, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
30
34
|
import * as Stories from './List.stories';
|
|
@@ -46,15 +50,18 @@ List item is the main building block of list. Each item has its own set of prope
|
|
|
46
50
|
- [Props](#props)
|
|
47
51
|
- [`List`](#list-1)
|
|
48
52
|
- [`ListItem`](#listitem)
|
|
49
|
-
- [Advanced Usage](#advanced-usage)
|
|
50
|
-
- [Variants](#variants)
|
|
51
53
|
- [Examples](#examples)
|
|
52
|
-
- [
|
|
53
|
-
- [
|
|
54
|
-
- [
|
|
55
|
-
- [
|
|
56
|
-
- [
|
|
57
|
-
- [
|
|
54
|
+
- [`ListItem` with container](#listitem-with-container)
|
|
55
|
+
- [`ListItem` with `Badge`](#listitem-with-badge)
|
|
56
|
+
- [`ListItem` with `Switch`](#listitem-with-switch)
|
|
57
|
+
- [`List` with `SectionHeader`](#list-with-sectionheader)
|
|
58
|
+
- [`List` with `ListAction`](#list-with-listaction)
|
|
59
|
+
- [`ListItem` with transaction](#listitem-with-transaction)
|
|
60
|
+
- [`ListItem` with numeric value](#listitem-with-numeric-value)
|
|
61
|
+
- [`ListItem` with `Link`](#listitem-with-link)
|
|
62
|
+
- [`List` with `FlatList`](#list-with-flatlist)
|
|
63
|
+
- [Advanced Usage](#advanced-usage)
|
|
64
|
+
- [Accessibility](#accessibility)
|
|
58
65
|
|
|
59
66
|
## Playground
|
|
60
67
|
|
|
@@ -65,10 +72,10 @@ List item is the main building block of list. Each item has its own set of prope
|
|
|
65
72
|
## Usage
|
|
66
73
|
|
|
67
74
|
<UsageWrap>
|
|
68
|
-
<List heading="Heading" helperText="Supporting text"
|
|
69
|
-
<ListItem
|
|
70
|
-
<ListItem
|
|
71
|
-
<ListItem
|
|
75
|
+
<List heading="Heading" helperText="Supporting text">
|
|
76
|
+
<ListItem heading="List Item 1" onPress={() => console.log('item pressed')} />
|
|
77
|
+
<ListItem heading="List Item 2" onPress={() => console.log('item pressed')} />
|
|
78
|
+
<ListItem heading="List Item 3" onPress={() => console.log('item pressed')} />
|
|
72
79
|
</List>
|
|
73
80
|
</UsageWrap>
|
|
74
81
|
|
|
@@ -76,10 +83,10 @@ List item is the main building block of list. Each item has its own set of prope
|
|
|
76
83
|
import { List, ListItem } from '@utilitywarehouse/hearth-react-native';
|
|
77
84
|
|
|
78
85
|
const MyComponent = () => (
|
|
79
|
-
<List
|
|
80
|
-
<ListItem
|
|
81
|
-
<ListItem
|
|
82
|
-
<ListItem
|
|
86
|
+
<List heading="Heading" helperText="Supporting text">
|
|
87
|
+
<ListItem heading="List Item 1" onPress={() => console.log('item pressed')} />
|
|
88
|
+
<ListItem heading="List Item 2" onPress={() => console.log('item pressed')} />
|
|
89
|
+
<ListItem heading="List Item 3" onPress={() => console.log('item pressed')} />
|
|
83
90
|
</List>
|
|
84
91
|
);
|
|
85
92
|
```
|
|
@@ -88,35 +95,38 @@ const MyComponent = () => (
|
|
|
88
95
|
|
|
89
96
|
### `List`
|
|
90
97
|
|
|
91
|
-
| Name
|
|
92
|
-
|
|
|
93
|
-
| container
|
|
94
|
-
| heading
|
|
95
|
-
| helperText
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
| linkTarget | `'_blank' \| '_self' \| '_parent' \| '_top'` | | Target for the link in the heading. | |
|
|
100
|
-
| linkIcon | `ComponentType` | | Icon for the heading link. |
|
|
101
|
-
| linkIconPosition | `'left' \| 'right'` | `'right'` | Position of the icon in the heading link. |
|
|
102
|
-
| linkShowIcon | `boolean` | `true` | Whether to show the icon in the heading link. |
|
|
103
|
-
| divider | `boolean` | `false` | Whether to display a divider below the list items. |
|
|
104
|
-
| loading | `boolean` | `false` | Whether to show the list items in loading state. |
|
|
105
|
-
| disabled | `boolean` | `false` | Whether to disable the list. |
|
|
98
|
+
| Name | Type | Default | Description |
|
|
99
|
+
| --------------------- | ------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------ |
|
|
100
|
+
| container | `'none' \| 'subtleWhite' \| 'emphasisWhite' \|` <br /> `'subtleWarmWhite' \| 'emphasisWarmWhite'` | `'none'` | The container style of the list. |
|
|
101
|
+
| heading | `string` | | The text to display in the heading of the list. |
|
|
102
|
+
| helperText | `string` | | The supporting text to display in the heading of the list. |
|
|
103
|
+
| headerTrailingContent | `ReactNode` | | Optional content to display on the right side of the header. |
|
|
104
|
+
| loading | `boolean` | `false` | Whether to show the list items in loading state. |
|
|
105
|
+
| disabled | `boolean` | `false` | Whether to disable the list. |
|
|
106
106
|
|
|
107
107
|
### `ListItem`
|
|
108
108
|
|
|
109
|
-
| Name | Type | Default
|
|
110
|
-
| --------------- | ------------------------ |
|
|
111
|
-
|
|
|
112
|
-
| onPress | `() => void` |
|
|
113
|
-
| helperText | `string` |
|
|
114
|
-
| leadingContent | `ReactNode` |
|
|
115
|
-
| trailingContent | `ReactNode` |
|
|
116
|
-
| variant | `'subtle' \| 'emphasis'` |
|
|
117
|
-
| disabled | `boolean` | `false`
|
|
118
|
-
| loading | `boolean` | `false`
|
|
119
|
-
|
|
|
109
|
+
| Name | Type | Default | Description |
|
|
110
|
+
| --------------- | ------------------------ | -------- | --------------------------------------------------------------- |
|
|
111
|
+
| heading | `string` | | The text to display in the list item. |
|
|
112
|
+
| onPress | `() => void` | | A callback function to be called when the list item is pressed. |
|
|
113
|
+
| helperText | `string` | | The supporting text to display in the list item. |
|
|
114
|
+
| leadingContent | `ReactNode` | | The leading content to display in the list item. |
|
|
115
|
+
| trailingContent | `ReactNode` | | The trailing content to display in the list item. |
|
|
116
|
+
| variant | `'subtle' \| 'emphasis'` | | The variant style of the list item. |
|
|
117
|
+
| disabled | `boolean` | `false` | Whether to disable the list item. |
|
|
118
|
+
| loading | `boolean` | `false` | Whether to show the list item in loading state. |
|
|
119
|
+
| badge | `BadgeProps` | | Props to pass to the Badge component. |
|
|
120
|
+
| badgePosition | `'top' \| 'bottom'` | `bottom` | Position of the badge in the list item. |
|
|
121
|
+
| numericValue | `string \| number` | | A numeric value to display on the right side of the item. |
|
|
122
|
+
|
|
123
|
+
### `ListAction`
|
|
124
|
+
|
|
125
|
+
| Name | Type | Default | Description |
|
|
126
|
+
| -------- | ------------ | ------- | -------------------------------------------- |
|
|
127
|
+
| heading | `string` | | The text to display in the list action item. |
|
|
128
|
+
| onPress | `() => void` | | A callback function to be called |
|
|
129
|
+
| disabled | `boolean` | `false` | Whether to disable the list action item. |
|
|
120
130
|
|
|
121
131
|
#### - `ListItemLeadingContent`
|
|
122
132
|
|
|
@@ -140,9 +150,319 @@ const MyComponent = () => (
|
|
|
140
150
|
| ---- | --------------- | ------- | ----------------------------------------------- |
|
|
141
151
|
| as | `ComponentType` | | The icon component to display in the list item. |
|
|
142
152
|
|
|
153
|
+
## Examples
|
|
154
|
+
|
|
155
|
+
### `ListItem` with Container
|
|
156
|
+
|
|
157
|
+
Thie `List` has an inbuilt `Card` component to wrap the list items and setting the `container` prop to one if `subtleWhite`,
|
|
158
|
+
`emphasisWhite`, `subtleWarmWhite`, or `emphasisWarmWhite` will apply the respective background color and border colour to
|
|
159
|
+
the `Card` and child `ListItem` components.
|
|
160
|
+
|
|
161
|
+
<Canvas of={Stories.WithContainer} />
|
|
162
|
+
|
|
163
|
+
```tsx
|
|
164
|
+
import { List, ListItem, Card } from '@utilitywarehouse/hearth-react-native';
|
|
165
|
+
import {
|
|
166
|
+
BillMediumIcon,
|
|
167
|
+
PaymentMediumIcon,
|
|
168
|
+
HomeMediumIcon,
|
|
169
|
+
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
170
|
+
|
|
171
|
+
const MyComponent = () => (
|
|
172
|
+
<List container="subtleWhite">
|
|
173
|
+
<ListItem
|
|
174
|
+
leadingContent={<BillMediumIcon />}
|
|
175
|
+
heading="Bills"
|
|
176
|
+
onPress={() => console.log('item pressed')}
|
|
177
|
+
/>
|
|
178
|
+
<ListItem
|
|
179
|
+
leadingContent={<PaymentMediumIcon />}
|
|
180
|
+
heading="Payments"
|
|
181
|
+
onPress={() => console.log('item pressed')}
|
|
182
|
+
/>
|
|
183
|
+
<ListItem
|
|
184
|
+
leadingContent={<HomeMediumIcon />}
|
|
185
|
+
heading="Moving Home"
|
|
186
|
+
onPress={() => console.log('item pressed')}
|
|
187
|
+
/>
|
|
188
|
+
</List>
|
|
189
|
+
);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### `ListItem` with `Badge`
|
|
193
|
+
|
|
194
|
+
You can use the `Badge` component to display additional information in the list item. You can achieve this by using the List Item's
|
|
195
|
+
parts like `ListItemLeadingContent`, `ListItemContent`, and `ListItemTrailingContent` components.
|
|
196
|
+
|
|
197
|
+
<Canvas of={Stories.WithBadge} />
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
import { List, ListItem, IconContainer, Flex, Box } from '@utilitywarehouse/hearth-react-native';
|
|
201
|
+
|
|
202
|
+
import { ElectricityMediumIcon, GasMediumIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
203
|
+
|
|
204
|
+
const BadgeList = () => {
|
|
205
|
+
return (
|
|
206
|
+
<List>
|
|
207
|
+
<ListItem
|
|
208
|
+
heading="Electricity"
|
|
209
|
+
helperText="Last reading 23/03/24"
|
|
210
|
+
onPress={() => console.log('pressed')}
|
|
211
|
+
leadingContent={
|
|
212
|
+
<IconContainer icon={ElectricityMediumIcon} size="md" variant="emphasis" color="energy" />
|
|
213
|
+
}
|
|
214
|
+
badge={{ text: 'Text' }}
|
|
215
|
+
/>
|
|
216
|
+
<ListItem
|
|
217
|
+
heading="Gas"
|
|
218
|
+
helperText="Last reading 23/03/24"
|
|
219
|
+
onPress={() => console.log('pressed')}
|
|
220
|
+
leadingContent={
|
|
221
|
+
<IconContainer icon={GasMediumIcon} size="md" variant="emphasis" color="energy" />
|
|
222
|
+
}
|
|
223
|
+
badge={{ text: 'Smart Meter' }}
|
|
224
|
+
/>
|
|
225
|
+
</List>
|
|
226
|
+
);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export default BadgeList;
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### `ListItem` with `Switch`
|
|
233
|
+
|
|
234
|
+
You can use a `Switch` component as the trailing content of a `ListItem` to create toggleable list items.
|
|
235
|
+
|
|
236
|
+
<Canvas of={Stories.WithSwitch} />
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
import { List, ListItem, Switch } from '@utilitywarehouse/hearth-react-native';
|
|
240
|
+
|
|
241
|
+
const MyComponent = () => (
|
|
242
|
+
<List container="subtleWhite">
|
|
243
|
+
<ListItem
|
|
244
|
+
heading="Enable notifications"
|
|
245
|
+
helperText="Receive updates and alerts"
|
|
246
|
+
onPress={() => console.log('item pressed')}
|
|
247
|
+
trailingContent={
|
|
248
|
+
<Switch size="small" value={true} onValueChange={() => console.log('switch toggled')} />
|
|
249
|
+
}
|
|
250
|
+
/>
|
|
251
|
+
<ListItem
|
|
252
|
+
heading="Dark mode"
|
|
253
|
+
helperText="Use dark theme throughout the app"
|
|
254
|
+
onPress={() => console.log('item pressed')}
|
|
255
|
+
trailingContent={
|
|
256
|
+
<Switch size="small" value={false} onValueChange={() => console.log('switch toggled')} />
|
|
257
|
+
}
|
|
258
|
+
/>
|
|
259
|
+
</List>
|
|
260
|
+
);
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### `List` with `SectionHeader`
|
|
264
|
+
|
|
265
|
+
You can use the `SectionHeader` component to add a heading and supporting text to your list.
|
|
266
|
+
|
|
267
|
+
<Canvas of={Stories.WithSectionHeader} />
|
|
268
|
+
|
|
269
|
+
```tsx
|
|
270
|
+
import {
|
|
271
|
+
List,
|
|
272
|
+
ListItem,
|
|
273
|
+
ListItemIcon,
|
|
274
|
+
ListItemTrailingIcon,
|
|
275
|
+
} from '@utilitywarehouse/hearth-react-native';
|
|
276
|
+
import {
|
|
277
|
+
BillMediumIcon,
|
|
278
|
+
ChevronRightSmallIcon,
|
|
279
|
+
PaymentMediumIcon,
|
|
280
|
+
HomeMediumIcon,
|
|
281
|
+
UserMediumIcon,
|
|
282
|
+
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
283
|
+
|
|
284
|
+
const MyComponent = ({ navigate }) => (
|
|
285
|
+
<List
|
|
286
|
+
heading="Your account"
|
|
287
|
+
helperText="Tap the links below to view your account"
|
|
288
|
+
headerTrailingContent={<Link onPress={navigate('account')}>View all</Link>}
|
|
289
|
+
>
|
|
290
|
+
<ListItem
|
|
291
|
+
heading="Bills"
|
|
292
|
+
helperText="View your bills"
|
|
293
|
+
leadingContent={<ListItemIcon as={BillMediumIcon} />}
|
|
294
|
+
trailingContent={<ListItemTrailingIcon as={ChevronRightSmallIcon} />}
|
|
295
|
+
onPress={() => console.log('pressed')}
|
|
296
|
+
/>
|
|
297
|
+
<ListItem
|
|
298
|
+
heading="Payments"
|
|
299
|
+
helperText="Make a payment"
|
|
300
|
+
leadingContent={<ListItemIcon as={PaymentMediumIcon} />}
|
|
301
|
+
trailingContent={<ListItemTrailingIcon as={ChevronRightSmallIcon} />}
|
|
302
|
+
onPress={() => console.log('pressed')}
|
|
303
|
+
/>
|
|
304
|
+
<ListItem
|
|
305
|
+
heading="Moving home"
|
|
306
|
+
helperText="Tell us if you're moving"
|
|
307
|
+
leadingContent={<ListItemIcon as={HomeMediumIcon} />}
|
|
308
|
+
trailingContent={<ListItemTrailingIcon as={ChevronRightSmallIcon} />}
|
|
309
|
+
onPress={() => console.log('pressed')}
|
|
310
|
+
/>
|
|
311
|
+
<ListItem
|
|
312
|
+
heading="Refer a friend"
|
|
313
|
+
helperText="Get rewarded with a friend"
|
|
314
|
+
leadingContent={<ListItemIcon as={UserMediumIcon} />}
|
|
315
|
+
trailingContent={<ListItemTrailingIcon as={ChevronRightSmallIcon} />}
|
|
316
|
+
onPress={() => console.log('pressed')}
|
|
317
|
+
/>
|
|
318
|
+
</List>
|
|
319
|
+
);
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
### `List` with `ListAction`
|
|
323
|
+
|
|
324
|
+
You can use the `ListAction` component to add actionable items to your list.
|
|
325
|
+
|
|
326
|
+
<Canvas of={Stories.WithListAction} />
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
import {
|
|
330
|
+
List,
|
|
331
|
+
ListItem,
|
|
332
|
+
ListItemTrailingIcon,
|
|
333
|
+
ListAction,
|
|
334
|
+
} from '@utilitywarehouse/hearth-react-native';
|
|
335
|
+
|
|
336
|
+
const MyComponent = () => (
|
|
337
|
+
<List container="subtleWarmWhite">
|
|
338
|
+
<ListItem
|
|
339
|
+
heading="Upgrade your plan"
|
|
340
|
+
helperText="Get more features with a premium plan"
|
|
341
|
+
onPress={() => console.log('Upgrade pressed')}
|
|
342
|
+
/>
|
|
343
|
+
<ListItem
|
|
344
|
+
heading="Manage payment methods"
|
|
345
|
+
helperText="Update your credit or debit cards"
|
|
346
|
+
onPress={() => console.log('Manage pressed')}
|
|
347
|
+
/>
|
|
348
|
+
<ListAction heading="Contact support" onPress={() => console.log('Contact pressed')} />
|
|
349
|
+
</List>
|
|
350
|
+
);
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### `ListItem` with transaction
|
|
354
|
+
|
|
355
|
+
You can use the `ListItem` component to display transaction details.
|
|
356
|
+
|
|
357
|
+
<Canvas of={Stories.WithTransactions} />
|
|
358
|
+
|
|
359
|
+
```tsx
|
|
360
|
+
import { List, ListItem, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
361
|
+
const MyComponent = () => (
|
|
362
|
+
<List container="subtleWhite">
|
|
363
|
+
<ListItem
|
|
364
|
+
heading="Coffee Shop"
|
|
365
|
+
helperText="Apr 5, 2024"
|
|
366
|
+
trailingContent={
|
|
367
|
+
<>
|
|
368
|
+
<BodyText>-£100.00</BodyText>
|
|
369
|
+
<BodyText color="textBrand">-£100.00</BodyText>
|
|
370
|
+
</>
|
|
371
|
+
}
|
|
372
|
+
onPress={() => console.log('Transaction pressed')}
|
|
373
|
+
/>
|
|
374
|
+
<ListItem
|
|
375
|
+
heading="Top up"
|
|
376
|
+
helperText="Apr 4, 2024"
|
|
377
|
+
trailingContent={
|
|
378
|
+
<>
|
|
379
|
+
<BodyText color="textAffirmative">+£100.00</BodyText>
|
|
380
|
+
</>
|
|
381
|
+
}
|
|
382
|
+
onPress={() => console.log('Transaction pressed')}
|
|
383
|
+
/>
|
|
384
|
+
</List>
|
|
385
|
+
);
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
### `ListItem` with numeric value
|
|
389
|
+
|
|
390
|
+
You can use the `numericValue` prop to display a numeric value on the right side of the `ListItem`.
|
|
391
|
+
|
|
392
|
+
<Canvas of={Stories.WithNumericValue} />
|
|
393
|
+
|
|
394
|
+
```tsx
|
|
395
|
+
import { List, ListItem } from '@utilitywarehouse/hearth-react-native';
|
|
396
|
+
|
|
397
|
+
const MyComponent = () => (
|
|
398
|
+
<List container="subtleWhite">
|
|
399
|
+
<ListItem
|
|
400
|
+
heading="Steps today"
|
|
401
|
+
numericValue="8,542"
|
|
402
|
+
onPress={() => console.log('Steps pressed')}
|
|
403
|
+
/>
|
|
404
|
+
<ListItem
|
|
405
|
+
heading="Calories burned"
|
|
406
|
+
numericValue="2,300 kcal"
|
|
407
|
+
onPress={() => console.log('Calories pressed')}
|
|
408
|
+
/>
|
|
409
|
+
</List>
|
|
410
|
+
);
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### `ListItem` with `Link`
|
|
414
|
+
|
|
415
|
+
You can use a `Link` component as the trailing content of a `ListItem` to create list items with links.
|
|
416
|
+
|
|
417
|
+
<Canvas of={Stories.WithLink} />
|
|
418
|
+
|
|
419
|
+
```tsx
|
|
420
|
+
import { List, ListItem, Link } from '@utilitywarehouse/hearth-react-native';
|
|
421
|
+
|
|
422
|
+
const MyComponent = () => (
|
|
423
|
+
<List container="subtleWhite">
|
|
424
|
+
<ListItem
|
|
425
|
+
heading="Terms of Service"
|
|
426
|
+
onPress={() => console.log('item pressed')}
|
|
427
|
+
trailingContent={<Link onPress={() => console.log('link pressed')}>View</Link>}
|
|
428
|
+
/>
|
|
429
|
+
<ListItem
|
|
430
|
+
heading="Privacy Policy"
|
|
431
|
+
onPress={() => console.log('item pressed')}
|
|
432
|
+
trailingContent={<Link onPress={() => console.log('link pressed')}>View</Link>}
|
|
433
|
+
/>
|
|
434
|
+
</List>
|
|
435
|
+
);
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### `List` with `FlatList`
|
|
439
|
+
|
|
440
|
+
You can use the `FlatList` component to render a large list of items efficiently.
|
|
441
|
+
|
|
442
|
+
```tsx
|
|
443
|
+
import { FlatList } from 'react-native';
|
|
444
|
+
import { List, ListItem } from '@utilitywarehouse/hearth-react-native';
|
|
445
|
+
|
|
446
|
+
const MyComponent = () => (
|
|
447
|
+
<List container="subtleWhite">
|
|
448
|
+
<FlatList
|
|
449
|
+
data={[
|
|
450
|
+
{ id: '1', heading: 'Item 1' },
|
|
451
|
+
{ id: '2', heading: 'Item 2' },
|
|
452
|
+
{ id: '3', heading: 'Item 3' },
|
|
453
|
+
]}
|
|
454
|
+
renderItem={({ item }) => (
|
|
455
|
+
<ListItem heading={item.heading} onPress={() => console.log(`${item.heading} pressed`)} />
|
|
456
|
+
)}
|
|
457
|
+
keyExtractor={item => item.id}
|
|
458
|
+
/>
|
|
459
|
+
</List>
|
|
460
|
+
);
|
|
461
|
+
```
|
|
462
|
+
|
|
143
463
|
## Advanced Usage
|
|
144
464
|
|
|
145
|
-
If you need to use the List component in a more advanced way, you can use the parts of the component directly.
|
|
465
|
+
If you need to use the `<List>` component in a more advanced way, you can use the parts of the component directly.
|
|
146
466
|
|
|
147
467
|
<UsageWrap>
|
|
148
468
|
<List>
|
|
@@ -274,147 +594,24 @@ const MyComponent = () => (
|
|
|
274
594
|
);
|
|
275
595
|
```
|
|
276
596
|
|
|
277
|
-
##
|
|
597
|
+
## Accessibility
|
|
278
598
|
|
|
279
|
-
The
|
|
599
|
+
The List component is designed with accessibility in mind to ensure all users can interact with list items effectively.
|
|
280
600
|
|
|
281
|
-
|
|
601
|
+
### Screen Reader Support
|
|
282
602
|
|
|
283
|
-
|
|
603
|
+
- **List Items with `onPress`**: When a `ListItem` has an `onPress` handler, it is automatically exposed to screen readers (VoiceOver on iOS and TalkBack on Android) as an interactive element. Users can focus on and activate these items using assistive technologies.
|
|
284
604
|
|
|
285
|
-
|
|
605
|
+
- **List Items without `onPress`**: Non-interactive list items are still accessible to screen readers, allowing users to navigate through and read the content. The list structure is preserved for context.
|
|
286
606
|
|
|
287
|
-
|
|
288
|
-
`emphasisWhite`, `subtleWarmWhite`, or `emphasisWarmWhite` will apply the respective background color and border colour to
|
|
289
|
-
the `Card` and child `ListItem` components.
|
|
607
|
+
- **List with Container**: When using the `container` prop (e.g., `subtleWhite`, `emphasisWhite`), the List wraps items in a Card component. The Card wrapper itself is hidden from screen readers, but all ListItems remain fully accessible and focusable.
|
|
290
608
|
|
|
291
|
-
|
|
292
|
-
<List container="subtleWhite">
|
|
293
|
-
<ListItem
|
|
294
|
-
leadingContent={<BillMediumIcon />}
|
|
295
|
-
text="Bills"
|
|
296
|
-
divider
|
|
297
|
-
onPress={() => console.log('item pressed')}
|
|
298
|
-
/>
|
|
299
|
-
<ListItem
|
|
300
|
-
leadingContent={<PaymentMediumIcon />}
|
|
301
|
-
text="Payments"
|
|
302
|
-
divider
|
|
303
|
-
onPress={() => console.log('item pressed')}
|
|
304
|
-
/>
|
|
305
|
-
<ListItem
|
|
306
|
-
leadingContent={<HomeMediumIcon />}
|
|
307
|
-
text="Moving Home"
|
|
308
|
-
onPress={() => console.log('item pressed')}
|
|
309
|
-
/>
|
|
310
|
-
</List>
|
|
311
|
-
</UsageWrap>
|
|
609
|
+
- **ListAction**: The `ListAction` component is always interactive and accessible as a button element with screen readers.
|
|
312
610
|
|
|
313
|
-
|
|
314
|
-
import { List, ListItem, Card } from '@utilitywarehouse/hearth-react-native';
|
|
315
|
-
import {
|
|
316
|
-
BillMediumIcon,
|
|
317
|
-
PaymentMediumIcon,
|
|
318
|
-
HomeMediumIcon,
|
|
319
|
-
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
611
|
+
### Best Practices
|
|
320
612
|
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
divider
|
|
327
|
-
onPress={() => console.log('item pressed')}
|
|
328
|
-
/>
|
|
329
|
-
<ListItem
|
|
330
|
-
leadingContent={<PaymentMediumIcon />}
|
|
331
|
-
text="Payments"
|
|
332
|
-
divider
|
|
333
|
-
onPress={() => console.log('item pressed')}
|
|
334
|
-
/>
|
|
335
|
-
<ListItem
|
|
336
|
-
leadingContent={<HomeMediumIcon />}
|
|
337
|
-
text="Moving Home"
|
|
338
|
-
onPress={() => console.log('item pressed')}
|
|
339
|
-
/>
|
|
340
|
-
</List>
|
|
341
|
-
);
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
### List Item with Badge
|
|
345
|
-
|
|
346
|
-
You can use the `Badge` component to display additional information in the list item. You can achieve this by using the List Item's
|
|
347
|
-
parts like `ListItemLeadingContent`, `ListItemContent`, and `ListItemTrailingContent` components.
|
|
348
|
-
|
|
349
|
-
<UsageWrap>
|
|
350
|
-
<BadgeList />
|
|
351
|
-
</UsageWrap>
|
|
352
|
-
|
|
353
|
-
```tsx
|
|
354
|
-
import {
|
|
355
|
-
List,
|
|
356
|
-
ListItem,
|
|
357
|
-
ListItemIcon,
|
|
358
|
-
ListItemLeadingContent,
|
|
359
|
-
ListItemHelperText,
|
|
360
|
-
ListItemText,
|
|
361
|
-
ListItemTrailingContent,
|
|
362
|
-
ListItemTrailingIcon,
|
|
363
|
-
ListItemContent,
|
|
364
|
-
Badge,
|
|
365
|
-
BadgeText,
|
|
366
|
-
Flex,
|
|
367
|
-
Box,
|
|
368
|
-
} from '@utilitywarehouse/hearth-react-native';
|
|
369
|
-
|
|
370
|
-
import {
|
|
371
|
-
ChevronRightSmallIcon,
|
|
372
|
-
ElectricityMediumIcon,
|
|
373
|
-
GasMediumIcon,
|
|
374
|
-
} from '@utilitywarehouse/hearth-react-native-icons';
|
|
375
|
-
|
|
376
|
-
const BadgeList = () => {
|
|
377
|
-
return (
|
|
378
|
-
<List>
|
|
379
|
-
<ListItem onPress={() => console.log('pressed')} divider>
|
|
380
|
-
<ListItemLeadingContent>
|
|
381
|
-
<Box padding="300" borderRadius="lg" bg={'energyBlue'}>
|
|
382
|
-
<ListItemIcon as={ElectricityMediumIcon} color="green900" />
|
|
383
|
-
</Box>
|
|
384
|
-
</ListItemLeadingContent>
|
|
385
|
-
<ListItemContent>
|
|
386
|
-
<ListItemText>Electricity</ListItemText>
|
|
387
|
-
<Badge colorScheme="info">
|
|
388
|
-
<BadgeText>Text</BadgeText>
|
|
389
|
-
</Badge>
|
|
390
|
-
<ListItemHelperText>Last reading 23/03/24</ListItemHelperText>
|
|
391
|
-
</ListItemContent>
|
|
392
|
-
<ListItemTrailingContent>
|
|
393
|
-
<ListItemTrailingIcon as={ChevronRightSmallIcon} />
|
|
394
|
-
</ListItemTrailingContent>
|
|
395
|
-
</ListItem>
|
|
396
|
-
<ListItem onPress={() => console.log('pressed')} divider={false}>
|
|
397
|
-
<ListItemLeadingContent>
|
|
398
|
-
<Box padding="300" borderRadius="lg" bg={'energyBlue'}>
|
|
399
|
-
<ListItemIcon as={GasMediumIcon} color="green900" />
|
|
400
|
-
</Box>
|
|
401
|
-
</ListItemLeadingContent>
|
|
402
|
-
<ListItemContent>
|
|
403
|
-
<Flex direction="row" style={{ justifyContent: 'space-between' }}>
|
|
404
|
-
<ListItemText>Gas</ListItemText>
|
|
405
|
-
<Badge colorScheme="positive">
|
|
406
|
-
<BadgeText>Smart meter</BadgeText>
|
|
407
|
-
</Badge>
|
|
408
|
-
</Flex>
|
|
409
|
-
<ListItemHelperText>Last reading 23/03/24</ListItemHelperText>
|
|
410
|
-
</ListItemContent>
|
|
411
|
-
<ListItemTrailingContent>
|
|
412
|
-
<ListItemTrailingIcon as={ChevronRightSmallIcon} />
|
|
413
|
-
</ListItemTrailingContent>
|
|
414
|
-
</ListItem>
|
|
415
|
-
</List>
|
|
416
|
-
);
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
export default BadgeList;
|
|
420
|
-
```
|
|
613
|
+
- Use descriptive `heading` and `helperText` to provide clear context for each list item
|
|
614
|
+
- Ensure `onPress` handlers provide meaningful feedback for interactive items
|
|
615
|
+
- When using custom content with `children`, ensure all interactive elements are properly labeled
|
|
616
|
+
- Test with VoiceOver (iOS) and TalkBack (Android) to verify the experience
|
|
617
|
+
- Avoid nesting too many interactive elements within a single ListItem to prevent confusion
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
import type { ViewProps } from 'react-native';
|
|
2
|
-
import { ComponentType } from 'react';
|
|
3
2
|
|
|
4
3
|
interface ListProps extends ViewProps {
|
|
5
4
|
container?: 'none' | 'subtleWhite' | 'emphasisWhite' | 'subtleWarmWhite' | 'emphasisWarmWhite';
|
|
6
5
|
heading?: string;
|
|
7
6
|
helperText?: string;
|
|
8
|
-
|
|
9
|
-
linkHref?: string;
|
|
10
|
-
linkIcon?: ComponentType;
|
|
11
|
-
linkIconPosition?: 'left' | 'right';
|
|
12
|
-
linkOnPress?: () => void;
|
|
13
|
-
linkTarget?: '_blank' | '_self' | '_parent' | '_top';
|
|
14
|
-
linkShowIcon?: boolean;
|
|
7
|
+
headerTrailingContent?: React.ReactNode;
|
|
15
8
|
disabled?: boolean;
|
|
16
9
|
loading?: boolean;
|
|
17
|
-
divider?: boolean;
|
|
18
10
|
}
|
|
19
11
|
|
|
20
12
|
export default ListProps;
|