@utilitywarehouse/hearth-react-native 0.4.2 → 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.
Files changed (207) hide show
  1. package/.storybook/main.ts +21 -1
  2. package/.turbo/turbo-build.log +1 -1
  3. package/.turbo/turbo-lint.log +1 -1
  4. package/CHANGELOG.md +52 -0
  5. package/build/components/Alert/AlertTitle.js +6 -6
  6. package/build/components/Badge/Badge.js +3 -3
  7. package/build/components/Badge/Badge.props.d.ts +1 -0
  8. package/build/components/Button/ButtonRoot.js +4 -0
  9. package/build/components/Button/ButtonText.js +2 -2
  10. package/build/components/Card/CardRoot.js +1 -1
  11. package/build/components/Carousel/Carousel.context.d.ts +4 -0
  12. package/build/components/Carousel/Carousel.context.js +4 -0
  13. package/build/components/Carousel/Carousel.d.ts +6 -0
  14. package/build/components/Carousel/Carousel.js +278 -0
  15. package/build/components/Carousel/Carousel.props.d.ts +65 -0
  16. package/build/components/Carousel/Carousel.props.js +1 -0
  17. package/build/components/Carousel/CarouselControlItem.d.ts +24 -0
  18. package/build/components/Carousel/CarouselControlItem.js +64 -0
  19. package/build/components/Carousel/CarouselControls.d.ts +4 -0
  20. package/build/components/Carousel/CarouselControls.js +74 -0
  21. package/build/components/Carousel/CarouselItem.d.ts +6 -0
  22. package/build/components/Carousel/CarouselItem.js +38 -0
  23. package/build/components/Carousel/index.d.ts +5 -0
  24. package/build/components/Carousel/index.js +5 -0
  25. package/build/components/Container/Container.d.ts +6 -0
  26. package/build/components/Container/Container.js +40 -0
  27. package/build/components/Container/Container.props.d.ts +85 -0
  28. package/build/components/Container/Container.props.js +1 -0
  29. package/build/components/Container/index.d.ts +2 -0
  30. package/build/components/Container/index.js +1 -0
  31. package/build/components/DescriptionList/DescriptionList.d.ts +1 -1
  32. package/build/components/DescriptionList/DescriptionList.js +2 -2
  33. package/build/components/DescriptionList/DescriptionList.props.d.ts +1 -8
  34. package/build/components/DescriptionList/DescriptionListItem.d.ts +1 -1
  35. package/build/components/DescriptionList/DescriptionListItem.js +4 -3
  36. package/build/components/DescriptionList/DescriptionListItem.props.d.ts +3 -8
  37. package/build/components/IndicatorIconButton/IndicatorIconButton.d.ts +6 -0
  38. package/build/components/IndicatorIconButton/IndicatorIconButton.js +26 -0
  39. package/build/components/IndicatorIconButton/IndicatorIconButton.props.d.ts +8 -0
  40. package/build/components/IndicatorIconButton/IndicatorIconButton.props.js +1 -0
  41. package/build/components/IndicatorIconButton/index.d.ts +2 -0
  42. package/build/components/IndicatorIconButton/index.js +1 -0
  43. package/build/components/Link/LinkText.js +3 -3
  44. package/build/components/List/List.context.d.ts +0 -2
  45. package/build/components/List/List.d.ts +1 -1
  46. package/build/components/List/List.js +5 -5
  47. package/build/components/List/List.props.d.ts +1 -9
  48. package/build/components/List/ListAction/ListAction.d.ts +18 -0
  49. package/build/components/List/ListAction/ListAction.js +103 -0
  50. package/build/components/List/ListAction/ListAction.props.d.ts +8 -0
  51. package/build/components/List/ListAction/ListAction.props.js +1 -0
  52. package/build/components/List/ListAction/ListActionContent.d.ts +6 -0
  53. package/build/components/List/ListAction/ListActionContent.js +14 -0
  54. package/build/components/List/ListAction/ListActionText.d.ts +6 -0
  55. package/build/components/List/ListAction/ListActionText.js +7 -0
  56. package/build/components/List/ListAction/ListActionTrailingContent.d.ts +6 -0
  57. package/build/components/List/ListAction/ListActionTrailingContent.js +5 -0
  58. package/build/components/List/ListAction/ListActionTrailingIcon.d.ts +9 -0
  59. package/build/components/List/ListAction/ListActionTrailingIcon.js +18 -0
  60. package/build/components/List/ListAction/index.d.ts +6 -0
  61. package/build/components/List/ListAction/index.js +5 -0
  62. package/build/components/List/ListItem/ListItem.context.d.ts +1 -1
  63. package/build/components/List/ListItem/ListItem.props.d.ts +9 -5
  64. package/build/components/List/ListItem/ListItemRoot.d.ts +1 -1
  65. package/build/components/List/ListItem/ListItemRoot.js +10 -12
  66. package/build/components/List/ListItem/index.d.ts +4 -4
  67. package/build/components/List/ListItem/index.js +3 -3
  68. package/build/components/List/index.d.ts +1 -0
  69. package/build/components/List/index.js +1 -0
  70. package/build/components/ProgressStepper/ProgressStep.d.ts +10 -0
  71. package/build/components/ProgressStepper/ProgressStep.js +100 -0
  72. package/build/components/ProgressStepper/ProgressStepper.d.ts +6 -0
  73. package/build/components/ProgressStepper/ProgressStepper.js +22 -0
  74. package/build/components/ProgressStepper/ProgressStepper.props.d.ts +22 -0
  75. package/build/components/ProgressStepper/ProgressStepper.props.js +1 -0
  76. package/build/components/ProgressStepper/ProgressStepperRoot.d.ts +6 -0
  77. package/build/components/ProgressStepper/ProgressStepperRoot.js +16 -0
  78. package/build/components/ProgressStepper/index.d.ts +3 -0
  79. package/build/components/ProgressStepper/index.js +2 -0
  80. package/build/components/SectionHeader/SectionHeader.d.ts +1 -1
  81. package/build/components/SectionHeader/SectionHeader.js +6 -3
  82. package/build/components/SectionHeader/SectionHeader.props.d.ts +9 -16
  83. package/build/components/SectionHeader/SectionHeaderTrailingContent.d.ts +6 -0
  84. package/build/components/SectionHeader/SectionHeaderTrailingContent.js +13 -0
  85. package/build/components/SectionHeader/index.d.ts +1 -0
  86. package/build/components/SectionHeader/index.js +1 -0
  87. package/build/components/Tabs/Tab.js +2 -2
  88. package/build/components/ThemedImage/ThemedImage.d.ts +12 -0
  89. package/build/components/ThemedImage/ThemedImage.js +27 -0
  90. package/build/components/ThemedImage/ThemedImage.props.d.ts +13 -0
  91. package/build/components/ThemedImage/ThemedImage.props.js +1 -0
  92. package/build/components/ThemedImage/index.d.ts +2 -0
  93. package/build/components/ThemedImage/index.js +1 -0
  94. package/build/components/ToggleButton/ToggleButtonText.js +2 -2
  95. package/build/components/UnstyledIconButton/UnstyledIconButton.props.d.ts +4 -1
  96. package/build/components/index.d.ts +5 -0
  97. package/build/components/index.js +5 -0
  98. package/build/core/themes.d.ts +12 -24
  99. package/build/hooks/useStyleProps.js +1 -1
  100. package/build/tokens/components/dark/button.d.ts +1 -1
  101. package/build/tokens/components/dark/button.js +1 -1
  102. package/build/tokens/components/dark/dialog.d.ts +1 -0
  103. package/build/tokens/components/dark/dialog.js +1 -0
  104. package/build/tokens/components/dark/illustrations.d.ts +1 -0
  105. package/build/tokens/components/dark/illustrations.js +1 -0
  106. package/build/tokens/components/dark/toast.d.ts +4 -1
  107. package/build/tokens/components/dark/toast.js +4 -1
  108. package/build/tokens/components/light/button.d.ts +1 -1
  109. package/build/tokens/components/light/button.js +1 -1
  110. package/build/tokens/components/light/dialog.d.ts +1 -0
  111. package/build/tokens/components/light/dialog.js +1 -0
  112. package/build/tokens/components/light/illustrations.d.ts +1 -0
  113. package/build/tokens/components/light/illustrations.js +1 -0
  114. package/build/tokens/components/light/toast.d.ts +4 -1
  115. package/build/tokens/components/light/toast.js +4 -1
  116. package/build/tokens/layout.d.ts +6 -12
  117. package/build/tokens/layout.js +3 -6
  118. package/docs/components/AllComponents.web.tsx +122 -5
  119. package/docs/components/BadgeList.tsx +20 -56
  120. package/docs/components/SwitchList.tsx +4 -8
  121. package/docs/getting-started.mdx +30 -14
  122. package/docs/introduction.mdx +1 -1
  123. package/docs/layout-components.docs.mdx +30 -0
  124. package/package.json +6 -4
  125. package/src/components/Alert/AlertTitle.tsx +7 -7
  126. package/src/components/Badge/Badge.props.ts +1 -0
  127. package/src/components/Badge/Badge.tsx +3 -2
  128. package/src/components/Button/ButtonRoot.tsx +4 -0
  129. package/src/components/Button/ButtonText.tsx +3 -3
  130. package/src/components/Card/CardRoot.tsx +2 -0
  131. package/src/components/Carousel/Carousel.context.tsx +8 -0
  132. package/src/components/Carousel/Carousel.docs.mdx +389 -0
  133. package/src/components/Carousel/Carousel.props.ts +89 -0
  134. package/src/components/Carousel/Carousel.stories.tsx +317 -0
  135. package/src/components/Carousel/Carousel.tsx +444 -0
  136. package/src/components/Carousel/CarouselControlItem.tsx +87 -0
  137. package/src/components/Carousel/CarouselControls.tsx +150 -0
  138. package/src/components/Carousel/CarouselItem.tsx +68 -0
  139. package/src/components/Carousel/index.ts +6 -0
  140. package/src/components/Container/Container.docs.mdx +168 -0
  141. package/src/components/Container/Container.props.ts +89 -0
  142. package/src/components/Container/Container.stories.tsx +274 -0
  143. package/src/components/Container/Container.tsx +52 -0
  144. package/src/components/Container/index.tsx +2 -0
  145. package/src/components/DescriptionList/DescriptionList.docs.mdx +24 -27
  146. package/src/components/DescriptionList/DescriptionList.props.ts +1 -8
  147. package/src/components/DescriptionList/DescriptionList.stories.tsx +13 -19
  148. package/src/components/DescriptionList/DescriptionList.tsx +2 -14
  149. package/src/components/DescriptionList/DescriptionListItem.props.ts +3 -8
  150. package/src/components/DescriptionList/DescriptionListItem.tsx +13 -21
  151. package/src/components/IndicatorIconButton/IndicatorIconButton.docs.mdx +85 -0
  152. package/src/components/IndicatorIconButton/IndicatorIconButton.props.ts +12 -0
  153. package/src/components/IndicatorIconButton/IndicatorIconButton.stories.tsx +142 -0
  154. package/src/components/IndicatorIconButton/IndicatorIconButton.tsx +36 -0
  155. package/src/components/IndicatorIconButton/index.tsx +2 -0
  156. package/src/components/Link/LinkText.tsx +4 -4
  157. package/src/components/List/List.context.ts +0 -1
  158. package/src/components/List/List.docs.mdx +376 -179
  159. package/src/components/List/List.props.ts +1 -9
  160. package/src/components/List/List.stories.tsx +289 -38
  161. package/src/components/List/List.tsx +5 -26
  162. package/src/components/List/ListAction/ListAction.props.ts +10 -0
  163. package/src/components/List/ListAction/ListAction.tsx +133 -0
  164. package/src/components/List/ListAction/ListActionContent.tsx +21 -0
  165. package/src/components/List/ListAction/ListActionText.tsx +14 -0
  166. package/src/components/List/ListAction/ListActionTrailingContent.tsx +9 -0
  167. package/src/components/List/ListAction/ListActionTrailingIcon.tsx +32 -0
  168. package/src/components/List/ListAction/index.ts +6 -0
  169. package/src/components/List/ListItem/ListItem.context.ts +1 -1
  170. package/src/components/List/ListItem/ListItem.props.ts +9 -5
  171. package/src/components/List/ListItem/ListItemRoot.tsx +18 -14
  172. package/src/components/List/ListItem/index.ts +4 -4
  173. package/src/components/List/index.ts +1 -0
  174. package/src/components/ProgressStepper/ProgressStep.tsx +134 -0
  175. package/src/components/ProgressStepper/ProgressStepper.docs.mdx +87 -0
  176. package/src/components/ProgressStepper/ProgressStepper.props.ts +27 -0
  177. package/src/components/ProgressStepper/ProgressStepper.stories.tsx +108 -0
  178. package/src/components/ProgressStepper/ProgressStepper.tsx +26 -0
  179. package/src/components/ProgressStepper/ProgressStepperRoot.tsx +32 -0
  180. package/src/components/ProgressStepper/index.ts +3 -0
  181. package/src/components/SectionHeader/SectionHeader.props.ts +9 -16
  182. package/src/components/SectionHeader/SectionHeader.stories.tsx +28 -18
  183. package/src/components/SectionHeader/SectionHeader.tsx +18 -19
  184. package/src/components/SectionHeader/SectionHeaderTrailingContent.tsx +20 -0
  185. package/src/components/SectionHeader/Sectionheader.docs.mdx +9 -24
  186. package/src/components/SectionHeader/index.ts +1 -0
  187. package/src/components/Switch/Switch.docs.mdx +0 -4
  188. package/src/components/Tabs/Tab.tsx +4 -2
  189. package/src/components/ThemedImage/ThemedImage.docs.mdx +208 -0
  190. package/src/components/ThemedImage/ThemedImage.props.ts +15 -0
  191. package/src/components/ThemedImage/ThemedImage.stories.tsx +175 -0
  192. package/src/components/ThemedImage/ThemedImage.tsx +34 -0
  193. package/src/components/ThemedImage/index.tsx +2 -0
  194. package/src/components/ToggleButton/ToggleButtonText.tsx +3 -3
  195. package/src/components/UnstyledIconButton/UnstyledIconButton.props.ts +2 -1
  196. package/src/components/index.ts +5 -0
  197. package/src/hooks/useStyleProps.ts +1 -1
  198. package/src/tokens/components/dark/button.ts +1 -1
  199. package/src/tokens/components/dark/dialog.ts +1 -0
  200. package/src/tokens/components/dark/illustrations.ts +1 -0
  201. package/src/tokens/components/dark/toast.ts +4 -1
  202. package/src/tokens/components/light/button.ts +1 -1
  203. package/src/tokens/components/light/dialog.ts +1 -0
  204. package/src/tokens/components/light/illustrations.ts +1 -0
  205. package/src/tokens/components/light/toast.ts +4 -1
  206. package/src/tokens/layout.ts +3 -6
  207. package/src/vite-env.d.ts +6 -0
@@ -0,0 +1,68 @@
1
+ import { useEffect } from 'react';
2
+ import { Platform, View } from 'react-native';
3
+ import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
4
+ import { StyleSheet } from 'react-native-unistyles';
5
+
6
+ import { CarouselItemProps } from './Carousel.props';
7
+
8
+ export const CarouselItem = ({
9
+ active,
10
+ children,
11
+ inactiveOpacity = 1,
12
+ style,
13
+ width,
14
+ ...props
15
+ }: CarouselItemProps) => {
16
+ const isWeb = Platform.OS === 'web';
17
+ const opacity = useSharedValue<number>(inactiveOpacity);
18
+
19
+ const animatedStyles = useAnimatedStyle(
20
+ () => ({
21
+ opacity: opacity.value,
22
+ width,
23
+ }),
24
+ [opacity, width]
25
+ );
26
+
27
+ useEffect(() => {
28
+ opacity.value = withTiming(active ? 1 : inactiveOpacity, { duration: 200 });
29
+ }, [active, inactiveOpacity, opacity]);
30
+
31
+ // For web, use a regular View with CSS transitions
32
+ if (isWeb) {
33
+ return (
34
+ <View
35
+ style={[
36
+ styles.container,
37
+ style,
38
+ {
39
+ opacity: active ? 1 : inactiveOpacity,
40
+ width,
41
+ },
42
+ ]}
43
+ {...props}
44
+ >
45
+ {children}
46
+ </View>
47
+ );
48
+ }
49
+
50
+ // For native, use Animated.View with reanimated
51
+ return (
52
+ <Animated.View style={[styles.container, style as false, animatedStyles]} {...props}>
53
+ {children}
54
+ </Animated.View>
55
+ );
56
+ };
57
+
58
+ CarouselItem.displayName = 'CarouselItem';
59
+
60
+ const styles = StyleSheet.create(() => ({
61
+ container: {
62
+ _web: {
63
+ transition: 'opacity 200ms ease-in-out',
64
+ },
65
+ },
66
+ }));
67
+
68
+ export default CarouselItem;
@@ -0,0 +1,6 @@
1
+ export * from './Carousel';
2
+ export * from './Carousel.props';
3
+ export * from './CarouselControls';
4
+ export * from './CarouselItem';
5
+
6
+ export { default as Carousel } from './Carousel';
@@ -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;
@@ -0,0 +1,2 @@
1
+ export { default as Container } from './Container';
2
+ export type { default as ContainerProps } from './Container.props';