@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,40 +1,36 @@
|
|
|
1
|
-
import { Meta, Story
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
2
|
import { Image } from './Image';
|
|
3
3
|
import image1 from '../../../images/src/type_logo.png';
|
|
4
|
-
import image2 from '../../../images/src/Marigold_Logo_Hotelstyle.png';
|
|
5
4
|
|
|
6
|
-
<Meta
|
|
5
|
+
<Meta
|
|
6
|
+
title="Components/Image"
|
|
7
|
+
argTypes={{
|
|
8
|
+
variant: {
|
|
9
|
+
control: {
|
|
10
|
+
type: 'text',
|
|
11
|
+
},
|
|
12
|
+
description: 'there is only one variant',
|
|
13
|
+
table: {
|
|
14
|
+
defaultValue: {
|
|
15
|
+
summary: 'fullWidth',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
alt: {
|
|
20
|
+
control: {
|
|
21
|
+
type: 'text',
|
|
22
|
+
},
|
|
23
|
+
description: 'Description text for screenreaders'
|
|
24
|
+
},
|
|
25
|
+
}}
|
|
26
|
+
/>
|
|
7
27
|
|
|
8
28
|
# Image
|
|
9
29
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
With the Image component you can render an `img` element.
|
|
13
|
-
The themeSection is `images` and the variant can be added with the variant prop which is `fullWidth` per default.
|
|
14
|
-
|
|
15
|
-
## Properties
|
|
16
|
-
|
|
17
|
-
| Property | Type | Default |
|
|
18
|
-
| :------------------- | :------- | :---------- |
|
|
19
|
-
| `variant` (optional) | `string` | `fullWidth` |
|
|
20
|
-
| `alt` (optional) | `string` | `` |
|
|
21
|
-
|
|
22
|
-
## Import
|
|
23
|
-
|
|
24
|
-
```tsx
|
|
25
|
-
import { Image } from '@marigold/components';
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Usage
|
|
30
|
+
export const Template = args => <Image src={image1} alt="marigold_logo" />;
|
|
29
31
|
|
|
30
32
|
<Canvas>
|
|
31
|
-
<Story name="
|
|
32
|
-
<Image src={image1} alt="marigold_logo" />
|
|
33
|
-
</Story>
|
|
33
|
+
<Story name="Default">{Template.bind({})}</Story>
|
|
34
34
|
</Canvas>
|
|
35
35
|
|
|
36
|
-
<
|
|
37
|
-
<Story name="secondImage">
|
|
38
|
-
<Image src={image2} width="500" height="300" />
|
|
39
|
-
</Story>
|
|
40
|
-
</Canvas>
|
|
36
|
+
<ArgsTable story="Default" />
|
|
@@ -1,45 +1,61 @@
|
|
|
1
|
-
import { Meta, Story
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
2
|
import { Input } from './Input';
|
|
3
3
|
import { Label } from '../Label';
|
|
4
4
|
|
|
5
|
-
<Meta
|
|
5
|
+
<Meta
|
|
6
|
+
title="Components/Input"
|
|
7
|
+
argTypes={{
|
|
8
|
+
variant: {
|
|
9
|
+
control: {
|
|
10
|
+
type: 'text',
|
|
11
|
+
},
|
|
12
|
+
description: '?',
|
|
13
|
+
table: {
|
|
14
|
+
defaultValue: {
|
|
15
|
+
summary: 'default',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
type: {
|
|
20
|
+
control: {
|
|
21
|
+
type: 'select',
|
|
22
|
+
},
|
|
23
|
+
options: [
|
|
24
|
+
'date',
|
|
25
|
+
'datetime-local',
|
|
26
|
+
'email',
|
|
27
|
+
'month',
|
|
28
|
+
'number',
|
|
29
|
+
'password',
|
|
30
|
+
'search',
|
|
31
|
+
'tel',
|
|
32
|
+
'text',
|
|
33
|
+
'time',
|
|
34
|
+
'time',
|
|
35
|
+
'url',
|
|
36
|
+
'week',
|
|
37
|
+
],
|
|
38
|
+
type: { required: true },
|
|
39
|
+
table: {
|
|
40
|
+
defaultValue: {
|
|
41
|
+
summary: 'text',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
6
47
|
|
|
7
48
|
# Input
|
|
8
49
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
| Property | Type | Default |
|
|
17
|
-
| :------------------- | :------- | :-------- |
|
|
18
|
-
| `variant` (optional) | `string` | `default` |
|
|
19
|
-
|
|
20
|
-
## Import
|
|
21
|
-
|
|
22
|
-
```tsx
|
|
23
|
-
import { Input } from '@marigold/components';
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Usage
|
|
50
|
+
export const Template = args => (
|
|
51
|
+
<Label htmlFor="input">
|
|
52
|
+
Label
|
|
53
|
+
<Input id="input" placeholder="Placeholder..." {...args} />
|
|
54
|
+
</Label>
|
|
55
|
+
);
|
|
27
56
|
|
|
28
57
|
<Canvas>
|
|
29
|
-
<Story name="
|
|
30
|
-
<div>
|
|
31
|
-
<Label htmlFor="input">
|
|
32
|
-
Label
|
|
33
|
-
<Input id="input" placeholder="Placeholder" />
|
|
34
|
-
</Label>
|
|
35
|
-
<Label htmlFor="input2">
|
|
36
|
-
Label
|
|
37
|
-
<Input id="input2" placeholder="Disabled" disabled />
|
|
38
|
-
</Label>
|
|
39
|
-
<Label htmlFor="input3">
|
|
40
|
-
Label
|
|
41
|
-
<Input id="input2" type="submit" />
|
|
42
|
-
</Label>
|
|
43
|
-
</div>
|
|
44
|
-
</Story>
|
|
58
|
+
<Story name="Default">{Template.bind({})}</Story>
|
|
45
59
|
</Canvas>
|
|
60
|
+
|
|
61
|
+
<ArgsTable story="Default" />
|
|
@@ -1,34 +1,52 @@
|
|
|
1
|
-
import { Meta, Story
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
2
|
import { Label } from './Label';
|
|
3
3
|
|
|
4
|
-
<Meta
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
4
|
+
<Meta
|
|
5
|
+
title="Components/Label"
|
|
6
|
+
argTypes={{
|
|
7
|
+
variant: {
|
|
8
|
+
control: {
|
|
9
|
+
type: 'text',
|
|
10
|
+
},
|
|
11
|
+
description: '?',
|
|
12
|
+
table: {
|
|
13
|
+
defaultValue: {
|
|
14
|
+
summary: 'above',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
htmlFor: {
|
|
19
|
+
control: {
|
|
20
|
+
type: 'text',
|
|
21
|
+
},
|
|
22
|
+
type: {
|
|
23
|
+
required: true,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
required: {
|
|
27
|
+
control: {
|
|
28
|
+
type: 'boolean',
|
|
29
|
+
},
|
|
30
|
+
description: 'Adds required Icon to label',
|
|
31
|
+
table: {
|
|
32
|
+
defaultValue: {
|
|
33
|
+
summary: false,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}}
|
|
38
|
+
/>
|
|
39
|
+
|
|
40
|
+
# Label
|
|
41
|
+
|
|
42
|
+
export const Template = args => (
|
|
43
|
+
<Label htmlFor="input" {...args}>
|
|
44
|
+
Label
|
|
45
|
+
</Label>
|
|
46
|
+
);
|
|
27
47
|
|
|
28
48
|
<Canvas>
|
|
29
|
-
<Story name="
|
|
30
|
-
<Label variant="label" htmlFor="labelId">
|
|
31
|
-
I am a Label!
|
|
32
|
-
</Label>
|
|
33
|
-
</Story>
|
|
49
|
+
<Story name="Default">{Template.bind({})}</Story>
|
|
34
50
|
</Canvas>
|
|
51
|
+
|
|
52
|
+
<ArgsTable story="Default" />
|
package/src/Label/Label.test.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { Label } from './Label';
|
|
|
5
5
|
|
|
6
6
|
const theme = {
|
|
7
7
|
label: {
|
|
8
|
-
|
|
8
|
+
above: {
|
|
9
9
|
fontFamily: 'Inter Regular',
|
|
10
10
|
},
|
|
11
11
|
myLabel: {
|
|
@@ -49,6 +49,20 @@ test('supports htmlFor prop', () => {
|
|
|
49
49
|
expect(label).toHaveAttribute('for');
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
+
test('supports required prop', () => {
|
|
53
|
+
render(
|
|
54
|
+
<ThemeProvider theme={theme}>
|
|
55
|
+
<Label htmlFor="labelId" required>
|
|
56
|
+
label
|
|
57
|
+
</Label>
|
|
58
|
+
</ThemeProvider>
|
|
59
|
+
);
|
|
60
|
+
const label = screen.getByText(/label/);
|
|
61
|
+
const parent = label.parentElement;
|
|
62
|
+
|
|
63
|
+
expect(parent instanceof HTMLSpanElement).toBeTruthy();
|
|
64
|
+
});
|
|
65
|
+
|
|
52
66
|
test('renders <label> element', () => {
|
|
53
67
|
render(
|
|
54
68
|
<ThemeProvider theme={theme}>
|
package/src/Label/Label.tsx
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ComponentProps } from '@marigold/types';
|
|
3
|
+
import { Required } from '@marigold/icons';
|
|
4
|
+
|
|
3
5
|
import { Box } from '../Box';
|
|
4
6
|
|
|
5
7
|
export type LabelProps = {
|
|
6
|
-
htmlFor
|
|
8
|
+
htmlFor?: string;
|
|
7
9
|
variant?: string;
|
|
10
|
+
required?: boolean;
|
|
8
11
|
} & ComponentProps<'label'>;
|
|
9
12
|
|
|
10
13
|
export const Label: React.FC<LabelProps> = ({
|
|
11
|
-
variant = '
|
|
14
|
+
variant = 'above',
|
|
15
|
+
required,
|
|
12
16
|
children,
|
|
13
17
|
...props
|
|
14
|
-
}) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
}) => {
|
|
19
|
+
return required ? (
|
|
20
|
+
<Box as="span" display="inline-flex" alignItems="center">
|
|
21
|
+
<Box {...props} as="label" variant={`label.${variant}`}>
|
|
22
|
+
{children}
|
|
23
|
+
</Box>
|
|
24
|
+
{required && <Box as={Required} size={16} css={{ color: 'red60' }} />}
|
|
25
|
+
</Box>
|
|
26
|
+
) : (
|
|
27
|
+
<Box {...props} as="label" variant={`label.${variant}`}>
|
|
28
|
+
{children}
|
|
29
|
+
</Box>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -1,38 +1,45 @@
|
|
|
1
|
-
import { Meta, Story
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
2
|
import { Link } from './Link';
|
|
3
3
|
import { Text } from '../Text';
|
|
4
4
|
|
|
5
|
-
<Meta
|
|
5
|
+
<Meta
|
|
6
|
+
title="Components/Link"
|
|
7
|
+
argTypes={{
|
|
8
|
+
variant: {
|
|
9
|
+
control: {
|
|
10
|
+
type: 'text',
|
|
11
|
+
},
|
|
12
|
+
description: '?',
|
|
13
|
+
table: {
|
|
14
|
+
defaultValue: {
|
|
15
|
+
summary: 'link',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
href: {
|
|
20
|
+
control: {
|
|
21
|
+
type: 'text',
|
|
22
|
+
},
|
|
23
|
+
description: 'The URL to direct to',
|
|
24
|
+
type: {
|
|
25
|
+
required: true,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
}}
|
|
29
|
+
/>
|
|
6
30
|
|
|
7
31
|
# Link
|
|
8
32
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
| :------------------- | :------- | :------ |
|
|
17
|
-
| `variant` (optional) | `string` | `link` |
|
|
18
|
-
| `href` | `string` | |
|
|
19
|
-
|
|
20
|
-
## Import
|
|
21
|
-
|
|
22
|
-
```tsx
|
|
23
|
-
import { Link } from '@marigold/components';
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Usage
|
|
33
|
+
export const Template = args => (
|
|
34
|
+
<Text>
|
|
35
|
+
<Link href="https://marigold-ui.io" target="_blank">
|
|
36
|
+
Cool site
|
|
37
|
+
</Link>
|
|
38
|
+
</Text>
|
|
39
|
+
);
|
|
27
40
|
|
|
28
41
|
<Canvas>
|
|
29
|
-
<Story name="
|
|
30
|
-
<Text>
|
|
31
|
-
Link something nice like{' '}
|
|
32
|
-
<Link href="#!" target="_blank">
|
|
33
|
-
Marigold
|
|
34
|
-
</Link>{' '}
|
|
35
|
-
in text.
|
|
36
|
-
</Text>
|
|
37
|
-
</Story>
|
|
42
|
+
<Story name="Default">{Template.bind({})}</Story>
|
|
38
43
|
</Canvas>
|
|
44
|
+
|
|
45
|
+
<ArgsTable story="Default" />
|
|
@@ -1,49 +1,81 @@
|
|
|
1
|
-
import { Meta, Story
|
|
2
|
-
import { Divider } from '../Divider';
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
3
2
|
import { Menu } from './Menu';
|
|
4
3
|
import { MenuItem } from '../MenuItem';
|
|
5
4
|
import { BurgerMenu } from '@marigold/icons';
|
|
5
|
+
import { useState } from 'react';
|
|
6
6
|
|
|
7
|
-
<Meta
|
|
7
|
+
<Meta
|
|
8
|
+
title="Components/Menu"
|
|
9
|
+
parameters={{
|
|
10
|
+
actions: {
|
|
11
|
+
handles: ['click'],
|
|
12
|
+
},
|
|
13
|
+
}}
|
|
14
|
+
argTypes={{
|
|
15
|
+
variant: {
|
|
16
|
+
control: {
|
|
17
|
+
type: 'text',
|
|
18
|
+
},
|
|
19
|
+
description: '?',
|
|
20
|
+
table: {
|
|
21
|
+
defaultValue: {
|
|
22
|
+
summary: 'default',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
label: {
|
|
27
|
+
control: {
|
|
28
|
+
type: 'text',
|
|
29
|
+
},
|
|
30
|
+
description: 'Menu label on hover',
|
|
31
|
+
table: {
|
|
32
|
+
defaultValue: {
|
|
33
|
+
summary: 'Menu',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
show: {
|
|
38
|
+
control: {
|
|
39
|
+
type: 'boolean',
|
|
40
|
+
},
|
|
41
|
+
options: [true, false],
|
|
42
|
+
description: 'Show what',
|
|
43
|
+
table: {
|
|
44
|
+
defaultValue: {
|
|
45
|
+
summary: false,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
onClick: {
|
|
50
|
+
control: {
|
|
51
|
+
type: 'text',
|
|
52
|
+
},
|
|
53
|
+
description: 'Function to show menu or toggle something',
|
|
54
|
+
type: { required: true },
|
|
55
|
+
},
|
|
56
|
+
}}
|
|
57
|
+
/>
|
|
8
58
|
|
|
9
59
|
# Menu
|
|
10
60
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```tsx
|
|
28
|
-
import { Menu } from '@marigold/components';
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Usage
|
|
61
|
+
export const Template = ({ onClick, ...args }) => {
|
|
62
|
+
const [showMenu, setShowMenu] = React.useState(false);
|
|
63
|
+
return (
|
|
64
|
+
<Menu
|
|
65
|
+
onClick={() => setShowMenu(!showMenu)}
|
|
66
|
+
show={showMenu}
|
|
67
|
+
label={<BurgerMenu />}
|
|
68
|
+
{...args}
|
|
69
|
+
>
|
|
70
|
+
<MenuItem href="#">Home</MenuItem>
|
|
71
|
+
<MenuItem href="#">Tickets</MenuItem>
|
|
72
|
+
<MenuItem href="#">Logout</MenuItem>
|
|
73
|
+
</Menu>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
32
76
|
|
|
33
77
|
<Canvas>
|
|
34
|
-
<Story name="menu">
|
|
35
|
-
{() => {
|
|
36
|
-
const [showMenu, setShowMenu] = React.useState(false);
|
|
37
|
-
const toggle = () => {
|
|
38
|
-
setShowMenu(!showMenu);
|
|
39
|
-
};
|
|
40
|
-
return (
|
|
41
|
-
<Menu onClick={toggle} show={showMenu} label={<BurgerMenu />}>
|
|
42
|
-
<MenuItem href="#">Home</MenuItem>
|
|
43
|
-
<MenuItem href="#">Tickets</MenuItem>
|
|
44
|
-
<MenuItem href="#">Kundenkonto</MenuItem>
|
|
45
|
-
</Menu>
|
|
46
|
-
);
|
|
47
|
-
}}
|
|
48
|
-
</Story>
|
|
78
|
+
<Story name="Mini menu">{Template.bind({})}</Story>
|
|
49
79
|
</Canvas>
|
|
80
|
+
|
|
81
|
+
<ArgsTable story="Mini menu" />
|
package/src/Menu/Menu.test.tsx
CHANGED
|
@@ -5,11 +5,11 @@ import { Menu } from './Menu';
|
|
|
5
5
|
import { MenuItem } from '../MenuItem';
|
|
6
6
|
|
|
7
7
|
const theme = {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
menu: {
|
|
9
|
+
default: {
|
|
10
10
|
padding: '4px',
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
custom: {
|
|
13
13
|
padding: '8px',
|
|
14
14
|
},
|
|
15
15
|
},
|
|
@@ -31,7 +31,7 @@ test('supports default variant and themeSection', () => {
|
|
|
31
31
|
test('accepts other variant than default', () => {
|
|
32
32
|
render(
|
|
33
33
|
<ThemeProvider theme={theme}>
|
|
34
|
-
<Menu variant="
|
|
34
|
+
<Menu variant="custom" title="menu" onClick={() => {}}>
|
|
35
35
|
<MenuItem href="#">Home</MenuItem>
|
|
36
36
|
</Menu>
|
|
37
37
|
</ThemeProvider>
|
package/src/Menu/Menu.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useStyles } from '@marigold/system';
|
|
3
2
|
import { ComponentProps } from '@marigold/types';
|
|
4
3
|
|
|
5
4
|
import { Button } from '../Button';
|
|
@@ -15,29 +14,28 @@ export type MenuProps = {
|
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
export const Menu: React.FC<MenuProps> = ({
|
|
18
|
-
variant = '
|
|
17
|
+
variant = 'default',
|
|
19
18
|
label = 'Menu',
|
|
20
19
|
onClick,
|
|
21
20
|
show = false,
|
|
22
21
|
children,
|
|
23
22
|
...props
|
|
24
23
|
}) => {
|
|
25
|
-
const itemStyles = useStyles({
|
|
26
|
-
css: {
|
|
27
|
-
position: 'absolute',
|
|
28
|
-
minWidth: '120px',
|
|
29
|
-
display: 'block',
|
|
30
|
-
textAlign: 'left',
|
|
31
|
-
borderRadius: '2px',
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
|
|
35
24
|
return (
|
|
36
|
-
<Box variant={`
|
|
25
|
+
<Box variant={`menu.${variant}`} {...props}>
|
|
37
26
|
<Button onClick={onClick} variant="menu">
|
|
38
27
|
{label}
|
|
39
28
|
</Button>
|
|
40
|
-
{show ?
|
|
29
|
+
{show ? (
|
|
30
|
+
<Box
|
|
31
|
+
display="block"
|
|
32
|
+
position="absolute"
|
|
33
|
+
minWidth="120px"
|
|
34
|
+
borderRadius="2px"
|
|
35
|
+
>
|
|
36
|
+
{children}
|
|
37
|
+
</Box>
|
|
38
|
+
) : null}
|
|
41
39
|
</Box>
|
|
42
40
|
);
|
|
43
41
|
};
|
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
import { Meta, Story
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
|
+
import { Menu } from '../Menu';
|
|
2
3
|
import { MenuItem } from './MenuItem';
|
|
3
4
|
|
|
4
|
-
<Meta
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
5
|
+
<Meta
|
|
6
|
+
title="Components/MenuItem"
|
|
7
|
+
parameters={{
|
|
8
|
+
actions: {
|
|
9
|
+
handles: ['click'],
|
|
10
|
+
},
|
|
11
|
+
}}
|
|
12
|
+
argTypes={{
|
|
13
|
+
variant: {
|
|
14
|
+
control: {
|
|
15
|
+
type: 'text',
|
|
16
|
+
},
|
|
17
|
+
description: '?',
|
|
18
|
+
table: {
|
|
19
|
+
defaultValue: {
|
|
20
|
+
summary: 'default',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
}}
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
# Menu Item
|
|
28
|
+
|
|
29
|
+
export const Template = args => {
|
|
30
|
+
return <MenuItem href="#">Home</MenuItem>;
|
|
31
|
+
};
|
|
27
32
|
|
|
28
33
|
<Canvas>
|
|
29
|
-
<Story name="
|
|
30
|
-
<MenuItem href="#">Menu Item</MenuItem>
|
|
31
|
-
</Story>
|
|
34
|
+
<Story name="Menu Item">{Template.bind({})}</Story>
|
|
32
35
|
</Canvas>
|
|
36
|
+
|
|
37
|
+
<ArgsTable story="Menu Item" />
|