@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.
- package/CHANGELOG.md +294 -0
- package/dist/ActionGroup/ActionGroup.d.ts +1 -2
- package/dist/ActionGroup/ActionGroup.stories.d.ts +5 -0
- package/dist/Alert/Alert.d.ts +10 -13
- package/dist/Alert/Alert.stories.d.ts +5 -0
- package/dist/Badge/Badge.d.ts +5 -0
- package/dist/Badge/Badge.stories.d.ts +5 -0
- package/dist/Box.d.ts +2 -0
- package/dist/Button/Button.d.ts +5 -0
- package/dist/Button/Button.stories.d.ts +5 -0
- package/dist/Card/Card.d.ts +5 -0
- package/dist/Card/Card.stories.d.ts +5 -0
- package/dist/Checkbox/Checkbox.d.ts +10 -5
- package/dist/Checkbox/Checkbox.stories.d.ts +5 -0
- package/dist/Checkbox/CheckboxIcons.d.ts +9 -9
- package/dist/Column/Column.stories.d.ts +5 -0
- package/dist/Columns/Columns.d.ts +2 -2
- package/dist/Columns/Columns.stories.d.ts +5 -0
- package/dist/Container/Container.stories.d.ts +5 -0
- package/dist/Dialog/Dialog.d.ts +5 -2
- package/dist/Dialog/Dialog.stories.d.ts +5 -0
- package/dist/Dialog/ModalDialog.d.ts +4 -1
- package/dist/Divider/Divider.d.ts +5 -0
- package/dist/Divider/Divider.stories.d.ts +5 -0
- package/dist/Field/Field.d.ts +2 -0
- package/dist/Field/Field.stories.d.ts +5 -0
- package/dist/Image/Image.d.ts +5 -0
- package/dist/Image/Image.stories.d.ts +5 -0
- package/dist/Inline/Inline.d.ts +7 -0
- package/dist/Inline/Inline.stories.d.ts +5 -0
- package/dist/Inline/index.d.ts +1 -0
- package/dist/Input/Input.d.ts +5 -0
- package/dist/Input/Input.stories.d.ts +5 -0
- package/dist/Label/Label.d.ts +12 -1
- package/dist/Label/Label.stories.d.ts +5 -0
- package/dist/Link/Link.d.ts +4 -1
- package/dist/Link/Link.stories.d.ts +5 -0
- package/dist/Menu/Menu.d.ts +3 -0
- package/dist/Menu/Menu.stories.d.ts +5 -0
- package/dist/MenuItem/MenuItem.d.ts +5 -0
- package/dist/MenuItem/MenuItem.stories.d.ts +5 -0
- package/dist/Message/Message.d.ts +5 -0
- package/dist/Message/Message.stories.d.ts +5 -0
- package/dist/Provider/MarigoldProvider.d.ts +11 -3
- package/dist/Provider/index.d.ts +1 -1
- package/dist/Radio/Radio.d.ts +6 -0
- package/dist/Radio/RadioIcons.d.ts +1 -0
- package/dist/Select/ListBox.d.ts +1 -0
- package/dist/Select/ListBoxSection.d.ts +1 -0
- package/dist/Select/Option.d.ts +1 -0
- package/dist/Select/Select.d.ts +15 -1
- package/dist/Select/Select.stories.d.ts +5 -0
- package/dist/Slider/Slider.d.ts +5 -0
- package/dist/Slider/Slider.stories.d.ts +5 -0
- package/dist/Stack/Stack.stories.d.ts +5 -0
- package/dist/Text/Text.d.ts +5 -0
- package/dist/Text/Text.stories.d.ts +5 -0
- package/dist/Textarea/Textarea.d.ts +5 -0
- package/dist/Textarea/Textarea.stories.d.ts +5 -0
- package/dist/ValidationMessage/ValidationMessage.d.ts +5 -0
- package/dist/ValidationMessage/ValidationMessage.stories.d.ts +5 -0
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +1 -0
- package/dist/VisuallyHidden/VisuallyHidden.stories.d.ts +5 -0
- package/dist/VisuallyHidden/index.d.ts +1 -0
- package/dist/components.cjs.development.js +480 -496
- 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 +415 -441
- package/dist/components.esm.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/theme.d.ts +23 -48
- package/package.json +4 -1
- package/src/ActionGroup/ActionGroup.stories.tsx +47 -0
- package/src/ActionGroup/ActionGroup.test.tsx +36 -36
- package/src/ActionGroup/ActionGroup.tsx +17 -28
- package/src/Alert/Alert.stories.tsx +32 -0
- package/src/Alert/Alert.test.tsx +4 -1
- package/src/Alert/Alert.tsx +18 -3
- package/src/Badge/Badge.stories.tsx +38 -0
- package/src/Badge/Badge.test.tsx +5 -1
- package/src/Badge/Badge.tsx +13 -1
- package/src/Box.ts +2 -0
- package/src/Button/{Button.stories.mdx → Button.stories.tsx} +10 -17
- package/src/Button/Button.test.tsx +34 -11
- package/src/Button/Button.tsx +17 -3
- package/src/Card/{Card.stories.mdx → Card.stories.tsx} +9 -17
- package/src/Card/Card.test.tsx +8 -3
- package/src/Card/Card.tsx +13 -1
- package/src/Checkbox/Checkbox.stories.mdx +11 -0
- package/src/Checkbox/Checkbox.stories.tsx +78 -0
- package/src/Checkbox/Checkbox.test.tsx +77 -8
- package/src/Checkbox/Checkbox.tsx +70 -90
- package/src/Checkbox/CheckboxIcons.tsx +51 -41
- package/src/Column/Column.stories.tsx +33 -0
- package/src/Columns/Columns.stories.tsx +75 -0
- package/src/Columns/Columns.test.tsx +34 -23
- package/src/Columns/Columns.tsx +30 -30
- package/src/Container/Container.stories.tsx +14 -0
- package/src/Dialog/{Dialog.stories.mdx → Dialog.stories.tsx} +33 -18
- package/src/Dialog/Dialog.test.tsx +91 -20
- package/src/Dialog/Dialog.tsx +63 -17
- package/src/Dialog/ModalDialog.tsx +33 -4
- package/src/Divider/{Divider.stories.mdx → Divider.stories.tsx} +10 -17
- package/src/Divider/Divider.test.tsx +13 -5
- package/src/Divider/Divider.tsx +12 -0
- package/src/Field/{Field.stories.mdx → Field.stories.tsx} +33 -20
- package/src/Field/Field.test.tsx +55 -5
- package/src/Field/Field.tsx +10 -8
- package/src/Image/Image.stories.tsx +34 -0
- package/src/Image/Image.test.tsx +4 -1
- package/src/Image/Image.tsx +13 -1
- package/src/Inline/Inline.stories.tsx +39 -0
- package/src/Inline/Inline.test.tsx +99 -0
- package/src/Inline/Inline.tsx +38 -0
- package/src/Inline/index.ts +1 -0
- package/src/Input/{Input.stories.mdx → Input.stories.tsx} +10 -17
- package/src/Input/Input.test.tsx +7 -3
- package/src/Input/Input.tsx +13 -1
- package/src/Label/{Label.stories.mdx → Label.stories.tsx} +10 -21
- package/src/Label/Label.test.tsx +25 -4
- package/src/Label/Label.tsx +42 -9
- package/src/Link/Link.stories.tsx +35 -0
- package/src/Link/Link.test.tsx +6 -2
- package/src/Link/Link.tsx +10 -0
- package/src/Menu/{Menu.stories.mdx → Menu.stories.tsx} +13 -32
- package/src/Menu/Menu.test.tsx +7 -2
- package/src/Menu/Menu.tsx +10 -0
- package/src/MenuItem/MenuItem.stories.tsx +30 -0
- package/src/MenuItem/MenuItem.test.tsx +7 -2
- package/src/MenuItem/MenuItem.tsx +12 -0
- package/src/Message/Message.stories.tsx +30 -0
- package/src/Message/Message.test.tsx +4 -1
- package/src/Message/Message.tsx +17 -5
- package/src/Provider/MarigoldProvider.test.tsx +65 -55
- package/src/Provider/MarigoldProvider.tsx +37 -19
- package/src/Provider/index.ts +2 -1
- package/src/Radio/Radio.stories.mdx +11 -0
- package/src/Radio/Radio.test.tsx +36 -2
- package/src/Radio/Radio.tsx +13 -2
- package/src/Radio/RadioIcons.tsx +1 -1
- package/src/Select/ListBox.tsx +1 -0
- package/src/Select/{Select.stories.mdx → Select.stories.tsx} +23 -20
- package/src/Select/Select.test.tsx +39 -1
- package/src/Select/Select.tsx +24 -13
- package/src/Slider/Slider.stories.tsx +24 -0
- package/src/Slider/Slider.test.tsx +10 -6
- package/src/Slider/Slider.tsx +25 -13
- package/src/Stack/Stack.stories.tsx +57 -0
- package/src/Stack/Stack.test.tsx +16 -7
- package/src/Text/{Text.stories.mdx → Text.stories.tsx} +20 -19
- package/src/Text/Text.test.tsx +2 -2
- package/src/Text/Text.tsx +12 -0
- package/src/Textarea/{Textarea.stories.mdx → Textarea.stories.tsx} +14 -24
- package/src/Textarea/Textarea.test.tsx +7 -3
- package/src/Textarea/Textarea.tsx +13 -1
- package/src/ValidationMessage/{ValidationMessage.stories.mdx → ValidationMessage.stories.tsx} +8 -17
- package/src/ValidationMessage/ValidationMessage.test.tsx +7 -2
- package/src/ValidationMessage/ValidationMessage.tsx +12 -0
- package/src/VisuallyHidden/VisuallyHidden.stories.tsx +19 -0
- package/src/VisuallyHidden/VisuallyHidden.test.tsx +10 -0
- package/src/VisuallyHidden/VisuallyHidden.tsx +1 -0
- package/src/VisuallyHidden/index.ts +1 -0
- package/src/index.ts +2 -2
- package/src/theme.ts +49 -48
- package/dist/Box/Box.d.ts +0 -47
- package/dist/Box/index.d.ts +0 -1
- package/dist/Heading/Heading.d.ts +0 -7
- package/dist/Heading/index.d.ts +0 -1
- package/dist/Hidden/Hidden.d.ts +0 -5
- package/dist/Hidden/index.d.ts +0 -1
- package/src/ActionGroup/ActionGroup.stories.mdx +0 -62
- package/src/Alert/Alert.stories.mdx +0 -35
- package/src/Badge/Badge.stories.mdx +0 -57
- package/src/Box/Box.stories.mdx +0 -334
- package/src/Box/Box.test.tsx +0 -133
- package/src/Box/Box.tsx +0 -165
- package/src/Box/index.ts +0 -1
- package/src/Column/Column.stories.mdx +0 -49
- package/src/Columns/Columns.stories.mdx +0 -65
- package/src/Container/Container.stories.mdx +0 -19
- package/src/Heading/Heading.stories.mdx +0 -39
- package/src/Heading/Heading.test.tsx +0 -77
- package/src/Heading/Heading.tsx +0 -19
- package/src/Heading/index.ts +0 -1
- package/src/Hidden/Hidden.stories.mdx +0 -39
- package/src/Hidden/Hidden.test.tsx +0 -24
- package/src/Hidden/Hidden.tsx +0 -16
- package/src/Hidden/index.ts +0 -1
- package/src/Image/Image.stories.mdx +0 -36
- package/src/Link/Link.stories.mdx +0 -45
- package/src/MenuItem/MenuItem.stories.mdx +0 -37
- package/src/Message/Message.stories.mdx +0 -44
- package/src/Slider/Slider.stories.mdx +0 -31
- package/src/Stack/Stack.stories.mdx +0 -51
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
2
3
|
import { Label } from './Label';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
title
|
|
6
|
-
argTypes
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/Label',
|
|
7
|
+
argTypes: {
|
|
7
8
|
variant: {
|
|
8
9
|
control: {
|
|
9
10
|
type: 'text',
|
|
@@ -19,9 +20,7 @@ import { Label } from './Label';
|
|
|
19
20
|
control: {
|
|
20
21
|
type: 'text',
|
|
21
22
|
},
|
|
22
|
-
|
|
23
|
-
required: true,
|
|
24
|
-
},
|
|
23
|
+
defaultValue: 'input',
|
|
25
24
|
},
|
|
26
25
|
required: {
|
|
27
26
|
control: {
|
|
@@ -34,19 +33,9 @@ import { Label } from './Label';
|
|
|
34
33
|
},
|
|
35
34
|
},
|
|
36
35
|
},
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
# Label
|
|
36
|
+
},
|
|
37
|
+
} as Meta;
|
|
41
38
|
|
|
42
|
-
export const
|
|
43
|
-
<Label
|
|
44
|
-
Label
|
|
45
|
-
</Label>
|
|
39
|
+
export const Basic: ComponentStory<typeof Label> = args => (
|
|
40
|
+
<Label {...args}>Label</Label>
|
|
46
41
|
);
|
|
47
|
-
|
|
48
|
-
<Canvas>
|
|
49
|
-
<Story name="Default">{Template.bind({})}</Story>
|
|
50
|
-
</Canvas>
|
|
51
|
-
|
|
52
|
-
<ArgsTable story="Default" />
|
package/src/Label/Label.test.tsx
CHANGED
|
@@ -4,17 +4,25 @@ import { ThemeProvider } from '@marigold/system';
|
|
|
4
4
|
import { Label } from './Label';
|
|
5
5
|
|
|
6
6
|
const theme = {
|
|
7
|
+
fonts: {
|
|
8
|
+
body: 'Inter Regular',
|
|
9
|
+
label: 'Oswald',
|
|
10
|
+
},
|
|
7
11
|
label: {
|
|
8
12
|
above: {
|
|
9
|
-
fontFamily: '
|
|
13
|
+
fontFamily: 'body',
|
|
10
14
|
},
|
|
11
15
|
myLabel: {
|
|
12
|
-
fontFamily: '
|
|
16
|
+
fontFamily: 'label',
|
|
13
17
|
},
|
|
14
18
|
},
|
|
19
|
+
colors: {
|
|
20
|
+
text: 'black',
|
|
21
|
+
disabled: 'gray',
|
|
22
|
+
},
|
|
15
23
|
};
|
|
16
24
|
|
|
17
|
-
test('supports default variant and
|
|
25
|
+
test('supports default variant and styles', () => {
|
|
18
26
|
render(
|
|
19
27
|
<ThemeProvider theme={theme}>
|
|
20
28
|
<Label htmlFor="labelId">label</Label>
|
|
@@ -23,6 +31,7 @@ test('supports default variant and themeSection', () => {
|
|
|
23
31
|
const label = screen.getByText(/label/);
|
|
24
32
|
|
|
25
33
|
expect(label).toHaveStyle(`font-family: Inter Regular`);
|
|
34
|
+
expect(label).toHaveStyle(`color: black`);
|
|
26
35
|
});
|
|
27
36
|
|
|
28
37
|
test('supports other variant than default', () => {
|
|
@@ -35,7 +44,7 @@ test('supports other variant than default', () => {
|
|
|
35
44
|
);
|
|
36
45
|
const label = screen.getByText(/label/);
|
|
37
46
|
|
|
38
|
-
expect(label).toHaveStyle(`font-family: Oswald
|
|
47
|
+
expect(label).toHaveStyle(`font-family: Oswald`);
|
|
39
48
|
});
|
|
40
49
|
|
|
41
50
|
test('supports htmlFor prop', () => {
|
|
@@ -63,6 +72,18 @@ test('supports required prop', () => {
|
|
|
63
72
|
expect(parent instanceof HTMLSpanElement).toBeTruthy();
|
|
64
73
|
});
|
|
65
74
|
|
|
75
|
+
test('supports color prop', () => {
|
|
76
|
+
render(
|
|
77
|
+
<ThemeProvider theme={theme}>
|
|
78
|
+
<Label htmlFor="labelId" color="disabled">
|
|
79
|
+
label
|
|
80
|
+
</Label>
|
|
81
|
+
</ThemeProvider>
|
|
82
|
+
);
|
|
83
|
+
const label = screen.getByText(/label/);
|
|
84
|
+
expect(label).toHaveStyle(`color: gray`);
|
|
85
|
+
});
|
|
86
|
+
|
|
66
87
|
test('renders <label> element', () => {
|
|
67
88
|
render(
|
|
68
89
|
<ThemeProvider theme={theme}>
|
package/src/Label/Label.tsx
CHANGED
|
@@ -1,31 +1,64 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
|
|
2
3
|
import { ComponentProps } from '@marigold/types';
|
|
3
4
|
import { Required } from '@marigold/icons';
|
|
5
|
+
import { ResponsiveStyleValue } from '@marigold/system';
|
|
4
6
|
|
|
5
7
|
import { Box } from '../Box';
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
// Theme Extension
|
|
10
|
+
// ---------------
|
|
11
|
+
export interface LabelThemeExtension<Value> {
|
|
12
|
+
label?: {
|
|
13
|
+
[key: string]: Value;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// LabelBase
|
|
18
|
+
// ---------------
|
|
19
|
+
export type LabelBaseProps = {
|
|
8
20
|
htmlFor?: string;
|
|
9
21
|
variant?: string;
|
|
10
22
|
required?: boolean;
|
|
23
|
+
color?: ResponsiveStyleValue<string>;
|
|
11
24
|
} & ComponentProps<'label'>;
|
|
12
25
|
|
|
13
|
-
export const
|
|
26
|
+
export const LabelBase: React.FC<LabelProps> = ({
|
|
14
27
|
variant = 'above',
|
|
28
|
+
required,
|
|
29
|
+
color = 'text',
|
|
30
|
+
children,
|
|
31
|
+
...props
|
|
32
|
+
}) => {
|
|
33
|
+
return (
|
|
34
|
+
<Box
|
|
35
|
+
{...props}
|
|
36
|
+
as="label"
|
|
37
|
+
__baseCSS={{ color: color }}
|
|
38
|
+
variant={`label.${variant}`}
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</Box>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// Label
|
|
46
|
+
// ---------------
|
|
47
|
+
export type LabelProps = {
|
|
48
|
+
required?: boolean;
|
|
49
|
+
} & LabelBaseProps;
|
|
50
|
+
|
|
51
|
+
export const Label: React.FC<LabelProps> = ({
|
|
15
52
|
required,
|
|
16
53
|
children,
|
|
17
54
|
...props
|
|
18
55
|
}) => {
|
|
19
56
|
return required ? (
|
|
20
57
|
<Box as="span" display="inline-flex" alignItems="center">
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
</Box>
|
|
24
|
-
{required && <Box as={Required} size={16} css={{ color: 'red60' }} />}
|
|
58
|
+
<LabelBase {...props}>{children}</LabelBase>
|
|
59
|
+
{required && <Box as={Required} size={16} css={{ color: 'error' }} />}
|
|
25
60
|
</Box>
|
|
26
61
|
) : (
|
|
27
|
-
<
|
|
28
|
-
{children}
|
|
29
|
-
</Box>
|
|
62
|
+
<LabelBase {...props}>{children}</LabelBase>
|
|
30
63
|
);
|
|
31
64
|
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
+
import { Link } from './Link';
|
|
4
|
+
import { Text } from '../Text';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Link',
|
|
8
|
+
argTypes: {
|
|
9
|
+
variant: {
|
|
10
|
+
control: {
|
|
11
|
+
type: 'text',
|
|
12
|
+
},
|
|
13
|
+
description: '?',
|
|
14
|
+
table: {
|
|
15
|
+
defaultValue: {
|
|
16
|
+
summary: 'link',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
href: {
|
|
21
|
+
control: {
|
|
22
|
+
type: 'text',
|
|
23
|
+
},
|
|
24
|
+
description: 'The URL to direct to',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
} as Meta;
|
|
28
|
+
|
|
29
|
+
export const Basic: ComponentStory<typeof Link> = args => (
|
|
30
|
+
<Text>
|
|
31
|
+
<Link href="https://marigold-ui.io" target="_blank" {...args}>
|
|
32
|
+
Marigold Docs
|
|
33
|
+
</Link>
|
|
34
|
+
</Text>
|
|
35
|
+
);
|
package/src/Link/Link.test.tsx
CHANGED
|
@@ -4,12 +4,16 @@ import { ThemeProvider } from '@marigold/system';
|
|
|
4
4
|
import { Link } from './Link';
|
|
5
5
|
|
|
6
6
|
const theme = {
|
|
7
|
+
fonts: {
|
|
8
|
+
link: 'Inter',
|
|
9
|
+
body: 'Oswald',
|
|
10
|
+
},
|
|
7
11
|
text: {
|
|
8
12
|
link: {
|
|
9
|
-
fontFamily: '
|
|
13
|
+
fontFamily: 'link',
|
|
10
14
|
},
|
|
11
15
|
second: {
|
|
12
|
-
fontFamily: '
|
|
16
|
+
fontFamily: 'body',
|
|
13
17
|
},
|
|
14
18
|
},
|
|
15
19
|
};
|
package/src/Link/Link.tsx
CHANGED
|
@@ -4,9 +4,19 @@ import { PolymorphicComponent, PolymorphicProps } from '@marigold/types';
|
|
|
4
4
|
|
|
5
5
|
import { Text, TextOwnProps } from '../Text';
|
|
6
6
|
|
|
7
|
+
// Theme Extension
|
|
8
|
+
// ---------------
|
|
9
|
+
export interface LinkThemeExtension<Value> {
|
|
10
|
+
link?: Value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Props
|
|
14
|
+
// ---------------
|
|
7
15
|
export type LinkOwnProps = { disabled?: boolean } & TextOwnProps;
|
|
8
16
|
export type LinkProps = PolymorphicProps<LinkOwnProps, 'a'>;
|
|
9
17
|
|
|
18
|
+
// Component
|
|
19
|
+
// ---------------
|
|
10
20
|
export const Link = (({
|
|
11
21
|
as = 'a',
|
|
12
22
|
variant = 'link',
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
2
3
|
import { Menu } from './Menu';
|
|
3
4
|
import { MenuItem } from '../MenuItem';
|
|
4
|
-
import { BurgerMenu } from '@marigold/icons';
|
|
5
|
-
import { useState } from 'react';
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
title
|
|
9
|
-
parameters
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Menu',
|
|
8
|
+
parameters: {
|
|
10
9
|
actions: {
|
|
11
10
|
handles: ['click'],
|
|
12
11
|
},
|
|
13
|
-
}
|
|
14
|
-
argTypes
|
|
12
|
+
},
|
|
13
|
+
argTypes: {
|
|
15
14
|
variant: {
|
|
16
15
|
control: {
|
|
17
16
|
type: 'text',
|
|
@@ -28,11 +27,7 @@ import { useState } from 'react';
|
|
|
28
27
|
type: 'text',
|
|
29
28
|
},
|
|
30
29
|
description: 'Menu label on hover',
|
|
31
|
-
|
|
32
|
-
defaultValue: {
|
|
33
|
-
summary: 'Menu',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
30
|
+
defaultValue: 'Menu',
|
|
36
31
|
},
|
|
37
32
|
show: {
|
|
38
33
|
control: {
|
|
@@ -51,31 +46,17 @@ import { useState } from 'react';
|
|
|
51
46
|
type: 'text',
|
|
52
47
|
},
|
|
53
48
|
description: 'Function to show menu or toggle something',
|
|
54
|
-
type: { required: true },
|
|
55
49
|
},
|
|
56
|
-
}
|
|
57
|
-
|
|
50
|
+
},
|
|
51
|
+
} as Meta;
|
|
58
52
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
export const Template = ({ onClick, ...args }) => {
|
|
62
|
-
const [showMenu, setShowMenu] = React.useState(false);
|
|
53
|
+
export const Basic: ComponentStory<typeof Menu> = ({ onClick, ...args }) => {
|
|
54
|
+
const [showMenu, setShowMenu] = useState(false);
|
|
63
55
|
return (
|
|
64
|
-
<Menu
|
|
65
|
-
onClick={() => setShowMenu(!showMenu)}
|
|
66
|
-
show={showMenu}
|
|
67
|
-
label={<BurgerMenu />}
|
|
68
|
-
{...args}
|
|
69
|
-
>
|
|
56
|
+
<Menu onClick={() => setShowMenu(!showMenu)} show={showMenu} {...args}>
|
|
70
57
|
<MenuItem href="#">Home</MenuItem>
|
|
71
58
|
<MenuItem href="#">Tickets</MenuItem>
|
|
72
59
|
<MenuItem href="#">Logout</MenuItem>
|
|
73
60
|
</Menu>
|
|
74
61
|
);
|
|
75
62
|
};
|
|
76
|
-
|
|
77
|
-
<Canvas>
|
|
78
|
-
<Story name="Mini menu">{Template.bind({})}</Story>
|
|
79
|
-
</Canvas>
|
|
80
|
-
|
|
81
|
-
<ArgsTable story="Mini menu" />
|
package/src/Menu/Menu.test.tsx
CHANGED
|
@@ -5,12 +5,17 @@ import { Menu } from './Menu';
|
|
|
5
5
|
import { MenuItem } from '../MenuItem';
|
|
6
6
|
|
|
7
7
|
const theme = {
|
|
8
|
+
space: {
|
|
9
|
+
none: 0,
|
|
10
|
+
small: 4,
|
|
11
|
+
medium: 8,
|
|
12
|
+
},
|
|
8
13
|
menu: {
|
|
9
14
|
default: {
|
|
10
|
-
padding: '
|
|
15
|
+
padding: 'small',
|
|
11
16
|
},
|
|
12
17
|
custom: {
|
|
13
|
-
padding: '
|
|
18
|
+
padding: 'medium',
|
|
14
19
|
},
|
|
15
20
|
},
|
|
16
21
|
};
|
package/src/Menu/Menu.tsx
CHANGED
|
@@ -4,6 +4,14 @@ import { ComponentProps } from '@marigold/types';
|
|
|
4
4
|
import { Button } from '../Button';
|
|
5
5
|
import { Box } from '../Box';
|
|
6
6
|
|
|
7
|
+
// Theme Extension
|
|
8
|
+
// ---------------
|
|
9
|
+
export interface MenuThemeExtension<Value> {
|
|
10
|
+
menu?: Value;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Props
|
|
14
|
+
// ---------------
|
|
7
15
|
export type MenuProps = {
|
|
8
16
|
variant?: string;
|
|
9
17
|
label?: string;
|
|
@@ -13,6 +21,8 @@ export type MenuProps = {
|
|
|
13
21
|
title?: string; // For testing
|
|
14
22
|
};
|
|
15
23
|
|
|
24
|
+
// Component
|
|
25
|
+
// ---------------
|
|
16
26
|
export const Menu: React.FC<MenuProps> = ({
|
|
17
27
|
variant = 'default',
|
|
18
28
|
label = 'Menu',
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
+
import { MenuItem } from './MenuItem';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/MenuItem',
|
|
7
|
+
parameters: {
|
|
8
|
+
actions: {
|
|
9
|
+
handles: ['click'],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
argTypes: {
|
|
13
|
+
variant: {
|
|
14
|
+
control: {
|
|
15
|
+
type: 'text',
|
|
16
|
+
},
|
|
17
|
+
table: {
|
|
18
|
+
defaultValue: {
|
|
19
|
+
summary: 'default',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
} as Meta;
|
|
25
|
+
|
|
26
|
+
export const Basic: ComponentStory<typeof MenuItem> = args => (
|
|
27
|
+
<MenuItem href="#" {...args}>
|
|
28
|
+
Home
|
|
29
|
+
</MenuItem>
|
|
30
|
+
);
|
|
@@ -4,12 +4,17 @@ import { ThemeProvider } from '@marigold/system';
|
|
|
4
4
|
import { MenuItem } from './MenuItem';
|
|
5
5
|
|
|
6
6
|
const theme = {
|
|
7
|
+
space: {
|
|
8
|
+
none: 0,
|
|
9
|
+
small: 4,
|
|
10
|
+
medium: 8,
|
|
11
|
+
},
|
|
7
12
|
menuItem: {
|
|
8
13
|
default: {
|
|
9
|
-
padding: '
|
|
14
|
+
padding: 'small',
|
|
10
15
|
},
|
|
11
16
|
item: {
|
|
12
|
-
padding: '
|
|
17
|
+
padding: 'medium',
|
|
13
18
|
},
|
|
14
19
|
},
|
|
15
20
|
};
|
|
@@ -3,10 +3,22 @@ import { ComponentProps } from '@marigold/types';
|
|
|
3
3
|
import { Link } from '../Link';
|
|
4
4
|
import { Box } from '../Box';
|
|
5
5
|
|
|
6
|
+
// Theme Extension
|
|
7
|
+
// ---------------
|
|
8
|
+
export interface MenuItemThemeExtension<Value> {
|
|
9
|
+
menuItem?: {
|
|
10
|
+
[key: string]: Value;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Props
|
|
15
|
+
// ---------------
|
|
6
16
|
export type MenuItemProps = {
|
|
7
17
|
variant?: string;
|
|
8
18
|
} & ComponentProps<typeof Link>;
|
|
9
19
|
|
|
20
|
+
// Component
|
|
21
|
+
// ---------------
|
|
10
22
|
export const MenuItem: React.FC<MenuItemProps> = ({
|
|
11
23
|
variant = 'default',
|
|
12
24
|
className,
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
+
import { Message } from './Message';
|
|
4
|
+
import { Text } from '../Text';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Message',
|
|
8
|
+
argTypes: {
|
|
9
|
+
variant: {
|
|
10
|
+
control: {
|
|
11
|
+
type: 'select',
|
|
12
|
+
},
|
|
13
|
+
options: ['warning', 'error', 'info'],
|
|
14
|
+
description: 'Messaging in different colors and icons',
|
|
15
|
+
},
|
|
16
|
+
messageTitle: {
|
|
17
|
+
control: {
|
|
18
|
+
type: 'text',
|
|
19
|
+
},
|
|
20
|
+
description: 'Content',
|
|
21
|
+
defaultValue: 'Danger Zone!',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
} as Meta;
|
|
25
|
+
|
|
26
|
+
export const Basic: ComponentStory<typeof Message> = args => (
|
|
27
|
+
<Message {...args}>
|
|
28
|
+
<Text>Hello, I am a simple message.</Text>
|
|
29
|
+
</Message>
|
|
30
|
+
);
|
package/src/Message/Message.tsx
CHANGED
|
@@ -2,13 +2,25 @@ import React from 'react';
|
|
|
2
2
|
import { Exclamation, Info, Notification } from '@marigold/icons';
|
|
3
3
|
import { ComponentProps } from '@marigold/types';
|
|
4
4
|
import { Box } from '../Box';
|
|
5
|
-
import {
|
|
5
|
+
import { Text } from '../Text';
|
|
6
6
|
|
|
7
|
+
// Theme Extension
|
|
8
|
+
// ---------------
|
|
9
|
+
export interface MessageThemeExtension<Value> {
|
|
10
|
+
message?: {
|
|
11
|
+
[key: string]: Value;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Props
|
|
16
|
+
// ---------------
|
|
7
17
|
export type MessageProps = {
|
|
8
18
|
messageTitle: string;
|
|
9
19
|
variant?: string;
|
|
10
20
|
} & ComponentProps<'div'>;
|
|
11
21
|
|
|
22
|
+
// Component
|
|
23
|
+
// ---------------
|
|
12
24
|
export const Message: React.FC<MessageProps> = ({
|
|
13
25
|
messageTitle,
|
|
14
26
|
variant = 'info',
|
|
@@ -27,15 +39,15 @@ export const Message: React.FC<MessageProps> = ({
|
|
|
27
39
|
return (
|
|
28
40
|
<Box
|
|
29
41
|
display="inline-block"
|
|
30
|
-
variant={`
|
|
42
|
+
variant={`message.${variant}`}
|
|
31
43
|
className={className}
|
|
32
44
|
{...props}
|
|
33
45
|
>
|
|
34
|
-
<Box display="flex" alignItems="center" variant="
|
|
46
|
+
<Box display="flex" alignItems="center" variant="message.title">
|
|
35
47
|
{icon}
|
|
36
|
-
<
|
|
48
|
+
<Text as="h4" variant="headline4">
|
|
37
49
|
{messageTitle}
|
|
38
|
-
</
|
|
50
|
+
</Text>
|
|
39
51
|
</Box>
|
|
40
52
|
<Box css={{ color: 'black' }}>{children}</Box>
|
|
41
53
|
</Box>
|