@marigold/components 0.2.0 → 0.3.3

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 (201) hide show
  1. package/CHANGELOG.md +180 -0
  2. package/dist/ActionGroup/ActionGroup.d.ts +1 -2
  3. package/dist/ActionGroup/ActionGroup.stories.d.ts +5 -0
  4. package/dist/Alert/Alert.d.ts +7 -1
  5. package/dist/Alert/Alert.stories.d.ts +5 -0
  6. package/dist/Badge/Badge.d.ts +5 -0
  7. package/dist/Badge/Badge.stories.d.ts +5 -0
  8. package/dist/Box.d.ts +2 -0
  9. package/dist/Button/Button.d.ts +5 -0
  10. package/dist/Button/Button.stories.d.ts +5 -0
  11. package/dist/Card/Card.d.ts +5 -0
  12. package/dist/Card/Card.stories.d.ts +5 -0
  13. package/dist/Checkbox/Checkbox.d.ts +10 -5
  14. package/dist/Checkbox/Checkbox.stories.d.ts +5 -0
  15. package/dist/Checkbox/CheckboxIcons.d.ts +9 -9
  16. package/dist/Column/Column.stories.d.ts +5 -0
  17. package/dist/Columns/Columns.d.ts +2 -2
  18. package/dist/Columns/Columns.stories.d.ts +5 -0
  19. package/dist/Container/Container.stories.d.ts +5 -0
  20. package/dist/Dialog/Dialog.d.ts +5 -2
  21. package/dist/Dialog/Dialog.stories.d.ts +5 -0
  22. package/dist/Dialog/ModalDialog.d.ts +4 -1
  23. package/dist/Divider/Divider.d.ts +7 -3
  24. package/dist/Divider/Divider.stories.d.ts +5 -0
  25. package/dist/Field/Field.d.ts +2 -0
  26. package/dist/Field/Field.stories.d.ts +5 -0
  27. package/dist/Image/Image.d.ts +5 -0
  28. package/dist/Image/Image.stories.d.ts +5 -0
  29. package/dist/Inline/Inline.d.ts +7 -0
  30. package/dist/Inline/Inline.stories.d.ts +5 -0
  31. package/dist/Inline/index.d.ts +1 -0
  32. package/dist/Input/Input.d.ts +5 -0
  33. package/dist/Input/Input.stories.d.ts +5 -0
  34. package/dist/Label/Label.d.ts +12 -1
  35. package/dist/Label/Label.stories.d.ts +5 -0
  36. package/dist/Link/Link.d.ts +3 -0
  37. package/dist/Link/Link.stories.d.ts +5 -0
  38. package/dist/Menu/Menu.d.ts +3 -0
  39. package/dist/Menu/Menu.stories.d.ts +5 -0
  40. package/dist/MenuItem/MenuItem.d.ts +5 -0
  41. package/dist/MenuItem/MenuItem.stories.d.ts +5 -0
  42. package/dist/Message/Message.d.ts +5 -0
  43. package/dist/Message/Message.stories.d.ts +5 -0
  44. package/dist/Provider/MarigoldProvider.d.ts +11 -3
  45. package/dist/Provider/index.d.ts +1 -1
  46. package/dist/Radio/Radio.d.ts +9 -5
  47. package/dist/Radio/Radio.stories.d.ts +5 -0
  48. package/dist/Radio/RadioIcon.d.ts +9 -0
  49. package/dist/Select/ListBox.d.ts +1 -0
  50. package/dist/Select/ListBoxSection.d.ts +1 -0
  51. package/dist/Select/Option.d.ts +1 -0
  52. package/dist/Select/Select.d.ts +15 -1
  53. package/dist/Select/Select.stories.d.ts +5 -0
  54. package/dist/Slider/Slider.d.ts +5 -0
  55. package/dist/Slider/Slider.stories.d.ts +5 -0
  56. package/dist/Stack/Stack.stories.d.ts +5 -0
  57. package/dist/Text/Text.d.ts +5 -0
  58. package/dist/Text/Text.stories.d.ts +5 -0
  59. package/dist/Textarea/Textarea.d.ts +5 -0
  60. package/dist/Textarea/Textarea.stories.d.ts +5 -0
  61. package/dist/ValidationMessage/ValidationMessage.d.ts +5 -0
  62. package/dist/ValidationMessage/ValidationMessage.stories.d.ts +5 -0
  63. package/dist/VisuallyHidden/VisuallyHidden.d.ts +1 -0
  64. package/dist/VisuallyHidden/VisuallyHidden.stories.d.ts +5 -0
  65. package/dist/VisuallyHidden/index.d.ts +1 -0
  66. package/dist/components.cjs.development.js +536 -580
  67. package/dist/components.cjs.development.js.map +1 -1
  68. package/dist/components.cjs.production.min.js +1 -1
  69. package/dist/components.cjs.production.min.js.map +1 -1
  70. package/dist/components.esm.js +481 -535
  71. package/dist/components.esm.js.map +1 -1
  72. package/dist/index.d.ts +2 -2
  73. package/dist/theme.d.ts +23 -48
  74. package/package.json +8 -4
  75. package/src/ActionGroup/ActionGroup.stories.tsx +47 -0
  76. package/src/ActionGroup/ActionGroup.test.tsx +36 -36
  77. package/src/ActionGroup/ActionGroup.tsx +17 -28
  78. package/src/Alert/Alert.stories.tsx +32 -0
  79. package/src/Alert/Alert.test.tsx +4 -1
  80. package/src/Alert/Alert.tsx +18 -3
  81. package/src/Badge/Badge.stories.tsx +38 -0
  82. package/src/Badge/Badge.test.tsx +5 -1
  83. package/src/Badge/Badge.tsx +13 -1
  84. package/src/Box.ts +2 -0
  85. package/src/Button/{Button.stories.mdx → Button.stories.tsx} +10 -17
  86. package/src/Button/Button.test.tsx +34 -11
  87. package/src/Button/Button.tsx +17 -3
  88. package/src/Card/{Card.stories.mdx → Card.stories.tsx} +9 -17
  89. package/src/Card/Card.test.tsx +8 -3
  90. package/src/Card/Card.tsx +13 -1
  91. package/src/Checkbox/{Checkbox.stories.mdx → Checkbox.stories.tsx} +31 -39
  92. package/src/Checkbox/Checkbox.test.tsx +77 -8
  93. package/src/Checkbox/Checkbox.tsx +70 -90
  94. package/src/Checkbox/CheckboxIcons.tsx +51 -41
  95. package/src/Column/Column.stories.tsx +33 -0
  96. package/src/Column/Column.tsx +0 -0
  97. package/src/Columns/Columns.stories.tsx +75 -0
  98. package/src/Columns/Columns.test.tsx +34 -23
  99. package/src/Columns/Columns.tsx +30 -30
  100. package/src/Container/Container.stories.tsx +14 -0
  101. package/src/Container/Container.tsx +0 -0
  102. package/src/Dialog/{Dialog.stories.mdx → Dialog.stories.tsx} +33 -18
  103. package/src/Dialog/Dialog.test.tsx +91 -20
  104. package/src/Dialog/Dialog.tsx +63 -17
  105. package/src/Dialog/ModalDialog.tsx +33 -4
  106. package/src/Divider/Divider.stories.tsx +30 -0
  107. package/src/Divider/Divider.test.tsx +32 -23
  108. package/src/Divider/Divider.tsx +27 -7
  109. package/src/Field/{Field.stories.mdx → Field.stories.tsx} +33 -20
  110. package/src/Field/Field.test.tsx +55 -5
  111. package/src/Field/Field.tsx +10 -8
  112. package/src/Image/Image.stories.tsx +34 -0
  113. package/src/Image/Image.test.tsx +4 -1
  114. package/src/Image/Image.tsx +13 -1
  115. package/src/Inline/Inline.stories.tsx +39 -0
  116. package/src/Inline/Inline.test.tsx +99 -0
  117. package/src/Inline/Inline.tsx +38 -0
  118. package/src/Inline/index.ts +1 -0
  119. package/src/Input/{Input.stories.mdx → Input.stories.tsx} +10 -17
  120. package/src/Input/Input.test.tsx +7 -3
  121. package/src/Input/Input.tsx +13 -1
  122. package/src/Label/{Label.stories.mdx → Label.stories.tsx} +10 -21
  123. package/src/Label/Label.test.tsx +25 -4
  124. package/src/Label/Label.tsx +42 -9
  125. package/src/Link/Link.stories.tsx +35 -0
  126. package/src/Link/Link.test.tsx +6 -2
  127. package/src/Link/Link.tsx +12 -1
  128. package/src/Menu/{Menu.stories.mdx → Menu.stories.tsx} +13 -32
  129. package/src/Menu/Menu.test.tsx +7 -2
  130. package/src/Menu/Menu.tsx +10 -0
  131. package/src/MenuItem/MenuItem.stories.tsx +30 -0
  132. package/src/MenuItem/MenuItem.test.tsx +7 -2
  133. package/src/MenuItem/MenuItem.tsx +12 -0
  134. package/src/Message/Message.stories.tsx +30 -0
  135. package/src/Message/Message.test.tsx +4 -1
  136. package/src/Message/Message.tsx +17 -5
  137. package/src/Provider/MarigoldProvider.test.tsx +65 -55
  138. package/src/Provider/MarigoldProvider.tsx +37 -19
  139. package/src/Provider/index.ts +2 -1
  140. package/src/Radio/{Radio.stories.mdx → Radio.stories.tsx} +31 -39
  141. package/src/Radio/Radio.test.tsx +78 -9
  142. package/src/Radio/Radio.tsx +58 -87
  143. package/src/Radio/RadioIcon.tsx +49 -0
  144. package/src/Select/ListBox.tsx +1 -0
  145. package/src/Select/{Select.stories.mdx → Select.stories.tsx} +23 -20
  146. package/src/Select/Select.test.tsx +39 -1
  147. package/src/Select/Select.tsx +24 -13
  148. package/src/Slider/Slider.stories.tsx +24 -0
  149. package/src/Slider/Slider.test.tsx +10 -6
  150. package/src/Slider/Slider.tsx +25 -13
  151. package/src/Stack/Stack.stories.tsx +57 -0
  152. package/src/Stack/Stack.test.tsx +16 -7
  153. package/src/Stack/Stack.tsx +0 -0
  154. package/src/Text/{Text.stories.mdx → Text.stories.tsx} +20 -19
  155. package/src/Text/Text.test.tsx +2 -2
  156. package/src/Text/Text.tsx +12 -0
  157. package/src/Textarea/{Textarea.stories.mdx → Textarea.stories.tsx} +14 -24
  158. package/src/Textarea/Textarea.test.tsx +7 -3
  159. package/src/Textarea/Textarea.tsx +13 -1
  160. package/src/ValidationMessage/{ValidationMessage.stories.mdx → ValidationMessage.stories.tsx} +8 -17
  161. package/src/ValidationMessage/ValidationMessage.test.tsx +7 -2
  162. package/src/ValidationMessage/ValidationMessage.tsx +12 -0
  163. package/src/VisuallyHidden/VisuallyHidden.stories.tsx +19 -0
  164. package/src/VisuallyHidden/VisuallyHidden.test.tsx +10 -0
  165. package/src/VisuallyHidden/VisuallyHidden.tsx +1 -0
  166. package/src/VisuallyHidden/index.ts +1 -0
  167. package/src/index.ts +2 -2
  168. package/src/theme.ts +49 -48
  169. package/dist/Box/Box.d.ts +0 -47
  170. package/dist/Box/index.d.ts +0 -1
  171. package/dist/Heading/Heading.d.ts +0 -7
  172. package/dist/Heading/index.d.ts +0 -1
  173. package/dist/Hidden/Hidden.d.ts +0 -5
  174. package/dist/Hidden/index.d.ts +0 -1
  175. package/dist/Radio/RadioIcons.d.ts +0 -9
  176. package/src/ActionGroup/ActionGroup.stories.mdx +0 -62
  177. package/src/Alert/Alert.stories.mdx +0 -35
  178. package/src/Badge/Badge.stories.mdx +0 -57
  179. package/src/Box/Box.stories.mdx +0 -334
  180. package/src/Box/Box.test.tsx +0 -133
  181. package/src/Box/Box.tsx +0 -165
  182. package/src/Box/index.ts +0 -1
  183. package/src/Column/Column.stories.mdx +0 -49
  184. package/src/Columns/Columns.stories.mdx +0 -65
  185. package/src/Container/Container.stories.mdx +0 -19
  186. package/src/Divider/Divider.stories.mdx +0 -37
  187. package/src/Heading/Heading.stories.mdx +0 -39
  188. package/src/Heading/Heading.test.tsx +0 -77
  189. package/src/Heading/Heading.tsx +0 -19
  190. package/src/Heading/index.ts +0 -1
  191. package/src/Hidden/Hidden.stories.mdx +0 -39
  192. package/src/Hidden/Hidden.test.tsx +0 -24
  193. package/src/Hidden/Hidden.tsx +0 -16
  194. package/src/Hidden/index.ts +0 -1
  195. package/src/Image/Image.stories.mdx +0 -36
  196. package/src/Link/Link.stories.mdx +0 -45
  197. package/src/MenuItem/MenuItem.stories.mdx +0 -37
  198. package/src/Message/Message.stories.mdx +0 -44
  199. package/src/Radio/RadioIcons.tsx +0 -39
  200. package/src/Slider/Slider.stories.mdx +0 -31
  201. package/src/Stack/Stack.stories.mdx +0 -51
@@ -1,334 +0,0 @@
1
- import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
2
- import { Box } from './Box';
3
- import { Button } from '../Button';
4
- import { Label } from '../Label';
5
-
6
- <Meta
7
- title="Components/Box"
8
- argTypes={{
9
- variant: {
10
- control: {
11
- type: 'text',
12
- },
13
- table: {
14
- category: 'General',
15
- },
16
- },
17
- display: {
18
- control: {
19
- type: 'text',
20
- },
21
- table: {
22
- category: 'General',
23
- },
24
- },
25
- height: {
26
- control: {
27
- type: 'text',
28
- },
29
- table: {
30
- category: 'Width',
31
- },
32
- },
33
- width: {
34
- control: {
35
- type: 'text',
36
- },
37
- table: {
38
- category: 'Width',
39
- },
40
- },
41
- minWidth: {
42
- control: {
43
- type: 'text',
44
- },
45
- table: {
46
- category: 'Width',
47
- },
48
- },
49
- maxWidth: {
50
- control: {
51
- type: 'text',
52
- },
53
- table: {
54
- category: 'Width',
55
- },
56
- },
57
- position: {
58
- control: {
59
- type: 'text',
60
- },
61
- table: {
62
- category: 'Position',
63
- },
64
- },
65
- top: {
66
- control: {
67
- type: 'text',
68
- },
69
- table: {
70
- category: 'Position',
71
- },
72
- },
73
- bottom: {
74
- control: {
75
- type: 'text',
76
- },
77
- table: {
78
- category: 'Position',
79
- },
80
- },
81
- right: {
82
- control: {
83
- type: 'text',
84
- },
85
- table: {
86
- category: 'Position',
87
- },
88
- },
89
- left: {
90
- control: {
91
- type: 'text',
92
- },
93
- table: {
94
- category: 'Position',
95
- },
96
- },
97
- zIndex: {
98
- control: {
99
- type: 'text',
100
- },
101
- table: {
102
- category: 'Position',
103
- },
104
- },
105
- p: {
106
- control: {
107
- type: 'text',
108
- },
109
- table: {
110
- category: 'Padding',
111
- },
112
- },
113
- px: {
114
- control: {
115
- type: 'text',
116
- },
117
- table: {
118
- category: 'Padding',
119
- },
120
- },
121
- py: {
122
- control: {
123
- type: 'text',
124
- },
125
- table: {
126
- category: 'Padding',
127
- },
128
- },
129
- pt: {
130
- control: {
131
- type: 'text',
132
- },
133
- table: {
134
- category: 'Padding',
135
- },
136
- },
137
- pb: {
138
- control: {
139
- type: 'text',
140
- },
141
- table: {
142
- category: 'Padding',
143
- },
144
- },
145
- pl: {
146
- control: {
147
- type: 'text',
148
- },
149
- table: {
150
- category: 'Padding',
151
- },
152
- },
153
- pr: {
154
- control: {
155
- type: 'text',
156
- },
157
- table: {
158
- category: 'Padding',
159
- },
160
- },
161
- m: {
162
- control: {
163
- type: 'text',
164
- },
165
- table: {
166
- category: 'Margin',
167
- },
168
- },
169
- mx: {
170
- control: {
171
- type: 'text',
172
- },
173
- table: {
174
- category: 'Margin',
175
- },
176
- },
177
- my: {
178
- control: {
179
- type: 'text',
180
- },
181
- table: {
182
- category: 'Margin',
183
- },
184
- },
185
- mt: {
186
- control: {
187
- type: 'text',
188
- },
189
- table: {
190
- category: 'Margin',
191
- },
192
- },
193
- mb: {
194
- control: {
195
- type: 'text',
196
- },
197
- table: {
198
- category: 'Margin',
199
- },
200
- },
201
- ml: {
202
- control: {
203
- type: 'text',
204
- },
205
- table: {
206
- category: 'Margin',
207
- },
208
- },
209
- mr: {
210
- control: {
211
- type: 'text',
212
- },
213
- table: {
214
- category: 'Margin',
215
- },
216
- },
217
- flexDirection: {
218
- control: {
219
- type: 'text',
220
- },
221
- table: {
222
- category: 'Flex',
223
- },
224
- },
225
- flexWrap: {
226
- control: {
227
- type: 'text',
228
- },
229
- table: {
230
- category: 'Flex',
231
- },
232
- },
233
- flexShrink: {
234
- control: {
235
- type: 'text',
236
- },
237
- table: {
238
- category: 'Flex',
239
- },
240
- },
241
- flexGrow: {
242
- control: {
243
- type: 'text',
244
- },
245
- table: {
246
- category: 'Flex',
247
- },
248
- },
249
- alignItems: {
250
- control: {
251
- type: 'text',
252
- },
253
- table: {
254
- category: 'Flex',
255
- },
256
- },
257
- justifyContent: {
258
- control: {
259
- type: 'text',
260
- },
261
- table: {
262
- category: 'Flex',
263
- },
264
- },
265
- bg: {
266
- control: {
267
- type: 'text',
268
- },
269
- table: {
270
- category: 'Other',
271
- },
272
- },
273
- border: {
274
- control: {
275
- type: 'text',
276
- },
277
- table: {
278
- category: 'Other',
279
- },
280
- },
281
- borderRadius: {
282
- control: {
283
- type: 'text',
284
- },
285
- table: {
286
- category: 'Other',
287
- },
288
- },
289
- boxShadow: {
290
- control: {
291
- type: 'text',
292
- },
293
- table: {
294
- category: 'Other',
295
- },
296
- },
297
- opacity: {
298
- control: {
299
- type: 'text',
300
- },
301
- table: {
302
- category: 'Other',
303
- },
304
- },
305
- overflow: {
306
- control: {
307
- type: 'text',
308
- },
309
- table: {
310
- category: 'Other',
311
- },
312
- },
313
- transition: {
314
- control: {
315
- type: 'text',
316
- },
317
- table: {
318
- category: 'Other',
319
- },
320
- },
321
- }}
322
- />
323
-
324
- # Box-Component
325
-
326
- ## For custom components
327
-
328
- export const Template = args => <Box {...args}>Style me!</Box>;
329
-
330
- <Canvas>
331
- <Story name="Default">{Template.bind({})}</Story>
332
- </Canvas>
333
-
334
- <ArgsTable story="Default" />
@@ -1,133 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
-
4
- import { ThemeProvider } from '@marigold/system';
5
- import { Box } from './Box';
6
-
7
- // Setup
8
- // ---------------
9
- const theme = {
10
- colors: {
11
- primary: 'hotpink',
12
- black: '#000',
13
- white: '#FFF',
14
- blue: '#2980b9',
15
- },
16
- space: [0, 2, 4, 8],
17
- sizes: [0, 8, 16, 32],
18
- borders: ['none', '1px solid black'],
19
- radii: [0, 2, 4],
20
- opacities: [0, 0.5, 1],
21
- transitions: ['none', '1s opacity'],
22
- shadows: ['none', '3px 3px 5px 6px #ccc', 'inset 0 0 10px #000000'],
23
- variant: {
24
- color: 'primary',
25
- p: 2,
26
- },
27
- };
28
-
29
- // Tests
30
- // ---------------
31
- test('renders a <div> by default', () => {
32
- render(<Box>box</Box>);
33
- const box = screen.getByText(/box/);
34
-
35
- expect(box instanceof HTMLDivElement).toBeTruthy();
36
- });
37
-
38
- test('changes rendered element via as prop', () => {
39
- render(<Box as="span">box</Box>);
40
- const box = screen.getByText(/box/);
41
-
42
- expect(box instanceof HTMLSpanElement).toBeTruthy();
43
- });
44
-
45
- test('passes down HTML attributes', () => {
46
- render(
47
- <Box className="my-custom-class" id="box-id" disabled>
48
- box
49
- </Box>
50
- );
51
- const box = screen.getByText(/box/);
52
-
53
- expect(box.getAttribute('id')).toEqual('box-id');
54
- expect(box.getAttribute('disabled')).toMatch('');
55
- expect(box.getAttribute('class')).toMatch('my-custom-class');
56
- });
57
-
58
- test('forwards ref', () => {
59
- const ref = React.createRef<HTMLButtonElement>();
60
- render(
61
- <Box as="button" ref={ref}>
62
- button
63
- </Box>
64
- );
65
-
66
- expect(ref.current instanceof HTMLButtonElement).toBeTruthy();
67
- });
68
-
69
- test.each([
70
- [{ display: 'flex' }, 'display: flex'],
71
- [{ height: 1 }, 'height: 8px'],
72
- [{ width: 2 }, 'width: 16px'],
73
- [{ minWidth: 1 }, 'min-width: 8px'],
74
- [{ maxWidth: 3 }, 'max-width: 32px'],
75
- [{ position: 'absolute' }, 'position: absolute'],
76
- [{ top: 0 }, 'top: 0px'],
77
- [{ bottom: 1 }, 'bottom: 2px'],
78
- [{ right: 3 }, 'right: 8px'],
79
- [{ left: 2 }, 'left: 4px'],
80
- [{ zIndex: 1000 }, 'z-index: 1000'],
81
- [{ p: 1 }, 'padding: 2px'],
82
- [{ px: 1 }, 'padding-left: 2px', 'padding-right: 2px'],
83
- [{ py: 2 }, 'padding-top: 4px', 'padding-bottom: 4px'],
84
- [{ pt: 1 }, 'padding-top: 2px'],
85
- [{ pb: 1 }, 'padding-bottom: 2px'],
86
- [{ pl: 1 }, 'padding-left: 2px'],
87
- [{ pr: 1 }, 'padding-right: 2px'],
88
- [{ m: 1 }, 'margin: 2px'],
89
- [{ mx: 1 }, 'margin-left: 2px', 'margin-right: 2px'],
90
- [{ my: 2 }, 'margin-top: 4px', 'margin-bottom: 4px'],
91
- [{ mt: 1 }, 'margin-top: 2px'],
92
- [{ mb: 1 }, 'margin-bottom: 2px'],
93
- [{ ml: 1 }, 'margin-left: 2px'],
94
- [{ mr: 1 }, 'margin-right: 2px'],
95
- [{ flexDirection: 'column' }, 'flex-direction: column'],
96
- [{ flexWrap: 'wrap' }, 'flex-wrap: wrap'],
97
- [{ flexShrink: 5 }, 'flex-shrink: 5'],
98
- [{ flexGrow: 1 }, 'flex-grow: 1'],
99
- [{ alignItems: 'baseline' }, 'align-items: baseline'],
100
- [{ justifyContent: 'space-between' }, 'justify-content: space-between'],
101
- [{ bg: 'primary' }, 'background-color: hotpink'],
102
- [{ border: 1 }, 'border: 1px solid black'],
103
- [{ borderRadius: 2 }, 'border-radius: 4px'],
104
- [{ boxShadow: 1 }, 'box-shadow: 3px 3px 5px 6px #ccc'],
105
- [{ opacity: 1 }, 'opacity: 0.5'],
106
- [{ overflow: 'hidden' }, 'overflow: hidden'],
107
- [{ transition: 1 }, 'transition: 1s opacity'],
108
- ])('test style prop %o', (...args) => {
109
- const props = args.shift();
110
-
111
- render(
112
- <ThemeProvider theme={theme}>
113
- <Box {...props}>What's in the box!</Box>
114
- </ThemeProvider>
115
- );
116
-
117
- const box = screen.getByText(`What's in the box!`);
118
- args.forEach((style: any) => {
119
- expect(box).toHaveStyle(style);
120
- });
121
- });
122
-
123
- test('support variants', () => {
124
- render(
125
- <ThemeProvider theme={theme}>
126
- <Box variant="variant">What's in the box!</Box>
127
- </ThemeProvider>
128
- );
129
-
130
- const box = screen.getByText(`What's in the box!`);
131
- expect(box).toHaveStyle('color: hotpink');
132
- expect(box).toHaveStyle('padding: 4px');
133
- });
package/src/Box/Box.tsx DELETED
@@ -1,165 +0,0 @@
1
- import React, { forwardRef } from 'react';
2
- import { CSSObject, Element, ResponsiveStyleValue } from '@marigold/system';
3
- import {
4
- PolymorphicPropsWithRef,
5
- PolymorphicComponentWithRef,
6
- } from '@marigold/types';
7
-
8
- export type BoxOwnProps = {
9
- className?: string;
10
- variant?: string | string[];
11
- css?: CSSObject;
12
-
13
- display?: ResponsiveStyleValue<string>;
14
-
15
- height?: ResponsiveStyleValue<number | string>;
16
- width?: ResponsiveStyleValue<number | string>;
17
- minWidth?: ResponsiveStyleValue<number | string>;
18
- maxWidth?: ResponsiveStyleValue<number | string>;
19
-
20
- position?: ResponsiveStyleValue<string>;
21
- top?: ResponsiveStyleValue<number | string>;
22
- bottom?: ResponsiveStyleValue<number | string>;
23
- right?: ResponsiveStyleValue<number | string>;
24
- left?: ResponsiveStyleValue<number | string>;
25
- zIndex?: ResponsiveStyleValue<number | string>;
26
-
27
- p?: ResponsiveStyleValue<number | string>;
28
- px?: ResponsiveStyleValue<number | string>;
29
- py?: ResponsiveStyleValue<number | string>;
30
- pt?: ResponsiveStyleValue<number | string>;
31
- pb?: ResponsiveStyleValue<number | string>;
32
- pl?: ResponsiveStyleValue<number | string>;
33
- pr?: ResponsiveStyleValue<number | string>;
34
-
35
- m?: ResponsiveStyleValue<number | string>;
36
- mx?: ResponsiveStyleValue<number | string>;
37
- my?: ResponsiveStyleValue<number | string>;
38
- mt?: ResponsiveStyleValue<number | string>;
39
- mb?: ResponsiveStyleValue<number | string>;
40
- ml?: ResponsiveStyleValue<number | string>;
41
- mr?: ResponsiveStyleValue<number | string>;
42
-
43
- flexDirection?: ResponsiveStyleValue<string>;
44
- flexWrap?: ResponsiveStyleValue<string>;
45
- flexShrink?: ResponsiveStyleValue<number | string>;
46
- flexGrow?: ResponsiveStyleValue<number | string>;
47
- alignItems?: ResponsiveStyleValue<string>;
48
- justifyContent?: ResponsiveStyleValue<string>;
49
-
50
- bg?: ResponsiveStyleValue<number | string>;
51
- border?: ResponsiveStyleValue<number | string>;
52
- borderRadius?: ResponsiveStyleValue<number | string>;
53
- boxShadow?: ResponsiveStyleValue<number | string>;
54
- opacity?: ResponsiveStyleValue<number | string>;
55
- overflow?: ResponsiveStyleValue<string>;
56
-
57
- transition?: ResponsiveStyleValue<number | string>;
58
- };
59
-
60
- export type BoxProps = PolymorphicPropsWithRef<BoxOwnProps, 'div'>;
61
-
62
- export const Box: PolymorphicComponentWithRef<BoxOwnProps, 'div'> = forwardRef(
63
- (
64
- {
65
- variant,
66
- as = 'div',
67
- css,
68
- children,
69
- className,
70
- display,
71
- height,
72
- width,
73
- minWidth,
74
- maxWidth,
75
- position,
76
- top,
77
- bottom,
78
- right,
79
- left,
80
- zIndex,
81
- p,
82
- px,
83
- py,
84
- pt,
85
- pb,
86
- pl,
87
- pr,
88
- m,
89
- mx,
90
- my,
91
- mt,
92
- mb,
93
- ml,
94
- mr,
95
- flexDirection,
96
- flexWrap,
97
- flexShrink,
98
- flexGrow,
99
- alignItems,
100
- justifyContent,
101
- bg,
102
- border,
103
- borderRadius,
104
- boxShadow,
105
- opacity,
106
- overflow,
107
- transition,
108
- ...props
109
- },
110
- ref
111
- ) => (
112
- <Element
113
- as={as}
114
- ref={ref}
115
- variant={variant}
116
- css={{
117
- ...{
118
- display,
119
- height,
120
- width,
121
- minWidth,
122
- maxWidth,
123
- position,
124
- top,
125
- bottom,
126
- right,
127
- left,
128
- zIndex,
129
- p,
130
- px,
131
- py,
132
- pt,
133
- pb,
134
- pl,
135
- pr,
136
- m,
137
- mx,
138
- my,
139
- mt,
140
- mb,
141
- ml,
142
- mr,
143
- flexDirection,
144
- flexWrap,
145
- flexShrink,
146
- flexGrow,
147
- alignItems,
148
- justifyContent,
149
- bg,
150
- border,
151
- borderRadius,
152
- boxShadow,
153
- opacity,
154
- overflow,
155
- transition,
156
- },
157
- ...css,
158
- }}
159
- className={className}
160
- {...props}
161
- >
162
- {children}
163
- </Element>
164
- )
165
- );
package/src/Box/index.ts DELETED
@@ -1 +0,0 @@
1
- export * from './Box';
@@ -1,49 +0,0 @@
1
- import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
2
- import { Column } from './Column';
3
- import { Text } from '../Text';
4
- import { useStyles } from '@marigold/system';
5
-
6
- <Meta
7
- title="Components/Column"
8
- argTypes={{
9
- width: {
10
- control: {
11
- type: 'range',
12
- min: 0,
13
- max: 12,
14
- step: 1,
15
- },
16
- description: 'Absolute width in 12 grid',
17
- table: {
18
- defaultValue: {
19
- summary: 12,
20
- },
21
- },
22
- },
23
- }}
24
- />
25
-
26
- # Column
27
-
28
- export const Template = args => (
29
- <Column
30
- className={useStyles({
31
- css: {
32
- textAlign: 'center',
33
- border: '1px solid red',
34
- padding: 2,
35
- margin: 2,
36
- },
37
- })}
38
- width={12}
39
- {...args}
40
- >
41
- <Text>full width</Text>
42
- </Column>
43
- );
44
-
45
- <Canvas>
46
- <Story name="Default">{Template.bind({})}</Story>
47
- </Canvas>
48
-
49
- <ArgsTable story="Default" />