@utilitywarehouse/hearth-react-native 0.20.0 → 0.22.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/manager.ts +1 -0
- package/.storybook/preview.tsx +1 -0
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +13 -13
- package/CHANGELOG.md +272 -0
- package/build/components/BodyText/BodyText.js +12 -5
- package/build/components/BodyText/BodyText.props.d.ts +5 -19
- package/build/components/Box/Box.js +23 -3
- package/build/components/Box/Box.props.d.ts +3 -95
- package/build/components/Card/Card.props.d.ts +4 -11
- package/build/components/Card/CardRoot.js +0 -1
- package/build/components/Checkbox/Checkbox.d.ts +1 -1
- package/build/components/Checkbox/Checkbox.js +2 -2
- package/build/components/Checkbox/Checkbox.props.d.ts +2 -0
- package/build/components/Container/Container.props.d.ts +2 -78
- package/build/components/DateInput/DateInput.d.ts +1 -1
- package/build/components/DateInput/DateInput.js +2 -2
- package/build/components/DateInput/DateInput.props.d.ts +15 -1
- package/build/components/DateInput/DateInputSegment.d.ts +1 -1
- package/build/components/DateInput/DateInputSegment.js +2 -2
- package/build/components/DetailText/DetailText.js +14 -13
- package/build/components/DetailText/DetailText.props.d.ts +4 -17
- package/build/components/Flex/Flex.js +3 -1
- package/build/components/Flex/Flex.props.d.ts +2 -2
- package/build/components/Heading/Heading.js +34 -13
- package/build/components/Heading/Heading.props.d.ts +4 -18
- package/build/components/Modal/Modal.js +1 -1
- package/build/components/Radio/Radio.d.ts +1 -1
- package/build/components/Radio/Radio.js +2 -2
- package/build/components/Radio/Radio.props.d.ts +2 -0
- package/build/core/themes.d.ts +188 -8
- package/build/core/themes.js +18 -2
- package/build/hooks/useStyleProps.js +22 -5
- package/build/tokens/color.d.ts +4 -0
- package/build/tokens/color.js +2 -0
- package/build/tokens/components/dark/modal.d.ts +6 -0
- package/build/tokens/components/dark/modal.js +6 -0
- package/build/tokens/components/dark/navigation.d.ts +1 -0
- package/build/tokens/components/dark/navigation.js +1 -0
- package/build/tokens/components/light/modal.d.ts +6 -0
- package/build/tokens/components/light/modal.js +6 -0
- package/build/tokens/components/light/navigation.d.ts +1 -0
- package/build/tokens/components/light/navigation.js +1 -0
- package/build/tokens/components/light/skeleton.d.ts +1 -1
- package/build/tokens/components/light/skeleton.js +1 -1
- package/build/tokens/font.d.ts +2 -0
- package/build/tokens/font.js +2 -0
- package/build/tokens/line-height.d.ts +2 -0
- package/build/tokens/line-height.js +2 -0
- package/build/tokens/primitive.d.ts +4 -0
- package/build/tokens/primitive.js +4 -0
- package/build/tokens/semantic-dark.d.ts +1 -0
- package/build/tokens/semantic-dark.js +1 -0
- package/build/tokens/semantic-light.d.ts +1 -0
- package/build/tokens/semantic-light.js +1 -0
- package/build/tokens/typography.d.ts +30 -0
- package/build/tokens/typography.js +15 -0
- package/build/types/index.d.ts +4 -2
- package/build/types/index.js +4 -2
- package/build/types/semanticColorValues.d.ts +22 -0
- package/build/types/semanticColorValues.js +1 -0
- package/build/types/utilityProps.d.ts +326 -0
- package/build/types/utilityProps.js +1 -0
- package/build/types/values.d.ts +4 -3
- package/build/utils/coloursAsArray.d.ts +4 -0
- package/build/utils/coloursAsArray.js +5 -0
- package/build/utils/index.d.ts +1 -1
- package/build/utils/index.js +1 -1
- package/build/utils/styleUtils.d.ts +26 -2
- package/build/utils/styleUtils.js +42 -13
- package/build/utils/themeValueHelpers.d.ts +13 -0
- package/build/utils/themeValueHelpers.js +29 -0
- package/docs/changelog.mdx +74 -2
- package/docs/components/AllComponents.web.tsx +23 -24
- package/docs/components/NextPrevPage.tsx +2 -2
- package/docs/components/UsageWrap.tsx +2 -2
- package/docs/introduction.mdx +0 -7
- package/package.json +8 -6
- package/src/components/BodyText/BodyText.props.ts +5 -19
- package/src/components/BodyText/BodyText.stories.tsx +2 -1
- package/src/components/BodyText/BodyText.tsx +17 -6
- package/src/components/Box/Box.docs.mdx +5 -4
- package/src/components/Box/Box.props.ts +3 -231
- package/src/components/Box/Box.stories.tsx +2 -2
- package/src/components/Box/Box.tsx +38 -9
- package/src/components/Button/Button.docs.mdx +46 -1
- package/src/components/Card/Card.docs.mdx +1 -1
- package/src/components/Card/Card.props.ts +5 -11
- package/src/components/Card/Card.stories.tsx +54 -23
- package/src/components/Card/CardRoot.tsx +0 -1
- package/src/components/Carousel/Carousel.docs.mdx +49 -44
- package/src/components/Center/Center.docs.mdx +6 -4
- package/src/components/Checkbox/Checkbox.docs.mdx +1 -0
- package/src/components/Checkbox/Checkbox.props.ts +2 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +26 -0
- package/src/components/Checkbox/Checkbox.tsx +2 -0
- package/src/components/Container/Container.docs.mdx +13 -8
- package/src/components/Container/Container.props.ts +9 -80
- package/src/components/Container/Container.stories.tsx +81 -65
- package/src/components/DateInput/DateInput.docs.mdx +43 -0
- package/src/components/DateInput/DateInput.props.ts +15 -1
- package/src/components/DateInput/DateInput.stories.tsx +37 -2
- package/src/components/DateInput/DateInput.tsx +6 -0
- package/src/components/DateInput/DateInputSegment.tsx +2 -0
- package/src/components/DetailText/DetailText.props.ts +4 -17
- package/src/components/DetailText/DetailText.stories.tsx +2 -3
- package/src/components/DetailText/DetailText.tsx +16 -17
- package/src/components/Flex/Flex.props.ts +2 -2
- package/src/components/Flex/Flex.stories.tsx +1 -1
- package/src/components/Flex/Flex.tsx +4 -1
- package/src/components/Grid/Grid.docs.mdx +53 -49
- package/src/components/Heading/Heading.props.ts +4 -18
- package/src/components/Heading/Heading.stories.tsx +2 -1
- package/src/components/Heading/Heading.tsx +40 -18
- package/src/components/Modal/Modal.tsx +1 -1
- package/src/components/Radio/Radio.docs.mdx +1 -0
- package/src/components/Radio/Radio.props.ts +2 -0
- package/src/components/Radio/Radio.stories.tsx +22 -0
- package/src/components/Radio/Radio.tsx +2 -0
- package/src/components/Radio/RadioTile.figma.tsx +4 -0
- package/src/components/Toast/ToastItem.figma.tsx +1 -8
- package/src/core/themes.ts +19 -2
- package/src/hooks/useStyleProps.ts +40 -5
- package/src/tokens/color.ts +2 -0
- package/src/tokens/components/dark/modal.ts +6 -0
- package/src/tokens/components/dark/navigation.ts +1 -0
- package/src/tokens/components/light/modal.ts +6 -0
- package/src/tokens/components/light/navigation.ts +1 -0
- package/src/tokens/components/light/skeleton.ts +1 -1
- package/src/tokens/font.ts +2 -0
- package/src/tokens/line-height.ts +2 -0
- package/src/tokens/primitive.ts +4 -0
- package/src/tokens/semantic-dark.ts +1 -0
- package/src/tokens/semantic-light.ts +1 -0
- package/src/tokens/typography.ts +15 -0
- package/src/types/index.ts +4 -2
- package/src/types/semanticColorValues.ts +26 -0
- package/src/types/utilityProps.ts +410 -0
- package/src/types/values.ts +4 -7
- package/src/utils/coloursAsArray.ts +6 -0
- package/src/utils/index.ts +8 -1
- package/src/utils/styleUtils.ts +45 -14
- package/src/utils/themeValueHelpers.ts +38 -0
|
@@ -2,6 +2,7 @@ import { Canvas, Controls, Meta, Primary, Story } from '@storybook/addon-docs/bl
|
|
|
2
2
|
import { BodyText, Box, Center, Grid } from '../..';
|
|
3
3
|
import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
4
4
|
import * as Stories from './Grid.stories';
|
|
5
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
5
6
|
|
|
6
7
|
<Meta title="Primitives / Grid" />
|
|
7
8
|
|
|
@@ -26,17 +27,17 @@ The Grid component helps you create responsive grid layouts with configurable co
|
|
|
26
27
|
<UsageWrap>
|
|
27
28
|
<Center>
|
|
28
29
|
<Grid columns={2} spacing="md" width={300}>
|
|
29
|
-
<Box backgroundColor=
|
|
30
|
-
<BodyText color="
|
|
30
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
31
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
31
32
|
</Box>
|
|
32
|
-
<Box backgroundColor=
|
|
33
|
-
<BodyText color="
|
|
33
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
34
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
34
35
|
</Box>
|
|
35
|
-
<Box backgroundColor=
|
|
36
|
-
<BodyText color="
|
|
36
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
37
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
37
38
|
</Box>
|
|
38
|
-
<Box backgroundColor=
|
|
39
|
-
<BodyText color="
|
|
39
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
40
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
40
41
|
</Box>
|
|
41
42
|
</Grid>
|
|
42
43
|
</Center>
|
|
@@ -44,20 +45,21 @@ The Grid component helps you create responsive grid layouts with configurable co
|
|
|
44
45
|
|
|
45
46
|
```jsx
|
|
46
47
|
import { Grid, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
48
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
47
49
|
|
|
48
50
|
const MyComponent = () => (
|
|
49
51
|
<Grid columns={2} spacing="md" width={300}>
|
|
50
|
-
<Box backgroundColor=
|
|
51
|
-
<BodyText color="
|
|
52
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
53
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
52
54
|
</Box>
|
|
53
|
-
<Box backgroundColor=
|
|
54
|
-
<BodyText color="
|
|
55
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
56
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
55
57
|
</Box>
|
|
56
|
-
<Box backgroundColor=
|
|
57
|
-
<BodyText color="
|
|
58
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
59
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
58
60
|
</Box>
|
|
59
|
-
<Box backgroundColor=
|
|
60
|
-
<BodyText color="
|
|
61
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
62
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
61
63
|
</Box>
|
|
62
64
|
</Grid>
|
|
63
65
|
);
|
|
@@ -79,17 +81,17 @@ The Grid component supports responsive column layouts based on screen size break
|
|
|
79
81
|
spacing="md"
|
|
80
82
|
width="100%"
|
|
81
83
|
>
|
|
82
|
-
<Box backgroundColor=
|
|
83
|
-
<BodyText color="
|
|
84
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
85
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
84
86
|
</Box>
|
|
85
|
-
<Box backgroundColor=
|
|
86
|
-
<BodyText color="
|
|
87
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
88
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
87
89
|
</Box>
|
|
88
|
-
<Box backgroundColor=
|
|
89
|
-
<BodyText color="
|
|
90
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
91
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
90
92
|
</Box>
|
|
91
|
-
<Box backgroundColor=
|
|
92
|
-
<BodyText color="
|
|
93
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
94
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
93
95
|
</Box>
|
|
94
96
|
</Grid>
|
|
95
97
|
</Center>
|
|
@@ -97,6 +99,7 @@ The Grid component supports responsive column layouts based on screen size break
|
|
|
97
99
|
|
|
98
100
|
```jsx
|
|
99
101
|
import { Grid, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
102
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
100
103
|
|
|
101
104
|
const MyComponent = () => (
|
|
102
105
|
<Grid
|
|
@@ -109,17 +112,17 @@ const MyComponent = () => (
|
|
|
109
112
|
spacing="md"
|
|
110
113
|
width="100%"
|
|
111
114
|
>
|
|
112
|
-
<Box backgroundColor=
|
|
113
|
-
<BodyText color="
|
|
115
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
116
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
114
117
|
</Box>
|
|
115
|
-
<Box backgroundColor=
|
|
116
|
-
<BodyText color="
|
|
118
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
119
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
117
120
|
</Box>
|
|
118
|
-
<Box backgroundColor=
|
|
119
|
-
<BodyText color="
|
|
121
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
122
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
120
123
|
</Box>
|
|
121
|
-
<Box backgroundColor=
|
|
122
|
-
<BodyText color="
|
|
124
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
125
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
123
126
|
</Box>
|
|
124
127
|
</Grid>
|
|
125
128
|
);
|
|
@@ -132,38 +135,39 @@ You can specify different horizontal and vertical spacing:
|
|
|
132
135
|
<UsageWrap>
|
|
133
136
|
<Center>
|
|
134
137
|
<Grid columns={2} columnGap={24} rowGap={16}>
|
|
135
|
-
<Box backgroundColor=
|
|
136
|
-
<BodyText color="
|
|
138
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
139
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
137
140
|
</Box>
|
|
138
|
-
<Box backgroundColor=
|
|
139
|
-
<BodyText color="
|
|
141
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
142
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
140
143
|
</Box>
|
|
141
|
-
<Box backgroundColor=
|
|
142
|
-
<BodyText color="
|
|
144
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
145
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
143
146
|
</Box>
|
|
144
|
-
<Box backgroundColor=
|
|
145
|
-
<BodyText color="
|
|
147
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
148
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
146
149
|
</Box>
|
|
147
150
|
</Grid>
|
|
148
151
|
</Center>
|
|
149
152
|
</UsageWrap>
|
|
150
153
|
|
|
151
154
|
```jsx
|
|
152
|
-
import { Grid, Box } from '@utilitywarehouse/hearth-react-native';
|
|
155
|
+
import { Grid, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
156
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
153
157
|
|
|
154
158
|
const MyComponent = () => (
|
|
155
159
|
<Grid columns={2} columnGap={24} rowGap={8}>
|
|
156
|
-
<Box backgroundColor=
|
|
157
|
-
<BodyText color="
|
|
160
|
+
<Box backgroundColor={color.green[400]} height={100} padding="200">
|
|
161
|
+
<BodyText color="inverted">Item 1</BodyText>
|
|
158
162
|
</Box>
|
|
159
|
-
<Box backgroundColor=
|
|
160
|
-
<BodyText color="
|
|
163
|
+
<Box backgroundColor={color.blue[400]} height={100} padding="200">
|
|
164
|
+
<BodyText color="inverted">Item 2</BodyText>
|
|
161
165
|
</Box>
|
|
162
|
-
<Box backgroundColor=
|
|
163
|
-
<BodyText color="
|
|
166
|
+
<Box backgroundColor={color.red[400]} height={100} padding="200">
|
|
167
|
+
<BodyText color="inverted">Item 3</BodyText>
|
|
164
168
|
</Box>
|
|
165
|
-
<Box backgroundColor=
|
|
166
|
-
<BodyText color="
|
|
169
|
+
<Box backgroundColor={color.yellow[400]} height={100} padding="200">
|
|
170
|
+
<BodyText color="inverted">Item 4</BodyText>
|
|
167
171
|
</Box>
|
|
168
172
|
</Grid>
|
|
169
173
|
);
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Text, TextProps, TextStyle } from 'react-native';
|
|
3
|
-
import type { ColorValue } from '../../types';
|
|
1
|
+
import type { CommonTextProps } from '../../types';
|
|
4
2
|
|
|
5
|
-
interface HeadingProps extends
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
underline?: boolean;
|
|
9
|
-
truncated?: boolean;
|
|
10
|
-
color?: ColorValue;
|
|
11
|
-
textTransform?: TextStyle['textTransform'];
|
|
12
|
-
textAlign?: TextStyle['textAlign'];
|
|
13
|
-
textAlignVertical?: TextStyle['textAlignVertical'];
|
|
14
|
-
textDecorationLine?: TextStyle['textDecorationLine'];
|
|
15
|
-
textDecorationStyle?: TextStyle['textDecorationStyle'];
|
|
16
|
-
textDecorationColor?: ColorValue;
|
|
17
|
-
userSelect?: TextStyle['userSelect'];
|
|
18
|
-
inverted?: boolean;
|
|
19
|
-
ref?: Ref<Text>;
|
|
3
|
+
interface HeadingProps extends CommonTextProps {
|
|
4
|
+
/** Heading size variant. */
|
|
5
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
20
6
|
}
|
|
21
7
|
|
|
22
8
|
export default HeadingProps;
|
|
@@ -2,6 +2,7 @@ import { Meta, StoryObj } from '@storybook/react-vite';
|
|
|
2
2
|
import { Heading } from '.';
|
|
3
3
|
import { VariantTitle } from '../../../docs/components';
|
|
4
4
|
import { coloursAsArray } from '../../utils';
|
|
5
|
+
import { textColorKeys } from '../../utils/coloursAsArray';
|
|
5
6
|
import { Box } from '../Box';
|
|
6
7
|
|
|
7
8
|
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
@@ -35,7 +36,7 @@ const meta = {
|
|
|
35
36
|
description: 'Strike through the text.',
|
|
36
37
|
},
|
|
37
38
|
color: {
|
|
38
|
-
options:
|
|
39
|
+
options: textColorKeys,
|
|
39
40
|
control: 'select',
|
|
40
41
|
description: 'Color of the text. Use the color name from the theme.',
|
|
41
42
|
},
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
1
|
import { Text, TextStyle } from 'react-native';
|
|
3
2
|
import { StyleSheet } from 'react-native-unistyles';
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { getFlattenedColorValue } from '../../utils';
|
|
3
|
+
import { useStyleProps } from '../../hooks';
|
|
4
|
+
import { getFlattenedColorValue, resolveThemeValueWithFallback } from '../../utils';
|
|
7
5
|
import type HeadingProps from './Heading.props';
|
|
8
6
|
|
|
9
7
|
const Heading = ({
|
|
@@ -23,26 +21,19 @@ const Heading = ({
|
|
|
23
21
|
inverted,
|
|
24
22
|
...props
|
|
25
23
|
}: HeadingProps) => {
|
|
24
|
+
// Extract margin utility props from remaining props
|
|
25
|
+
const { computedStyles: utilityStyles, remainingProps } = useStyleProps(props);
|
|
26
|
+
|
|
26
27
|
styles.useVariants({
|
|
27
28
|
size,
|
|
28
29
|
underline,
|
|
29
30
|
strikeThrough,
|
|
30
31
|
inverted,
|
|
31
32
|
});
|
|
32
|
-
|
|
33
|
-
const colorValue: ColorValue = useMemo(
|
|
34
|
-
() => getFlattenedColorValue(color, themeColor),
|
|
35
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
36
|
-
[color, colorMode]
|
|
37
|
-
);
|
|
38
|
-
const decorationColor = useMemo(
|
|
39
|
-
() => getFlattenedColorValue(textDecorationColor, themeColor),
|
|
40
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
-
[textDecorationColor, colorMode]
|
|
42
|
-
);
|
|
33
|
+
|
|
43
34
|
return (
|
|
44
35
|
<Text
|
|
45
|
-
{...
|
|
36
|
+
{...remainingProps}
|
|
46
37
|
{...(truncated
|
|
47
38
|
? {
|
|
48
39
|
numberOfLines: 1,
|
|
@@ -51,16 +42,16 @@ const Heading = ({
|
|
|
51
42
|
: {})}
|
|
52
43
|
style={[
|
|
53
44
|
styles.text,
|
|
45
|
+
utilityStyles,
|
|
54
46
|
{
|
|
55
|
-
...(colorValue ? { color: colorValue } : {}),
|
|
56
47
|
...(textTransform ? { textTransform } : {}),
|
|
57
48
|
...(textAlign ? { textAlign } : {}),
|
|
58
49
|
...(textAlignVertical ? { textAlignVertical } : {}),
|
|
59
|
-
...(decorationColor && { textDecorationColor: decorationColor }),
|
|
60
50
|
...(textDecorationLine && { textDecorationLine }),
|
|
61
51
|
...(textDecorationStyle && { textDecorationStyle }),
|
|
62
52
|
...(userSelect && { userSelect }),
|
|
63
53
|
},
|
|
54
|
+
styles.getColours(color, textDecorationColor),
|
|
64
55
|
props.style,
|
|
65
56
|
]}
|
|
66
57
|
>
|
|
@@ -147,6 +138,23 @@ const styles = StyleSheet.create(theme => ({
|
|
|
147
138
|
lg: theme.typography.desktop.heading.xl.lineHeight,
|
|
148
139
|
},
|
|
149
140
|
},
|
|
141
|
+
'2xl': {
|
|
142
|
+
fontSize: {
|
|
143
|
+
base: theme.typography.mobile.heading['2xl'].fontSize,
|
|
144
|
+
md: theme.typography.tablet.heading['2xl'].fontSize,
|
|
145
|
+
lg: theme.typography.desktop.heading['2xl'].fontSize,
|
|
146
|
+
},
|
|
147
|
+
fontWeight: {
|
|
148
|
+
base: theme.typography.mobile.heading['2xl'].fontWeight,
|
|
149
|
+
md: theme.typography.tablet.heading['2xl'].fontWeight,
|
|
150
|
+
lg: theme.typography.desktop.heading['2xl'].fontWeight,
|
|
151
|
+
},
|
|
152
|
+
lineHeight: {
|
|
153
|
+
base: theme.typography.mobile.heading['2xl'].lineHeight,
|
|
154
|
+
md: theme.typography.tablet.heading['2xl'].lineHeight,
|
|
155
|
+
lg: theme.typography.desktop.heading['2xl'].lineHeight,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
150
158
|
},
|
|
151
159
|
underline: {
|
|
152
160
|
true: {
|
|
@@ -165,6 +173,20 @@ const styles = StyleSheet.create(theme => ({
|
|
|
165
173
|
},
|
|
166
174
|
},
|
|
167
175
|
},
|
|
176
|
+
getColours: (color?: string, textDecorationColor?: string) => ({
|
|
177
|
+
...(color
|
|
178
|
+
? {
|
|
179
|
+
color: resolveThemeValueWithFallback(
|
|
180
|
+
color,
|
|
181
|
+
theme.helpers.semanticColor.text,
|
|
182
|
+
theme.color
|
|
183
|
+
),
|
|
184
|
+
}
|
|
185
|
+
: {}),
|
|
186
|
+
...(textDecorationColor
|
|
187
|
+
? { textDecorationColor: getFlattenedColorValue(textDecorationColor, theme.color) }
|
|
188
|
+
: {}),
|
|
189
|
+
}),
|
|
168
190
|
}));
|
|
169
191
|
|
|
170
192
|
export default Heading;
|
|
@@ -100,6 +100,7 @@ const MyComponent = () => {
|
|
|
100
100
|
| `label` | `string` | - | The label to be displayed next to the radio. |
|
|
101
101
|
| `helperText` | `string` | - | The helper text to be displayed below the radio. |
|
|
102
102
|
| `helperIcon` | `React.ComponentType` | - | The icon to be displayed next to the helper text. |
|
|
103
|
+
| `badge` | `ReactNode` | - | The badge to be displayed below the helper text. |
|
|
103
104
|
| `invalidText` | `string` | - | The invalid text to be displayed below the radio. |
|
|
104
105
|
| `validText` | `string` | - | The valid text to be displayed below the radio. |
|
|
105
106
|
| `showValidationIcon` | `boolean` | `true` | Whether to show the validation icon. |
|
|
@@ -14,6 +14,7 @@ interface RadioWithChildrenProps extends RadioBaseProps {
|
|
|
14
14
|
label?: never;
|
|
15
15
|
helperText?: never;
|
|
16
16
|
helperIcon?: never;
|
|
17
|
+
badge?: never;
|
|
17
18
|
invalidText?: never;
|
|
18
19
|
validText?: never;
|
|
19
20
|
showValidationIcon?: never;
|
|
@@ -25,6 +26,7 @@ interface RadioWithoutChildrenProps extends RadioBaseProps {
|
|
|
25
26
|
label?: string;
|
|
26
27
|
helperText?: string;
|
|
27
28
|
helperIcon?: ComponentType;
|
|
29
|
+
badge?: ReactNode;
|
|
28
30
|
invalidText?: string;
|
|
29
31
|
validText?: string;
|
|
30
32
|
showValidationIcon?: boolean;
|
|
@@ -5,6 +5,7 @@ import { Radio, RadioGroup, RadioImage } from '.';
|
|
|
5
5
|
import bankLogo from '../../../docs/assets/bank-logo.png';
|
|
6
6
|
import bankLogo1 from '../../../docs/assets/bank-logo1.png';
|
|
7
7
|
import { VariantTitle } from '../../../docs/components';
|
|
8
|
+
import { Badge } from '../Badge';
|
|
8
9
|
import { Flex } from '../Flex';
|
|
9
10
|
import { FormField } from '../FormField';
|
|
10
11
|
|
|
@@ -136,6 +137,27 @@ export const WithImage: Story = {
|
|
|
136
137
|
),
|
|
137
138
|
};
|
|
138
139
|
|
|
140
|
+
export const WithBadge: Story = {
|
|
141
|
+
args: {
|
|
142
|
+
value: 'Option 1',
|
|
143
|
+
label: 'Label',
|
|
144
|
+
helperText: 'Helper text',
|
|
145
|
+
},
|
|
146
|
+
render: args => (
|
|
147
|
+
<RadioGroup>
|
|
148
|
+
<Radio
|
|
149
|
+
aria-label="Label 1"
|
|
150
|
+
onChange={(checked: boolean) => {
|
|
151
|
+
console.log(checked, '###');
|
|
152
|
+
}}
|
|
153
|
+
nativeID="Radio-1"
|
|
154
|
+
badge={<Badge>New</Badge>}
|
|
155
|
+
{...args}
|
|
156
|
+
/>
|
|
157
|
+
</RadioGroup>
|
|
158
|
+
),
|
|
159
|
+
};
|
|
160
|
+
|
|
139
161
|
export const Variants: Story = {
|
|
140
162
|
parameters: {
|
|
141
163
|
controls: { exclude: ['value', 'label', 'disabled'] },
|
|
@@ -36,6 +36,7 @@ const Radio = ({
|
|
|
36
36
|
disabled,
|
|
37
37
|
helperIcon,
|
|
38
38
|
helperText,
|
|
39
|
+
badge,
|
|
39
40
|
invalidText,
|
|
40
41
|
validText,
|
|
41
42
|
validationStatus: validation,
|
|
@@ -60,6 +61,7 @@ const Radio = ({
|
|
|
60
61
|
<RadioTextContent>
|
|
61
62
|
{!!label && <RadioLabel>{label}</RadioLabel>}
|
|
62
63
|
{!!helperText && <Helper disabled={disabled} icon={helperIcon} text={helperText} />}
|
|
64
|
+
{badge ? badge : null}
|
|
63
65
|
{validationStatus === 'invalid' && !!invalidText && (
|
|
64
66
|
<Helper
|
|
65
67
|
showIcon={showValidationIcon}
|
|
@@ -9,6 +9,9 @@ figma.connect(
|
|
|
9
9
|
helperText: figma.boolean('Helper text?', {
|
|
10
10
|
true: figma.string('Helper text'),
|
|
11
11
|
}),
|
|
12
|
+
badge: figma.boolean('Badge?', {
|
|
13
|
+
true: figma.children('Badge'),
|
|
14
|
+
}),
|
|
12
15
|
label: figma.string('Label'),
|
|
13
16
|
image: figma.boolean('Image?', {
|
|
14
17
|
true: figma.instance('Radio Image'),
|
|
@@ -24,6 +27,7 @@ figma.connect(
|
|
|
24
27
|
<RadioTile
|
|
25
28
|
label={props.label}
|
|
26
29
|
helperText={props.helperText}
|
|
30
|
+
badge={props.badge}
|
|
27
31
|
image={props.image}
|
|
28
32
|
checked={props.checked}
|
|
29
33
|
disabled={props.indicator.disabled}
|
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
import figma from '@figma/code-connect';
|
|
2
2
|
import ToastItem from './ToastItem';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* -- This file was auto-generated by Code Connect --
|
|
6
|
-
* None of your props could be automatically mapped to Figma properties.
|
|
7
|
-
* You should update the `props` object to include a mapping from your
|
|
8
|
-
* code props to Figma properties, and update the `example` function to
|
|
9
|
-
* return the code example you'd like to see in Figma
|
|
10
|
-
*/
|
|
11
4
|
|
|
12
5
|
figma.connect(ToastItem, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?node-id=7072%3A913', {
|
|
13
6
|
props: {
|
|
@@ -18,5 +11,5 @@ figma.connect(ToastItem, 'https://www.figma.com/design/6NKZXZhFSExXrcbBgc6zTR?no
|
|
|
18
11
|
// "icon24": figma.instance('Icon-24'),
|
|
19
12
|
// "dismiss": figma.boolean('Dismiss?')
|
|
20
13
|
},
|
|
21
|
-
example: props => <ToastItem
|
|
14
|
+
example: props => <ToastItem />,
|
|
22
15
|
});
|
package/src/core/themes.ts
CHANGED
|
@@ -306,9 +306,18 @@ export const lightTheme = {
|
|
|
306
306
|
white: '#ffffff',
|
|
307
307
|
black: '#000000',
|
|
308
308
|
} as const,
|
|
309
|
+
|
|
309
310
|
components: components.light,
|
|
310
311
|
...shared,
|
|
311
|
-
helpers:
|
|
312
|
+
helpers: {
|
|
313
|
+
...lightHelpers /** Simplified semantic color tokens grouped by category */,
|
|
314
|
+
semanticColor: {
|
|
315
|
+
background: light.background,
|
|
316
|
+
border: light.border,
|
|
317
|
+
text: light.text,
|
|
318
|
+
icon: light.icon,
|
|
319
|
+
},
|
|
320
|
+
},
|
|
312
321
|
} as const;
|
|
313
322
|
|
|
314
323
|
const darkHelpers = {
|
|
@@ -364,7 +373,15 @@ export const darkTheme = {
|
|
|
364
373
|
},
|
|
365
374
|
components: components.dark,
|
|
366
375
|
...shared,
|
|
367
|
-
helpers:
|
|
376
|
+
helpers: {
|
|
377
|
+
...darkHelpers /** Simplified semantic color tokens grouped by category */,
|
|
378
|
+
semanticColor: {
|
|
379
|
+
background: dark.background,
|
|
380
|
+
border: dark.border,
|
|
381
|
+
text: dark.text,
|
|
382
|
+
icon: dark.icon,
|
|
383
|
+
},
|
|
384
|
+
},
|
|
368
385
|
} as const;
|
|
369
386
|
|
|
370
387
|
export const themes = {
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { ViewStyle } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
propStyleMapping,
|
|
5
|
+
resolveThemeKey,
|
|
6
|
+
resolveThemeValueWithFallback,
|
|
7
|
+
semanticPropMapping,
|
|
8
|
+
themeStyleFallbackMapping,
|
|
9
|
+
themeStyleMapping,
|
|
10
|
+
viewStyleProps,
|
|
11
|
+
} from '../utils';
|
|
4
12
|
import useTheme from './useTheme';
|
|
5
13
|
|
|
6
14
|
/**
|
|
@@ -28,8 +36,23 @@ export const useStyleProps = (props: Record<string, any>): StylePropsResult => {
|
|
|
28
36
|
Object.entries(props).forEach(([propName, propValue]) => {
|
|
29
37
|
if (propValue === undefined) return;
|
|
30
38
|
|
|
39
|
+
// Check for semantic prop mappings first (e.g., iconColor, color)
|
|
40
|
+
const semanticMapping = semanticPropMapping[propName];
|
|
41
|
+
if (semanticMapping) {
|
|
42
|
+
const { styleProp, themeKey } = semanticMapping;
|
|
43
|
+
const themeMapping = resolveThemeKey(theme, themeKey);
|
|
44
|
+
const fallbackKey = themeStyleFallbackMapping[themeKey];
|
|
45
|
+
const fallbackMapping = fallbackKey ? resolveThemeKey(theme, fallbackKey) : undefined;
|
|
46
|
+
|
|
47
|
+
computedStyles[styleProp] = resolveThemeValueWithFallback(
|
|
48
|
+
propValue,
|
|
49
|
+
themeMapping,
|
|
50
|
+
fallbackMapping
|
|
51
|
+
);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
|
|
31
55
|
let stylePropName: keyof ViewStyle | undefined;
|
|
32
|
-
let themeKey: keyof typeof theme | undefined;
|
|
33
56
|
|
|
34
57
|
// Handle shorthand props
|
|
35
58
|
if (propStyleMapping[propName]) {
|
|
@@ -42,10 +65,22 @@ export const useStyleProps = (props: Record<string, any>): StylePropsResult => {
|
|
|
42
65
|
|
|
43
66
|
if (stylePropName) {
|
|
44
67
|
// Resolve theme value if needed
|
|
45
|
-
themeKey = themeStyleMapping[stylePropName
|
|
68
|
+
const themeKey = themeStyleMapping[stylePropName as string];
|
|
69
|
+
|
|
70
|
+
if (themeKey) {
|
|
71
|
+
const themeObj = resolveThemeKey(theme, themeKey);
|
|
72
|
+
const fallbackKey = themeStyleFallbackMapping[themeKey];
|
|
73
|
+
const fallbackMapping = fallbackKey ? resolveThemeKey(theme, fallbackKey) : undefined;
|
|
46
74
|
|
|
47
|
-
|
|
48
|
-
|
|
75
|
+
if (themeObj) {
|
|
76
|
+
computedStyles[stylePropName] = resolveThemeValueWithFallback(
|
|
77
|
+
propValue,
|
|
78
|
+
themeObj,
|
|
79
|
+
fallbackMapping
|
|
80
|
+
);
|
|
81
|
+
} else {
|
|
82
|
+
computedStyles[stylePropName] = propValue;
|
|
83
|
+
}
|
|
49
84
|
} else {
|
|
50
85
|
computedStyles[stylePropName] = propValue;
|
|
51
86
|
}
|
package/src/tokens/color.ts
CHANGED
|
@@ -232,6 +232,7 @@ export const yellow = {
|
|
|
232
232
|
export const light = {
|
|
233
233
|
background: {
|
|
234
234
|
brand: '#7a42c8',
|
|
235
|
+
loading: '#f1efe4',
|
|
235
236
|
primary: '#fcfbf2',
|
|
236
237
|
secondary: '#ffffff',
|
|
237
238
|
},
|
|
@@ -480,6 +481,7 @@ export const light = {
|
|
|
480
481
|
export const dark = {
|
|
481
482
|
background: {
|
|
482
483
|
brand: '#7a42c8',
|
|
484
|
+
loading: '#30302c',
|
|
483
485
|
primary: '#191917',
|
|
484
486
|
secondary: '#232323',
|
|
485
487
|
},
|
package/src/tokens/font.ts
CHANGED