@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
|
@@ -5,36 +5,32 @@ import { ActionGroup } from './ActionGroup';
|
|
|
5
5
|
import { Button } from '../Button';
|
|
6
6
|
|
|
7
7
|
const theme = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
custom: {
|
|
13
|
-
p: '12px',
|
|
14
|
-
},
|
|
8
|
+
space: {
|
|
9
|
+
none: 0,
|
|
10
|
+
small: 2,
|
|
15
11
|
},
|
|
16
12
|
};
|
|
17
13
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<ThemeProvider theme={theme}>
|
|
21
|
-
<ActionGroup title="actionGroup" />
|
|
22
|
-
</ThemeProvider>
|
|
23
|
-
);
|
|
24
|
-
const actionGroup = screen.getByTitle(/actionGroup/);
|
|
14
|
+
const getLeftPadding = (element: HTMLElement) =>
|
|
15
|
+
getComputedStyle(element).getPropertyValue('padding-left');
|
|
25
16
|
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
const getTopPadding = (element: HTMLElement) =>
|
|
18
|
+
getComputedStyle(element).getPropertyValue('padding-top');
|
|
28
19
|
|
|
29
|
-
test('
|
|
20
|
+
test('default space is "none"', () => {
|
|
30
21
|
render(
|
|
31
22
|
<ThemeProvider theme={theme}>
|
|
32
|
-
<ActionGroup
|
|
23
|
+
<ActionGroup title="actionGroup">
|
|
24
|
+
<Button title="Button1">Button1</Button>
|
|
25
|
+
<Button title="Button2">Button2</Button>
|
|
26
|
+
</ActionGroup>
|
|
33
27
|
</ThemeProvider>
|
|
34
28
|
);
|
|
35
|
-
const
|
|
29
|
+
const first = screen.getByTitle(/Button1/).parentElement!;
|
|
30
|
+
const second = screen.getByTitle(/Button2/).parentElement!;
|
|
36
31
|
|
|
37
|
-
expect(
|
|
32
|
+
expect(getLeftPadding(first)).toEqual('');
|
|
33
|
+
expect(second).toHaveStyle(`padding-left: 0px`);
|
|
38
34
|
});
|
|
39
35
|
|
|
40
36
|
test('supports space prop', () => {
|
|
@@ -46,38 +42,42 @@ test('supports space prop', () => {
|
|
|
46
42
|
</ActionGroup>
|
|
47
43
|
</ThemeProvider>
|
|
48
44
|
);
|
|
49
|
-
const
|
|
50
|
-
const
|
|
45
|
+
const first = screen.getByTitle(/Button1/).parentElement!;
|
|
46
|
+
const second = screen.getByTitle(/Button2/).parentElement;
|
|
51
47
|
|
|
52
|
-
expect(
|
|
53
|
-
expect(
|
|
54
|
-
expect(button2.parentElement).not.toHaveStyle(`margin-right: 8px;`);
|
|
48
|
+
expect(getLeftPadding(first)).toEqual('');
|
|
49
|
+
expect(second).toHaveStyle(`padding-left: 8px`);
|
|
55
50
|
});
|
|
56
51
|
|
|
57
|
-
test('
|
|
52
|
+
test('accepts and uses spacing from theme', () => {
|
|
58
53
|
render(
|
|
59
54
|
<ThemeProvider theme={theme}>
|
|
60
|
-
<ActionGroup title="actionGroup" space="
|
|
55
|
+
<ActionGroup title="actionGroup" space="small">
|
|
61
56
|
<Button title="Button1">Button1</Button>
|
|
62
57
|
<Button title="Button2">Button2</Button>
|
|
63
58
|
</ActionGroup>
|
|
64
59
|
</ThemeProvider>
|
|
65
60
|
);
|
|
66
|
-
const
|
|
67
|
-
const
|
|
61
|
+
const first = screen.getByTitle(/Button1/).parentElement!;
|
|
62
|
+
const second = screen.getByTitle(/Button2/).parentElement;
|
|
68
63
|
|
|
69
|
-
expect(
|
|
70
|
-
expect(
|
|
71
|
-
expect(button2.parentElement).not.toHaveStyle(`margin-bottom: 8px;`);
|
|
64
|
+
expect(getLeftPadding(first)).toEqual('');
|
|
65
|
+
expect(second).toHaveStyle(`padding-left: 2px`);
|
|
72
66
|
});
|
|
73
67
|
|
|
74
|
-
test('
|
|
68
|
+
test('supports verticalAlignment prop', () => {
|
|
75
69
|
render(
|
|
76
70
|
<ThemeProvider theme={theme}>
|
|
77
|
-
<ActionGroup title="actionGroup"
|
|
71
|
+
<ActionGroup title="actionGroup" space="small" verticalAlignment>
|
|
72
|
+
<Button title="Button1">Button1</Button>
|
|
73
|
+
<Button title="Button2">Button2</Button>
|
|
74
|
+
</ActionGroup>
|
|
78
75
|
</ThemeProvider>
|
|
79
76
|
);
|
|
80
|
-
const actionGroup = screen.getByTitle(/actionGroup/);
|
|
81
77
|
|
|
82
|
-
|
|
78
|
+
const button1 = screen.getByText(/Button1/);
|
|
79
|
+
const button2 = screen.getByText(/Button2/);
|
|
80
|
+
|
|
81
|
+
expect(getTopPadding(button1.parentElement!)).toEqual('');
|
|
82
|
+
expect(button2.parentElement).toHaveStyle(`padding-top: 2px`);
|
|
83
83
|
});
|
|
@@ -1,43 +1,32 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import flattenChildren from 'react-keyed-flatten-children';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
|
|
4
3
|
import { ResponsiveStyleValue } from '@marigold/system';
|
|
5
4
|
import { ComponentProps } from '@marigold/types';
|
|
6
5
|
|
|
7
|
-
import {
|
|
6
|
+
import { Inline } from '../Inline';
|
|
7
|
+
import { Stack } from '../Stack';
|
|
8
8
|
|
|
9
|
+
// Props
|
|
10
|
+
// ---------------
|
|
9
11
|
export type ActionGroupProps = {
|
|
10
|
-
|
|
11
|
-
space?: ResponsiveStyleValue<number | string>;
|
|
12
|
+
space?: ResponsiveStyleValue<string>;
|
|
12
13
|
verticalAlignment?: boolean;
|
|
13
14
|
} & ComponentProps<'div'>;
|
|
14
15
|
|
|
16
|
+
// Component
|
|
17
|
+
// ---------------
|
|
15
18
|
export const ActionGroup: React.FC<ActionGroupProps> = ({
|
|
16
|
-
variant = 'default',
|
|
17
19
|
space = 'none',
|
|
18
20
|
verticalAlignment = false,
|
|
19
21
|
children,
|
|
20
|
-
className,
|
|
21
22
|
...props
|
|
22
|
-
}) =>
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
child !== null &&
|
|
32
|
-
child !== undefined && (
|
|
33
|
-
<Box
|
|
34
|
-
as={verticalAlignment ? 'div' : 'span'}
|
|
35
|
-
css={i < Children.count(children) - 1 ? childStyle : undefined}
|
|
36
|
-
>
|
|
37
|
-
{child}
|
|
38
|
-
</Box>
|
|
39
|
-
)
|
|
40
|
-
)}
|
|
41
|
-
</Box>
|
|
23
|
+
}) =>
|
|
24
|
+
verticalAlignment ? (
|
|
25
|
+
<Stack space={space} {...props}>
|
|
26
|
+
{children}
|
|
27
|
+
</Stack>
|
|
28
|
+
) : (
|
|
29
|
+
<Inline space={space} {...props}>
|
|
30
|
+
{children}
|
|
31
|
+
</Inline>
|
|
42
32
|
);
|
|
43
|
-
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Alert } from './Alert';
|
|
5
|
+
import { Text } from '../Text';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/Alert',
|
|
9
|
+
argTypes: {
|
|
10
|
+
variant: {
|
|
11
|
+
description: 'usage types',
|
|
12
|
+
control: {
|
|
13
|
+
type: 'select',
|
|
14
|
+
},
|
|
15
|
+
options: ['success', 'warning', 'error'],
|
|
16
|
+
defaultValue: 'success',
|
|
17
|
+
},
|
|
18
|
+
children: {
|
|
19
|
+
description: 'text to display',
|
|
20
|
+
control: {
|
|
21
|
+
type: 'text',
|
|
22
|
+
},
|
|
23
|
+
defaultValue: 'Put some text here!',
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
} as Meta;
|
|
27
|
+
|
|
28
|
+
export const Basic: ComponentStory<typeof Alert> = ({ children, ...args }) => (
|
|
29
|
+
<Alert {...args}>
|
|
30
|
+
<Text>{children}</Text>
|
|
31
|
+
</Alert>
|
|
32
|
+
);
|
package/src/Alert/Alert.test.tsx
CHANGED
package/src/Alert/Alert.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ComponentProps } from '@marigold/types';
|
|
3
2
|
import { Exclamation, Check, Notification } from '@marigold/icons';
|
|
3
|
+
import { type ComponentProps } from '@marigold/types';
|
|
4
|
+
|
|
4
5
|
import { Box } from '../Box';
|
|
5
6
|
|
|
6
7
|
const ICON_MAP = {
|
|
@@ -9,10 +10,24 @@ const ICON_MAP = {
|
|
|
9
10
|
error: Exclamation,
|
|
10
11
|
} as const;
|
|
11
12
|
|
|
13
|
+
export type AlertVariants = keyof typeof ICON_MAP;
|
|
14
|
+
|
|
15
|
+
// Theme Extension
|
|
16
|
+
// ---------------
|
|
17
|
+
export interface AlertThemeExtension<Value> {
|
|
18
|
+
alert?: {
|
|
19
|
+
[key in AlertVariants]?: Value;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Props
|
|
24
|
+
// ---------------
|
|
12
25
|
export type AlertProps = {
|
|
13
|
-
variant?:
|
|
26
|
+
variant?: AlertVariants;
|
|
14
27
|
} & ComponentProps<'div'>;
|
|
15
28
|
|
|
29
|
+
// Component
|
|
30
|
+
// ---------------
|
|
16
31
|
export const Alert: React.FC<AlertProps> = ({
|
|
17
32
|
variant = 'success',
|
|
18
33
|
children,
|
|
@@ -21,7 +36,7 @@ export const Alert: React.FC<AlertProps> = ({
|
|
|
21
36
|
const Icon = ICON_MAP[variant];
|
|
22
37
|
|
|
23
38
|
return (
|
|
24
|
-
<Box {...props} display="flex" variant={`
|
|
39
|
+
<Box {...props} display="flex" variant={`alert.${variant}`}>
|
|
25
40
|
<Box
|
|
26
41
|
display="inline-block"
|
|
27
42
|
alignItems="center"
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import { Badge } from './Badge';
|
|
5
|
+
import { Check } from '@marigold/icons';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Components/Badge',
|
|
9
|
+
argTypes: {
|
|
10
|
+
variant: {
|
|
11
|
+
description: 'badge variant',
|
|
12
|
+
control: {
|
|
13
|
+
type: 'text',
|
|
14
|
+
},
|
|
15
|
+
defaultValue: '',
|
|
16
|
+
},
|
|
17
|
+
bgColor: {
|
|
18
|
+
description: 'background color',
|
|
19
|
+
control: {
|
|
20
|
+
type: 'text',
|
|
21
|
+
},
|
|
22
|
+
defaultValue: 'primary',
|
|
23
|
+
},
|
|
24
|
+
borderColor: {
|
|
25
|
+
description: 'outline color',
|
|
26
|
+
control: {
|
|
27
|
+
type: 'text',
|
|
28
|
+
},
|
|
29
|
+
defaultValue: 'transparent',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
} as Meta;
|
|
33
|
+
|
|
34
|
+
export const Basic: ComponentStory<typeof Badge> = args => (
|
|
35
|
+
<Badge {...args}>
|
|
36
|
+
<Check /> Check
|
|
37
|
+
</Badge>
|
|
38
|
+
);
|
package/src/Badge/Badge.test.tsx
CHANGED
package/src/Badge/Badge.tsx
CHANGED
|
@@ -2,14 +2,26 @@ import React from 'react';
|
|
|
2
2
|
import { ComponentProps } from '@marigold/types';
|
|
3
3
|
import { Box } from '../Box';
|
|
4
4
|
|
|
5
|
+
// Theme Extension
|
|
6
|
+
// ---------------
|
|
7
|
+
export interface BadgeThemeExtension<Value> {
|
|
8
|
+
badge?: {
|
|
9
|
+
[key: string]: Value;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Props
|
|
14
|
+
// ---------------
|
|
5
15
|
export type BadgeProps = {
|
|
6
16
|
variant?: string;
|
|
7
17
|
bgColor?: string;
|
|
8
18
|
borderColor?: string;
|
|
9
19
|
} & ComponentProps<'div'>;
|
|
10
20
|
|
|
21
|
+
// Component
|
|
22
|
+
// ---------------
|
|
11
23
|
export const Badge: React.FC<BadgeProps> = ({
|
|
12
|
-
variant = '
|
|
24
|
+
variant = '',
|
|
13
25
|
bgColor = 'transparent',
|
|
14
26
|
borderColor = 'transparent',
|
|
15
27
|
children,
|
package/src/Box.ts
ADDED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
2
3
|
import { Facebook } from '@marigold/icons';
|
|
3
4
|
import { Button } from './Button';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
title
|
|
7
|
-
parameters
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Button',
|
|
8
|
+
parameters: {
|
|
8
9
|
actions: {
|
|
9
10
|
handles: ['click'],
|
|
10
11
|
},
|
|
11
|
-
}
|
|
12
|
-
argTypes
|
|
12
|
+
},
|
|
13
|
+
argTypes: {
|
|
13
14
|
variant: {
|
|
14
15
|
control: {
|
|
15
16
|
type: 'select',
|
|
@@ -46,19 +47,11 @@ import { Button } from './Button';
|
|
|
46
47
|
},
|
|
47
48
|
},
|
|
48
49
|
},
|
|
49
|
-
}
|
|
50
|
-
|
|
50
|
+
},
|
|
51
|
+
} as Meta;
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
export const Template = args => (
|
|
53
|
+
export const Basic: ComponentStory<typeof Button> = args => (
|
|
55
54
|
<Button {...args}>
|
|
56
55
|
<Facebook /> Like me
|
|
57
56
|
</Button>
|
|
58
57
|
);
|
|
59
|
-
|
|
60
|
-
<Canvas>
|
|
61
|
-
<Story name="Default">{Template.bind({})}</Story>
|
|
62
|
-
</Canvas>
|
|
63
|
-
|
|
64
|
-
<ArgsTable story="Default" />
|
|
@@ -5,18 +5,27 @@ import { Button } from './Button';
|
|
|
5
5
|
import { Facebook } from '@marigold/icons';
|
|
6
6
|
|
|
7
7
|
const theme = {
|
|
8
|
+
fonts: {
|
|
9
|
+
body: 'Arial',
|
|
10
|
+
fancy: 'Inter',
|
|
11
|
+
},
|
|
12
|
+
space: {
|
|
13
|
+
none: 0,
|
|
14
|
+
small: 2,
|
|
15
|
+
large: 16,
|
|
16
|
+
},
|
|
8
17
|
button: {
|
|
9
18
|
large: {
|
|
10
|
-
p: '
|
|
19
|
+
p: 'large',
|
|
11
20
|
},
|
|
12
21
|
small: {
|
|
13
|
-
p: '
|
|
22
|
+
p: 'large',
|
|
14
23
|
},
|
|
15
24
|
primary: {
|
|
16
|
-
fontFamily: '
|
|
25
|
+
fontFamily: 'fancy',
|
|
17
26
|
},
|
|
18
27
|
secondary: {
|
|
19
|
-
fontFamily: '
|
|
28
|
+
fontFamily: 'body',
|
|
20
29
|
},
|
|
21
30
|
},
|
|
22
31
|
};
|
|
@@ -29,7 +38,7 @@ test('supports default variant', () => {
|
|
|
29
38
|
);
|
|
30
39
|
const button = screen.getByText(/button/);
|
|
31
40
|
|
|
32
|
-
expect(button
|
|
41
|
+
expect(button).toHaveStyle(`font-family: Inter`);
|
|
33
42
|
});
|
|
34
43
|
|
|
35
44
|
test('supports default size', () => {
|
|
@@ -40,7 +49,7 @@ test('supports default size', () => {
|
|
|
40
49
|
);
|
|
41
50
|
const button = screen.getByText(/button/);
|
|
42
51
|
|
|
43
|
-
expect(button
|
|
52
|
+
expect(button).toHaveStyle(`padding: 16px`);
|
|
44
53
|
});
|
|
45
54
|
|
|
46
55
|
test('accepts other variant than default', () => {
|
|
@@ -51,7 +60,7 @@ test('accepts other variant than default', () => {
|
|
|
51
60
|
);
|
|
52
61
|
const button = screen.getByText(/button/);
|
|
53
62
|
|
|
54
|
-
expect(button
|
|
63
|
+
expect(button).toHaveStyle(`font-family: Arial`);
|
|
55
64
|
});
|
|
56
65
|
|
|
57
66
|
test('accepts other size than default', () => {
|
|
@@ -62,7 +71,7 @@ test('accepts other size than default', () => {
|
|
|
62
71
|
);
|
|
63
72
|
const button = screen.getByText(/button/);
|
|
64
73
|
|
|
65
|
-
expect(button
|
|
74
|
+
expect(button).toHaveStyle(`padding: 16px`);
|
|
66
75
|
});
|
|
67
76
|
|
|
68
77
|
test('renders <button> element', () => {
|
|
@@ -73,8 +82,7 @@ test('renders <button> element', () => {
|
|
|
73
82
|
);
|
|
74
83
|
const button = screen.getByText(/button/);
|
|
75
84
|
|
|
76
|
-
expect(button
|
|
77
|
-
expect(button instanceof HTMLSpanElement).toBeTruthy();
|
|
85
|
+
expect(button instanceof HTMLButtonElement).toBeTruthy();
|
|
78
86
|
});
|
|
79
87
|
|
|
80
88
|
test('accepts other button components', () => {
|
|
@@ -105,13 +113,28 @@ test('add icon in button works as expected', () => {
|
|
|
105
113
|
const button = screen.getByText(/iconbutton/);
|
|
106
114
|
const icon = screen.getByTitle(/facebook/);
|
|
107
115
|
|
|
108
|
-
expect(button instanceof
|
|
116
|
+
expect(button instanceof HTMLButtonElement).toBeTruthy();
|
|
109
117
|
expect(button).toHaveStyle('display: inline-flex');
|
|
110
118
|
expect(button.firstChild instanceof SVGElement).toBeTruthy();
|
|
111
119
|
expect(icon.getAttribute('fill')).toEqual('red');
|
|
112
120
|
expect(icon.getAttribute('width')).toEqual('30');
|
|
113
121
|
});
|
|
114
122
|
|
|
123
|
+
test('add space to button works as expected', () => {
|
|
124
|
+
render(
|
|
125
|
+
<ThemeProvider theme={theme}>
|
|
126
|
+
<Button title="iconbutton" space="small">
|
|
127
|
+
<Facebook fill="red" size={30} title="facebook" />
|
|
128
|
+
iconbutton
|
|
129
|
+
</Button>
|
|
130
|
+
</ThemeProvider>
|
|
131
|
+
);
|
|
132
|
+
const button = screen.getByTitle(/iconbutton/);
|
|
133
|
+
|
|
134
|
+
const style = window.getComputedStyle(button);
|
|
135
|
+
expect(style.columnGap).toBe(`2px`);
|
|
136
|
+
});
|
|
137
|
+
|
|
115
138
|
test('accepts custom styles prop className', () => {
|
|
116
139
|
render(
|
|
117
140
|
<ThemeProvider theme={theme}>
|
package/src/Button/Button.tsx
CHANGED
|
@@ -7,8 +7,20 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import { Box, BoxOwnProps } from '../Box';
|
|
9
9
|
|
|
10
|
+
// Theme Extension
|
|
11
|
+
// ---------------
|
|
12
|
+
export interface ButtonThemeExtension<Value> {
|
|
13
|
+
button?: {
|
|
14
|
+
[key: string]: Value;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Props
|
|
19
|
+
// ---------------
|
|
10
20
|
export type ButtonProps = PolymorphicPropsWithRef<BoxOwnProps, 'button'>;
|
|
11
21
|
|
|
22
|
+
// Component
|
|
23
|
+
// ---------------
|
|
12
24
|
export const Button: PolymorphicComponentWithRef<BoxOwnProps, 'button'> =
|
|
13
25
|
forwardRef(
|
|
14
26
|
(
|
|
@@ -16,6 +28,7 @@ export const Button: PolymorphicComponentWithRef<BoxOwnProps, 'button'> =
|
|
|
16
28
|
as = 'button',
|
|
17
29
|
variant = 'primary',
|
|
18
30
|
size = 'large',
|
|
31
|
+
space = 'none',
|
|
19
32
|
disabled,
|
|
20
33
|
children,
|
|
21
34
|
className,
|
|
@@ -37,13 +50,14 @@ export const Button: PolymorphicComponentWithRef<BoxOwnProps, 'button'> =
|
|
|
37
50
|
{...buttonProps}
|
|
38
51
|
{...props}
|
|
39
52
|
as={as}
|
|
53
|
+
display="inline-flex"
|
|
54
|
+
alignItems="center"
|
|
40
55
|
variant={[`button.${variant}`, `button.${size}`]}
|
|
41
56
|
className={className}
|
|
42
57
|
ref={ref}
|
|
58
|
+
css={{ columnGap: space }}
|
|
43
59
|
>
|
|
44
|
-
|
|
45
|
-
{children}
|
|
46
|
-
</Box>
|
|
60
|
+
{children}
|
|
47
61
|
</Box>
|
|
48
62
|
);
|
|
49
63
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
3
|
import { Card } from './Card';
|
|
4
4
|
import { Text } from '../Text';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
title
|
|
8
|
-
argTypes
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Card',
|
|
8
|
+
argTypes: {
|
|
9
9
|
variant: {
|
|
10
10
|
control: {
|
|
11
11
|
type: 'text',
|
|
12
12
|
},
|
|
13
13
|
table: {
|
|
14
14
|
defaultValue: {
|
|
15
|
-
summary: '
|
|
15
|
+
summary: '__default',
|
|
16
16
|
},
|
|
17
17
|
},
|
|
18
18
|
},
|
|
@@ -28,12 +28,10 @@ import { Text } from '../Text';
|
|
|
28
28
|
},
|
|
29
29
|
description: 'max width of the card',
|
|
30
30
|
},
|
|
31
|
-
}
|
|
32
|
-
|
|
31
|
+
},
|
|
32
|
+
} as Meta;
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
export const Template = args => (
|
|
34
|
+
export const Basic: ComponentStory<typeof Card> = args => (
|
|
37
35
|
<Card title="Card" {...args}>
|
|
38
36
|
<Text>
|
|
39
37
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
|
|
@@ -41,9 +39,3 @@ export const Template = args => (
|
|
|
41
39
|
</Text>
|
|
42
40
|
</Card>
|
|
43
41
|
);
|
|
44
|
-
|
|
45
|
-
<Canvas>
|
|
46
|
-
<Story name="Default">{Template.bind({})}</Story>
|
|
47
|
-
</Canvas>
|
|
48
|
-
|
|
49
|
-
<ArgsTable story="Default" />
|
package/src/Card/Card.test.tsx
CHANGED
|
@@ -5,12 +5,17 @@ import { ThemeProvider } from '@marigold/system';
|
|
|
5
5
|
import { Card } from './Card';
|
|
6
6
|
|
|
7
7
|
const theme = {
|
|
8
|
+
space: {
|
|
9
|
+
none: 0,
|
|
10
|
+
small: 4,
|
|
11
|
+
medium: 8,
|
|
12
|
+
},
|
|
8
13
|
card: {
|
|
9
|
-
|
|
10
|
-
p: '
|
|
14
|
+
__default: {
|
|
15
|
+
p: 'medium',
|
|
11
16
|
},
|
|
12
17
|
custom: {
|
|
13
|
-
p: '
|
|
18
|
+
p: 'small',
|
|
14
19
|
},
|
|
15
20
|
},
|
|
16
21
|
};
|
package/src/Card/Card.tsx
CHANGED
|
@@ -4,14 +4,26 @@ import { ComponentProps } from '@marigold/types';
|
|
|
4
4
|
|
|
5
5
|
import { Box } from '../Box';
|
|
6
6
|
|
|
7
|
+
// Theme Extension
|
|
8
|
+
// ---------------
|
|
9
|
+
export interface CardThemeExtension<Value> {
|
|
10
|
+
card?: {
|
|
11
|
+
[key: string]: Value;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Props
|
|
16
|
+
// ---------------
|
|
7
17
|
export type CardProps = {
|
|
8
18
|
title?: string;
|
|
9
19
|
width?: ResponsiveStyleValue<string>;
|
|
10
20
|
variant?: string;
|
|
11
21
|
} & ComponentProps<'div'>;
|
|
12
22
|
|
|
23
|
+
// Component
|
|
24
|
+
// ---------------
|
|
13
25
|
export const Card: React.FC<CardProps> = ({
|
|
14
|
-
variant = '
|
|
26
|
+
variant = '',
|
|
15
27
|
title,
|
|
16
28
|
width,
|
|
17
29
|
className,
|
|
@@ -28,6 +28,17 @@ import { useState } from 'react';
|
|
|
28
28
|
},
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
|
+
labelVariant: {
|
|
32
|
+
control: {
|
|
33
|
+
type: 'text',
|
|
34
|
+
},
|
|
35
|
+
description: 'Checkbox label variant',
|
|
36
|
+
table: {
|
|
37
|
+
defaultValue: {
|
|
38
|
+
summary: 'inline',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
31
42
|
label: {
|
|
32
43
|
control: {
|
|
33
44
|
type: 'text',
|