@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.
- package/dist/ActionGroup/ActionGroup.d.ts +9 -0
- package/dist/ActionGroup/index.d.ts +1 -0
- package/dist/Alert/Alert.d.ts +16 -1
- package/dist/Box/Box.d.ts +2 -1
- package/dist/Button/Button.d.ts +4 -6
- package/dist/Card/Card.d.ts +9 -0
- package/dist/Card/index.d.ts +1 -0
- package/dist/Checkbox/Checkbox.d.ts +3 -0
- package/dist/Checkbox/CheckboxIcons.d.ts +9 -0
- package/dist/Column/Column.d.ts +3 -1
- package/dist/Dialog/Dialog.d.ts +8 -1
- package/dist/Dialog/ModalDialog.d.ts +5 -0
- package/dist/Field/Field.d.ts +4 -2
- package/dist/Label/Label.d.ts +2 -1
- package/dist/Provider/MarigoldProvider.d.ts +3 -0
- package/dist/Provider/index.d.ts +3 -0
- package/dist/Radio/Radio.d.ts +3 -0
- package/dist/Radio/RadioIcons.d.ts +9 -0
- package/dist/Select/ListBox.d.ts +8 -0
- package/dist/Select/ListBoxSection.d.ts +8 -0
- package/dist/Select/Option.d.ts +8 -0
- package/dist/Select/Popover.d.ts +9 -0
- package/dist/Select/Select.d.ts +11 -4
- package/dist/Stack/Stack.d.ts +1 -3
- package/dist/Textarea/Textarea.d.ts +2 -1
- package/dist/components.cjs.development.js +868 -357
- package/dist/components.cjs.development.js.map +1 -1
- package/dist/components.cjs.production.min.js +1 -1
- package/dist/components.cjs.production.min.js.map +1 -1
- package/dist/components.esm.js +837 -359
- package/dist/components.esm.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/package.json +18 -3
- package/src/ActionGroup/ActionGroup.stories.mdx +62 -0
- package/src/ActionGroup/ActionGroup.test.tsx +83 -0
- package/src/ActionGroup/ActionGroup.tsx +43 -0
- package/src/ActionGroup/index.ts +1 -0
- package/src/Alert/Alert.stories.mdx +28 -38
- package/src/Alert/Alert.test.tsx +1 -1
- package/src/Alert/Alert.tsx +11 -33
- package/src/Badge/Badge.stories.mdx +48 -34
- package/src/Badge/Badge.test.tsx +7 -15
- package/src/Badge/Badge.tsx +1 -2
- package/src/Box/Box.stories.mdx +322 -26
- package/src/Box/Box.tsx +58 -50
- package/src/Button/Button.stories.mdx +54 -166
- package/src/Button/Button.test.tsx +48 -8
- package/src/Button/Button.tsx +47 -18
- package/src/Card/Card.stories.mdx +49 -0
- package/src/Card/Card.test.tsx +66 -0
- package/src/Card/Card.tsx +36 -0
- package/src/Card/index.ts +1 -0
- package/src/Checkbox/Checkbox.stories.mdx +76 -71
- package/src/Checkbox/Checkbox.test.tsx +70 -24
- package/src/Checkbox/Checkbox.tsx +68 -49
- package/src/Checkbox/CheckboxIcons.tsx +49 -0
- package/src/Column/Column.stories.mdx +39 -64
- package/src/Column/Column.test.tsx +8 -0
- package/src/Column/Column.tsx +12 -2
- package/src/Columns/Columns.stories.mdx +58 -240
- package/src/Container/Container.stories.mdx +8 -25
- package/src/Dialog/Dialog.stories.mdx +65 -56
- package/src/Dialog/Dialog.test.tsx +64 -24
- package/src/Dialog/Dialog.tsx +64 -12
- package/src/Dialog/ModalDialog.tsx +47 -0
- package/src/Divider/Divider.stories.mdx +28 -34
- package/src/Field/Field.stories.mdx +88 -48
- package/src/Field/Field.test.tsx +31 -40
- package/src/Field/Field.tsx +26 -21
- package/src/Heading/Heading.stories.mdx +30 -82
- package/src/Hidden/Hidden.stories.mdx +29 -54
- package/src/Image/Image.stories.mdx +26 -30
- package/src/Input/Input.stories.mdx +52 -36
- package/src/Label/Label.stories.mdx +47 -29
- package/src/Label/Label.test.tsx +15 -1
- package/src/Label/Label.tsx +20 -7
- package/src/Link/Link.stories.mdx +36 -29
- package/src/Menu/Menu.stories.mdx +71 -39
- package/src/Menu/Menu.test.tsx +4 -4
- package/src/Menu/Menu.tsx +12 -14
- package/src/MenuItem/MenuItem.stories.mdx +32 -27
- package/src/MenuItem/MenuItem.test.tsx +15 -11
- package/src/MenuItem/MenuItem.tsx +7 -10
- package/src/Message/Message.stories.mdx +35 -35
- package/src/Message/Message.tsx +2 -10
- package/src/Provider/MarigoldProvider.test.tsx +126 -0
- package/src/Provider/MarigoldProvider.tsx +29 -0
- package/src/Provider/index.ts +3 -0
- package/src/Radio/Radio.stories.mdx +78 -92
- package/src/Radio/Radio.test.tsx +57 -15
- package/src/Radio/Radio.tsx +71 -51
- package/src/Radio/RadioIcons.tsx +39 -0
- package/src/Select/ListBox.tsx +39 -0
- package/src/Select/ListBoxSection.tsx +40 -0
- package/src/Select/Option.tsx +48 -0
- package/src/Select/Popover.tsx +50 -0
- package/src/Select/Select.stories.mdx +70 -36
- package/src/Select/Select.test.tsx +279 -35
- package/src/Select/Select.tsx +151 -18
- package/src/Slider/Slider.stories.mdx +22 -49
- package/src/Stack/Stack.stories.mdx +40 -94
- package/src/Stack/Stack.test.tsx +84 -65
- package/src/Stack/Stack.tsx +25 -41
- package/src/Text/Text.stories.mdx +52 -52
- package/src/Text/Text.tsx +13 -14
- package/src/Textarea/Textarea.stories.mdx +65 -56
- package/src/Textarea/Textarea.test.tsx +4 -5
- package/src/Textarea/Textarea.tsx +28 -37
- package/src/ValidationMessage/ValidationMessage.stories.mdx +26 -26
- package/src/ValidationMessage/ValidationMessage.test.tsx +4 -4
- package/src/ValidationMessage/ValidationMessage.tsx +11 -12
- package/src/index.ts +5 -0
|
@@ -1,65 +1,74 @@
|
|
|
1
|
-
import { Meta, Story
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
2
|
import { Textarea } from '../Textarea';
|
|
3
3
|
|
|
4
|
-
<Meta
|
|
4
|
+
<Meta
|
|
5
|
+
title="Components/Textarea"
|
|
6
|
+
argTypes={{
|
|
7
|
+
variant: {
|
|
8
|
+
control: {
|
|
9
|
+
type: 'text',
|
|
10
|
+
},
|
|
11
|
+
table: {
|
|
12
|
+
defaultValue: {
|
|
13
|
+
summary: 'default',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
label: {
|
|
18
|
+
control: {
|
|
19
|
+
type: 'text',
|
|
20
|
+
},
|
|
21
|
+
description: 'Text above',
|
|
22
|
+
},
|
|
23
|
+
htmlFor: {
|
|
24
|
+
control: {
|
|
25
|
+
type: 'text',
|
|
26
|
+
},
|
|
27
|
+
description: 'Bind to label',
|
|
28
|
+
table: {
|
|
29
|
+
defaultValue: {
|
|
30
|
+
summary: 'textarea',
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
error: {
|
|
35
|
+
control: {
|
|
36
|
+
type: 'boolean',
|
|
37
|
+
},
|
|
38
|
+
description: 'Error',
|
|
39
|
+
table: {
|
|
40
|
+
defaultValue: {
|
|
41
|
+
summary: false,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
errorMessage: {
|
|
46
|
+
control: {
|
|
47
|
+
type: 'text',
|
|
48
|
+
},
|
|
49
|
+
description: 'Error Message',
|
|
50
|
+
},
|
|
51
|
+
required: {
|
|
52
|
+
control: {
|
|
53
|
+
type: 'boolean',
|
|
54
|
+
},
|
|
55
|
+
table: {
|
|
56
|
+
defaultValue: {
|
|
57
|
+
summary: false,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
}}
|
|
62
|
+
/>
|
|
5
63
|
|
|
6
64
|
# Textarea
|
|
7
65
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
The element uses always the themeSection with the name: `textarea` in your given theme. The variant in your section can be added with the variant prop. The default variant is `default`.
|
|
12
|
-
If you use the label prop you have to add htmlFor. Optionally you can pass an errorMessage or the required prop.
|
|
13
|
-
|
|
14
|
-
## Properties
|
|
15
|
-
|
|
16
|
-
| Property | Type | Default |
|
|
17
|
-
| :------------------------ | :-------- | :--------- |
|
|
18
|
-
| `variant` (optional) | `string` | `default` |
|
|
19
|
-
| `label` (optional) | `string` | |
|
|
20
|
-
| `htmlFor` (optional) | `string` | `textarea` |
|
|
21
|
-
| `errorMessage` (optional) | `string` | |
|
|
22
|
-
| `required` (optional) | `boolean` | |
|
|
23
|
-
|
|
24
|
-
## Import
|
|
25
|
-
|
|
26
|
-
```tsx
|
|
27
|
-
import { Textarea } from '@marigold/components';
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Usage
|
|
31
|
-
|
|
32
|
-
### basic & disabled
|
|
66
|
+
export const Template = args => (
|
|
67
|
+
<Textarea placeholder="Placeholder..." label="Textarea Label" {...args} />
|
|
68
|
+
);
|
|
33
69
|
|
|
34
70
|
<Canvas>
|
|
35
|
-
<Story name="
|
|
36
|
-
<Textarea placeholder="Placeholder" />
|
|
37
|
-
</Story>
|
|
38
|
-
<Story name="Textarea disabled">
|
|
39
|
-
<Textarea placeholder="Placeholder disabled" disabled />
|
|
40
|
-
</Story>
|
|
71
|
+
<Story name="Default">{Template.bind({})}</Story>
|
|
41
72
|
</Canvas>
|
|
42
73
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<Canvas>
|
|
46
|
-
<Story name="Textarea label">
|
|
47
|
-
<Textarea label="Labeled" htmlFor="label" />
|
|
48
|
-
</Story>
|
|
49
|
-
<Story name="Textarea required">
|
|
50
|
-
<Textarea label="Required" htmlFor="required" required />
|
|
51
|
-
</Story>
|
|
52
|
-
</Canvas>
|
|
53
|
-
|
|
54
|
-
### with error
|
|
55
|
-
|
|
56
|
-
<Canvas>
|
|
57
|
-
<Story name="Textarea error">
|
|
58
|
-
<Textarea
|
|
59
|
-
label="Required with error"
|
|
60
|
-
htmlFor="error"
|
|
61
|
-
required
|
|
62
|
-
errorMessage="Oh no, we have an error!"
|
|
63
|
-
/>
|
|
64
|
-
</Story>
|
|
65
|
-
</Canvas>
|
|
74
|
+
<ArgsTable story="Default" />
|
|
@@ -58,14 +58,13 @@ test('supports label prop', () => {
|
|
|
58
58
|
expect(textarea instanceof HTMLLabelElement).toBeTruthy();
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
test('supports errorMessage prop', () => {
|
|
61
|
+
test('supports error and errorMessage prop', () => {
|
|
62
62
|
render(
|
|
63
63
|
<ThemeProvider theme={theme}>
|
|
64
|
-
<Textarea errorMessage="error" title="textarea" />
|
|
64
|
+
<Textarea error errorMessage="error" label="label" title="textarea" />
|
|
65
65
|
</ThemeProvider>
|
|
66
66
|
);
|
|
67
67
|
const textarea = screen.getByText(/error/);
|
|
68
|
-
|
|
69
68
|
expect(textarea).toBeDefined();
|
|
70
69
|
});
|
|
71
70
|
|
|
@@ -75,9 +74,9 @@ test('supports required prop', () => {
|
|
|
75
74
|
<Textarea label="test" htmlFor="myId" required title="textarea" />
|
|
76
75
|
</ThemeProvider>
|
|
77
76
|
);
|
|
78
|
-
const
|
|
77
|
+
const label = screen.getByText(/test/);
|
|
79
78
|
|
|
80
|
-
expect(
|
|
79
|
+
expect(label.nextSibling instanceof SVGElement).toBeTruthy();
|
|
81
80
|
});
|
|
82
81
|
|
|
83
82
|
test('accepts custom styles prop className', () => {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { Exclamation, Required } from '@marigold/icons';
|
|
2
|
+
import { Exclamation } from '@marigold/icons';
|
|
4
3
|
import { ComponentProps } from '@marigold/types';
|
|
5
4
|
|
|
6
5
|
import { ValidationMessage } from '../ValidationMessage';
|
|
@@ -11,49 +10,41 @@ export type TextareaProps = {
|
|
|
11
10
|
variant?: string;
|
|
12
11
|
label?: string;
|
|
13
12
|
htmlFor?: string;
|
|
14
|
-
errorMessage?: string;
|
|
15
13
|
required?: boolean;
|
|
14
|
+
error?: boolean;
|
|
15
|
+
errorMessage?: string;
|
|
16
16
|
} & ComponentProps<'textarea'>;
|
|
17
17
|
|
|
18
18
|
export const Textarea: React.FC<TextareaProps> = ({
|
|
19
19
|
variant = 'default',
|
|
20
20
|
htmlFor = 'textarea',
|
|
21
21
|
label,
|
|
22
|
+
error,
|
|
22
23
|
errorMessage,
|
|
23
|
-
required
|
|
24
|
+
required,
|
|
24
25
|
className = '',
|
|
25
26
|
children,
|
|
26
27
|
...props
|
|
27
|
-
}) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
/>
|
|
51
|
-
{errorMessage && (
|
|
52
|
-
<ValidationMessage>
|
|
53
|
-
<Exclamation size={16} />
|
|
54
|
-
{errorMessage}
|
|
55
|
-
</ValidationMessage>
|
|
56
|
-
)}
|
|
57
|
-
</Box>
|
|
58
|
-
);
|
|
59
|
-
};
|
|
28
|
+
}) => (
|
|
29
|
+
<Box>
|
|
30
|
+
{label && (
|
|
31
|
+
<Label htmlFor={htmlFor} required={required}>
|
|
32
|
+
{label}
|
|
33
|
+
</Label>
|
|
34
|
+
)}
|
|
35
|
+
<Box
|
|
36
|
+
as="textarea"
|
|
37
|
+
{...props}
|
|
38
|
+
display="block"
|
|
39
|
+
variant={`textarea.${variant}`}
|
|
40
|
+
css={{ outlineColor: error && 'error' }}
|
|
41
|
+
className={className}
|
|
42
|
+
/>
|
|
43
|
+
{error && errorMessage && (
|
|
44
|
+
<ValidationMessage>
|
|
45
|
+
<Exclamation size={16} />
|
|
46
|
+
{errorMessage}
|
|
47
|
+
</ValidationMessage>
|
|
48
|
+
)}
|
|
49
|
+
</Box>
|
|
50
|
+
);
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { Meta, Story
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
2
|
import { ValidationMessage } from './ValidationMessage';
|
|
3
3
|
import { Exclamation } from '@marigold/icons';
|
|
4
4
|
|
|
5
|
-
<Meta
|
|
5
|
+
<Meta
|
|
6
|
+
title="Components/ValidationMessage"
|
|
7
|
+
argTypes={{
|
|
8
|
+
variant: {
|
|
9
|
+
control: {
|
|
10
|
+
type: 'text',
|
|
11
|
+
},
|
|
12
|
+
description: '?',
|
|
13
|
+
table: {
|
|
14
|
+
defaultValue: {
|
|
15
|
+
summary: 'error',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
6
21
|
|
|
7
22
|
# ValidationMessage
|
|
8
23
|
|
|
9
|
-
## Description
|
|
10
24
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
| `variant` (optional) | `string` | `error` |
|
|
18
|
-
|
|
19
|
-
## Import
|
|
20
|
-
|
|
21
|
-
```tsx
|
|
22
|
-
import { ValidationMessage } from '@marigold/components';
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Usage
|
|
25
|
+
export const Template = args => (
|
|
26
|
+
<ValidationMessage {...args}>
|
|
27
|
+
<Exclamation />
|
|
28
|
+
Validation message
|
|
29
|
+
</ValidationMessage>
|
|
30
|
+
);
|
|
26
31
|
|
|
27
32
|
<Canvas>
|
|
28
|
-
<Story name="
|
|
29
|
-
<div>
|
|
30
|
-
<ValidationMessage>
|
|
31
|
-
<Exclamation />
|
|
32
|
-
Validation message
|
|
33
|
-
</ValidationMessage>
|
|
34
|
-
</div>
|
|
35
|
-
</Story>
|
|
33
|
+
<Story name="Default">{Template.bind({})}</Story>
|
|
36
34
|
</Canvas>
|
|
35
|
+
|
|
36
|
+
<ArgsTable story="Default" />
|
|
@@ -6,10 +6,10 @@ import { ValidationMessage } from './ValidationMessage';
|
|
|
6
6
|
const theme = {
|
|
7
7
|
validation: {
|
|
8
8
|
error: {
|
|
9
|
-
|
|
9
|
+
p: '8px',
|
|
10
10
|
},
|
|
11
11
|
warning: {
|
|
12
|
-
|
|
12
|
+
p: '4px',
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
};
|
|
@@ -22,7 +22,7 @@ test('supports default variant and themeSection', () => {
|
|
|
22
22
|
);
|
|
23
23
|
const validation = screen.getByTitle(/error/);
|
|
24
24
|
|
|
25
|
-
expect(validation).toHaveStyle(`
|
|
25
|
+
expect(validation).toHaveStyle(`padding: 8px`);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
test('accepts other variant than default', () => {
|
|
@@ -35,7 +35,7 @@ test('accepts other variant than default', () => {
|
|
|
35
35
|
);
|
|
36
36
|
const validation = screen.getByTitle(/warning/);
|
|
37
37
|
|
|
38
|
-
expect(validation).toHaveStyle(`
|
|
38
|
+
expect(validation).toHaveStyle(`padding: 4px`);
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
test('renders correct HTML element', () => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useStyles } from '@marigold/system';
|
|
3
2
|
import { ComponentProps } from '@marigold/types';
|
|
4
3
|
|
|
4
|
+
import { Box } from '../Box';
|
|
5
|
+
|
|
5
6
|
export type ValidationMessageProps = {
|
|
6
7
|
variant?: string;
|
|
7
8
|
} & ComponentProps<'span'>;
|
|
@@ -12,18 +13,16 @@ export const ValidationMessage: React.FC<ValidationMessageProps> = ({
|
|
|
12
13
|
className,
|
|
13
14
|
...props
|
|
14
15
|
}) => {
|
|
15
|
-
const classNames = useStyles({
|
|
16
|
-
variant: `validation.${variant}`,
|
|
17
|
-
css: {
|
|
18
|
-
display: 'flex',
|
|
19
|
-
alignItems: 'center',
|
|
20
|
-
},
|
|
21
|
-
className,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
16
|
return (
|
|
25
|
-
<
|
|
17
|
+
<Box
|
|
18
|
+
as="span"
|
|
19
|
+
display="flex"
|
|
20
|
+
alignItems="center"
|
|
21
|
+
variant={`validation.${variant}`}
|
|
22
|
+
className={className}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
26
25
|
{children}
|
|
27
|
-
</
|
|
26
|
+
</Box>
|
|
28
27
|
);
|
|
29
28
|
};
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export * from './theme';
|
|
2
2
|
|
|
3
|
+
export * from './ActionGroup';
|
|
3
4
|
export * from './Alert';
|
|
4
5
|
export * from './Badge';
|
|
5
6
|
export * from './Box';
|
|
6
7
|
export * from './Button';
|
|
8
|
+
export * from './Card';
|
|
7
9
|
export * from './Checkbox';
|
|
8
10
|
export * from './Column';
|
|
9
11
|
export * from './Columns';
|
|
@@ -18,6 +20,7 @@ export * from './Link';
|
|
|
18
20
|
export * from './Menu';
|
|
19
21
|
export * from './MenuItem';
|
|
20
22
|
export * from './Message';
|
|
23
|
+
export * from './Provider';
|
|
21
24
|
export * from './Radio';
|
|
22
25
|
export * from './Slider';
|
|
23
26
|
export * from './Select';
|
|
@@ -27,3 +30,5 @@ export * from './Textarea';
|
|
|
27
30
|
export * from './Input';
|
|
28
31
|
export * from './Container';
|
|
29
32
|
export * from './ValidationMessage';
|
|
33
|
+
|
|
34
|
+
export { Item, Section } from '@react-stately/collections';
|