@marigold/components 0.1.0 → 0.2.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 (112) hide show
  1. package/dist/ActionGroup/ActionGroup.d.ts +9 -0
  2. package/dist/ActionGroup/index.d.ts +1 -0
  3. package/dist/Alert/Alert.d.ts +16 -1
  4. package/dist/Box/Box.d.ts +2 -1
  5. package/dist/Button/Button.d.ts +4 -6
  6. package/dist/Card/Card.d.ts +9 -0
  7. package/dist/Card/index.d.ts +1 -0
  8. package/dist/Checkbox/Checkbox.d.ts +3 -0
  9. package/dist/Checkbox/CheckboxIcons.d.ts +9 -0
  10. package/dist/Column/Column.d.ts +3 -1
  11. package/dist/Dialog/Dialog.d.ts +8 -1
  12. package/dist/Dialog/ModalDialog.d.ts +5 -0
  13. package/dist/Field/Field.d.ts +4 -2
  14. package/dist/Label/Label.d.ts +2 -1
  15. package/dist/Provider/MarigoldProvider.d.ts +3 -0
  16. package/dist/Provider/index.d.ts +3 -0
  17. package/dist/Radio/Radio.d.ts +3 -0
  18. package/dist/Radio/RadioIcons.d.ts +9 -0
  19. package/dist/Select/ListBox.d.ts +8 -0
  20. package/dist/Select/ListBoxSection.d.ts +8 -0
  21. package/dist/Select/Option.d.ts +8 -0
  22. package/dist/Select/Popover.d.ts +9 -0
  23. package/dist/Select/Select.d.ts +11 -4
  24. package/dist/Stack/Stack.d.ts +1 -3
  25. package/dist/Textarea/Textarea.d.ts +2 -1
  26. package/dist/components.cjs.development.js +868 -357
  27. package/dist/components.cjs.development.js.map +1 -1
  28. package/dist/components.cjs.production.min.js +1 -1
  29. package/dist/components.cjs.production.min.js.map +1 -1
  30. package/dist/components.esm.js +837 -359
  31. package/dist/components.esm.js.map +1 -1
  32. package/dist/index.d.ts +4 -0
  33. package/package.json +18 -3
  34. package/src/ActionGroup/ActionGroup.stories.mdx +62 -0
  35. package/src/ActionGroup/ActionGroup.test.tsx +83 -0
  36. package/src/ActionGroup/ActionGroup.tsx +43 -0
  37. package/src/ActionGroup/index.ts +1 -0
  38. package/src/Alert/Alert.stories.mdx +28 -38
  39. package/src/Alert/Alert.test.tsx +1 -1
  40. package/src/Alert/Alert.tsx +11 -33
  41. package/src/Badge/Badge.stories.mdx +48 -34
  42. package/src/Badge/Badge.test.tsx +7 -15
  43. package/src/Badge/Badge.tsx +1 -2
  44. package/src/Box/Box.stories.mdx +322 -26
  45. package/src/Box/Box.tsx +58 -50
  46. package/src/Button/Button.stories.mdx +54 -166
  47. package/src/Button/Button.test.tsx +48 -8
  48. package/src/Button/Button.tsx +47 -18
  49. package/src/Card/Card.stories.mdx +49 -0
  50. package/src/Card/Card.test.tsx +66 -0
  51. package/src/Card/Card.tsx +36 -0
  52. package/src/Card/index.ts +1 -0
  53. package/src/Checkbox/Checkbox.stories.mdx +76 -71
  54. package/src/Checkbox/Checkbox.test.tsx +70 -24
  55. package/src/Checkbox/Checkbox.tsx +68 -49
  56. package/src/Checkbox/CheckboxIcons.tsx +49 -0
  57. package/src/Column/Column.stories.mdx +39 -64
  58. package/src/Column/Column.test.tsx +8 -0
  59. package/src/Column/Column.tsx +12 -2
  60. package/src/Columns/Columns.stories.mdx +58 -240
  61. package/src/Container/Container.stories.mdx +8 -25
  62. package/src/Dialog/Dialog.stories.mdx +65 -56
  63. package/src/Dialog/Dialog.test.tsx +64 -24
  64. package/src/Dialog/Dialog.tsx +64 -12
  65. package/src/Dialog/ModalDialog.tsx +47 -0
  66. package/src/Divider/Divider.stories.mdx +28 -34
  67. package/src/Field/Field.stories.mdx +88 -48
  68. package/src/Field/Field.test.tsx +31 -40
  69. package/src/Field/Field.tsx +26 -21
  70. package/src/Heading/Heading.stories.mdx +30 -82
  71. package/src/Hidden/Hidden.stories.mdx +29 -54
  72. package/src/Image/Image.stories.mdx +26 -30
  73. package/src/Input/Input.stories.mdx +52 -36
  74. package/src/Label/Label.stories.mdx +47 -29
  75. package/src/Label/Label.test.tsx +15 -1
  76. package/src/Label/Label.tsx +20 -7
  77. package/src/Link/Link.stories.mdx +36 -29
  78. package/src/Menu/Menu.stories.mdx +71 -39
  79. package/src/Menu/Menu.test.tsx +4 -4
  80. package/src/Menu/Menu.tsx +12 -14
  81. package/src/MenuItem/MenuItem.stories.mdx +32 -27
  82. package/src/MenuItem/MenuItem.test.tsx +15 -11
  83. package/src/MenuItem/MenuItem.tsx +7 -10
  84. package/src/Message/Message.stories.mdx +35 -35
  85. package/src/Message/Message.tsx +2 -10
  86. package/src/Provider/MarigoldProvider.test.tsx +126 -0
  87. package/src/Provider/MarigoldProvider.tsx +29 -0
  88. package/src/Provider/index.ts +3 -0
  89. package/src/Radio/Radio.stories.mdx +78 -92
  90. package/src/Radio/Radio.test.tsx +57 -15
  91. package/src/Radio/Radio.tsx +71 -51
  92. package/src/Radio/RadioIcons.tsx +39 -0
  93. package/src/Select/ListBox.tsx +39 -0
  94. package/src/Select/ListBoxSection.tsx +40 -0
  95. package/src/Select/Option.tsx +48 -0
  96. package/src/Select/Popover.tsx +50 -0
  97. package/src/Select/Select.stories.mdx +70 -36
  98. package/src/Select/Select.test.tsx +279 -35
  99. package/src/Select/Select.tsx +151 -18
  100. package/src/Slider/Slider.stories.mdx +22 -49
  101. package/src/Stack/Stack.stories.mdx +40 -94
  102. package/src/Stack/Stack.test.tsx +84 -65
  103. package/src/Stack/Stack.tsx +25 -41
  104. package/src/Text/Text.stories.mdx +52 -52
  105. package/src/Text/Text.tsx +13 -14
  106. package/src/Textarea/Textarea.stories.mdx +65 -56
  107. package/src/Textarea/Textarea.test.tsx +4 -5
  108. package/src/Textarea/Textarea.tsx +28 -37
  109. package/src/ValidationMessage/ValidationMessage.stories.mdx +26 -26
  110. package/src/ValidationMessage/ValidationMessage.test.tsx +4 -4
  111. package/src/ValidationMessage/ValidationMessage.tsx +11 -12
  112. package/src/index.ts +5 -0
@@ -1,45 +1,35 @@
1
- import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
2
- import { useStyles } from '@marigold/system';
1
+ import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
3
2
  import { Alert } from './Alert';
4
- import { Text } from '../Text/';
5
-
6
- <Meta title="Components/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
+ />
7
22
 
8
23
  # Alert
9
24
 
10
- ## Description
11
-
12
- Simple colored element to display an alert message as a reaction to an event.
13
- Predefined variants are info, success, danger and warning.
14
-
15
- ## Properties
16
-
17
- | Property | Type | Default |
18
- | :------------------- | :------------------------ | :-------- |
19
- | `variant` (optional) | `success, error, warning` | `success` |
20
-
21
- ## Import
22
-
23
- ```tsx
24
- import { Alert } from '@marigold/components';
25
- ```
26
-
27
- ## Usage
25
+ export const Template = args => (
26
+ <Alert {...args}>
27
+ <Text>Alert</Text>
28
+ </Alert>
29
+ );
28
30
 
29
31
  <Canvas>
30
- <Story name="Success">
31
- <Alert>
32
- <Text>Success message</Text>
33
- </Alert>
34
- </Story>
35
- <Story name="Error">
36
- <Alert variant="error">
37
- <Text>Error message</Text>
38
- </Alert>
39
- </Story>
40
- <Story name="Warning">
41
- <Alert variant="warning">
42
- <Text>Warning message</Text>
43
- </Alert>
44
- </Story>
32
+ <Story name="Default">{Template.bind({})}</Story>
45
33
  </Canvas>
34
+
35
+ <ArgsTable story="Default" />
@@ -5,7 +5,7 @@ import { Alert } from './Alert';
5
5
 
6
6
  const theme = {
7
7
  alerts: {
8
- info: {
8
+ success: {
9
9
  alignItems: 'center',
10
10
  },
11
11
  error: {
@@ -1,57 +1,35 @@
1
1
  import React from 'react';
2
2
  import { ComponentProps } from '@marigold/types';
3
3
  import { Exclamation, Check, Notification } from '@marigold/icons';
4
- import { useStyles } from '@marigold/system';
5
4
  import { Box } from '../Box';
6
5
 
6
+ const ICON_MAP = {
7
+ success: Check,
8
+ warning: Notification,
9
+ error: Exclamation,
10
+ } as const;
11
+
7
12
  export type AlertProps = {
8
- variant?: string;
13
+ variant?: keyof typeof ICON_MAP;
9
14
  } & ComponentProps<'div'>;
10
15
 
11
16
  export const Alert: React.FC<AlertProps> = ({
12
17
  variant = 'success',
13
18
  children,
14
- className,
15
19
  ...props
16
20
  }) => {
17
- const classNames = useStyles({
18
- css: {
19
- display: 'flex',
20
- alignItems: 'center',
21
- },
22
- variant: `alerts.${variant}`,
23
- className,
24
- });
25
-
26
- var bgColor = 'success';
27
- if (variant === 'warning') {
28
- bgColor = 'warning';
29
- } else if (variant === 'error') {
30
- bgColor = 'error';
31
- }
32
- const iconClassName = useStyles({ css: { bg: bgColor, m: '10px' } });
33
-
34
- var icon = <Check size={12} color="#ffffff" className={iconClassName} />;
35
- if (variant === 'warning') {
36
- icon = <Notification size={12} color="#ffffff" className={iconClassName} />;
37
- } else if (variant === 'error') {
38
- icon = <Exclamation size={12} color="#ffffff" className={iconClassName} />;
39
- }
21
+ const Icon = ICON_MAP[variant];
40
22
 
41
23
  return (
42
- <Box {...props} className={classNames}>
24
+ <Box {...props} display="flex" variant={`alerts.${variant}`}>
43
25
  <Box
44
26
  display="inline-block"
45
27
  alignItems="center"
46
28
  width="32px"
47
29
  height="32px"
48
- className={useStyles({
49
- css: {
50
- bg: bgColor,
51
- },
52
- })}
30
+ bg={variant}
53
31
  >
54
- {icon}
32
+ <Box as={Icon} size={12} color="#fff" bg={variant} m={10} />
55
33
  </Box>
56
34
  <Box mx="16px">{children}</Box>
57
35
  </Box>
@@ -1,43 +1,57 @@
1
- import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
1
+ import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
2
2
  import { Badge } from './Badge';
3
- import { Text } from '../Text';
4
3
  import { Check } from '@marigold/icons';
5
- import { useStyles } from '@marigold/system';
6
4
 
7
- <Meta title="Components/Badge" />
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
+ />
8
44
 
9
45
  # Badge
10
46
 
11
- ## Description
12
-
13
- A badge tags an element with a short note and color. The content of the badge can be anything but preferably a string and/or icon.
14
-
15
- ## Properties
16
-
17
- | Property | Type | Default |
18
- | :----------------------- | :------- | :------------ |
19
- | `variant` (optional) | `string` | `default` |
20
- | `borderColor` (optional) | `string` | `transparent` |
21
- | `bgColor` (optional) | `string` | `inherit` |
22
-
23
- ## Import
24
-
25
- ```tsx
26
- import { Badge } from '@marigold/components';
27
- ```
28
-
29
- ## Usage
47
+ export const Template = args => (
48
+ <Badge {...args}>
49
+ <Check /> Check
50
+ </Badge>
51
+ );
30
52
 
31
53
  <Canvas>
32
- <Story name="Colored Background">
33
- <Badge borderColor="black" bgColor="orange">
34
- <Text>New</Text>
35
- </Badge>
36
- </Story>
37
- <Story name="Outlined">
38
- <Badge borderColor="orange" className={useStyles({ display: 'flex' })}>
39
- <Check size={18} />
40
- cool
41
- </Badge>
42
- </Story>
54
+ <Story name="Default">{Template.bind({})}</Story>
43
55
  </Canvas>
56
+
57
+ <ArgsTable story="Default" />
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
- import { useStyles, ThemeProvider } from '@marigold/system';
3
+ import { ThemeProvider } from '@marigold/system';
4
4
  import { Badge } from './Badge';
5
5
 
6
6
  const theme = {
@@ -48,22 +48,14 @@ test('supports other variant than default', () => {
48
48
  });
49
49
 
50
50
  test('accepts custom styles prop className', () => {
51
- const TestComponent: React.FC = ({ children, ...props }) => {
52
- const classNames = useStyles({ css: { fontSize: '8px' } });
53
- return (
54
- <Badge className={classNames} {...props}>
55
- {children}
56
- </Badge>
57
- );
58
- };
59
-
60
- const { getByText } = render(
51
+ render(
61
52
  <ThemeProvider theme={theme}>
62
- <TestComponent>text</TestComponent>
53
+ <Badge className="custom-class-name" title="badge">
54
+ badge
55
+ </Badge>
63
56
  </ThemeProvider>
64
57
  );
65
- const testelem = getByText('text');
66
- const text = getComputedStyle(testelem);
58
+ const badge = screen.getByTitle(/badge/);
67
59
 
68
- expect(text.fontSize).toEqual('8px');
60
+ expect(badge.className).toMatch('custom-class-name');
69
61
  });
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ComponentProps } from '@marigold/types';
3
3
  import { Box } from '../Box';
4
- import { useStyles } from '@marigold/system';
5
4
 
6
5
  export type BadgeProps = {
7
6
  variant?: string;
@@ -17,7 +16,7 @@ export const Badge: React.FC<BadgeProps> = ({
17
16
  ...props
18
17
  }) => (
19
18
  <Box
20
- className={useStyles({ css: { bg: bgColor, borderColor: borderColor } })}
19
+ css={{ bg: bgColor, borderColor: borderColor }}
21
20
  variant={`badge.${variant}`}
22
21
  {...props}
23
22
  >
@@ -1,38 +1,334 @@
1
- import { Meta, Story, Canvas } from '@storybook/addon-docs/blocks';
1
+ import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
2
2
  import { Box } from './Box';
3
3
  import { Button } from '../Button';
4
4
  import { Label } from '../Label';
5
5
 
6
- <Meta title="Components/Box" />
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
+ />
7
323
 
8
324
  # Box-Component
9
325
 
10
- ## Import
326
+ ## For custom components
11
327
 
12
- ```js
13
- import { Box } from '@marigold/components';
14
- ```
15
-
16
- ## Usage
17
-
18
- <Canvas>
19
- <Story name="div-box">
20
- <Box>I am basic box!</Box>
21
- </Story>
22
- </Canvas>
328
+ export const Template = args => <Box {...args}>Style me!</Box>;
23
329
 
24
330
  <Canvas>
25
- <Story name="button-box">
26
- <Box as="button" bg="primary">
27
- I am a button box!
28
- </Box>
29
- </Story>
331
+ <Story name="Default">{Template.bind({})}</Story>
30
332
  </Canvas>
31
333
 
32
- <Canvas>
33
- <Story name="h1-box">
34
- <Box as="h1" p="3">
35
- I am a blue headline!
36
- </Box>
37
- </Story>
38
- </Canvas>
334
+ <ArgsTable story="Default" />