@marigold/components 0.2.0 → 0.3.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 (195) hide show
  1. package/CHANGELOG.md +294 -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 +10 -13
  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 +5 -0
  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 +4 -1
  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 +6 -0
  47. package/dist/Radio/RadioIcons.d.ts +1 -0
  48. package/dist/Select/ListBox.d.ts +1 -0
  49. package/dist/Select/ListBoxSection.d.ts +1 -0
  50. package/dist/Select/Option.d.ts +1 -0
  51. package/dist/Select/Select.d.ts +15 -1
  52. package/dist/Select/Select.stories.d.ts +5 -0
  53. package/dist/Slider/Slider.d.ts +5 -0
  54. package/dist/Slider/Slider.stories.d.ts +5 -0
  55. package/dist/Stack/Stack.stories.d.ts +5 -0
  56. package/dist/Text/Text.d.ts +5 -0
  57. package/dist/Text/Text.stories.d.ts +5 -0
  58. package/dist/Textarea/Textarea.d.ts +5 -0
  59. package/dist/Textarea/Textarea.stories.d.ts +5 -0
  60. package/dist/ValidationMessage/ValidationMessage.d.ts +5 -0
  61. package/dist/ValidationMessage/ValidationMessage.stories.d.ts +5 -0
  62. package/dist/VisuallyHidden/VisuallyHidden.d.ts +1 -0
  63. package/dist/VisuallyHidden/VisuallyHidden.stories.d.ts +5 -0
  64. package/dist/VisuallyHidden/index.d.ts +1 -0
  65. package/dist/components.cjs.development.js +480 -496
  66. package/dist/components.cjs.development.js.map +1 -1
  67. package/dist/components.cjs.production.min.js +1 -1
  68. package/dist/components.cjs.production.min.js.map +1 -1
  69. package/dist/components.esm.js +415 -441
  70. package/dist/components.esm.js.map +1 -1
  71. package/dist/index.d.ts +2 -2
  72. package/dist/theme.d.ts +23 -48
  73. package/package.json +4 -1
  74. package/src/ActionGroup/ActionGroup.stories.tsx +47 -0
  75. package/src/ActionGroup/ActionGroup.test.tsx +36 -36
  76. package/src/ActionGroup/ActionGroup.tsx +17 -28
  77. package/src/Alert/Alert.stories.tsx +32 -0
  78. package/src/Alert/Alert.test.tsx +4 -1
  79. package/src/Alert/Alert.tsx +18 -3
  80. package/src/Badge/Badge.stories.tsx +38 -0
  81. package/src/Badge/Badge.test.tsx +5 -1
  82. package/src/Badge/Badge.tsx +13 -1
  83. package/src/Box.ts +2 -0
  84. package/src/Button/{Button.stories.mdx → Button.stories.tsx} +10 -17
  85. package/src/Button/Button.test.tsx +34 -11
  86. package/src/Button/Button.tsx +17 -3
  87. package/src/Card/{Card.stories.mdx → Card.stories.tsx} +9 -17
  88. package/src/Card/Card.test.tsx +8 -3
  89. package/src/Card/Card.tsx +13 -1
  90. package/src/Checkbox/Checkbox.stories.mdx +11 -0
  91. package/src/Checkbox/Checkbox.stories.tsx +78 -0
  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/Columns/Columns.stories.tsx +75 -0
  97. package/src/Columns/Columns.test.tsx +34 -23
  98. package/src/Columns/Columns.tsx +30 -30
  99. package/src/Container/Container.stories.tsx +14 -0
  100. package/src/Dialog/{Dialog.stories.mdx → Dialog.stories.tsx} +33 -18
  101. package/src/Dialog/Dialog.test.tsx +91 -20
  102. package/src/Dialog/Dialog.tsx +63 -17
  103. package/src/Dialog/ModalDialog.tsx +33 -4
  104. package/src/Divider/{Divider.stories.mdx → Divider.stories.tsx} +10 -17
  105. package/src/Divider/Divider.test.tsx +13 -5
  106. package/src/Divider/Divider.tsx +12 -0
  107. package/src/Field/{Field.stories.mdx → Field.stories.tsx} +33 -20
  108. package/src/Field/Field.test.tsx +55 -5
  109. package/src/Field/Field.tsx +10 -8
  110. package/src/Image/Image.stories.tsx +34 -0
  111. package/src/Image/Image.test.tsx +4 -1
  112. package/src/Image/Image.tsx +13 -1
  113. package/src/Inline/Inline.stories.tsx +39 -0
  114. package/src/Inline/Inline.test.tsx +99 -0
  115. package/src/Inline/Inline.tsx +38 -0
  116. package/src/Inline/index.ts +1 -0
  117. package/src/Input/{Input.stories.mdx → Input.stories.tsx} +10 -17
  118. package/src/Input/Input.test.tsx +7 -3
  119. package/src/Input/Input.tsx +13 -1
  120. package/src/Label/{Label.stories.mdx → Label.stories.tsx} +10 -21
  121. package/src/Label/Label.test.tsx +25 -4
  122. package/src/Label/Label.tsx +42 -9
  123. package/src/Link/Link.stories.tsx +35 -0
  124. package/src/Link/Link.test.tsx +6 -2
  125. package/src/Link/Link.tsx +10 -0
  126. package/src/Menu/{Menu.stories.mdx → Menu.stories.tsx} +13 -32
  127. package/src/Menu/Menu.test.tsx +7 -2
  128. package/src/Menu/Menu.tsx +10 -0
  129. package/src/MenuItem/MenuItem.stories.tsx +30 -0
  130. package/src/MenuItem/MenuItem.test.tsx +7 -2
  131. package/src/MenuItem/MenuItem.tsx +12 -0
  132. package/src/Message/Message.stories.tsx +30 -0
  133. package/src/Message/Message.test.tsx +4 -1
  134. package/src/Message/Message.tsx +17 -5
  135. package/src/Provider/MarigoldProvider.test.tsx +65 -55
  136. package/src/Provider/MarigoldProvider.tsx +37 -19
  137. package/src/Provider/index.ts +2 -1
  138. package/src/Radio/Radio.stories.mdx +11 -0
  139. package/src/Radio/Radio.test.tsx +36 -2
  140. package/src/Radio/Radio.tsx +13 -2
  141. package/src/Radio/RadioIcons.tsx +1 -1
  142. package/src/Select/ListBox.tsx +1 -0
  143. package/src/Select/{Select.stories.mdx → Select.stories.tsx} +23 -20
  144. package/src/Select/Select.test.tsx +39 -1
  145. package/src/Select/Select.tsx +24 -13
  146. package/src/Slider/Slider.stories.tsx +24 -0
  147. package/src/Slider/Slider.test.tsx +10 -6
  148. package/src/Slider/Slider.tsx +25 -13
  149. package/src/Stack/Stack.stories.tsx +57 -0
  150. package/src/Stack/Stack.test.tsx +16 -7
  151. package/src/Text/{Text.stories.mdx → Text.stories.tsx} +20 -19
  152. package/src/Text/Text.test.tsx +2 -2
  153. package/src/Text/Text.tsx +12 -0
  154. package/src/Textarea/{Textarea.stories.mdx → Textarea.stories.tsx} +14 -24
  155. package/src/Textarea/Textarea.test.tsx +7 -3
  156. package/src/Textarea/Textarea.tsx +13 -1
  157. package/src/ValidationMessage/{ValidationMessage.stories.mdx → ValidationMessage.stories.tsx} +8 -17
  158. package/src/ValidationMessage/ValidationMessage.test.tsx +7 -2
  159. package/src/ValidationMessage/ValidationMessage.tsx +12 -0
  160. package/src/VisuallyHidden/VisuallyHidden.stories.tsx +19 -0
  161. package/src/VisuallyHidden/VisuallyHidden.test.tsx +10 -0
  162. package/src/VisuallyHidden/VisuallyHidden.tsx +1 -0
  163. package/src/VisuallyHidden/index.ts +1 -0
  164. package/src/index.ts +2 -2
  165. package/src/theme.ts +49 -48
  166. package/dist/Box/Box.d.ts +0 -47
  167. package/dist/Box/index.d.ts +0 -1
  168. package/dist/Heading/Heading.d.ts +0 -7
  169. package/dist/Heading/index.d.ts +0 -1
  170. package/dist/Hidden/Hidden.d.ts +0 -5
  171. package/dist/Hidden/index.d.ts +0 -1
  172. package/src/ActionGroup/ActionGroup.stories.mdx +0 -62
  173. package/src/Alert/Alert.stories.mdx +0 -35
  174. package/src/Badge/Badge.stories.mdx +0 -57
  175. package/src/Box/Box.stories.mdx +0 -334
  176. package/src/Box/Box.test.tsx +0 -133
  177. package/src/Box/Box.tsx +0 -165
  178. package/src/Box/index.ts +0 -1
  179. package/src/Column/Column.stories.mdx +0 -49
  180. package/src/Columns/Columns.stories.mdx +0 -65
  181. package/src/Container/Container.stories.mdx +0 -19
  182. package/src/Heading/Heading.stories.mdx +0 -39
  183. package/src/Heading/Heading.test.tsx +0 -77
  184. package/src/Heading/Heading.tsx +0 -19
  185. package/src/Heading/index.ts +0 -1
  186. package/src/Hidden/Hidden.stories.mdx +0 -39
  187. package/src/Hidden/Hidden.test.tsx +0 -24
  188. package/src/Hidden/Hidden.tsx +0 -16
  189. package/src/Hidden/index.ts +0 -1
  190. package/src/Image/Image.stories.mdx +0 -36
  191. package/src/Link/Link.stories.mdx +0 -45
  192. package/src/MenuItem/MenuItem.stories.mdx +0 -37
  193. package/src/Message/Message.stories.mdx +0 -44
  194. package/src/Slider/Slider.stories.mdx +0 -31
  195. package/src/Stack/Stack.stories.mdx +0 -51
@@ -1,62 +0,0 @@
1
- import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
2
- import { ActionGroup } from './ActionGroup';
3
- import { Button } from '../Button';
4
-
5
- <Meta
6
- title="Components/ActionGroup"
7
- argTypes={{
8
- variant: {
9
- control: {
10
- type: 'select',
11
- },
12
- options: ['default'],
13
- description: 'ActionGroup style',
14
- table: {
15
- defaultValue: {
16
- summary: 'default',
17
- },
18
- },
19
- },
20
- space: {
21
- control: {
22
- type: 'text',
23
- },
24
- description: 'space between the children',
25
- table: {
26
- defaultValue: {
27
- summary: 'none',
28
- },
29
- },
30
- },
31
- verticalAlignment: {
32
- control: {
33
- type: 'boolean',
34
- },
35
- description: 'alignment vertical',
36
- table: {
37
- defaultValue: {
38
- summary: false,
39
- },
40
- },
41
- },
42
- }}
43
- />
44
-
45
- # ActionGroup
46
-
47
- export const Template = args => (
48
- <ActionGroup {...args}>
49
- <Button variant="text" size="small">
50
- Cancel
51
- </Button>
52
- <Button variant="primary" size="small">
53
- Confirm
54
- </Button>
55
- </ActionGroup>
56
- );
57
-
58
- <Canvas>
59
- <Story name="Default">{Template.bind({})}</Story>
60
- </Canvas>
61
-
62
- <ArgsTable story="Default" />
@@ -1,35 +0,0 @@
1
- import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
2
- import { Alert } from './Alert';
3
- import { Text } from '../Text';
4
-
5
- <Meta
6
- title="Components/Alert"
7
- argTypes={{
8
- variant: {
9
- control: {
10
- type: 'select',
11
- },
12
- options: ['success', 'warning', 'error'],
13
- description: 'Alerting in different colors and icons',
14
- table: {
15
- defaultValue: {
16
- summary: 'success',
17
- },
18
- },
19
- },
20
- }}
21
- />
22
-
23
- # Alert
24
-
25
- export const Template = args => (
26
- <Alert {...args}>
27
- <Text>Alert</Text>
28
- </Alert>
29
- );
30
-
31
- <Canvas>
32
- <Story name="Default">{Template.bind({})}</Story>
33
- </Canvas>
34
-
35
- <ArgsTable story="Default" />
@@ -1,57 +0,0 @@
1
- import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
2
- import { Badge } from './Badge';
3
- import { Check } from '@marigold/icons';
4
-
5
- <Meta
6
- title="Components/Badge"
7
- argTypes={{
8
- variant: {
9
- control: {
10
- type: 'select',
11
- },
12
- options: ['default'],
13
- description: 'Badge style',
14
- table: {
15
- defaultValue: {
16
- summary: 'default',
17
- },
18
- },
19
- },
20
- bgColor: {
21
- control: {
22
- type: 'text',
23
- },
24
- description: 'background',
25
- table: {
26
- defaultValue: {
27
- summary: 'inherit',
28
- },
29
- },
30
- },
31
- borderColor: {
32
- control: {
33
- type: 'text',
34
- },
35
- description: 'Outline color',
36
- table: {
37
- defaultValue: {
38
- summary: 'transparent',
39
- },
40
- },
41
- },
42
- }}
43
- />
44
-
45
- # Badge
46
-
47
- export const Template = args => (
48
- <Badge {...args}>
49
- <Check /> Check
50
- </Badge>
51
- );
52
-
53
- <Canvas>
54
- <Story name="Default">{Template.bind({})}</Story>
55
- </Canvas>
56
-
57
- <ArgsTable story="Default" />
@@ -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
- });