@utilitywarehouse/hearth-react-native 0.3.0 → 0.3.1

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 (133) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-lint.log +3 -1
  3. package/CHANGELOG.md +12 -0
  4. package/build/components/Alert/AlertCloseButton.js +25 -3
  5. package/build/components/Alert/AlertIcon.js +17 -1
  6. package/build/components/Alert/AlertIconButton.js +27 -1
  7. package/build/components/Alert/AlertLink.js +47 -1
  8. package/build/components/Alert/AlertText.d.ts +1 -1
  9. package/build/components/Alert/AlertText.js +26 -2
  10. package/build/components/Alert/AlertTitle.d.ts +1 -1
  11. package/build/components/Alert/AlertTitle.js +26 -2
  12. package/build/components/Badge/BadgeIcon.js +72 -0
  13. package/build/components/Badge/BadgeText.js +72 -0
  14. package/build/components/Button/ButtonRoot.js +1 -0
  15. package/build/components/Checkbox/Checkbox.d.ts +2 -2
  16. package/build/components/Checkbox/Checkbox.js +11 -10
  17. package/build/components/Checkbox/Checkbox.props.d.ts +3 -1
  18. package/build/components/Checkbox/CheckboxIcon.js +1 -1
  19. package/build/components/Checkbox/CheckboxImage.d.ts +6 -0
  20. package/build/components/Checkbox/CheckboxImage.js +5 -0
  21. package/build/components/Checkbox/CheckboxTileRoot.js +1 -1
  22. package/build/components/Checkbox/index.d.ts +3 -2
  23. package/build/components/Checkbox/index.js +2 -1
  24. package/build/components/Link/Link.d.ts +1 -1
  25. package/build/components/Link/Link.js +4 -4
  26. package/build/components/Link/Link.props.d.ts +3 -0
  27. package/build/components/Radio/Radio.d.ts +2 -2
  28. package/build/components/Radio/Radio.js +9 -8
  29. package/build/components/Radio/Radio.props.d.ts +3 -1
  30. package/build/components/Radio/RadioImage.d.ts +6 -0
  31. package/build/components/Radio/RadioImage.js +5 -0
  32. package/build/components/Radio/RadioTileRoot.js +1 -1
  33. package/build/components/Radio/index.d.ts +3 -2
  34. package/build/components/Radio/index.js +2 -1
  35. package/build/components/Select/SelectOption.js +1 -7
  36. package/build/components/UnstyledIconButton/UnstyledIconButton.d.ts +1 -1
  37. package/build/components/UnstyledIconButton/UnstyledIconButton.js +4 -4
  38. package/build/components/UnstyledIconButton/UnstyledIconButton.props.d.ts +2 -1
  39. package/build/core/themes.d.ts +12 -12
  40. package/build/tokens/color.d.ts +12 -12
  41. package/build/tokens/color.js +6 -6
  42. package/build/tokens/components/dark/alert.d.ts +13 -0
  43. package/build/tokens/components/dark/alert.js +13 -0
  44. package/build/tokens/components/dark/checkbox.d.ts +3 -0
  45. package/build/tokens/components/dark/checkbox.js +3 -0
  46. package/build/tokens/components/dark/icon-button.d.ts +7 -0
  47. package/build/tokens/components/dark/icon-button.js +7 -0
  48. package/build/tokens/components/dark/index.d.ts +1 -0
  49. package/build/tokens/components/dark/index.js +1 -0
  50. package/build/tokens/components/dark/link.d.ts +5 -0
  51. package/build/tokens/components/dark/link.js +5 -0
  52. package/build/tokens/components/dark/progress-bar.d.ts +41 -0
  53. package/build/tokens/components/dark/progress-bar.js +40 -0
  54. package/build/tokens/components/light/alert.d.ts +13 -0
  55. package/build/tokens/components/light/alert.js +13 -0
  56. package/build/tokens/components/light/checkbox.d.ts +3 -0
  57. package/build/tokens/components/light/checkbox.js +3 -0
  58. package/build/tokens/components/light/icon-button.d.ts +7 -0
  59. package/build/tokens/components/light/icon-button.js +7 -0
  60. package/build/tokens/components/light/index.d.ts +1 -0
  61. package/build/tokens/components/light/index.js +1 -0
  62. package/build/tokens/components/light/link.d.ts +5 -0
  63. package/build/tokens/components/light/link.js +5 -0
  64. package/build/tokens/components/light/progress-bar.d.ts +41 -0
  65. package/build/tokens/components/light/progress-bar.js +40 -0
  66. package/build/tokens/index.d.ts +1 -0
  67. package/build/tokens/index.js +1 -0
  68. package/build/tokens/motion.d.ts +23 -0
  69. package/build/tokens/motion.js +22 -0
  70. package/build/tokens/primitive.d.ts +19 -0
  71. package/build/tokens/primitive.js +19 -0
  72. package/build/tokens/semantic-dark.d.ts +5 -5
  73. package/build/tokens/semantic-dark.js +5 -5
  74. package/build/tokens/semantic-light.d.ts +1 -1
  75. package/build/tokens/semantic-light.js +1 -1
  76. package/docs/assets/bank-logo.png +0 -0
  77. package/docs/assets/bank-logo1.png +0 -0
  78. package/docs/components/index.ts +6 -7
  79. package/docs/introduction.mdx +3 -3
  80. package/package.json +12 -11
  81. package/src/components/Alert/AlertCloseButton.tsx +33 -5
  82. package/src/components/Alert/AlertIcon.tsx +17 -1
  83. package/src/components/Alert/AlertIconButton.tsx +37 -4
  84. package/src/components/Alert/AlertLink.tsx +52 -1
  85. package/src/components/Alert/AlertText.tsx +28 -3
  86. package/src/components/Alert/AlertTitle.tsx +28 -3
  87. package/src/components/Badge/BadgeIcon.tsx +72 -0
  88. package/src/components/Badge/BadgeText.tsx +72 -0
  89. package/src/components/Button/ButtonRoot.tsx +1 -0
  90. package/src/components/Checkbox/Checkbox.docs.mdx +45 -7
  91. package/src/components/Checkbox/Checkbox.props.ts +3 -1
  92. package/src/components/Checkbox/Checkbox.stories.tsx +37 -1
  93. package/src/components/Checkbox/Checkbox.tsx +12 -9
  94. package/src/components/Checkbox/CheckboxIcon.tsx +1 -1
  95. package/src/components/Checkbox/CheckboxImage.tsx +9 -0
  96. package/src/components/Checkbox/CheckboxTileRoot.tsx +1 -1
  97. package/src/components/Checkbox/index.ts +3 -2
  98. package/src/components/IconContainer/IconContainer.docs.mdx +4 -4
  99. package/src/components/Link/Link.props.ts +3 -0
  100. package/src/components/Link/Link.tsx +12 -6
  101. package/src/components/List/List.docs.mdx +24 -23
  102. package/src/components/Radio/Radio.docs.mdx +96 -124
  103. package/src/components/Radio/Radio.props.ts +3 -1
  104. package/src/components/Radio/Radio.stories.tsx +47 -0
  105. package/src/components/Radio/Radio.tsx +10 -7
  106. package/src/components/Radio/RadioImage.tsx +9 -0
  107. package/src/components/Radio/RadioTileRoot.tsx +1 -1
  108. package/src/components/Radio/index.ts +3 -2
  109. package/src/components/Select/Select.docs.mdx +6 -6
  110. package/src/components/Select/Select.stories.tsx +7 -7
  111. package/src/components/Select/SelectOption.tsx +4 -10
  112. package/src/components/UnstyledIconButton/UnstyledIconButton.props.ts +2 -1
  113. package/src/components/UnstyledIconButton/UnstyledIconButton.tsx +9 -3
  114. package/src/tokens/color.ts +6 -6
  115. package/src/tokens/components/dark/alert.ts +13 -0
  116. package/src/tokens/components/dark/checkbox.ts +3 -0
  117. package/src/tokens/components/dark/icon-button.ts +7 -0
  118. package/src/tokens/components/dark/index.ts +1 -0
  119. package/src/tokens/components/dark/link.ts +5 -0
  120. package/src/tokens/components/dark/progress-bar.ts +41 -0
  121. package/src/tokens/components/light/alert.ts +13 -0
  122. package/src/tokens/components/light/checkbox.ts +3 -0
  123. package/src/tokens/components/light/icon-button.ts +7 -0
  124. package/src/tokens/components/light/index.ts +1 -0
  125. package/src/tokens/components/light/link.ts +5 -0
  126. package/src/tokens/components/light/progress-bar.ts +41 -0
  127. package/src/tokens/index.ts +1 -0
  128. package/src/tokens/motion.ts +23 -0
  129. package/src/tokens/primitive.ts +19 -0
  130. package/src/tokens/semantic-dark.ts +5 -5
  131. package/src/tokens/semantic-light.ts +1 -1
  132. package/docs/assets/react-native-pig.png +0 -0
  133. package/docs/components/AdvancedRadioExample.tsx +0 -126
@@ -2,8 +2,8 @@ import { Canvas, Controls, Meta, Story } from '@storybook/addon-docs/blocks';
2
2
  import {
3
3
  BroadbandMediumIcon,
4
4
  CashbackCardMediumIcon,
5
- ConfettiMediumIcon,
6
5
  ElectricityMediumIcon,
6
+ EmailMediumIcon,
7
7
  InsuranceMediumIcon,
8
8
  MobileMediumIcon,
9
9
  } from '@utilitywarehouse/hearth-react-native-icons';
@@ -42,7 +42,7 @@ Wrap an icon with the `IconContainer` to apply sizing + background styles withou
42
42
  <IconContainer icon={MobileMediumIcon} size="md" variant="emphasis" color="mobile" />
43
43
  <IconContainer icon={InsuranceMediumIcon} size="md" variant="emphasis" color="insurance" />
44
44
  <IconContainer icon={CashbackCardMediumIcon} size="md" variant="emphasis" color="cashback" />
45
- <IconContainer icon={ConfettiMediumIcon} size="md" variant="emphasis" color="pig" />
45
+ <IconContainer icon={EmailMediumIcon} size="md" variant="emphasis" color="pig" />
46
46
  </Flex>
47
47
  </Center>
48
48
  </UsageWrap>
@@ -55,7 +55,7 @@ import {
55
55
  MobileMediumIcon,
56
56
  InsuranceMediumIcon,
57
57
  CashbackCardMediumIcon,
58
- ConfettiMediumIcon,
58
+ ,
59
59
  } from '@utilitywarehouse/hearth-react-native-icons';
60
60
 
61
61
  const MyComponent = () => (
@@ -65,7 +65,7 @@ const MyComponent = () => (
65
65
  <IconContainer icon={MobileMediumIcon} size="md" variant="emphasis" color="mobile" />
66
66
  <IconContainer icon={InsuranceMediumIcon} size="md" variant="emphasis" color="insurance" />
67
67
  <IconContainer icon={CashbackCardMediumIcon} size="md" variant="emphasis" color="cashback" />
68
- <IconContainer icon={ConfettiMediumIcon} size="md" variant="emphasis" color="pig" />
68
+ <IconContainer icon={EmailMediumIcon} size="md" variant="emphasis" color="pig" />
69
69
  </>
70
70
  );
71
71
  ```
@@ -1,5 +1,6 @@
1
1
  import { ComponentType } from 'react';
2
2
  import { PressableProps, TextProps } from 'react-native';
3
+ import { IconProps } from '../Icon';
3
4
 
4
5
  export interface LinkProps extends Omit<PressableProps, 'children'> {
5
6
  children: TextProps['children'];
@@ -10,6 +11,8 @@ export interface LinkProps extends Omit<PressableProps, 'children'> {
10
11
  icon?: ComponentType;
11
12
  iconPosition?: 'left' | 'right';
12
13
  showIcon?: boolean;
14
+ textStyle?: TextProps['style'];
15
+ iconStyle?: IconProps['style'];
13
16
  }
14
17
 
15
18
  export default LinkProps;
@@ -1,9 +1,9 @@
1
- import type { LinkProps } from './Link.props';
2
1
  import { createLink } from '@gluestack-ui/link';
2
+ import { ChevronRightSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
3
+ import type { LinkProps } from './Link.props';
4
+ import LinkIcon from './LinkIcon';
3
5
  import LinkRoot from './LinkRoot';
4
6
  import LinkTextComponent from './LinkText';
5
- import LinkIcon from './LinkIcon';
6
- import { ChevronRightSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
7
7
 
8
8
  const LinkComponent = createLink({
9
9
  Root: LinkRoot,
@@ -21,14 +21,20 @@ const Link = ({
21
21
  target = '_self',
22
22
  iconPosition = 'right',
23
23
  showIcon = true,
24
+ textStyle,
25
+ iconStyle,
24
26
  ...props
25
27
  }: LinkProps) => {
26
28
  const LinkAny = LinkComponent as any;
27
29
  return (
28
30
  <LinkAny {...props} isDisabled={disabled} isExternal={target === '_blank'}>
29
- {showIcon && icon && iconPosition === 'left' ? <LinkIcon as={icon} /> : null}
30
- <LinkText>{children}</LinkText>
31
- {showIcon && icon && iconPosition === 'right' ? <LinkIcon as={icon} /> : null}
31
+ {showIcon && icon && iconPosition === 'left' ? (
32
+ <LinkIcon as={icon} style={iconStyle} />
33
+ ) : null}
34
+ <LinkText style={textStyle}>{children}</LinkText>
35
+ {showIcon && icon && iconPosition === 'right' ? (
36
+ <LinkIcon as={icon} style={iconStyle} />
37
+ ) : null}
32
38
  </LinkAny>
33
39
  );
34
40
  };
@@ -4,7 +4,8 @@ import {
4
4
  ChevronRightSmallIcon,
5
5
  ElectricityMediumIcon,
6
6
  GasMediumIcon,
7
- HomeFilledMediumIcon,
7
+ InfoMediumIcon as HomeMediumIcon,
8
+ // HomeMediumIcon,
8
9
  PaymentMediumIcon,
9
10
  UserMediumIcon,
10
11
  } from '@utilitywarehouse/hearth-react-native-icons';
@@ -15,7 +16,6 @@ import {
15
16
  FlatList,
16
17
  Image,
17
18
  List,
18
- SectionHeader,
19
19
  ListItem,
20
20
  ListItemContent,
21
21
  ListItemHelperText,
@@ -24,6 +24,7 @@ import {
24
24
  ListItemText,
25
25
  ListItemTrailingContent,
26
26
  ListItemTrailingIcon,
27
+ SectionHeader,
27
28
  } from '../../';
28
29
  import { BackToTopButton, BadgeList, UsageWrap, ViewFigmaButton } from '../../../docs/components';
29
30
  import * as Stories from './List.stories';
@@ -87,21 +88,21 @@ const MyComponent = () => (
87
88
 
88
89
  ### `List`
89
90
 
90
- | Name | Type | Default | Description |
91
- | ----------------------- | ------------------------------------------------------------------------------------------------- | --------- | ---------------------------------------------------------- |
92
- | container | `'none' \| 'subtleWhite' \| 'emphasisWhite' \|` <br /> `'subtleWarmWhite' \| 'emphasisWarmWhite'` | `'none'` | The container style of the list. |
93
- | heading | `string` | | The text to display in the heading of the list. |
94
- | helperText | `string` | | The supporting text to display in the heading of the list. |
95
- | linkText | `string` | | The text for the link in the heading. |
96
- | linkHref | `string` | | The href for the link in the heading. |
97
- | linkOnPress | `() => void` | | Callback function when the heading link is pressed. |
98
- | linkTarget | `'_blank' \| '_self' \| '_parent' \| '_top'` | | Target for the link in the heading. | |
99
- | linkIcon | `ComponentType` | | Icon for the heading link. |
100
- | linkIconPosition | `'left' \| 'right'` | `'right'` | Position of the icon in the heading link. |
101
- | linkShowIcon | `boolean` | `true` | Whether to show the icon in the heading link. |
102
- | divider | `boolean` | `false` | Whether to display a divider below the list items. |
103
- | loading | `boolean` | `false` | Whether to show the list items in loading state. |
104
- | disabled | `boolean` | `false` | Whether to disable the list. |
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. |
105
106
 
106
107
  ### `ListItem`
107
108
 
@@ -172,7 +173,7 @@ If you need to use the List component in a more advanced way, you can use the pa
172
173
  </ListItem>
173
174
  <ListItem onPress={() => console.log('pressed')}>
174
175
  <ListItemLeadingContent>
175
- <ListItemIcon as={HomeFilledMediumIcon} />
176
+ <ListItemIcon as={HomeMediumIcon} />
176
177
  </ListItemLeadingContent>
177
178
  <ListItemContent>
178
179
  <ListItemText>Moving home</ListItemText>
@@ -214,7 +215,7 @@ import {
214
215
  BillMediumIcon,
215
216
  ChevronRightSmallIcon,
216
217
  PaymentMediumIcon,
217
- HomeFilledMediumIcon,
218
+ HomeMediumIcon,
218
219
  UserMediumIcon,
219
220
  } from '@utilitywarehouse/hearth-react-native-icons';
220
221
 
@@ -247,7 +248,7 @@ const MyComponent = () => (
247
248
  </ListItem>
248
249
  <ListItem onPress={() => console.log('pressed')}>
249
250
  <ListItemLeadingContent>
250
- <ListItemIcon as={HomeFilledMediumIcon} />
251
+ <ListItemIcon as={HomeMediumIcon} />
251
252
  </ListItemLeadingContent>
252
253
  <ListItemContent>
253
254
  <ListItemText>Moving home</ListItemText>
@@ -302,7 +303,7 @@ the `Card` and child `ListItem` components.
302
303
  onPress={() => console.log('item pressed')}
303
304
  />
304
305
  <ListItem
305
- leadingContent={<HomeFilledMediumIcon />}
306
+ leadingContent={<HomeMediumIcon />}
306
307
  text="Moving Home"
307
308
  onPress={() => console.log('item pressed')}
308
309
  />
@@ -314,7 +315,7 @@ import { List, ListItem, Card } from '@utilitywarehouse/hearth-react-native';
314
315
  import {
315
316
  BillMediumIcon,
316
317
  PaymentMediumIcon,
317
- HomeFilledMediumIcon,
318
+ HomeMediumIcon,
318
319
  } from '@utilitywarehouse/hearth-react-native-icons';
319
320
 
320
321
  const MyComponent = () => (
@@ -332,7 +333,7 @@ const MyComponent = () => (
332
333
  onPress={() => console.log('item pressed')}
333
334
  />
334
335
  <ListItem
335
- leadingContent={<HomeFilledMediumIcon />}
336
+ leadingContent={<HomeMediumIcon />}
336
337
  text="Moving Home"
337
338
  onPress={() => console.log('item pressed')}
338
339
  />
@@ -1,22 +1,20 @@
1
- import { Meta, Canvas, Story, Controls } from '@storybook/addon-docs/blocks';
2
- import * as Stories from './Radio.stories';
1
+ import { Canvas, Controls, Meta, Story } from '@storybook/addon-docs/blocks';
2
+ import { TickSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
3
3
  import {
4
+ Box,
5
+ Center,
4
6
  Radio,
5
7
  RadioGroup,
6
- RadioIndicator,
7
8
  RadioIcon,
9
+ RadioImage,
10
+ RadioIndicator,
8
11
  RadioLabel,
9
- Center,
10
- Box,
11
12
  RadioTile,
12
13
  } from '../../';
13
- import { TickSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
14
- import {
15
- ViewFigmaButton,
16
- BackToTopButton,
17
- UsageWrap,
18
- AdvancedRadioExample,
19
- } from '../../../docs/components';
14
+ import mastercardLogo from '../../../docs/assets/bank-logo.png';
15
+ import visaLogo from '../../../docs/assets/bank-logo1.png';
16
+ import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
17
+ import * as Stories from './Radio.stories';
20
18
 
21
19
  <Meta title="Forms / Radio" />
22
20
 
@@ -38,10 +36,12 @@ The Radio component presents users with predefined choices and enables them to s
38
36
  - [`RadioIcon`](#radioicon)
39
37
  - [`RadioLabel`](#radiolabel)
40
38
  - [`RadioGroup`](#radiogroup)
39
+ - [`RadioImage`](#radioimage)
41
40
  - [Variants](#variants)
42
41
  - [Advanced Usage](#advanced-usage)
43
42
  - [Examples](#examples)
44
43
  - [`RadioTile` component](#radiotile-component)
44
+ - [`RadioImage` component](#radioimage-component)
45
45
  - [`RadioGroup` component](#radiogroup-component)
46
46
 
47
47
  ## Playground
@@ -104,6 +104,7 @@ const MyComponent = () => {
104
104
  | `validText` | `string` | - | The valid text to be displayed below the radio. |
105
105
  | `showValidationIcon` | `boolean` | `true` | Whether to show the validation icon. |
106
106
  | `type` | `'default' \| 'tile'` | `default` | The type of the radio. |
107
+ | `image` | `ImageProps` | - | The image to be displayed next to the label. |
107
108
 
108
109
  ## Components
109
110
 
@@ -147,6 +148,10 @@ Contains all Group related layout style props and actions. It inherits all the p
147
148
  | `direction` | `'row' \| 'column'` | `column` | The direction of the radio group. |
148
149
  | `gap` | `string` | - | The gap between the radio group items. |
149
150
 
151
+ ### `RadioImage`
152
+
153
+ Contains all Image related layout style props and actions. It inherits all the properties of React Native's [Image component](https://reactnative.dev/docs/image).
154
+
150
155
  ## Variants
151
156
 
152
157
  <Canvas of={Stories.Variants} />
@@ -158,133 +163,65 @@ In this example, we will create a custom Radio component with a badge and bullet
158
163
 
159
164
  <UsageWrap>
160
165
  <Center>
161
- <AdvancedRadioExample />
166
+ <RadioGroup type="tile" aria-label="Radio Group" nativeID="Radio-group">
167
+ <Radio value="option-1" aria-label="Label 1">
168
+ <RadioIndicator>
169
+ <RadioIcon />
170
+ </RadioIndicator>
171
+ <RadioImage source={visaLogo} style={{ width: 40, height: 24, resizeMode: 'contain' }} />
172
+ <RadioLabel>Visa</RadioLabel>
173
+ </Radio>
174
+ <Radio value="option-2" aria-label="Label 2">
175
+ <RadioIndicator>
176
+ <RadioIcon />
177
+ </RadioIndicator>
178
+ <RadioImage
179
+ source={mastercardLogo}
180
+ style={{ width: 40, height: 24, resizeMode: 'contain' }}
181
+ />
182
+ <RadioLabel>Mastercard</RadioLabel>
183
+ </Radio>
184
+ </RadioGroup>
162
185
  </Center>
163
186
  </UsageWrap>
164
187
 
165
188
  ```tsx
166
189
  import {
167
- Badge,
168
- Heading,
169
190
  Radio,
170
191
  RadioGroup,
171
- RadioIcon,
192
+ RadioLabel,
172
193
  RadioIndicator,
173
- BodyText,
174
- Box,
175
- type RadioProps as NativeUIRadioProps,
176
- } from '../../src';
194
+ RadioIcon,
195
+ RadioImage,
196
+ } from '@utilitywarehouse/native-ui';
177
197
  import { TickSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
198
+ import visaLogo from '../../assets/bank-logo1.png';
199
+ import mastercardLogo from '../../assets/bank-logo.png';
178
200
 
179
- import { StyleSheet } from 'react-native-unistyles';
180
-
181
- interface RadioProps {
182
- currentValue: string;
183
- }
184
-
185
- const styles = StyleSheet.create(({ colorMode, color, borderRadius, borderWidth, space }) => ({
186
- radio: {
187
- borderWidth: borderWidth[2],
188
- borderColor: colorMode === 'light' ? color.grey[500] : color.grey[700],
189
- borderRadius: borderRadius.xl,
190
- padding: space[200],
191
- variants: {
192
- checked: {
193
- true: {
194
- borderColor: colorMode === 'light' ? color.green[500] : color.green[700],
195
- },
196
- },
197
- },
198
- },
199
- indicator: {
200
- variants: {
201
- checked: {
202
- true: {
203
- backgroundColor: colorMode === 'light' ? color.green[500] : color.green[700],
204
- borderColor: colorMode === 'light' ? color.green[500] : color.green[700],
205
- },
206
- },
207
- },
208
- },
209
- heading: {
210
- marginBottom: space[100],
211
- },
212
- badge: {
213
- marginRight: space[200],
214
- alignSelf: 'flex-end',
215
- },
216
- }));
217
-
218
- const CustomRadio: React.FC<
219
- RadioProps &
220
- Omit<
221
- NativeUIRadioProps,
222
- 'label' | 'helperText' | 'helperIcon' | 'invalidText' | 'validText' | 'showValidationIcon'
223
- >
224
- > = ({ children, currentValue, ...props }) => {
225
- styles.useVariants({ checked: currentValue === props.value });
201
+ const AdvancedExample = () => {
202
+ const [value, setValue] = React.useState('option-1');
226
203
  return (
227
- <Radio style={styles.radio} {...props}>
228
- <Box flexDirection="row" flex={1}>
229
- <Box pr="200" flex={1}>
230
- {children}
231
- </Box>
232
- <RadioIndicator style={styles.indicator}>
233
- <RadioIcon as={TickSmallIcon} color="white" />
204
+ <RadioGroup value={value} onChange={setValue} aria-label="Card type" type="tile">
205
+ <Radio value="option-1" aria-label="Visa">
206
+ <RadioIndicator>
207
+ <RadioIcon />
234
208
  </RadioIndicator>
235
- </Box>
236
- </Radio>
237
- );
238
- };
239
-
240
- const BulletListItem = ({ children }: { children: React.ReactNode }) => (
241
- <BodyText>
242
- {'\u2022'} {children}
243
- </BodyText>
244
- );
245
-
246
- const BulletList = ({ children }: { children: React.ReactNode }) => (
247
- <Box pl="200" gap="100">
248
- {children}
249
- </Box>
250
- );
251
-
252
- const AdvancedRadioExample: React.FC = () => {
253
- const [value, setValue] = React.useState('Option 1');
254
-
255
- const handleChange = (val: string) => setValue(val);
256
-
257
- return (
258
- <RadioGroup onChange={handleChange} value={value} gap="200">
259
- <Box>
260
- <Badge colorScheme={value === 'Option 1' ? 'green' : 'grey'} flatBase style={styles.badge}>
261
- Recommended
262
- </Badge>
263
- <CustomRadio value="Option 1" currentValue={value}>
264
- <Heading size="md" style={styles.heading}>
265
- Instant bank transfer
266
- </Heading>
267
- <BulletList>
268
- <BulletListItem>Receive your money instantly</BulletListItem>
269
- <BulletListItem>No fees</BulletListItem>
270
- <BulletListItem>Available 24/7</BulletListItem>
271
- </BulletList>
272
- </CustomRadio>
273
- </Box>
274
- <CustomRadio value="Option 2" currentValue={value}>
275
- <Heading size="md" style={styles.heading}>
276
- Debit card payment
277
- </Heading>
278
- <BulletList>
279
- <BulletListItem>£0.35 fee</BulletListItem>
280
- <BulletListItem>Available 24/7</BulletListItem>
281
- </BulletList>
282
- </CustomRadio>
209
+ <RadioImage source={visaLogo} style={{ width: 40, height: 24, resizeMode: 'contain' }} />
210
+ <RadioLabel>Visa</RadioLabel>
211
+ </Radio>
212
+ <Radio value="option-2" aria-label="Mastercard">
213
+ <RadioIndicator>
214
+ <RadioIcon />
215
+ </RadioIndicator>
216
+ <RadioImage
217
+ source={mastercardLogo}
218
+ style={{ width: 40, height: 24, resizeMode: 'contain' }}
219
+ />
220
+ <RadioLabel>Mastercard</RadioLabel>
221
+ </Radio>
283
222
  </RadioGroup>
284
223
  );
285
224
  };
286
-
287
- export default AdvancedRadioExample;
288
225
  ```
289
226
 
290
227
  ## Examples
@@ -317,6 +254,41 @@ const MyComponent = () => {
317
254
  };
318
255
  ```
319
256
 
257
+ ### `RadioImage` component
258
+
259
+ The `RadioImage` component is used to display an image next to the radio button.
260
+
261
+ <Canvas of={Stories.WithImage} />
262
+
263
+ ```tsx
264
+ import { Radio, RadioGroup } from '@utilitywarehouse/native-ui';
265
+ import visaLogo from './visa-logo.png';
266
+ import mastarcardLogo from './mastercard-logo.png';
267
+
268
+ const MyComponent = () => {
269
+ const [value, setValue] = React.useState('Option 1');
270
+ return (
271
+ <RadioGroup value={value} onChange={setValue} aria-label="Radio Group" nativeID="Radio-group">
272
+ <Radio
273
+ value="visa"
274
+ aria-label="Visa"
275
+ label="Visa"
276
+ image={{ source: visaLogo, style: { width: 40, height: 24, resizeMode: 'contain' } }}
277
+ />
278
+ <Radio
279
+ value="mastercard"
280
+ aria-label="Mastercard"
281
+ label="Mastercard"
282
+ image={{
283
+ source: mastarcardLogo,
284
+ style: { width: 40, height: 24, resizeMode: 'contain' },
285
+ }}
286
+ />
287
+ </RadioGroup>
288
+ );
289
+ };
290
+ ```
291
+
320
292
  ### `RadioGroup` component
321
293
 
322
294
  The `RadioGroup` component is used to group multiple `Radio` components together.
@@ -1,5 +1,5 @@
1
1
  import type { ComponentType } from 'react';
2
- import type { PressableProps, ViewProps } from 'react-native';
2
+ import type { ImageProps, PressableProps, ViewProps } from 'react-native';
3
3
 
4
4
  interface RadioBaseProps extends Omit<PressableProps, 'children'> {
5
5
  value: string;
@@ -17,6 +17,7 @@ interface RadioWithChildrenProps extends RadioBaseProps {
17
17
  invalidText?: never;
18
18
  validText?: never;
19
19
  showValidationIcon?: never;
20
+ image?: never;
20
21
  }
21
22
 
22
23
  interface RadioWithoutChildrenProps extends RadioBaseProps {
@@ -27,6 +28,7 @@ interface RadioWithoutChildrenProps extends RadioBaseProps {
27
28
  invalidText?: string;
28
29
  validText?: string;
29
30
  showValidationIcon?: boolean;
31
+ image?: ImageProps;
30
32
  }
31
33
 
32
34
  type RadioProps = RadioWithChildrenProps | RadioWithoutChildrenProps;
@@ -1,6 +1,9 @@
1
1
  import { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { useState } from 'react';
3
+ import { ImageSourcePropType } from 'react-native';
3
4
  import { Radio, RadioGroup } from '.';
5
+ import bankLogo from '../../../docs/assets/bank-logo.png';
6
+ import bankLogo1 from '../../../docs/assets/bank-logo1.png';
4
7
  import { VariantTitle } from '../../../docs/components';
5
8
  import { Flex } from '../Flex';
6
9
 
@@ -84,6 +87,50 @@ export const Playground: Story = {
84
87
  ),
85
88
  };
86
89
 
90
+ export const WithImage: Story = {
91
+ parameters: {
92
+ controls: { exclude: ['image'] },
93
+ },
94
+ args: {
95
+ value: 'Option 1',
96
+ label: 'Label',
97
+ },
98
+ render: ({ children, ...args }) => (
99
+ <RadioGroup>
100
+ <Radio
101
+ aria-label="Label 1"
102
+ onChange={(checked: boolean) => {
103
+ console.log(checked, '###');
104
+ }}
105
+ nativeID="Radio-1"
106
+ {...args}
107
+ label="Visa"
108
+ value="Option 1"
109
+ image={{
110
+ source: bankLogo1 as ImageSourcePropType,
111
+ style: { width: 48, height: 32 },
112
+ resizeMode: 'cover',
113
+ }}
114
+ />
115
+ <Radio
116
+ aria-label="Label 2"
117
+ onChange={(checked: boolean) => {
118
+ console.log(checked, '###');
119
+ }}
120
+ nativeID="Radio-2"
121
+ {...args}
122
+ label="Mastercard"
123
+ value="Option 2"
124
+ image={{
125
+ source: bankLogo as ImageSourcePropType,
126
+ style: { width: 48, height: 32 },
127
+ resizeMode: 'cover',
128
+ }}
129
+ />
130
+ </RadioGroup>
131
+ ),
132
+ };
133
+
87
134
  export const Variants: Story = {
88
135
  parameters: {
89
136
  controls: { exclude: ['value', 'label', 'disabled'] },
@@ -1,16 +1,17 @@
1
1
  import { createRadio } from '@gluestack-ui/radio';
2
- import StyledRadio from './RadioRoot';
3
- import StyledRadioIndicator from './RadioIndicator';
2
+ import RadioProps from './Radio.props';
3
+ import StyledRadioGroup from './RadioGroupRoot';
4
4
  import StyledRadioIcon from './RadioIcon';
5
+ import StyledRadioIndicator from './RadioIndicator';
5
6
  import StyledRadioLabel from './RadioLabel';
6
- import StyledRadioGroup from './RadioGroupRoot';
7
- import RadioProps from './Radio.props';
7
+ import StyledRadio from './RadioRoot';
8
8
 
9
+ import { useFormFieldContext } from '../FormField';
9
10
  import { Helper } from '../Helper';
10
11
  import { useRadioGroupContext } from './RadioGroup.context';
11
- import { useFormFieldContext } from '../FormField';
12
- import RadioTileRoot from './RadioTileRoot';
12
+ import RadioImage from './RadioImage';
13
13
  import RadioTextContent from './RadioTextContent';
14
+ import RadioTileRoot from './RadioTileRoot';
14
15
 
15
16
  const RadioComponent = createRadio({
16
17
  Root: StyledRadio,
@@ -41,6 +42,7 @@ const Radio = ({
41
42
  validationStatus: validation,
42
43
  showValidationIcon,
43
44
  type = 'default',
45
+ image,
44
46
  ...props
45
47
  }: RadioProps) => {
46
48
  const { validationStatus: fieldValidationStatus } = useFormFieldContext();
@@ -55,6 +57,7 @@ const Radio = ({
55
57
  <RadioIndicator>
56
58
  <RadioIcon />
57
59
  </RadioIndicator>
60
+ {image ? <RadioImage {...image} /> : null}
58
61
  <RadioTextContent>
59
62
  {!!label && <RadioLabel>{label}</RadioLabel>}
60
63
  {!!helperText && <Helper disabled={disabled} icon={helperIcon} text={helperText} />}
@@ -89,6 +92,6 @@ const RadioTile = ({ type = 'tile', ...props }: RadioProps) => <Radio {...props}
89
92
  RadioTile.displayName = 'RadioTile';
90
93
  Radio.displayName = 'Radio';
91
94
 
92
- export { Radio, RadioGroup, RadioIndicator, RadioIcon, RadioLabel, RadioTile };
95
+ export { Radio, RadioGroup, RadioIcon, RadioIndicator, RadioLabel, RadioTile };
93
96
 
94
97
  export default Radio;
@@ -0,0 +1,9 @@
1
+ import { Image, ImageProps } from 'react-native';
2
+
3
+ const RadioImage = ({ source, style, ...props }: ImageProps) => (
4
+ <Image source={source} style={style} {...props} />
5
+ );
6
+
7
+ RadioImage.displayName = 'RadioImage';
8
+
9
+ export default RadioImage;
@@ -19,7 +19,7 @@ const styles = StyleSheet.create(theme => ({
19
19
  gap: theme.components.radio.gap,
20
20
  padding: theme.components.radio.tile.padding,
21
21
  borderWidth: theme.components.radio.tile.borderWidth,
22
- borderColor: theme.color.border.subtle,
22
+ borderColor: theme.color.border.strong,
23
23
  borderRadius: theme.components.radio.tile.borderRadius,
24
24
  backgroundColor: theme.color.surface.neutral.strong,
25
25
  variants: {
@@ -1,5 +1,6 @@
1
- export { default as Radio, RadioIndicator, RadioLabel, RadioIcon, RadioTile } from './Radio';
1
+ export { default as Radio, RadioIcon, RadioIndicator, RadioLabel, RadioTile } from './Radio';
2
+ export type { default as RadioProps } from './Radio.props';
2
3
  export { default as RadioGroup } from './RadioGroup';
3
4
  export { default as RadioGroupTextContent } from './RadioGroupTextContent';
5
+ export { default as RadioImage } from './RadioImage';
4
6
  export { default as RadioTextContent } from './RadioTextContent';
5
- export type { default as RadioProps } from './Radio.props';