@utilitywarehouse/hearth-react-native 0.19.1 → 0.21.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 +299 -4
- 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 +2 -5
- 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/Select/Select.d.ts +1 -1
- package/build/components/Select/Select.js +9 -10
- package/build/components/Select/Select.props.d.ts +16 -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/UsageWrap.tsx +2 -2
- package/docs/introduction.mdx +0 -7
- package/package.json +5 -3
- 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 +2 -5
- package/src/components/Card/Card.stories.tsx +54 -23
- package/src/components/Carousel/Carousel.docs.mdx +49 -44
- package/src/components/Center/Center.docs.mdx +6 -4
- package/src/components/Checkbox/CheckboxGroup.figma.tsx +21 -1
- 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/PillGroup/Pill.figma.tsx +4 -17
- package/src/components/PillGroup/PillGroup.figma.tsx +8 -9
- package/src/components/ProgressStepper/ProgressStep.figma.tsx +4 -15
- package/src/components/ProgressStepper/ProgressStepper.figma.tsx +9 -16
- package/src/components/Radio/Radio.figma.tsx +35 -22
- package/src/components/Radio/RadioGroup.figma.tsx +69 -41
- package/src/components/Radio/RadioTile.figma.tsx +34 -0
- package/src/components/RadioCard/RadioCard.figma.tsx +24 -0
- package/src/components/SectionHeader/SectionHeader.figma.tsx +31 -25
- package/src/components/Select/Select.docs.mdx +76 -28
- package/src/components/Select/Select.figma.tsx +44 -43
- package/src/components/Select/Select.props.ts +16 -0
- package/src/components/Select/Select.tsx +42 -35
- package/src/components/Select/SelectOption.figma.tsx +3 -21
- package/src/components/Spinner/Spinner.figma.tsx +12 -25
- package/src/components/Switch/Switch.figma.tsx +2 -23
- package/src/components/Tabs/Tab.figma.tsx +21 -0
- package/src/components/Tabs/Tabs.figma.tsx +18 -27
- package/src/components/Textarea/Textarea.figma.tsx +64 -0
- package/src/components/Toast/ToastItem.figma.tsx +1 -8
- package/src/components/ToggleButtonCard/ToggleButtonCard.figma.tsx +24 -0
- package/src/components/VerificationInput/VerificationInput.figma.tsx +53 -0
- 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
- package/src/components/Radio/RadioTileRoot.figma.tsx +0 -31
|
@@ -1,228 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { ViewProps
|
|
3
|
-
import type {
|
|
4
|
-
BorderRadiusValue,
|
|
5
|
-
BordeWidthValue,
|
|
6
|
-
ColorValue,
|
|
7
|
-
OpacityValue,
|
|
8
|
-
SpaceValue,
|
|
9
|
-
SpacingValues,
|
|
10
|
-
} from '../../types';
|
|
11
|
-
|
|
12
|
-
export type OmittedStyles = Omit<
|
|
13
|
-
ViewStyle,
|
|
14
|
-
| 'backgroundColor'
|
|
15
|
-
| 'borderBlockColor'
|
|
16
|
-
| 'borderBlockEndColor'
|
|
17
|
-
| 'borderBlockStartColor'
|
|
18
|
-
| 'borderBottomColor'
|
|
19
|
-
| 'borderBottomEndRadius'
|
|
20
|
-
| 'borderBottomLeftRadius'
|
|
21
|
-
| 'borderBottomRightRadius'
|
|
22
|
-
| 'borderBottomStartRadius'
|
|
23
|
-
| 'borderBottomWidth'
|
|
24
|
-
| 'borderColor'
|
|
25
|
-
| 'borderEndColor'
|
|
26
|
-
| 'borderEndEndRadius'
|
|
27
|
-
| 'borderEndStartRadius'
|
|
28
|
-
| 'borderEndWidth'
|
|
29
|
-
| 'borderLeftColor'
|
|
30
|
-
| 'borderLeftWidth'
|
|
31
|
-
| 'borderRadius'
|
|
32
|
-
| 'borderRightColor'
|
|
33
|
-
| 'borderRightWidth'
|
|
34
|
-
| 'borderStartColor'
|
|
35
|
-
| 'borderStartEndRadius'
|
|
36
|
-
| 'borderStartStartRadius'
|
|
37
|
-
| 'borderStartWidth'
|
|
38
|
-
| 'borderTopColor'
|
|
39
|
-
| 'borderTopEndRadius'
|
|
40
|
-
| 'borderTopLeftRadius'
|
|
41
|
-
| 'borderTopRightRadius'
|
|
42
|
-
| 'borderTopStartRadius'
|
|
43
|
-
| 'borderTopWidth'
|
|
44
|
-
| 'borderWidth'
|
|
45
|
-
| 'bottom'
|
|
46
|
-
| 'columnGap'
|
|
47
|
-
| 'end'
|
|
48
|
-
| 'gap'
|
|
49
|
-
| 'height'
|
|
50
|
-
| 'left'
|
|
51
|
-
| 'margin'
|
|
52
|
-
| 'marginBottom'
|
|
53
|
-
| 'marginEnd'
|
|
54
|
-
| 'marginHorizontal'
|
|
55
|
-
| 'marginLeft'
|
|
56
|
-
| 'marginRight'
|
|
57
|
-
| 'marginStart'
|
|
58
|
-
| 'marginTop'
|
|
59
|
-
| 'marginVertical'
|
|
60
|
-
| 'maxHeight'
|
|
61
|
-
| 'maxWidth'
|
|
62
|
-
| 'minHeight'
|
|
63
|
-
| 'minWidth'
|
|
64
|
-
| 'opacity'
|
|
65
|
-
| 'outlineColor'
|
|
66
|
-
| 'padding'
|
|
67
|
-
| 'paddingBottom'
|
|
68
|
-
| 'paddingEnd'
|
|
69
|
-
| 'paddingHorizontal'
|
|
70
|
-
| 'paddingLeft'
|
|
71
|
-
| 'paddingRight'
|
|
72
|
-
| 'paddingStart'
|
|
73
|
-
| 'paddingTop'
|
|
74
|
-
| 'paddingVertical'
|
|
75
|
-
| 'right'
|
|
76
|
-
| 'rowGap'
|
|
77
|
-
| 'shadowColor'
|
|
78
|
-
| 'start'
|
|
79
|
-
| 'top'
|
|
80
|
-
| 'width'
|
|
81
|
-
// deprecated
|
|
82
|
-
| 'rotation'
|
|
83
|
-
| 'scaleX'
|
|
84
|
-
| 'scaleY'
|
|
85
|
-
| 'transformMatrix'
|
|
86
|
-
| 'translateX'
|
|
87
|
-
| 'translateY'
|
|
88
|
-
>;
|
|
89
|
-
|
|
90
|
-
export type OtherBoxViewStyles = Pick<
|
|
91
|
-
OmittedStyles,
|
|
92
|
-
// List of other styles to include
|
|
93
|
-
| 'alignContent'
|
|
94
|
-
| 'alignItems'
|
|
95
|
-
| 'alignSelf'
|
|
96
|
-
| 'aspectRatio'
|
|
97
|
-
| 'backfaceVisibility'
|
|
98
|
-
| 'borderCurve'
|
|
99
|
-
| 'borderStyle'
|
|
100
|
-
| 'cursor'
|
|
101
|
-
| 'direction'
|
|
102
|
-
| 'display'
|
|
103
|
-
| 'elevation'
|
|
104
|
-
| 'flex'
|
|
105
|
-
| 'flexBasis'
|
|
106
|
-
| 'flexDirection'
|
|
107
|
-
| 'flexGrow'
|
|
108
|
-
| 'flexShrink'
|
|
109
|
-
| 'flexWrap'
|
|
110
|
-
| 'justifyContent'
|
|
111
|
-
| 'boxShadow'
|
|
112
|
-
| 'outlineOffset'
|
|
113
|
-
| 'outlineStyle'
|
|
114
|
-
| 'outlineWidth'
|
|
115
|
-
| 'overflow'
|
|
116
|
-
| 'pointerEvents'
|
|
117
|
-
| 'position'
|
|
118
|
-
| 'shadowOffset'
|
|
119
|
-
| 'shadowOpacity'
|
|
120
|
-
| 'shadowRadius'
|
|
121
|
-
| 'transform'
|
|
122
|
-
| 'transformOrigin'
|
|
123
|
-
| 'zIndex'
|
|
124
|
-
>;
|
|
125
|
-
|
|
126
|
-
export interface BoxStyleMappingValues {
|
|
127
|
-
// Style Mapping
|
|
128
|
-
// - Colors
|
|
129
|
-
bg?: ColorValue;
|
|
130
|
-
bgColor?: ColorValue;
|
|
131
|
-
// - Space
|
|
132
|
-
h?: SpaceValue;
|
|
133
|
-
w?: SpaceValue;
|
|
134
|
-
p?: SpaceValue;
|
|
135
|
-
px?: SpaceValue;
|
|
136
|
-
py?: SpaceValue;
|
|
137
|
-
pt?: SpaceValue;
|
|
138
|
-
pb?: SpaceValue;
|
|
139
|
-
pr?: SpaceValue;
|
|
140
|
-
pl?: SpaceValue;
|
|
141
|
-
m?: SpaceValue;
|
|
142
|
-
mx?: SpaceValue;
|
|
143
|
-
my?: SpaceValue;
|
|
144
|
-
mt?: SpaceValue;
|
|
145
|
-
mb?: SpaceValue;
|
|
146
|
-
mr?: SpaceValue;
|
|
147
|
-
ml?: SpaceValue;
|
|
148
|
-
// - Radii
|
|
149
|
-
rounded?: BorderRadiusValue;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export interface ThemedBoxViewStyleProps {
|
|
153
|
-
// - Space
|
|
154
|
-
top?: SpaceValue;
|
|
155
|
-
bottom?: SpaceValue;
|
|
156
|
-
left?: SpaceValue;
|
|
157
|
-
right?: SpaceValue;
|
|
158
|
-
padding?: SpaceValue;
|
|
159
|
-
paddingHorizontal?: SpaceValue;
|
|
160
|
-
paddingVertical?: SpaceValue;
|
|
161
|
-
paddingTop?: SpaceValue;
|
|
162
|
-
paddingBottom?: SpaceValue;
|
|
163
|
-
paddingLeft?: SpaceValue;
|
|
164
|
-
paddingRight?: SpaceValue;
|
|
165
|
-
paddingEnd?: SpaceValue;
|
|
166
|
-
paddingStart?: SpaceValue;
|
|
167
|
-
margin?: SpaceValue;
|
|
168
|
-
marginHorizontal?: SpaceValue;
|
|
169
|
-
marginVertical?: SpaceValue;
|
|
170
|
-
marginTop?: SpaceValue;
|
|
171
|
-
marginBottom?: SpaceValue;
|
|
172
|
-
marginLeft?: SpaceValue;
|
|
173
|
-
marginRight?: SpaceValue;
|
|
174
|
-
marginEnd?: SpaceValue;
|
|
175
|
-
marginStart?: SpaceValue;
|
|
176
|
-
columnGap?: SpaceValue;
|
|
177
|
-
gap?: SpaceValue;
|
|
178
|
-
rowGap?: SpaceValue;
|
|
179
|
-
height?: SpaceValue;
|
|
180
|
-
width?: SpaceValue;
|
|
181
|
-
minHeight?: SpaceValue;
|
|
182
|
-
minWidth?: SpaceValue;
|
|
183
|
-
maxWidth?: SpaceValue;
|
|
184
|
-
maxHeight?: SpaceValue;
|
|
185
|
-
start?: SpaceValue;
|
|
186
|
-
end?: SpaceValue;
|
|
187
|
-
// - Colors
|
|
188
|
-
backgroundColor?: ColorValue;
|
|
189
|
-
borderColor?: ColorValue;
|
|
190
|
-
borderBottomColor?: ColorValue;
|
|
191
|
-
borderLeftColor?: ColorValue;
|
|
192
|
-
borderRightColor?: ColorValue;
|
|
193
|
-
borderTopColor?: ColorValue;
|
|
194
|
-
borderBlockColor?: ColorValue;
|
|
195
|
-
borderBlockEndColor?: ColorValue;
|
|
196
|
-
borderBlockStartColor?: ColorValue;
|
|
197
|
-
borderEndColor?: ColorValue;
|
|
198
|
-
borderStartColor?: ColorValue;
|
|
199
|
-
outlineColor?: ColorValue;
|
|
200
|
-
shadowColor?: ColorValue;
|
|
201
|
-
// - Radii
|
|
202
|
-
borderRadius?: BorderRadiusValue;
|
|
203
|
-
borderBottomEndRadius?: BorderRadiusValue;
|
|
204
|
-
borderBottomLeftRadius?: BorderRadiusValue;
|
|
205
|
-
borderBottomRightRadius?: BorderRadiusValue;
|
|
206
|
-
borderBottomStartRadius?: BorderRadiusValue;
|
|
207
|
-
borderTopEndRadius?: BorderRadiusValue;
|
|
208
|
-
borderTopLeftRadius?: BorderRadiusValue;
|
|
209
|
-
borderTopRightRadius?: BorderRadiusValue;
|
|
210
|
-
borderTopStartRadius?: BorderRadiusValue;
|
|
211
|
-
borderEndEndRadius?: BorderRadiusValue;
|
|
212
|
-
borderEndStartRadius?: BorderRadiusValue;
|
|
213
|
-
borderStartEndRadius?: BorderRadiusValue;
|
|
214
|
-
borderStartStartRadius?: BorderRadiusValue;
|
|
215
|
-
// - Opacity
|
|
216
|
-
opacity?: OpacityValue;
|
|
217
|
-
// - Border Width
|
|
218
|
-
borderBottomWidth?: BordeWidthValue;
|
|
219
|
-
borderEndWidth?: BordeWidthValue;
|
|
220
|
-
borderLeftWidth?: BordeWidthValue;
|
|
221
|
-
borderRightWidth?: BordeWidthValue;
|
|
222
|
-
borderStartWidth?: BordeWidthValue;
|
|
223
|
-
borderTopWidth?: BordeWidthValue;
|
|
224
|
-
borderWidth?: BordeWidthValue;
|
|
225
|
-
}
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import type { AllUtilityProps, SpacingValues } from '../../types';
|
|
226
4
|
|
|
227
5
|
interface CustomBoxProps {
|
|
228
6
|
// Custom props
|
|
@@ -230,12 +8,6 @@ interface CustomBoxProps {
|
|
|
230
8
|
spacing?: SpacingValues;
|
|
231
9
|
}
|
|
232
10
|
|
|
233
|
-
export interface BoxProps
|
|
234
|
-
extends
|
|
235
|
-
BoxStyleMappingValues,
|
|
236
|
-
ThemedBoxViewStyleProps,
|
|
237
|
-
OtherBoxViewStyles,
|
|
238
|
-
ViewProps,
|
|
239
|
-
CustomBoxProps {}
|
|
11
|
+
export interface BoxProps extends AllUtilityProps, ViewProps, CustomBoxProps {}
|
|
240
12
|
|
|
241
13
|
export default BoxProps;
|
|
@@ -2,11 +2,11 @@ import { Meta, StoryObj } from '@storybook/react-vite';
|
|
|
2
2
|
import { primitive } from '@utilitywarehouse/hearth-tokens/js';
|
|
3
3
|
import { InputType } from 'storybook/internal/types';
|
|
4
4
|
import { Box } from '.';
|
|
5
|
-
import {
|
|
5
|
+
import { backgroundColorKeys } from '../../utils/coloursAsArray';
|
|
6
6
|
import { BodyText } from '../BodyText';
|
|
7
7
|
|
|
8
8
|
const backgroundColor: InputType = {
|
|
9
|
-
options:
|
|
9
|
+
options: backgroundColorKeys,
|
|
10
10
|
control: 'select',
|
|
11
11
|
description: 'Background color of the box.',
|
|
12
12
|
};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
1
|
import React, { useMemo } from 'react';
|
|
3
2
|
import { View, ViewStyle } from 'react-native';
|
|
4
3
|
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
-
import type BoxProps from './Box.props';
|
|
6
4
|
import {
|
|
7
5
|
propStyleMapping,
|
|
8
|
-
|
|
6
|
+
resolveThemeKey,
|
|
7
|
+
resolveThemeValueWithFallback,
|
|
8
|
+
semanticPropMapping,
|
|
9
|
+
themeStyleFallbackMapping,
|
|
9
10
|
themeStyleMapping,
|
|
10
11
|
viewStyleProps,
|
|
11
12
|
} from '../../utils';
|
|
13
|
+
import type BoxProps from './Box.props';
|
|
12
14
|
|
|
13
15
|
// --- Box component definition ---
|
|
14
16
|
const BoxComponent = ({ as, style, children, ...props }: BoxProps) => {
|
|
@@ -18,6 +20,7 @@ const BoxComponent = ({ as, style, children, ...props }: BoxProps) => {
|
|
|
18
20
|
Object.entries(props).forEach(([propName, propValue]) => {
|
|
19
21
|
if (propValue === undefined) return;
|
|
20
22
|
|
|
23
|
+
if (semanticPropMapping[propName]) return;
|
|
21
24
|
if (propStyleMapping[propName] || viewStyleProps.has(propName)) {
|
|
22
25
|
return;
|
|
23
26
|
}
|
|
@@ -44,6 +47,22 @@ const styles = StyleSheet.create(theme => ({
|
|
|
44
47
|
Object.entries(props).forEach(([propName, propValue]) => {
|
|
45
48
|
if (propValue === undefined) return;
|
|
46
49
|
|
|
50
|
+
// Check for semantic prop mappings first (e.g., iconColor, color)
|
|
51
|
+
const semanticMapping = semanticPropMapping[propName];
|
|
52
|
+
if (semanticMapping) {
|
|
53
|
+
const { styleProp, themeKey } = semanticMapping;
|
|
54
|
+
const themeMapping = resolveThemeKey(theme, themeKey);
|
|
55
|
+
const fallbackKey = themeStyleFallbackMapping[themeKey];
|
|
56
|
+
const fallbackMapping = fallbackKey ? resolveThemeKey(theme, fallbackKey) : undefined;
|
|
57
|
+
|
|
58
|
+
computedStyles[styleProp] = resolveThemeValueWithFallback(
|
|
59
|
+
propValue,
|
|
60
|
+
themeMapping,
|
|
61
|
+
fallbackMapping
|
|
62
|
+
);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
47
66
|
let stylePropName: keyof ViewStyle | undefined;
|
|
48
67
|
|
|
49
68
|
// Handle shorthand props
|
|
@@ -58,12 +77,22 @@ const styles = StyleSheet.create(theme => ({
|
|
|
58
77
|
if (!stylePropName) return;
|
|
59
78
|
|
|
60
79
|
// Resolve theme value if needed
|
|
61
|
-
const themeKey
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
80
|
+
const themeKey = themeStyleMapping[stylePropName as string];
|
|
81
|
+
|
|
82
|
+
if (themeKey) {
|
|
83
|
+
const themeObj = resolveThemeKey(theme, themeKey);
|
|
84
|
+
const fallbackKey = themeStyleFallbackMapping[themeKey];
|
|
85
|
+
const fallbackMapping = fallbackKey ? resolveThemeKey(theme, fallbackKey) : undefined;
|
|
86
|
+
|
|
87
|
+
if (themeObj) {
|
|
88
|
+
computedStyles[stylePropName] = resolveThemeValueWithFallback(
|
|
89
|
+
propValue,
|
|
90
|
+
themeObj,
|
|
91
|
+
fallbackMapping
|
|
92
|
+
);
|
|
93
|
+
} else {
|
|
94
|
+
computedStyles[stylePropName] = propValue;
|
|
95
|
+
}
|
|
67
96
|
} else {
|
|
68
97
|
computedStyles[stylePropName] = propValue;
|
|
69
98
|
}
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { Canvas, Controls, Meta, Story } from '@storybook/addon-docs/blocks';
|
|
2
2
|
import { AddSmallIcon } from '@utilitywarehouse/hearth-react-native-icons';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
Box,
|
|
5
|
+
Button,
|
|
6
|
+
ButtonGroup,
|
|
7
|
+
ButtonIcon,
|
|
8
|
+
ButtonSpinner,
|
|
9
|
+
ButtonText,
|
|
10
|
+
Card,
|
|
11
|
+
Center,
|
|
12
|
+
DetailText,
|
|
13
|
+
Flex,
|
|
14
|
+
} from '../../';
|
|
4
15
|
import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
5
16
|
import * as Stories from './Button.stories';
|
|
6
17
|
|
|
@@ -26,6 +37,7 @@ The `Button` component is used to trigger an action or event, such as submitting
|
|
|
26
37
|
- [`ButtonSpinner`](#buttonspinner)
|
|
27
38
|
- [Examples](#examples)
|
|
28
39
|
- [Padding None](#padding-none)
|
|
40
|
+
- [Full width button](#full-width-button)
|
|
29
41
|
|
|
30
42
|
## Playground
|
|
31
43
|
|
|
@@ -286,3 +298,36 @@ const MyComponent = () => {
|
|
|
286
298
|
);
|
|
287
299
|
};
|
|
288
300
|
```
|
|
301
|
+
|
|
302
|
+
### Full width button
|
|
303
|
+
|
|
304
|
+
Use layout components, like `Box` or `Flex`, to define your UI layouts, which can also be responsive.
|
|
305
|
+
|
|
306
|
+
<UsageWrap>
|
|
307
|
+
<Box spacing="md">
|
|
308
|
+
<Flex align="stretch">
|
|
309
|
+
<Button>Full width button</Button>
|
|
310
|
+
</Flex>
|
|
311
|
+
|
|
312
|
+
<Card>
|
|
313
|
+
<DetailText size="xl">Button inside a Card component</DetailText>
|
|
314
|
+
<Box width="100%" paddingTop="md">
|
|
315
|
+
<Button>Refetch</Button>
|
|
316
|
+
</Box>
|
|
317
|
+
</Card>
|
|
318
|
+
</Box>
|
|
319
|
+
</UsageWrap>
|
|
320
|
+
|
|
321
|
+
```tsx
|
|
322
|
+
<Flex align="stretch">
|
|
323
|
+
<Button>Full width button</Button>
|
|
324
|
+
</Flex>
|
|
325
|
+
|
|
326
|
+
// Card example
|
|
327
|
+
<Card>
|
|
328
|
+
<DetailText size="xl">Button inside a Card component</DetailText>
|
|
329
|
+
<Box width="100%" paddingTop="md">
|
|
330
|
+
<Button>Refetch</Button>
|
|
331
|
+
</Box>
|
|
332
|
+
</Card>
|
|
333
|
+
```
|
|
@@ -70,7 +70,7 @@ const MyComponent = () => (
|
|
|
70
70
|
| selected | `boolean` | Whether the card is selected. | `false` |
|
|
71
71
|
| onPress | `() => void` | Callback function to be called. | `-` |
|
|
72
72
|
| disabled | `boolean` | Whether the card is disabled. | `false` |
|
|
73
|
-
|
|
|
73
|
+
| spacing | `'none' \| '2xs' \| 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| '2xl'` | The space between the content. | `none` |
|
|
74
74
|
| alignItems | `'flex-start' \| 'flex-end' \| `<br />`'center' \| 'stretch' \| 'baseline'` | The align items of the flex container. | `flex-start` |
|
|
75
75
|
| justifyContent | `'flex-start' \| 'flex-end' \| 'center' \| 'space-between' \| `<br />` 'space-around' \| 'space-evenly'` | The justify content of the flex container. | `flex-start` |
|
|
76
76
|
| flexWrap | `'wrap' \| 'nowrap' \| 'wrap-reverse'` | The wrap of the flex container. | `nowrap` |
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PressableProps, ViewStyle } from 'react-native';
|
|
2
|
-
import {
|
|
2
|
+
import { GapProps, MarginProps, SpacingValues } from '../../types';
|
|
3
3
|
|
|
4
|
-
interface CardProps extends PressableProps {
|
|
4
|
+
interface CardProps extends PressableProps, MarginProps, GapProps {
|
|
5
5
|
variant?: 'emphasis' | 'subtle';
|
|
6
6
|
colorScheme?:
|
|
7
7
|
| 'neutralStrong'
|
|
@@ -31,9 +31,6 @@ interface CardProps extends PressableProps {
|
|
|
31
31
|
justifyContent?: ViewStyle['justifyContent'];
|
|
32
32
|
flexDirection?: ViewStyle['flexDirection'];
|
|
33
33
|
flexWrap?: ViewStyle['flexWrap'];
|
|
34
|
-
gap?: SpaceValue;
|
|
35
|
-
rowGap?: SpaceValue;
|
|
36
|
-
columnGap?: SpaceValue;
|
|
37
34
|
}
|
|
38
35
|
|
|
39
36
|
export default CardProps;
|
|
@@ -77,29 +77,60 @@ export const Playground: Story = {
|
|
|
77
77
|
export const WithActions: Story = {
|
|
78
78
|
render: ({ children, ...props }) => {
|
|
79
79
|
return (
|
|
80
|
-
<
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
80
|
+
<Flex gap="400">
|
|
81
|
+
<Card
|
|
82
|
+
{...props}
|
|
83
|
+
flexDirection="column"
|
|
84
|
+
alignItems="stretch"
|
|
85
|
+
spacing="md"
|
|
86
|
+
variant="emphasis"
|
|
87
|
+
>
|
|
88
|
+
<BodyText>{children as string}</BodyText>
|
|
89
|
+
<CardActions>
|
|
90
|
+
<CardAction
|
|
91
|
+
onPress={() => console.log('Card action pressed')}
|
|
92
|
+
heading="Card Action Head"
|
|
93
|
+
helperText="Some helper text"
|
|
94
|
+
leadingIcon={BellMediumIcon}
|
|
95
|
+
/>
|
|
96
|
+
<CardAction
|
|
97
|
+
onPress={() => console.log('Card action pressed')}
|
|
98
|
+
heading="Card Action Head"
|
|
99
|
+
leadingIcon={BellMediumIcon}
|
|
100
|
+
/>
|
|
101
|
+
<CardAction
|
|
102
|
+
onPress={() => console.log('Card action pressed')}
|
|
103
|
+
heading="Card Action Head"
|
|
104
|
+
helperText="Testing"
|
|
105
|
+
leadingIcon={BellMediumIcon}
|
|
106
|
+
iconContainer={false}
|
|
107
|
+
/>
|
|
108
|
+
</CardActions>
|
|
109
|
+
</Card>
|
|
110
|
+
<Card {...props} flexDirection="column" alignItems="stretch" spacing="md" variant="subtle">
|
|
111
|
+
<BodyText>{children as string}</BodyText>
|
|
112
|
+
<CardActions>
|
|
113
|
+
<CardAction
|
|
114
|
+
onPress={() => console.log('Card action pressed')}
|
|
115
|
+
heading="Card Action Head"
|
|
116
|
+
helperText="Some helper text"
|
|
117
|
+
leadingIcon={BellMediumIcon}
|
|
118
|
+
/>
|
|
119
|
+
<CardAction
|
|
120
|
+
onPress={() => console.log('Card action pressed')}
|
|
121
|
+
heading="Card Action Head"
|
|
122
|
+
leadingIcon={BellMediumIcon}
|
|
123
|
+
/>
|
|
124
|
+
<CardAction
|
|
125
|
+
onPress={() => console.log('Card action pressed')}
|
|
126
|
+
heading="Card Action Head"
|
|
127
|
+
helperText="Testing"
|
|
128
|
+
leadingIcon={BellMediumIcon}
|
|
129
|
+
iconContainer={false}
|
|
130
|
+
/>
|
|
131
|
+
</CardActions>
|
|
132
|
+
</Card>
|
|
133
|
+
</Flex>
|
|
103
134
|
);
|
|
104
135
|
},
|
|
105
136
|
};
|