@utilitywarehouse/hearth-react-native 0.20.0 → 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 +249 -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 +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/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/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/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
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '../../../docs/components';
|
|
9
9
|
import { Carousel, CarouselControls, CarouselItem } from './';
|
|
10
10
|
import * as Stories from './Carousel.stories';
|
|
11
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
11
12
|
|
|
12
13
|
<Meta title="Components / Carousel" />
|
|
13
14
|
|
|
@@ -53,13 +54,13 @@ Carousel Controls are used to clearly indicate multiple pieces of content and to
|
|
|
53
54
|
<Center flex={1}>
|
|
54
55
|
<Carousel width={300}>
|
|
55
56
|
<CarouselItem>
|
|
56
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
57
|
-
<BodyText color="
|
|
57
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.purple[800]}>
|
|
58
|
+
<BodyText color="inverted">I'm a Carousel item!</BodyText>
|
|
58
59
|
</Box>
|
|
59
60
|
</CarouselItem>
|
|
60
61
|
<CarouselItem>
|
|
61
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
62
|
-
<BodyText color="
|
|
62
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.red[800]}>
|
|
63
|
+
<BodyText color="inverted">I'm another Carousel item!</BodyText>
|
|
63
64
|
</Box>
|
|
64
65
|
</CarouselItem>
|
|
65
66
|
</Carousel>
|
|
@@ -68,17 +69,18 @@ Carousel Controls are used to clearly indicate multiple pieces of content and to
|
|
|
68
69
|
|
|
69
70
|
```jsx
|
|
70
71
|
import { BodyText, Box, Carousel, CarouselItem } from '@utilitywarehouse/hearth-react-native';
|
|
72
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
71
73
|
|
|
72
74
|
const MyComponent = () => (
|
|
73
75
|
<Carousel width={300}>
|
|
74
76
|
<CarouselItem>
|
|
75
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
76
|
-
<BodyText color="
|
|
77
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.purple[800]}>
|
|
78
|
+
<BodyText color="inverted">I'm a Carousel item!</BodyText>
|
|
77
79
|
</Box>
|
|
78
80
|
</CarouselItem>
|
|
79
81
|
<CarouselItem>
|
|
80
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
81
|
-
<BodyText color="
|
|
82
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.red[800]}>
|
|
83
|
+
<BodyText color="inverted">I'm another Carousel item!</BodyText>
|
|
82
84
|
</Box>
|
|
83
85
|
</CarouselItem>
|
|
84
86
|
</Carousel>
|
|
@@ -93,13 +95,13 @@ The `Carousel` component includes built-in pagination controls by default. You c
|
|
|
93
95
|
<Center flex={1}>
|
|
94
96
|
<Carousel width={300}>
|
|
95
97
|
<CarouselItem>
|
|
96
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
97
|
-
<BodyText color="
|
|
98
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.purple[800]}>
|
|
99
|
+
<BodyText color="inverted">I'm a Carousel item!</BodyText>
|
|
98
100
|
</Box>
|
|
99
101
|
</CarouselItem>
|
|
100
102
|
<CarouselItem>
|
|
101
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
102
|
-
<BodyText color="
|
|
103
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.red[800]}>
|
|
104
|
+
<BodyText color="inverted">I'm another Carousel item!</BodyText>
|
|
103
105
|
</Box>
|
|
104
106
|
</CarouselItem>
|
|
105
107
|
</Carousel>
|
|
@@ -108,17 +110,18 @@ The `Carousel` component includes built-in pagination controls by default. You c
|
|
|
108
110
|
|
|
109
111
|
```jsx
|
|
110
112
|
import { BodyText, Box, Carousel, CarouselItem } from '@utilitywarehouse/hearth-react-native';
|
|
113
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
111
114
|
|
|
112
115
|
const MyComponent = () => (
|
|
113
116
|
<Carousel width={300}>
|
|
114
117
|
<CarouselItem>
|
|
115
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
116
|
-
<BodyText color="
|
|
118
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.purple[800]}>
|
|
119
|
+
<BodyText color="inverted">I'm a Carousel item!</BodyText>
|
|
117
120
|
</Box>
|
|
118
121
|
</CarouselItem>
|
|
119
122
|
<CarouselItem>
|
|
120
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
121
|
-
<BodyText color="
|
|
123
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.red[800]}>
|
|
124
|
+
<BodyText color="inverted">I'm another Carousel item!</BodyText>
|
|
122
125
|
</Box>
|
|
123
126
|
</CarouselItem>
|
|
124
127
|
</Carousel>
|
|
@@ -133,13 +136,13 @@ Add previous and next navigation buttons to the controls by setting `showNavigat
|
|
|
133
136
|
<Center flex={1}>
|
|
134
137
|
<Carousel width={300} showNavigation>
|
|
135
138
|
<CarouselItem>
|
|
136
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
137
|
-
<BodyText color="
|
|
139
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.purple[800]}>
|
|
140
|
+
<BodyText color="inverted">I'm a Carousel item!</BodyText>
|
|
138
141
|
</Box>
|
|
139
142
|
</CarouselItem>
|
|
140
143
|
<CarouselItem>
|
|
141
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
142
|
-
<BodyText color="
|
|
144
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.red[800]}>
|
|
145
|
+
<BodyText color="inverted">I'm another Carousel item!</BodyText>
|
|
143
146
|
</Box>
|
|
144
147
|
</CarouselItem>
|
|
145
148
|
</Carousel>
|
|
@@ -148,17 +151,18 @@ Add previous and next navigation buttons to the controls by setting `showNavigat
|
|
|
148
151
|
|
|
149
152
|
```jsx
|
|
150
153
|
import { BodyText, Box, Carousel, CarouselItem } from '@utilitywarehouse/hearth-react-native';
|
|
154
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
151
155
|
|
|
152
156
|
const MyComponent = () => (
|
|
153
157
|
<Carousel width={300} showNavigation>
|
|
154
158
|
<CarouselItem>
|
|
155
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
156
|
-
<BodyText color="
|
|
159
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.purple[800]}>
|
|
160
|
+
<BodyText color="inverted">I'm a Carousel item!</BodyText>
|
|
157
161
|
</Box>
|
|
158
162
|
</CarouselItem>
|
|
159
163
|
<CarouselItem>
|
|
160
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
161
|
-
<BodyText color="
|
|
164
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.red[800]}>
|
|
165
|
+
<BodyText color="inverted">I'm another Carousel item!</BodyText>
|
|
162
166
|
</Box>
|
|
163
167
|
</CarouselItem>
|
|
164
168
|
</Carousel>
|
|
@@ -173,13 +177,13 @@ The `CarouselControls` component is to be used in conjunction with the `Carousel
|
|
|
173
177
|
<Center flex={1}>
|
|
174
178
|
<Carousel width={300}>
|
|
175
179
|
<CarouselItem>
|
|
176
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
177
|
-
<BodyText color="
|
|
180
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.purple[800]}>
|
|
181
|
+
<BodyText color="inverted">I'm a Carousel item!</BodyText>
|
|
178
182
|
</Box>
|
|
179
183
|
</CarouselItem>
|
|
180
184
|
<CarouselItem>
|
|
181
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
182
|
-
<BodyText color="
|
|
185
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.red[800]}>
|
|
186
|
+
<BodyText color="inverted">I'm another Carousel item!</BodyText>
|
|
183
187
|
</Box>
|
|
184
188
|
</CarouselItem>
|
|
185
189
|
<CarouselControls style={{ marginTop: 16 }} />
|
|
@@ -189,17 +193,18 @@ The `CarouselControls` component is to be used in conjunction with the `Carousel
|
|
|
189
193
|
|
|
190
194
|
```jsx
|
|
191
195
|
import { BodyText, Box, Carousel, CarouselControls } from '@utilitywarehouse/hearth-react-native';
|
|
196
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
192
197
|
|
|
193
198
|
const MyComponent = () => (
|
|
194
199
|
<Carousel width={300}>
|
|
195
200
|
<CarouselItem>
|
|
196
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
197
|
-
<BodyText color="
|
|
201
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.purple[800]}>
|
|
202
|
+
<BodyText color="inverted">I'm a Carousel item!</BodyText>
|
|
198
203
|
</Box>
|
|
199
204
|
</CarouselItem>
|
|
200
205
|
<CarouselItem>
|
|
201
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
202
|
-
<BodyText color="
|
|
206
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.red[800]}>
|
|
207
|
+
<BodyText color="inverted">I'm another Carousel item!</BodyText>
|
|
203
208
|
</Box>
|
|
204
209
|
</CarouselItem>
|
|
205
210
|
<CarouselControls style={{ marginTop: 16 }} />
|
|
@@ -232,13 +237,13 @@ const MyComponent = () => {
|
|
|
232
237
|
<>
|
|
233
238
|
<Carousel ref={carouselRef} width={300}>
|
|
234
239
|
<CarouselItem>
|
|
235
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
236
|
-
<BodyText color="
|
|
240
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.purple[800]}>
|
|
241
|
+
<BodyText color="inverted">Slide 1</BodyText>
|
|
237
242
|
</Box>
|
|
238
243
|
</CarouselItem>
|
|
239
244
|
<CarouselItem>
|
|
240
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
241
|
-
<BodyText color="
|
|
245
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.red[800]}>
|
|
246
|
+
<BodyText color="inverted">Slide 2</BodyText>
|
|
242
247
|
</Box>
|
|
243
248
|
</CarouselItem>
|
|
244
249
|
</Carousel>
|
|
@@ -262,13 +267,13 @@ const MyComponent = () => {
|
|
|
262
267
|
return (
|
|
263
268
|
<Carousel width={carouselWidth} itemWidth={itemWidth} centered showOverflow>
|
|
264
269
|
<CarouselItem>
|
|
265
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
266
|
-
<BodyText color="
|
|
270
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.purple[800]}>
|
|
271
|
+
<BodyText color="inverted">I'm a Carousel item!</BodyText>
|
|
267
272
|
</Box>
|
|
268
273
|
</CarouselItem>
|
|
269
274
|
<CarouselItem>
|
|
270
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
271
|
-
<BodyText color="
|
|
275
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.red[800]}>
|
|
276
|
+
<BodyText color="inverted">I'm another Carousel item!</BodyText>
|
|
272
277
|
</Box>
|
|
273
278
|
</CarouselItem>
|
|
274
279
|
</Carousel>
|
|
@@ -345,9 +350,9 @@ When using a screen reader, users will navigate through the carousel items in or
|
|
|
345
350
|
```jsx
|
|
346
351
|
<Carousel width={300}>
|
|
347
352
|
<CarouselItem>
|
|
348
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
353
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.purple[800]}>
|
|
349
354
|
<BodyText
|
|
350
|
-
color="
|
|
355
|
+
color="inverted"
|
|
351
356
|
accessibilityLabel="Special offer: 20% off your next bill"
|
|
352
357
|
accessibilityHint="Double tap to view offer details"
|
|
353
358
|
>
|
|
@@ -356,9 +361,9 @@ When using a screen reader, users will navigate through the carousel items in or
|
|
|
356
361
|
</Box>
|
|
357
362
|
</CarouselItem>
|
|
358
363
|
<CarouselItem>
|
|
359
|
-
<Box p="100" aspectRatio={1.6} backgroundColor=
|
|
364
|
+
<Box p="100" aspectRatio={1.6} backgroundColor={color.red[800]}>
|
|
360
365
|
<BodyText
|
|
361
|
-
color="
|
|
366
|
+
color="inverted"
|
|
362
367
|
accessibilityLabel="Refer a friend and earn rewards"
|
|
363
368
|
accessibilityHint="Double tap to learn more about referrals"
|
|
364
369
|
>
|
|
@@ -2,6 +2,7 @@ import { Meta, Canvas, Story, Controls, Primary } from '@storybook/addon-docs/bl
|
|
|
2
2
|
import * as Stories from './Center.stories';
|
|
3
3
|
import { Center, Pressable, Box, BodyText } from '../..';
|
|
4
4
|
import { UsageWrap, BackToTopButton, ViewFigmaButton } from '../../../docs/components';
|
|
5
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
5
6
|
|
|
6
7
|
<Meta title="Primitives / Center" />
|
|
7
8
|
|
|
@@ -18,18 +19,19 @@ When you need to center-align content, the Center component comes in handy. It i
|
|
|
18
19
|
|
|
19
20
|
<UsageWrap>
|
|
20
21
|
<Center>
|
|
21
|
-
<Center backgroundColor=
|
|
22
|
-
<BodyText color="
|
|
22
|
+
<Center backgroundColor={color.red[400]} width={300} height={200} padding="200">
|
|
23
|
+
<BodyText color="inverted">It's hard being in the middle of everything.</BodyText>
|
|
23
24
|
</Center>
|
|
24
25
|
</Center>
|
|
25
26
|
</UsageWrap>
|
|
26
27
|
|
|
27
28
|
```jsx
|
|
28
29
|
import { Center, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
30
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
29
31
|
|
|
30
32
|
const MyComponent = () => (
|
|
31
|
-
<Center backgroundColor=
|
|
32
|
-
<BodyText color="
|
|
33
|
+
<Center backgroundColor={color.red[400]} width={300} height={200} padding="200">
|
|
34
|
+
<BodyText color="inverted">It's hard being in the middle of everything.</BodyText>
|
|
33
35
|
</Center>
|
|
34
36
|
);
|
|
35
37
|
```
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Canvas, Controls, Meta, Primary, Story } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
2
3
|
import { BodyText, Box, Container } from '../..';
|
|
3
4
|
import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
4
5
|
import * as Stories from './Container.stories';
|
|
@@ -33,8 +34,8 @@ The Container component is a layout primitive that provides consistent spacing a
|
|
|
33
34
|
The Container component uses layout tokens automatically for responsive spacing:
|
|
34
35
|
|
|
35
36
|
<UsageWrap>
|
|
36
|
-
<Container backgroundColor="
|
|
37
|
-
<Box bg=
|
|
37
|
+
<Container backgroundColor="secondary">
|
|
38
|
+
<Box bg={color.blue['400']} p="200" borderRadius="md">
|
|
38
39
|
<BodyText>Container content</BodyText>
|
|
39
40
|
</Box>
|
|
40
41
|
</Container>
|
|
@@ -42,10 +43,11 @@ The Container component uses layout tokens automatically for responsive spacing:
|
|
|
42
43
|
|
|
43
44
|
```jsx
|
|
44
45
|
import { Container, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
46
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
45
47
|
|
|
46
48
|
const MyComponent = () => (
|
|
47
49
|
<Container>
|
|
48
|
-
<Box bg=
|
|
50
|
+
<Box bg={color.cyan['400']} p="200" borderRadius="md">
|
|
49
51
|
<BodyText>Container content</BodyText>
|
|
50
52
|
</Box>
|
|
51
53
|
</Container>
|
|
@@ -60,10 +62,11 @@ You can override the default padding with custom values using space tokens:
|
|
|
60
62
|
|
|
61
63
|
```jsx
|
|
62
64
|
import { Container, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
65
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
63
66
|
|
|
64
67
|
const MyComponent = () => (
|
|
65
68
|
<Container padding="300">
|
|
66
|
-
<Box bg=
|
|
69
|
+
<Box bg={color.cyan['400']} p="200" borderRadius="md">
|
|
67
70
|
<BodyText>Container with padding</BodyText>
|
|
68
71
|
</Box>
|
|
69
72
|
</Container>
|
|
@@ -78,10 +81,11 @@ You can override the default margin with custom values using space tokens:
|
|
|
78
81
|
|
|
79
82
|
```jsx
|
|
80
83
|
import { Container, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
84
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
81
85
|
|
|
82
86
|
const MyComponent = () => (
|
|
83
87
|
<Container margin="300">
|
|
84
|
-
<Box bg=
|
|
88
|
+
<Box bg={color.cyan['400']} p="200" borderRadius="md">
|
|
85
89
|
<BodyText>Container with margin</BodyText>
|
|
86
90
|
</Box>
|
|
87
91
|
</Container>
|
|
@@ -96,16 +100,17 @@ The Container component supports a `spacing` prop for controlling gap between ch
|
|
|
96
100
|
|
|
97
101
|
```jsx
|
|
98
102
|
import { Container, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
103
|
+
import { color } from '@utilitywarehouse/hearth-tokens';
|
|
99
104
|
|
|
100
105
|
const MyComponent = () => (
|
|
101
106
|
<Container spacing="xl" paddingHorizontal="200" paddingVertical="300">
|
|
102
|
-
<Box bg=
|
|
107
|
+
<Box bg={color.cyan['400']} p="200" borderRadius="md">
|
|
103
108
|
<BodyText>Item 1</BodyText>
|
|
104
109
|
</Box>
|
|
105
|
-
<Box bg=
|
|
110
|
+
<Box bg={color.purple['400']} p="200" borderRadius="md">
|
|
106
111
|
<BodyText>Item 2</BodyText>
|
|
107
112
|
</Box>
|
|
108
|
-
<Box bg=
|
|
113
|
+
<Box bg={color.pink['400']} p="200" borderRadius="md">
|
|
109
114
|
<BodyText>Item 3</BodyText>
|
|
110
115
|
</Box>
|
|
111
116
|
</Container>
|
|
@@ -1,79 +1,14 @@
|
|
|
1
1
|
import type { ViewProps } from 'react-native';
|
|
2
|
-
import {
|
|
2
|
+
import type {
|
|
3
|
+
BackgroundColorProps,
|
|
4
|
+
GapProps,
|
|
5
|
+
MarginProps,
|
|
6
|
+
PaddingProps,
|
|
7
|
+
SpacingValues,
|
|
8
|
+
} from '../../types';
|
|
3
9
|
|
|
4
|
-
interface ContainerProps
|
|
5
|
-
|
|
6
|
-
* The padding of the container.
|
|
7
|
-
*/
|
|
8
|
-
padding?: SpaceValue;
|
|
9
|
-
/**
|
|
10
|
-
* The horizontal padding of the container.
|
|
11
|
-
*/
|
|
12
|
-
paddingHorizontal?: SpaceValue;
|
|
13
|
-
/**
|
|
14
|
-
* The vertical padding of the container.
|
|
15
|
-
*/
|
|
16
|
-
paddingVertical?: SpaceValue;
|
|
17
|
-
/**
|
|
18
|
-
* The top padding of the container.
|
|
19
|
-
*/
|
|
20
|
-
paddingTop?: SpaceValue;
|
|
21
|
-
/**
|
|
22
|
-
* The bottom padding of the container.
|
|
23
|
-
*/
|
|
24
|
-
paddingBottom?: SpaceValue;
|
|
25
|
-
/**
|
|
26
|
-
* The left padding of the container.
|
|
27
|
-
*/
|
|
28
|
-
paddingLeft?: SpaceValue;
|
|
29
|
-
/**
|
|
30
|
-
* The right padding of the container.
|
|
31
|
-
*/
|
|
32
|
-
paddingRight?: SpaceValue;
|
|
33
|
-
/**
|
|
34
|
-
* The margin of the container.
|
|
35
|
-
*/
|
|
36
|
-
margin?: SpaceValue;
|
|
37
|
-
/**
|
|
38
|
-
* The horizontal margin of the container.
|
|
39
|
-
*/
|
|
40
|
-
marginHorizontal?: SpaceValue;
|
|
41
|
-
/**
|
|
42
|
-
* The vertical margin of the container.
|
|
43
|
-
*/
|
|
44
|
-
marginVertical?: SpaceValue;
|
|
45
|
-
/**
|
|
46
|
-
* The top margin of the container.
|
|
47
|
-
*/
|
|
48
|
-
marginTop?: SpaceValue;
|
|
49
|
-
/**
|
|
50
|
-
* The bottom margin of the container.
|
|
51
|
-
*/
|
|
52
|
-
marginBottom?: SpaceValue;
|
|
53
|
-
/**
|
|
54
|
-
* The left margin of the container.
|
|
55
|
-
*/
|
|
56
|
-
marginLeft?: SpaceValue;
|
|
57
|
-
/**
|
|
58
|
-
* The right margin of the container.
|
|
59
|
-
*/
|
|
60
|
-
marginRight?: SpaceValue;
|
|
61
|
-
// Padding
|
|
62
|
-
p?: SpaceValue;
|
|
63
|
-
px?: SpaceValue;
|
|
64
|
-
py?: SpaceValue;
|
|
65
|
-
pt?: SpaceValue;
|
|
66
|
-
pb?: SpaceValue;
|
|
67
|
-
pl?: SpaceValue;
|
|
68
|
-
pr?: SpaceValue;
|
|
69
|
-
// Margin
|
|
70
|
-
m?: SpaceValue;
|
|
71
|
-
mx?: SpaceValue;
|
|
72
|
-
my?: SpaceValue;
|
|
73
|
-
mt?: SpaceValue;
|
|
74
|
-
mb?: SpaceValue;
|
|
75
|
-
ml?: SpaceValue;
|
|
76
|
-
mr?: SpaceValue;
|
|
10
|
+
interface ContainerProps
|
|
11
|
+
extends ViewProps, MarginProps, PaddingProps, GapProps, BackgroundColorProps {
|
|
77
12
|
/**
|
|
78
13
|
* The spacing between child elements (gap).
|
|
79
14
|
*/
|
|
@@ -83,12 +18,6 @@ interface ContainerProps extends ViewProps {
|
|
|
83
18
|
* @deprecated Use `spacing` instead. The `space` prop will be removed in a future release.
|
|
84
19
|
*/
|
|
85
20
|
space?: SpacingValues;
|
|
86
|
-
/**
|
|
87
|
-
* The space between child elements.
|
|
88
|
-
*/
|
|
89
|
-
gap?: SpaceValue;
|
|
90
|
-
backgroundColor?: 'backgroundBrand' | 'backgroundPrimary' | 'backgroundSecondary' | 'transparent';
|
|
91
|
-
bg?: 'backgroundBrand' | 'backgroundPrimary' | 'backgroundSecondary' | 'transparent';
|
|
92
21
|
}
|
|
93
22
|
|
|
94
23
|
export default ContainerProps;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { Container } from '.';
|
|
3
3
|
import { lightTheme } from '../../core/themes';
|
|
4
|
+
import { useTheme } from '../../hooks';
|
|
4
5
|
import { BodyText } from '../BodyText';
|
|
5
6
|
import { Box } from '../Box';
|
|
6
7
|
|
|
@@ -165,12 +166,12 @@ const meta = {
|
|
|
165
166
|
description: 'The space between child elements.',
|
|
166
167
|
},
|
|
167
168
|
backgroundColor: {
|
|
168
|
-
options: ['
|
|
169
|
+
options: ['brand', 'primary', 'secondary', 'transparent'],
|
|
169
170
|
control: 'select',
|
|
170
171
|
description: 'The background color of the container.',
|
|
171
172
|
},
|
|
172
173
|
bg: {
|
|
173
|
-
options: ['
|
|
174
|
+
options: ['brand', 'primary', 'secondary', 'transparent'],
|
|
174
175
|
control: 'select',
|
|
175
176
|
description: 'The background color of the container.',
|
|
176
177
|
},
|
|
@@ -185,51 +186,60 @@ export default meta;
|
|
|
185
186
|
type Story = StoryObj<typeof meta>;
|
|
186
187
|
|
|
187
188
|
export const Playground: Story = {
|
|
188
|
-
render: args =>
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
189
|
+
render: args => {
|
|
190
|
+
const { color } = useTheme();
|
|
191
|
+
return (
|
|
192
|
+
<Box backgroundColor={color.red['100']}>
|
|
193
|
+
<Container {...args} backgroundColor="secondary">
|
|
194
|
+
<Box bg={color.blue['400']} p="200" borderRadius="md">
|
|
195
|
+
<BodyText>Container content 1</BodyText>
|
|
196
|
+
</Box>
|
|
197
|
+
<Box bg={color.purple['400']} p="200" borderRadius="md">
|
|
198
|
+
<BodyText>Container content 2</BodyText>
|
|
199
|
+
</Box>
|
|
200
|
+
<Box bg={color.piggyPink['400']} p="200" borderRadius="md">
|
|
201
|
+
<BodyText>Container content 3</BodyText>
|
|
202
|
+
</Box>
|
|
203
|
+
</Container>
|
|
204
|
+
</Box>
|
|
205
|
+
);
|
|
206
|
+
},
|
|
203
207
|
};
|
|
204
208
|
|
|
205
209
|
export const WithPadding: Story = {
|
|
206
210
|
args: {
|
|
207
211
|
padding: '300',
|
|
208
212
|
},
|
|
209
|
-
render: args =>
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
213
|
+
render: args => {
|
|
214
|
+
const { color } = useTheme();
|
|
215
|
+
return (
|
|
216
|
+
<Box backgroundColor={color.red['100']}>
|
|
217
|
+
<Container {...args} backgroundColor="secondary">
|
|
218
|
+
<Box bg={color.blue['400']} p="200" borderRadius="md">
|
|
219
|
+
<BodyText>Container with padding</BodyText>
|
|
220
|
+
</Box>
|
|
221
|
+
</Container>
|
|
222
|
+
</Box>
|
|
223
|
+
);
|
|
224
|
+
},
|
|
218
225
|
};
|
|
219
226
|
|
|
220
227
|
export const WithMargin: Story = {
|
|
221
228
|
args: {
|
|
222
229
|
margin: '300',
|
|
223
230
|
},
|
|
224
|
-
render: args =>
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
render: args => {
|
|
232
|
+
const { color } = useTheme();
|
|
233
|
+
return (
|
|
234
|
+
<Box backgroundColor={color.red['100']}>
|
|
235
|
+
<Container {...args} backgroundColor="secondary">
|
|
236
|
+
<Box bg={color.blue['400']} p="200" borderRadius="md">
|
|
237
|
+
<BodyText>Container with margin</BodyText>
|
|
238
|
+
</Box>
|
|
239
|
+
</Container>
|
|
240
|
+
</Box>
|
|
241
|
+
);
|
|
242
|
+
},
|
|
233
243
|
};
|
|
234
244
|
|
|
235
245
|
export const WithCustomSpacing: Story = {
|
|
@@ -238,37 +248,43 @@ export const WithCustomSpacing: Story = {
|
|
|
238
248
|
paddingHorizontal: '200',
|
|
239
249
|
paddingVertical: '300',
|
|
240
250
|
},
|
|
241
|
-
render: args =>
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
251
|
+
render: args => {
|
|
252
|
+
const { color } = useTheme();
|
|
253
|
+
return (
|
|
254
|
+
<Box backgroundColor={color.red['100']}>
|
|
255
|
+
<Container {...args} backgroundColor="secondary">
|
|
256
|
+
<Box bg={color.blue['400']} p="200" borderRadius="md">
|
|
257
|
+
<BodyText>Item 1</BodyText>
|
|
258
|
+
</Box>
|
|
259
|
+
<Box bg={color.purple['400']} p="200" borderRadius="md">
|
|
260
|
+
<BodyText>Item 2</BodyText>
|
|
261
|
+
</Box>
|
|
262
|
+
<Box bg={color.piggyPink['400']} p="200" borderRadius="md">
|
|
263
|
+
<BodyText>Item 3</BodyText>
|
|
264
|
+
</Box>
|
|
265
|
+
<Box bg={color.orange['400']} p="200" borderRadius="md">
|
|
266
|
+
<BodyText>Item 4</BodyText>
|
|
267
|
+
</Box>
|
|
268
|
+
</Container>
|
|
269
|
+
</Box>
|
|
270
|
+
);
|
|
271
|
+
},
|
|
259
272
|
};
|
|
260
273
|
|
|
261
274
|
export const LayoutTokens: Story = {
|
|
262
|
-
render: () =>
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
275
|
+
render: () => {
|
|
276
|
+
const { color } = useTheme();
|
|
277
|
+
return (
|
|
278
|
+
<Box backgroundColor={color.red['100']}>
|
|
279
|
+
<Container backgroundColor="secondary">
|
|
280
|
+
<Box bg={color.blue['100']} p="200" borderRadius="md">
|
|
281
|
+
<BodyText>
|
|
282
|
+
This Container uses the responsive layout tokens from the design system. It will
|
|
283
|
+
automatically adjust margin and padding based on the current breakpoint.
|
|
284
|
+
</BodyText>
|
|
285
|
+
</Box>
|
|
286
|
+
</Container>
|
|
287
|
+
</Box>
|
|
288
|
+
);
|
|
289
|
+
},
|
|
274
290
|
};
|