@utilitywarehouse/hearth-react-native 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.storybook/main.ts +21 -1
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +8 -0
- package/build/components/Container/Container.d.ts +6 -0
- package/build/components/Container/Container.js +40 -0
- package/build/components/Container/Container.props.d.ts +85 -0
- package/build/components/Container/Container.props.js +1 -0
- package/build/components/Container/index.d.ts +2 -0
- package/build/components/Container/index.js +1 -0
- package/build/components/ProgressStepper/ProgressStep.d.ts +1 -1
- package/build/components/ProgressStepper/ProgressStep.js +6 -6
- package/build/components/ProgressStepper/ProgressStepper.props.d.ts +3 -3
- package/build/components/ProgressStepper/index.d.ts +1 -1
- package/build/components/ThemedImage/ThemedImage.d.ts +12 -0
- package/build/components/ThemedImage/ThemedImage.js +27 -0
- package/build/components/ThemedImage/ThemedImage.props.d.ts +13 -0
- package/build/components/ThemedImage/ThemedImage.props.js +1 -0
- package/build/components/ThemedImage/index.d.ts +2 -0
- package/build/components/ThemedImage/index.js +1 -0
- package/build/components/index.d.ts +2 -0
- package/build/components/index.js +2 -0
- package/build/hooks/useStyleProps.js +1 -1
- package/docs/components/AllComponents.web.tsx +38 -3
- package/docs/layout-components.docs.mdx +30 -0
- package/package.json +3 -1
- package/src/components/Container/Container.docs.mdx +168 -0
- package/src/components/Container/Container.props.ts +89 -0
- package/src/components/Container/Container.stories.tsx +274 -0
- package/src/components/Container/Container.tsx +52 -0
- package/src/components/Container/index.tsx +2 -0
- package/src/components/ProgressStepper/ProgressStep.tsx +8 -8
- package/src/components/ProgressStepper/ProgressStepper.docs.mdx +11 -11
- package/src/components/ProgressStepper/ProgressStepper.props.ts +3 -3
- package/src/components/ProgressStepper/ProgressStepper.stories.tsx +27 -27
- package/src/components/ProgressStepper/index.ts +1 -1
- package/src/components/ThemedImage/ThemedImage.docs.mdx +208 -0
- package/src/components/ThemedImage/ThemedImage.props.ts +15 -0
- package/src/components/ThemedImage/ThemedImage.stories.tsx +175 -0
- package/src/components/ThemedImage/ThemedImage.tsx +34 -0
- package/src/components/ThemedImage/index.tsx +2 -0
- package/src/components/index.ts +2 -0
- package/src/hooks/useStyleProps.ts +1 -1
- package/src/vite-env.d.ts +6 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Canvas, Controls, Meta, Primary, Story } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import { BodyText, Box, Container } from '../..';
|
|
3
|
+
import { BackToTopButton, UsageWrap, ViewFigmaButton } from '../../../docs/components';
|
|
4
|
+
import * as Stories from './Container.stories';
|
|
5
|
+
|
|
6
|
+
<Meta title="Primitives / Container" />
|
|
7
|
+
|
|
8
|
+
<BackToTopButton />
|
|
9
|
+
|
|
10
|
+
# Container
|
|
11
|
+
|
|
12
|
+
The Container component is a layout primitive that provides consistent spacing and structure using the design system's layout tokens. It automatically applies responsive margin and padding based on the current breakpoint, and supports additional customization through spacing props.
|
|
13
|
+
|
|
14
|
+
- [Playground](#playground)
|
|
15
|
+
- [Usage](#usage)
|
|
16
|
+
- [Basic Usage](#basic-usage)
|
|
17
|
+
- [With Custom Padding](#with-custom-padding)
|
|
18
|
+
- [With Custom Margin](#with-custom-margin)
|
|
19
|
+
- [With Custom Spacing](#with-custom-spacing)
|
|
20
|
+
- [Props](#props)
|
|
21
|
+
- [Design Tokens](#design-tokens)
|
|
22
|
+
|
|
23
|
+
## Playground
|
|
24
|
+
|
|
25
|
+
<Canvas of={Stories.Playground} />
|
|
26
|
+
|
|
27
|
+
<Controls of={Stories.Playground} />
|
|
28
|
+
|
|
29
|
+
## Usage
|
|
30
|
+
|
|
31
|
+
### Basic Usage
|
|
32
|
+
|
|
33
|
+
The Container component uses layout tokens automatically for responsive spacing:
|
|
34
|
+
|
|
35
|
+
<UsageWrap>
|
|
36
|
+
<Container backgroundColor="backgroundSecondary">
|
|
37
|
+
<Box bg="blue400" p="200" borderRadius="md">
|
|
38
|
+
<BodyText>Container content</BodyText>
|
|
39
|
+
</Box>
|
|
40
|
+
</Container>
|
|
41
|
+
</UsageWrap>
|
|
42
|
+
|
|
43
|
+
```jsx
|
|
44
|
+
import { Container, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
45
|
+
|
|
46
|
+
const MyComponent = () => (
|
|
47
|
+
<Container>
|
|
48
|
+
<Box bg="cyan400" p="200" borderRadius="md">
|
|
49
|
+
<BodyText>Container content</BodyText>
|
|
50
|
+
</Box>
|
|
51
|
+
</Container>
|
|
52
|
+
);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### With Custom Padding
|
|
56
|
+
|
|
57
|
+
You can override the default padding with custom values using space tokens:
|
|
58
|
+
|
|
59
|
+
<Canvas of={Stories.WithPadding} />
|
|
60
|
+
|
|
61
|
+
```jsx
|
|
62
|
+
import { Container, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
63
|
+
|
|
64
|
+
const MyComponent = () => (
|
|
65
|
+
<Container padding="300">
|
|
66
|
+
<Box bg="cyan400" p="200" borderRadius="md">
|
|
67
|
+
<BodyText>Container with padding</BodyText>
|
|
68
|
+
</Box>
|
|
69
|
+
</Container>
|
|
70
|
+
);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### With Custom Margin
|
|
74
|
+
|
|
75
|
+
You can override the default margin with custom values using space tokens:
|
|
76
|
+
|
|
77
|
+
<Canvas of={Stories.WithMargin} />
|
|
78
|
+
|
|
79
|
+
```jsx
|
|
80
|
+
import { Container, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
81
|
+
|
|
82
|
+
const MyComponent = () => (
|
|
83
|
+
<Container margin="300">
|
|
84
|
+
<Box bg="cyan400" p="200" borderRadius="md">
|
|
85
|
+
<BodyText>Container with margin</BodyText>
|
|
86
|
+
</Box>
|
|
87
|
+
</Container>
|
|
88
|
+
);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### With Custom Spacing
|
|
92
|
+
|
|
93
|
+
The Container component supports a `space` prop for controlling gap between child elements, as well as directional padding and margin props:
|
|
94
|
+
|
|
95
|
+
<Canvas of={Stories.WithCustomSpacing} />
|
|
96
|
+
|
|
97
|
+
```jsx
|
|
98
|
+
import { Container, Box, BodyText } from '@utilitywarehouse/hearth-react-native';
|
|
99
|
+
|
|
100
|
+
const MyComponent = () => (
|
|
101
|
+
<Container space="xl" paddingHorizontal="200" paddingVertical="300">
|
|
102
|
+
<Box bg="cyan400" p="200" borderRadius="md">
|
|
103
|
+
<BodyText>Item 1</BodyText>
|
|
104
|
+
</Box>
|
|
105
|
+
<Box bg="purple400" p="200" borderRadius="md">
|
|
106
|
+
<BodyText>Item 2</BodyText>
|
|
107
|
+
</Box>
|
|
108
|
+
<Box bg="pink400" p="200" borderRadius="md">
|
|
109
|
+
<BodyText>Item 3</BodyText>
|
|
110
|
+
</Box>
|
|
111
|
+
</Container>
|
|
112
|
+
);
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Props
|
|
116
|
+
|
|
117
|
+
The Container component supports spacing props similar to the Box component, with both long-form and shorthand syntax:
|
|
118
|
+
|
|
119
|
+
### Spacing Props
|
|
120
|
+
|
|
121
|
+
| Name | Shorthand | Type | Default | Description |
|
|
122
|
+
| ------------------- | --------- | ------------ | ------- | ---------------------------------------- |
|
|
123
|
+
| `padding` | `p` | `SpaceValue` | - | The padding of the container. |
|
|
124
|
+
| `paddingHorizontal` | `px` | `SpaceValue` | - | The horizontal padding of the container. |
|
|
125
|
+
| `paddingVertical` | `py` | `SpaceValue` | - | The vertical padding of the container. |
|
|
126
|
+
| `paddingTop` | `pt` | `SpaceValue` | - | The top padding of the container. |
|
|
127
|
+
| `paddingBottom` | `pb` | `SpaceValue` | - | The bottom padding of the container. |
|
|
128
|
+
| `paddingLeft` | `pl` | `SpaceValue` | - | The left padding of the container. |
|
|
129
|
+
| `paddingRight` | `pr` | `SpaceValue` | - | The right padding of the container. |
|
|
130
|
+
| `margin` | `m` | `SpaceValue` | - | The margin of the container. |
|
|
131
|
+
| `marginHorizontal` | `mx` | `SpaceValue` | - | The horizontal margin of the container. |
|
|
132
|
+
| `marginVertical` | `my` | `SpaceValue` | - | The vertical margin of the container. |
|
|
133
|
+
| `marginTop` | `mt` | `SpaceValue` | - | The top margin of the container. |
|
|
134
|
+
| `marginBottom` | `mb` | `SpaceValue` | - | The bottom margin of the container. |
|
|
135
|
+
| `marginLeft` | `ml` | `SpaceValue` | - | The left margin of the container. |
|
|
136
|
+
| `marginRight` | `mr` | `SpaceValue` | - | The right margin of the container. |
|
|
137
|
+
|
|
138
|
+
## Design Tokens
|
|
139
|
+
|
|
140
|
+
The Container component uses the following layout tokens from the design system:
|
|
141
|
+
|
|
142
|
+
### Mobile (320px - 740px)
|
|
143
|
+
|
|
144
|
+
- **Margin Horizontal**: 16px
|
|
145
|
+
- **Padding Top**: 24px
|
|
146
|
+
- **Padding Bottom**: 32px
|
|
147
|
+
|
|
148
|
+
### Tablet (740px - 992px)
|
|
149
|
+
|
|
150
|
+
- **Margin Horizontal**: 32px
|
|
151
|
+
- **Padding Top**: 24px
|
|
152
|
+
- **Padding Bottom**: 32px
|
|
153
|
+
|
|
154
|
+
### Desktop (992px+)
|
|
155
|
+
|
|
156
|
+
- **Margin Horizontal**: 32px
|
|
157
|
+
- **Padding Top**: 32px
|
|
158
|
+
- **Padding Bottom**: 48px
|
|
159
|
+
|
|
160
|
+
These values are automatically applied based on the current breakpoint. You can override them using the padding and margin props.
|
|
161
|
+
|
|
162
|
+
### Space Tokens
|
|
163
|
+
|
|
164
|
+
For the `padding`, `margin`, and directional spacing props, you can use any of the following space token values:
|
|
165
|
+
|
|
166
|
+
`'0'`, `'25'`, `'50'`, `'75'`, `'100'`, `'150'`, `'175'`, `'200'`, `'250'`, `'300'`, `'350'`, `'400'`, `'500'`, `'600'`, `'700'`, `'800'`, `'900'`, `'1000'`
|
|
167
|
+
|
|
168
|
+
These correspond to pixel values: 0px, 2px, 4px, 6px, 8px, 12px, 14px, 16px, 20px, 24px, 28px, 32px, 40px, 48px, 56px, 64px, 72px, 80px respectively.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import { SpaceValue, SpacingValues } from '../../types';
|
|
3
|
+
|
|
4
|
+
interface ContainerProps extends ViewProps {
|
|
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;
|
|
77
|
+
/**
|
|
78
|
+
* The space between child elements (gap).
|
|
79
|
+
*/
|
|
80
|
+
space?: SpacingValues;
|
|
81
|
+
/**
|
|
82
|
+
* The space between child elements.
|
|
83
|
+
*/
|
|
84
|
+
gap?: SpaceValue;
|
|
85
|
+
backgroundColor?: 'backgroundBrand' | 'backgroundPrimary' | 'backgroundSecondary' | 'transparent';
|
|
86
|
+
bg?: 'backgroundBrand' | 'backgroundPrimary' | 'backgroundSecondary' | 'transparent';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default ContainerProps;
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { Container } from '.';
|
|
3
|
+
import { lightTheme } from '../../core/themes';
|
|
4
|
+
import { BodyText } from '../BodyText';
|
|
5
|
+
import { Box } from '../Box';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
|
|
8
|
+
const meta = {
|
|
9
|
+
title: 'Stories / Container',
|
|
10
|
+
component: Container,
|
|
11
|
+
parameters: {
|
|
12
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
13
|
+
layout: 'fullscreen',
|
|
14
|
+
},
|
|
15
|
+
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
16
|
+
argTypes: {
|
|
17
|
+
padding: {
|
|
18
|
+
options: Object.keys(lightTheme.space),
|
|
19
|
+
control: 'select',
|
|
20
|
+
description: 'The padding of the container.',
|
|
21
|
+
},
|
|
22
|
+
p: {
|
|
23
|
+
options: Object.keys(lightTheme.space),
|
|
24
|
+
control: 'select',
|
|
25
|
+
description: 'The padding of the container.',
|
|
26
|
+
},
|
|
27
|
+
paddingHorizontal: {
|
|
28
|
+
options: Object.keys(lightTheme.space),
|
|
29
|
+
control: 'select',
|
|
30
|
+
description: 'The horizontal padding of the container.',
|
|
31
|
+
},
|
|
32
|
+
px: {
|
|
33
|
+
options: Object.keys(lightTheme.space),
|
|
34
|
+
control: 'select',
|
|
35
|
+
description: 'The horizontal padding of the container.',
|
|
36
|
+
},
|
|
37
|
+
paddingVertical: {
|
|
38
|
+
options: Object.keys(lightTheme.space),
|
|
39
|
+
control: 'select',
|
|
40
|
+
description: 'The vertical padding of the container.',
|
|
41
|
+
},
|
|
42
|
+
py: {
|
|
43
|
+
options: Object.keys(lightTheme.space),
|
|
44
|
+
control: 'select',
|
|
45
|
+
description: 'The vertical padding of the container.',
|
|
46
|
+
},
|
|
47
|
+
paddingTop: {
|
|
48
|
+
options: Object.keys(lightTheme.space),
|
|
49
|
+
control: 'select',
|
|
50
|
+
description: 'The top padding of the container.',
|
|
51
|
+
},
|
|
52
|
+
pt: {
|
|
53
|
+
options: Object.keys(lightTheme.space),
|
|
54
|
+
control: 'select',
|
|
55
|
+
description: 'The top padding of the container.',
|
|
56
|
+
},
|
|
57
|
+
paddingBottom: {
|
|
58
|
+
options: Object.keys(lightTheme.space),
|
|
59
|
+
control: 'select',
|
|
60
|
+
description: 'The bottom padding of the container.',
|
|
61
|
+
},
|
|
62
|
+
pb: {
|
|
63
|
+
options: Object.keys(lightTheme.space),
|
|
64
|
+
control: 'select',
|
|
65
|
+
description: 'The bottom padding of the container.',
|
|
66
|
+
},
|
|
67
|
+
paddingLeft: {
|
|
68
|
+
options: Object.keys(lightTheme.space),
|
|
69
|
+
control: 'select',
|
|
70
|
+
description: 'The left padding of the container.',
|
|
71
|
+
},
|
|
72
|
+
pl: {
|
|
73
|
+
options: Object.keys(lightTheme.space),
|
|
74
|
+
control: 'select',
|
|
75
|
+
description: 'The left padding of the container.',
|
|
76
|
+
},
|
|
77
|
+
paddingRight: {
|
|
78
|
+
options: Object.keys(lightTheme.space),
|
|
79
|
+
control: 'select',
|
|
80
|
+
description: 'The right padding of the container.',
|
|
81
|
+
},
|
|
82
|
+
pr: {
|
|
83
|
+
options: Object.keys(lightTheme.space),
|
|
84
|
+
control: 'select',
|
|
85
|
+
description: 'The right padding of the container.',
|
|
86
|
+
},
|
|
87
|
+
margin: {
|
|
88
|
+
options: Object.keys(lightTheme.space),
|
|
89
|
+
control: 'select',
|
|
90
|
+
description: 'The margin of the container.',
|
|
91
|
+
},
|
|
92
|
+
m: {
|
|
93
|
+
options: Object.keys(lightTheme.space),
|
|
94
|
+
control: 'select',
|
|
95
|
+
description: 'The margin of the container.',
|
|
96
|
+
},
|
|
97
|
+
marginHorizontal: {
|
|
98
|
+
options: Object.keys(lightTheme.space),
|
|
99
|
+
control: 'select',
|
|
100
|
+
description: 'The horizontal margin of the container.',
|
|
101
|
+
},
|
|
102
|
+
mx: {
|
|
103
|
+
options: Object.keys(lightTheme.space),
|
|
104
|
+
control: 'select',
|
|
105
|
+
description: 'The horizontal margin of the container.',
|
|
106
|
+
},
|
|
107
|
+
marginVertical: {
|
|
108
|
+
options: Object.keys(lightTheme.space),
|
|
109
|
+
control: 'select',
|
|
110
|
+
description: 'The vertical margin of the container.',
|
|
111
|
+
},
|
|
112
|
+
my: {
|
|
113
|
+
options: Object.keys(lightTheme.space),
|
|
114
|
+
control: 'select',
|
|
115
|
+
description: 'The vertical margin of the container.',
|
|
116
|
+
},
|
|
117
|
+
marginTop: {
|
|
118
|
+
options: Object.keys(lightTheme.space),
|
|
119
|
+
control: 'select',
|
|
120
|
+
description: 'The top margin of the container.',
|
|
121
|
+
},
|
|
122
|
+
mt: {
|
|
123
|
+
options: Object.keys(lightTheme.space),
|
|
124
|
+
control: 'select',
|
|
125
|
+
description: 'The top margin of the container.',
|
|
126
|
+
},
|
|
127
|
+
marginBottom: {
|
|
128
|
+
options: Object.keys(lightTheme.space),
|
|
129
|
+
control: 'select',
|
|
130
|
+
description: 'The bottom margin of the container.',
|
|
131
|
+
},
|
|
132
|
+
mb: {
|
|
133
|
+
options: Object.keys(lightTheme.space),
|
|
134
|
+
control: 'select',
|
|
135
|
+
description: 'The bottom margin of the container.',
|
|
136
|
+
},
|
|
137
|
+
marginLeft: {
|
|
138
|
+
options: Object.keys(lightTheme.space),
|
|
139
|
+
control: 'select',
|
|
140
|
+
description: 'The left margin of the container.',
|
|
141
|
+
},
|
|
142
|
+
ml: {
|
|
143
|
+
options: Object.keys(lightTheme.space),
|
|
144
|
+
control: 'select',
|
|
145
|
+
description: 'The left margin of the container.',
|
|
146
|
+
},
|
|
147
|
+
marginRight: {
|
|
148
|
+
options: Object.keys(lightTheme.space),
|
|
149
|
+
control: 'select',
|
|
150
|
+
description: 'The right margin of the container.',
|
|
151
|
+
},
|
|
152
|
+
mr: {
|
|
153
|
+
options: Object.keys(lightTheme.space),
|
|
154
|
+
control: 'select',
|
|
155
|
+
description: 'The right margin of the container.',
|
|
156
|
+
},
|
|
157
|
+
space: {
|
|
158
|
+
options: ['none', '2xs', 'xs', 'sm', 'md', 'lg', 'xl', '2xl'],
|
|
159
|
+
control: 'radio',
|
|
160
|
+
description: 'The space between child elements (gap).',
|
|
161
|
+
},
|
|
162
|
+
gap: {
|
|
163
|
+
options: Object.keys(lightTheme.space),
|
|
164
|
+
control: 'select',
|
|
165
|
+
description: 'The space between child elements.',
|
|
166
|
+
},
|
|
167
|
+
backgroundColor: {
|
|
168
|
+
options: ['backgroundBrand', 'backgroundPrimary', 'backgroundSecondary', 'transparent'],
|
|
169
|
+
control: 'select',
|
|
170
|
+
description: 'The background color of the container.',
|
|
171
|
+
},
|
|
172
|
+
bg: {
|
|
173
|
+
options: ['backgroundBrand', 'backgroundPrimary', 'backgroundSecondary', 'transparent'],
|
|
174
|
+
control: 'select',
|
|
175
|
+
description: 'The background color of the container.',
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
// Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
|
|
179
|
+
args: {
|
|
180
|
+
space: 'md',
|
|
181
|
+
},
|
|
182
|
+
} satisfies Meta<typeof Container>;
|
|
183
|
+
|
|
184
|
+
export default meta;
|
|
185
|
+
type Story = StoryObj<typeof meta>;
|
|
186
|
+
|
|
187
|
+
export const Playground: Story = {
|
|
188
|
+
render: args => (
|
|
189
|
+
<Box backgroundColor="red100">
|
|
190
|
+
<Container {...args} backgroundColor="backgroundSecondary">
|
|
191
|
+
<Box bg="blue400" p="200" borderRadius="md">
|
|
192
|
+
<BodyText>Container content 1</BodyText>
|
|
193
|
+
</Box>
|
|
194
|
+
<Box bg="purple400" p="200" borderRadius="md">
|
|
195
|
+
<BodyText>Container content 2</BodyText>
|
|
196
|
+
</Box>
|
|
197
|
+
<Box bg="piggyPink400" p="200" borderRadius="md">
|
|
198
|
+
<BodyText>Container content 3</BodyText>
|
|
199
|
+
</Box>
|
|
200
|
+
</Container>
|
|
201
|
+
</Box>
|
|
202
|
+
),
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
export const WithPadding: Story = {
|
|
206
|
+
args: {
|
|
207
|
+
padding: '300',
|
|
208
|
+
},
|
|
209
|
+
render: args => (
|
|
210
|
+
<Box backgroundColor="red100">
|
|
211
|
+
<Container {...args} backgroundColor="backgroundSecondary">
|
|
212
|
+
<Box bg="blue400" p="200" borderRadius="md">
|
|
213
|
+
<BodyText>Container with padding</BodyText>
|
|
214
|
+
</Box>
|
|
215
|
+
</Container>
|
|
216
|
+
</Box>
|
|
217
|
+
),
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
export const WithMargin: Story = {
|
|
221
|
+
args: {
|
|
222
|
+
margin: '300',
|
|
223
|
+
},
|
|
224
|
+
render: args => (
|
|
225
|
+
<Box backgroundColor="red100">
|
|
226
|
+
<Container {...args} backgroundColor="backgroundSecondary">
|
|
227
|
+
<Box bg="blue400" p="200" borderRadius="md">
|
|
228
|
+
<BodyText>Container with margin</BodyText>
|
|
229
|
+
</Box>
|
|
230
|
+
</Container>
|
|
231
|
+
</Box>
|
|
232
|
+
),
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export const WithCustomSpacing: Story = {
|
|
236
|
+
args: {
|
|
237
|
+
space: 'xl',
|
|
238
|
+
paddingHorizontal: '200',
|
|
239
|
+
paddingVertical: '300',
|
|
240
|
+
},
|
|
241
|
+
render: args => (
|
|
242
|
+
<Box backgroundColor="red100">
|
|
243
|
+
<Container {...args} backgroundColor="backgroundSecondary">
|
|
244
|
+
<Box bg="blue400" p="200" borderRadius="md">
|
|
245
|
+
<BodyText>Item 1</BodyText>
|
|
246
|
+
</Box>
|
|
247
|
+
<Box bg="purple400" p="200" borderRadius="md">
|
|
248
|
+
<BodyText>Item 2</BodyText>
|
|
249
|
+
</Box>
|
|
250
|
+
<Box bg="piggyPink400" p="200" borderRadius="md">
|
|
251
|
+
<BodyText>Item 3</BodyText>
|
|
252
|
+
</Box>
|
|
253
|
+
<Box bg="orange400" p="200" borderRadius="md">
|
|
254
|
+
<BodyText>Item 4</BodyText>
|
|
255
|
+
</Box>
|
|
256
|
+
</Container>
|
|
257
|
+
</Box>
|
|
258
|
+
),
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
export const LayoutTokens: Story = {
|
|
262
|
+
render: () => (
|
|
263
|
+
<Box backgroundColor="red100">
|
|
264
|
+
<Container backgroundColor="backgroundSecondary">
|
|
265
|
+
<Box bg="blue100" p="200" borderRadius="md">
|
|
266
|
+
<BodyText>
|
|
267
|
+
This Container uses the responsive layout tokens from the design system. It will
|
|
268
|
+
automatically adjust margin and padding based on the current breakpoint.
|
|
269
|
+
</BodyText>
|
|
270
|
+
</Box>
|
|
271
|
+
</Container>
|
|
272
|
+
</Box>
|
|
273
|
+
),
|
|
274
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { View } from 'react-native';
|
|
2
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
3
|
+
import { useStyleProps } from '../../hooks';
|
|
4
|
+
import type ContainerProps from './Container.props';
|
|
5
|
+
|
|
6
|
+
const Container = ({ style, children, space = 'md', ...props }: ContainerProps) => {
|
|
7
|
+
const { computedStyles, remainingProps } = useStyleProps(props);
|
|
8
|
+
|
|
9
|
+
styles.useVariants({ space });
|
|
10
|
+
return (
|
|
11
|
+
<View style={[styles.container(computedStyles), style]} {...remainingProps}>
|
|
12
|
+
{children}
|
|
13
|
+
</View>
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
Container.displayName = 'Container';
|
|
18
|
+
|
|
19
|
+
const styles = StyleSheet.create(theme => ({
|
|
20
|
+
container: extra => ({
|
|
21
|
+
paddingTop:
|
|
22
|
+
typeof extra.padding === 'undefined' && typeof extra.paddingVertical === 'undefined'
|
|
23
|
+
? {
|
|
24
|
+
base: theme.layout.mobile.container.paddingTop,
|
|
25
|
+
md: theme.layout.tablet.container.paddingTop,
|
|
26
|
+
lg: theme.layout.desktop.container.paddingTop,
|
|
27
|
+
}
|
|
28
|
+
: undefined,
|
|
29
|
+
paddingBottom:
|
|
30
|
+
typeof extra.padding === 'undefined' && typeof extra.paddingVertical === 'undefined'
|
|
31
|
+
? {
|
|
32
|
+
base: theme.layout.mobile.container.paddingBottom,
|
|
33
|
+
md: theme.layout.tablet.container.paddingBottom,
|
|
34
|
+
lg: theme.layout.desktop.container.paddingBottom,
|
|
35
|
+
}
|
|
36
|
+
: undefined,
|
|
37
|
+
marginHorizontal:
|
|
38
|
+
typeof extra.margin === 'undefined' && typeof extra.marginHorizontal === 'undefined'
|
|
39
|
+
? {
|
|
40
|
+
base: theme.layout.mobile.container.margin,
|
|
41
|
+
md: theme.layout.tablet.container.margin,
|
|
42
|
+
lg: theme.layout.desktop.container.margin,
|
|
43
|
+
}
|
|
44
|
+
: undefined,
|
|
45
|
+
...extra,
|
|
46
|
+
variants: {
|
|
47
|
+
space: theme.globalStyle.variants.space,
|
|
48
|
+
},
|
|
49
|
+
}),
|
|
50
|
+
}));
|
|
51
|
+
|
|
52
|
+
export default Container;
|
|
@@ -11,8 +11,8 @@ interface ProgressStepInternalProps extends ProgressStepProps {
|
|
|
11
11
|
isLast?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const ProgressStep = ({
|
|
15
|
-
styles.useVariants({
|
|
14
|
+
const ProgressStep = ({ status, index = 0, isLast = false, ...rest }: ProgressStepInternalProps) => {
|
|
15
|
+
styles.useVariants({ status, isLast });
|
|
16
16
|
|
|
17
17
|
const renderStepNumber = () => {
|
|
18
18
|
return (
|
|
@@ -26,13 +26,13 @@ const ProgressStep = ({ state, index = 0, isLast = false, ...rest }: ProgressSte
|
|
|
26
26
|
<View
|
|
27
27
|
style={styles.container}
|
|
28
28
|
accessible
|
|
29
|
-
aria-label={`Step ${index + 1}, ${rest.id}, ${
|
|
29
|
+
aria-label={`Step ${index + 1}, ${rest.id}, ${status}`}
|
|
30
30
|
{...rest}
|
|
31
31
|
>
|
|
32
32
|
<View style={styles.step}>
|
|
33
|
-
{
|
|
33
|
+
{status === 'complete' ? (
|
|
34
34
|
<Icon as={TickSmallIcon} width={20} height={20} style={styles.text} />
|
|
35
|
-
) :
|
|
35
|
+
) : status === 'active' ? (
|
|
36
36
|
<View style={styles.inner}>{renderStepNumber()}</View>
|
|
37
37
|
) : (
|
|
38
38
|
renderStepNumber()
|
|
@@ -70,7 +70,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
70
70
|
alignItems: 'center',
|
|
71
71
|
justifyContent: 'center',
|
|
72
72
|
variants: {
|
|
73
|
-
|
|
73
|
+
status: {
|
|
74
74
|
complete: {
|
|
75
75
|
backgroundColor: theme.color.surface.brand.default,
|
|
76
76
|
},
|
|
@@ -97,7 +97,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
97
97
|
},
|
|
98
98
|
text: {
|
|
99
99
|
variants: {
|
|
100
|
-
|
|
100
|
+
status: {
|
|
101
101
|
complete: {
|
|
102
102
|
color: theme.color.text.inverted,
|
|
103
103
|
},
|
|
@@ -116,7 +116,7 @@ const styles = StyleSheet.create(theme => ({
|
|
|
116
116
|
flex: 1,
|
|
117
117
|
height: theme.components.progressStepper.bar.height,
|
|
118
118
|
variants: {
|
|
119
|
-
|
|
119
|
+
status: {
|
|
120
120
|
complete: {
|
|
121
121
|
backgroundColor: theme.components.progressStepper.bar.complete.backgroundColor,
|
|
122
122
|
},
|
|
@@ -15,7 +15,7 @@ A form helper component that displays a series of dots connected by lines, showi
|
|
|
15
15
|
- [Usage](#usage)
|
|
16
16
|
- [Examples](#examples)
|
|
17
17
|
- [API](#api)
|
|
18
|
-
- [Step
|
|
18
|
+
- [Step Statuses](#step-statuses-1)
|
|
19
19
|
- [Accessibility](#accessibility)
|
|
20
20
|
- [Best Practices](#best-practices)
|
|
21
21
|
|
|
@@ -29,11 +29,11 @@ The `ProgressStepper` component uses a compound component pattern, making it eas
|
|
|
29
29
|
import { ProgressStepper, ProgressStep } from '@hearth/react-native';
|
|
30
30
|
|
|
31
31
|
<ProgressStepper>
|
|
32
|
-
<ProgressStep id={"1"}
|
|
33
|
-
<ProgressStep id={"2"}
|
|
34
|
-
<ProgressStep id={"3"}
|
|
35
|
-
<ProgressStep id={"4"}
|
|
36
|
-
<ProgressStep id={"5"}
|
|
32
|
+
<ProgressStep id={"1"} status="complete" />
|
|
33
|
+
<ProgressStep id={"2"} status="complete" />
|
|
34
|
+
<ProgressStep id={"3"} status="active" />
|
|
35
|
+
<ProgressStep id={"4"} status="incomplete" />
|
|
36
|
+
<ProgressStep id={"5"} status="incomplete" />
|
|
37
37
|
</ProgressStepper>
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -43,11 +43,11 @@ import { ProgressStepper, ProgressStep } from '@hearth/react-native';
|
|
|
43
43
|
|
|
44
44
|
<Canvas of={ProgressStepperStories.Playground} />
|
|
45
45
|
|
|
46
|
-
### Step
|
|
46
|
+
### Step Statuses
|
|
47
47
|
|
|
48
|
-
See how different step
|
|
48
|
+
See how different step statuses are visualized:
|
|
49
49
|
|
|
50
|
-
<Canvas of={ProgressStepperStories.
|
|
50
|
+
<Canvas of={ProgressStepperStories.StepStatuses} />
|
|
51
51
|
|
|
52
52
|
### Basic
|
|
53
53
|
|
|
@@ -66,9 +66,9 @@ See how different step states are visualized:
|
|
|
66
66
|
| Prop | Type | Default | Description |
|
|
67
67
|
|------|------|---------|-------------|
|
|
68
68
|
| `id` | `string` | Required | Unique identifier for the step |
|
|
69
|
-
| `
|
|
69
|
+
| `status` | `'complete' \| 'active' \| 'incomplete'` | Required | Current status of the step |
|
|
70
70
|
|
|
71
|
-
## Step
|
|
71
|
+
## Step Statuses
|
|
72
72
|
|
|
73
73
|
- **complete**: Step has been finished, shows a checkmark icon
|
|
74
74
|
- **active**: Current step, shows a number with highlighted background
|