@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.
Files changed (207) hide show
  1. package/.storybook/main.ts +21 -1
  2. package/.turbo/turbo-build.log +1 -1
  3. package/.turbo/turbo-lint.log +1 -1
  4. package/CHANGELOG.md +52 -0
  5. package/build/components/Alert/AlertTitle.js +6 -6
  6. package/build/components/Badge/Badge.js +3 -3
  7. package/build/components/Badge/Badge.props.d.ts +1 -0
  8. package/build/components/Button/ButtonRoot.js +4 -0
  9. package/build/components/Button/ButtonText.js +2 -2
  10. package/build/components/Card/CardRoot.js +1 -1
  11. package/build/components/Carousel/Carousel.context.d.ts +4 -0
  12. package/build/components/Carousel/Carousel.context.js +4 -0
  13. package/build/components/Carousel/Carousel.d.ts +6 -0
  14. package/build/components/Carousel/Carousel.js +278 -0
  15. package/build/components/Carousel/Carousel.props.d.ts +65 -0
  16. package/build/components/Carousel/Carousel.props.js +1 -0
  17. package/build/components/Carousel/CarouselControlItem.d.ts +24 -0
  18. package/build/components/Carousel/CarouselControlItem.js +64 -0
  19. package/build/components/Carousel/CarouselControls.d.ts +4 -0
  20. package/build/components/Carousel/CarouselControls.js +74 -0
  21. package/build/components/Carousel/CarouselItem.d.ts +6 -0
  22. package/build/components/Carousel/CarouselItem.js +38 -0
  23. package/build/components/Carousel/index.d.ts +5 -0
  24. package/build/components/Carousel/index.js +5 -0
  25. package/build/components/Container/Container.d.ts +6 -0
  26. package/build/components/Container/Container.js +40 -0
  27. package/build/components/Container/Container.props.d.ts +85 -0
  28. package/build/components/Container/Container.props.js +1 -0
  29. package/build/components/Container/index.d.ts +2 -0
  30. package/build/components/Container/index.js +1 -0
  31. package/build/components/DescriptionList/DescriptionList.d.ts +1 -1
  32. package/build/components/DescriptionList/DescriptionList.js +2 -2
  33. package/build/components/DescriptionList/DescriptionList.props.d.ts +1 -8
  34. package/build/components/DescriptionList/DescriptionListItem.d.ts +1 -1
  35. package/build/components/DescriptionList/DescriptionListItem.js +4 -3
  36. package/build/components/DescriptionList/DescriptionListItem.props.d.ts +3 -8
  37. package/build/components/IndicatorIconButton/IndicatorIconButton.d.ts +6 -0
  38. package/build/components/IndicatorIconButton/IndicatorIconButton.js +26 -0
  39. package/build/components/IndicatorIconButton/IndicatorIconButton.props.d.ts +8 -0
  40. package/build/components/IndicatorIconButton/IndicatorIconButton.props.js +1 -0
  41. package/build/components/IndicatorIconButton/index.d.ts +2 -0
  42. package/build/components/IndicatorIconButton/index.js +1 -0
  43. package/build/components/Link/LinkText.js +3 -3
  44. package/build/components/List/List.context.d.ts +0 -2
  45. package/build/components/List/List.d.ts +1 -1
  46. package/build/components/List/List.js +5 -5
  47. package/build/components/List/List.props.d.ts +1 -9
  48. package/build/components/List/ListAction/ListAction.d.ts +18 -0
  49. package/build/components/List/ListAction/ListAction.js +103 -0
  50. package/build/components/List/ListAction/ListAction.props.d.ts +8 -0
  51. package/build/components/List/ListAction/ListAction.props.js +1 -0
  52. package/build/components/List/ListAction/ListActionContent.d.ts +6 -0
  53. package/build/components/List/ListAction/ListActionContent.js +14 -0
  54. package/build/components/List/ListAction/ListActionText.d.ts +6 -0
  55. package/build/components/List/ListAction/ListActionText.js +7 -0
  56. package/build/components/List/ListAction/ListActionTrailingContent.d.ts +6 -0
  57. package/build/components/List/ListAction/ListActionTrailingContent.js +5 -0
  58. package/build/components/List/ListAction/ListActionTrailingIcon.d.ts +9 -0
  59. package/build/components/List/ListAction/ListActionTrailingIcon.js +18 -0
  60. package/build/components/List/ListAction/index.d.ts +6 -0
  61. package/build/components/List/ListAction/index.js +5 -0
  62. package/build/components/List/ListItem/ListItem.context.d.ts +1 -1
  63. package/build/components/List/ListItem/ListItem.props.d.ts +9 -5
  64. package/build/components/List/ListItem/ListItemRoot.d.ts +1 -1
  65. package/build/components/List/ListItem/ListItemRoot.js +10 -12
  66. package/build/components/List/ListItem/index.d.ts +4 -4
  67. package/build/components/List/ListItem/index.js +3 -3
  68. package/build/components/List/index.d.ts +1 -0
  69. package/build/components/List/index.js +1 -0
  70. package/build/components/ProgressStepper/ProgressStep.d.ts +10 -0
  71. package/build/components/ProgressStepper/ProgressStep.js +100 -0
  72. package/build/components/ProgressStepper/ProgressStepper.d.ts +6 -0
  73. package/build/components/ProgressStepper/ProgressStepper.js +22 -0
  74. package/build/components/ProgressStepper/ProgressStepper.props.d.ts +22 -0
  75. package/build/components/ProgressStepper/ProgressStepper.props.js +1 -0
  76. package/build/components/ProgressStepper/ProgressStepperRoot.d.ts +6 -0
  77. package/build/components/ProgressStepper/ProgressStepperRoot.js +16 -0
  78. package/build/components/ProgressStepper/index.d.ts +3 -0
  79. package/build/components/ProgressStepper/index.js +2 -0
  80. package/build/components/SectionHeader/SectionHeader.d.ts +1 -1
  81. package/build/components/SectionHeader/SectionHeader.js +6 -3
  82. package/build/components/SectionHeader/SectionHeader.props.d.ts +9 -16
  83. package/build/components/SectionHeader/SectionHeaderTrailingContent.d.ts +6 -0
  84. package/build/components/SectionHeader/SectionHeaderTrailingContent.js +13 -0
  85. package/build/components/SectionHeader/index.d.ts +1 -0
  86. package/build/components/SectionHeader/index.js +1 -0
  87. package/build/components/Tabs/Tab.js +2 -2
  88. package/build/components/ThemedImage/ThemedImage.d.ts +12 -0
  89. package/build/components/ThemedImage/ThemedImage.js +27 -0
  90. package/build/components/ThemedImage/ThemedImage.props.d.ts +13 -0
  91. package/build/components/ThemedImage/ThemedImage.props.js +1 -0
  92. package/build/components/ThemedImage/index.d.ts +2 -0
  93. package/build/components/ThemedImage/index.js +1 -0
  94. package/build/components/ToggleButton/ToggleButtonText.js +2 -2
  95. package/build/components/UnstyledIconButton/UnstyledIconButton.props.d.ts +4 -1
  96. package/build/components/index.d.ts +5 -0
  97. package/build/components/index.js +5 -0
  98. package/build/core/themes.d.ts +12 -24
  99. package/build/hooks/useStyleProps.js +1 -1
  100. package/build/tokens/components/dark/button.d.ts +1 -1
  101. package/build/tokens/components/dark/button.js +1 -1
  102. package/build/tokens/components/dark/dialog.d.ts +1 -0
  103. package/build/tokens/components/dark/dialog.js +1 -0
  104. package/build/tokens/components/dark/illustrations.d.ts +1 -0
  105. package/build/tokens/components/dark/illustrations.js +1 -0
  106. package/build/tokens/components/dark/toast.d.ts +4 -1
  107. package/build/tokens/components/dark/toast.js +4 -1
  108. package/build/tokens/components/light/button.d.ts +1 -1
  109. package/build/tokens/components/light/button.js +1 -1
  110. package/build/tokens/components/light/dialog.d.ts +1 -0
  111. package/build/tokens/components/light/dialog.js +1 -0
  112. package/build/tokens/components/light/illustrations.d.ts +1 -0
  113. package/build/tokens/components/light/illustrations.js +1 -0
  114. package/build/tokens/components/light/toast.d.ts +4 -1
  115. package/build/tokens/components/light/toast.js +4 -1
  116. package/build/tokens/layout.d.ts +6 -12
  117. package/build/tokens/layout.js +3 -6
  118. package/docs/components/AllComponents.web.tsx +122 -5
  119. package/docs/components/BadgeList.tsx +20 -56
  120. package/docs/components/SwitchList.tsx +4 -8
  121. package/docs/getting-started.mdx +30 -14
  122. package/docs/introduction.mdx +1 -1
  123. package/docs/layout-components.docs.mdx +30 -0
  124. package/package.json +6 -4
  125. package/src/components/Alert/AlertTitle.tsx +7 -7
  126. package/src/components/Badge/Badge.props.ts +1 -0
  127. package/src/components/Badge/Badge.tsx +3 -2
  128. package/src/components/Button/ButtonRoot.tsx +4 -0
  129. package/src/components/Button/ButtonText.tsx +3 -3
  130. package/src/components/Card/CardRoot.tsx +2 -0
  131. package/src/components/Carousel/Carousel.context.tsx +8 -0
  132. package/src/components/Carousel/Carousel.docs.mdx +389 -0
  133. package/src/components/Carousel/Carousel.props.ts +89 -0
  134. package/src/components/Carousel/Carousel.stories.tsx +317 -0
  135. package/src/components/Carousel/Carousel.tsx +444 -0
  136. package/src/components/Carousel/CarouselControlItem.tsx +87 -0
  137. package/src/components/Carousel/CarouselControls.tsx +150 -0
  138. package/src/components/Carousel/CarouselItem.tsx +68 -0
  139. package/src/components/Carousel/index.ts +6 -0
  140. package/src/components/Container/Container.docs.mdx +168 -0
  141. package/src/components/Container/Container.props.ts +89 -0
  142. package/src/components/Container/Container.stories.tsx +274 -0
  143. package/src/components/Container/Container.tsx +52 -0
  144. package/src/components/Container/index.tsx +2 -0
  145. package/src/components/DescriptionList/DescriptionList.docs.mdx +24 -27
  146. package/src/components/DescriptionList/DescriptionList.props.ts +1 -8
  147. package/src/components/DescriptionList/DescriptionList.stories.tsx +13 -19
  148. package/src/components/DescriptionList/DescriptionList.tsx +2 -14
  149. package/src/components/DescriptionList/DescriptionListItem.props.ts +3 -8
  150. package/src/components/DescriptionList/DescriptionListItem.tsx +13 -21
  151. package/src/components/IndicatorIconButton/IndicatorIconButton.docs.mdx +85 -0
  152. package/src/components/IndicatorIconButton/IndicatorIconButton.props.ts +12 -0
  153. package/src/components/IndicatorIconButton/IndicatorIconButton.stories.tsx +142 -0
  154. package/src/components/IndicatorIconButton/IndicatorIconButton.tsx +36 -0
  155. package/src/components/IndicatorIconButton/index.tsx +2 -0
  156. package/src/components/Link/LinkText.tsx +4 -4
  157. package/src/components/List/List.context.ts +0 -1
  158. package/src/components/List/List.docs.mdx +376 -179
  159. package/src/components/List/List.props.ts +1 -9
  160. package/src/components/List/List.stories.tsx +289 -38
  161. package/src/components/List/List.tsx +5 -26
  162. package/src/components/List/ListAction/ListAction.props.ts +10 -0
  163. package/src/components/List/ListAction/ListAction.tsx +133 -0
  164. package/src/components/List/ListAction/ListActionContent.tsx +21 -0
  165. package/src/components/List/ListAction/ListActionText.tsx +14 -0
  166. package/src/components/List/ListAction/ListActionTrailingContent.tsx +9 -0
  167. package/src/components/List/ListAction/ListActionTrailingIcon.tsx +32 -0
  168. package/src/components/List/ListAction/index.ts +6 -0
  169. package/src/components/List/ListItem/ListItem.context.ts +1 -1
  170. package/src/components/List/ListItem/ListItem.props.ts +9 -5
  171. package/src/components/List/ListItem/ListItemRoot.tsx +18 -14
  172. package/src/components/List/ListItem/index.ts +4 -4
  173. package/src/components/List/index.ts +1 -0
  174. package/src/components/ProgressStepper/ProgressStep.tsx +134 -0
  175. package/src/components/ProgressStepper/ProgressStepper.docs.mdx +87 -0
  176. package/src/components/ProgressStepper/ProgressStepper.props.ts +27 -0
  177. package/src/components/ProgressStepper/ProgressStepper.stories.tsx +108 -0
  178. package/src/components/ProgressStepper/ProgressStepper.tsx +26 -0
  179. package/src/components/ProgressStepper/ProgressStepperRoot.tsx +32 -0
  180. package/src/components/ProgressStepper/index.ts +3 -0
  181. package/src/components/SectionHeader/SectionHeader.props.ts +9 -16
  182. package/src/components/SectionHeader/SectionHeader.stories.tsx +28 -18
  183. package/src/components/SectionHeader/SectionHeader.tsx +18 -19
  184. package/src/components/SectionHeader/SectionHeaderTrailingContent.tsx +20 -0
  185. package/src/components/SectionHeader/Sectionheader.docs.mdx +9 -24
  186. package/src/components/SectionHeader/index.ts +1 -0
  187. package/src/components/Switch/Switch.docs.mdx +0 -4
  188. package/src/components/Tabs/Tab.tsx +4 -2
  189. package/src/components/ThemedImage/ThemedImage.docs.mdx +208 -0
  190. package/src/components/ThemedImage/ThemedImage.props.ts +15 -0
  191. package/src/components/ThemedImage/ThemedImage.stories.tsx +175 -0
  192. package/src/components/ThemedImage/ThemedImage.tsx +34 -0
  193. package/src/components/ThemedImage/index.tsx +2 -0
  194. package/src/components/ToggleButton/ToggleButtonText.tsx +3 -3
  195. package/src/components/UnstyledIconButton/UnstyledIconButton.props.ts +2 -1
  196. package/src/components/index.ts +5 -0
  197. package/src/hooks/useStyleProps.ts +1 -1
  198. package/src/tokens/components/dark/button.ts +1 -1
  199. package/src/tokens/components/dark/dialog.ts +1 -0
  200. package/src/tokens/components/dark/illustrations.ts +1 -0
  201. package/src/tokens/components/dark/toast.ts +4 -1
  202. package/src/tokens/components/light/button.ts +1 -1
  203. package/src/tokens/components/light/dialog.ts +1 -0
  204. package/src/tokens/components/light/illustrations.ts +1 -0
  205. package/src/tokens/components/light/toast.ts +4 -1
  206. package/src/tokens/layout.ts +3 -6
  207. 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
- - [List Item with Container](#list-item-with-container)
53
- - [List Item with Badge](#list-item-with-badge)
54
- - [Checbox List](#checbox-list)
55
- - [Radio List](#radio-list)
56
- - [Switch List](#switch-list)
57
- - [List with FlatList](#list-with-flatlist)
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" divider>
69
- <ListItem text="List Item 1" onPress={() => console.log('item pressed')} />
70
- <ListItem text="List Item 2" onPress={() => console.log('item pressed')} />
71
- <ListItem text="List Item 3" onPress={() => console.log('item pressed')} />
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 headingText="Heading" headingHelperText="Supporting text" divider>
80
- <ListItem text="List Item 1" onPress={() => console.log('item pressed')} />
81
- <ListItem text="List Item 2" onPress={() => console.log('item pressed')} />
82
- <ListItem text="List Item 3" onPress={() => console.log('item pressed')} />
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 | Type | Default | Description |
92
- | ---------------- | ------------------------------------------------------------------------------------------------- | --------- | ---------------------------------------------------------- | --- |
93
- | container | `'none' \| 'subtleWhite' \| 'emphasisWhite' \|` <br /> `'subtleWarmWhite' \| 'emphasisWarmWhite'` | `'none'` | The container style of the list. |
94
- | heading | `string` | | The text to display in the heading of the list. |
95
- | helperText | `string` | | The supporting text to display in the heading of the list. |
96
- | linkText | `string` | | The text for the link in the heading. |
97
- | linkHref | `string` | | The href for the link in the heading. |
98
- | linkOnPress | `() => void` | | Callback function when the heading link is pressed. |
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 | Description |
110
- | --------------- | ------------------------ | ------- | --------------------------------------------------------------- |
111
- | text | `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
- | divider | `boolean` | `false` | Whether to display a divider below the list item. |
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
- ## Variants
597
+ ## Accessibility
278
598
 
279
- The `List` component has different ways to display the list.
599
+ The List component is designed with accessibility in mind to ensure all users can interact with list items effectively.
280
600
 
281
- <Canvas of={Stories.KitchenSink} />
601
+ ### Screen Reader Support
282
602
 
283
- ## Examples
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
- ### List Item with Container
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
- Thie `List` has an inbuilt `Card` component to wrap the list items and setting the `container` prop to one if `subtleWhite`,
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
- <UsageWrap>
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
- ```tsx
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
- const MyComponent = () => (
322
- <List container="subtleWhite">
323
- <ListItem
324
- leadingContent={<BillMediumIcon />}
325
- text="Bills"
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
- linkText?: string;
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;