@marigold/components 0.3.3 → 0.4.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 +19 -0
- package/dist/index.d.ts +364 -32
- package/dist/index.js +1421 -5
- package/dist/index.mjs +1369 -0
- package/package.json +29 -10
- package/dist/ActionGroup/ActionGroup.d.ts +0 -8
- package/dist/ActionGroup/ActionGroup.stories.d.ts +0 -5
- package/dist/ActionGroup/index.d.ts +0 -1
- package/dist/Alert/Alert.d.ts +0 -27
- package/dist/Alert/Alert.stories.d.ts +0 -5
- package/dist/Alert/index.d.ts +0 -1
- package/dist/Badge/Badge.d.ts +0 -13
- package/dist/Badge/Badge.stories.d.ts +0 -5
- package/dist/Badge/index.d.ts +0 -1
- package/dist/Box.d.ts +0 -2
- package/dist/Button/Button.d.ts +0 -9
- package/dist/Button/Button.stories.d.ts +0 -5
- package/dist/Button/index.d.ts +0 -1
- package/dist/Card/Card.d.ts +0 -14
- package/dist/Card/Card.stories.d.ts +0 -5
- package/dist/Card/index.d.ts +0 -1
- package/dist/Checkbox/Checkbox.d.ts +0 -20
- package/dist/Checkbox/Checkbox.stories.d.ts +0 -5
- package/dist/Checkbox/CheckboxIcons.d.ts +0 -9
- package/dist/Checkbox/index.d.ts +0 -1
- package/dist/Column/Column.d.ts +0 -8
- package/dist/Column/Column.stories.d.ts +0 -5
- package/dist/Column/index.d.ts +0 -1
- package/dist/Columns/Columns.d.ts +0 -10
- package/dist/Columns/Columns.stories.d.ts +0 -5
- package/dist/Columns/index.d.ts +0 -1
- package/dist/Container/Container.d.ts +0 -6
- package/dist/Container/Container.stories.d.ts +0 -5
- package/dist/Container/index.d.ts +0 -1
- package/dist/Dialog/Dialog.d.ts +0 -17
- package/dist/Dialog/Dialog.stories.d.ts +0 -5
- package/dist/Dialog/ModalDialog.d.ts +0 -8
- package/dist/Dialog/index.d.ts +0 -1
- package/dist/Divider/Divider.d.ts +0 -11
- package/dist/Divider/Divider.stories.d.ts +0 -5
- package/dist/Divider/index.d.ts +0 -1
- package/dist/Field/Field.d.ts +0 -13
- package/dist/Field/Field.stories.d.ts +0 -5
- package/dist/Field/index.d.ts +0 -1
- package/dist/Image/Image.d.ts +0 -12
- package/dist/Image/Image.stories.d.ts +0 -5
- package/dist/Image/index.d.ts +0 -1
- package/dist/Inline/Inline.d.ts +0 -7
- package/dist/Inline/Inline.stories.d.ts +0 -5
- package/dist/Inline/index.d.ts +0 -1
- package/dist/Input/Input.d.ts +0 -11
- package/dist/Input/Input.stories.d.ts +0 -5
- package/dist/Input/index.d.ts +0 -1
- package/dist/Label/Label.d.ts +0 -19
- package/dist/Label/Label.stories.d.ts +0 -5
- package/dist/Label/index.d.ts +0 -1
- package/dist/Link/Link.d.ts +0 -10
- package/dist/Link/Link.stories.d.ts +0 -5
- package/dist/Link/index.d.ts +0 -1
- package/dist/Menu/Menu.d.ts +0 -15
- package/dist/Menu/Menu.stories.d.ts +0 -5
- package/dist/Menu/index.d.ts +0 -1
- package/dist/MenuItem/MenuItem.d.ts +0 -12
- package/dist/MenuItem/MenuItem.stories.d.ts +0 -5
- package/dist/MenuItem/index.d.ts +0 -1
- package/dist/Message/Message.d.ts +0 -12
- package/dist/Message/Message.stories.d.ts +0 -5
- package/dist/Message/index.d.ts +0 -1
- package/dist/Provider/MarigoldProvider.d.ts +0 -11
- package/dist/Provider/index.d.ts +0 -3
- package/dist/Radio/Radio.d.ts +0 -19
- package/dist/Radio/Radio.stories.d.ts +0 -5
- package/dist/Radio/RadioIcon.d.ts +0 -9
- package/dist/Radio/index.d.ts +0 -1
- package/dist/Select/ListBox.d.ts +0 -9
- package/dist/Select/ListBoxSection.d.ts +0 -9
- package/dist/Select/Option.d.ts +0 -9
- package/dist/Select/Popover.d.ts +0 -9
- package/dist/Select/Select.d.ts +0 -27
- package/dist/Select/Select.stories.d.ts +0 -5
- package/dist/Select/index.d.ts +0 -1
- package/dist/Slider/Slider.d.ts +0 -11
- package/dist/Slider/Slider.stories.d.ts +0 -5
- package/dist/Slider/index.d.ts +0 -1
- package/dist/Stack/Stack.d.ts +0 -7
- package/dist/Stack/Stack.stories.d.ts +0 -5
- package/dist/Stack/index.d.ts +0 -1
- package/dist/Text/Text.d.ts +0 -17
- package/dist/Text/Text.stories.d.ts +0 -5
- package/dist/Text/index.d.ts +0 -1
- package/dist/Textarea/Textarea.d.ts +0 -16
- package/dist/Textarea/Textarea.stories.d.ts +0 -5
- package/dist/Textarea/index.d.ts +0 -1
- package/dist/ValidationMessage/ValidationMessage.d.ts +0 -11
- package/dist/ValidationMessage/ValidationMessage.stories.d.ts +0 -5
- package/dist/ValidationMessage/index.d.ts +0 -1
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +0 -1
- package/dist/VisuallyHidden/VisuallyHidden.stories.d.ts +0 -5
- package/dist/VisuallyHidden/index.d.ts +0 -1
- package/dist/components.cjs.development.js +0 -1394
- package/dist/components.cjs.development.js.map +0 -1
- package/dist/components.cjs.production.min.js +0 -2
- package/dist/components.cjs.production.min.js.map +0 -1
- package/dist/components.esm.js +0 -1320
- package/dist/components.esm.js.map +0 -1
- package/dist/theme.d.ts +0 -23
- package/src/ActionGroup/ActionGroup.stories.tsx +0 -47
- package/src/ActionGroup/ActionGroup.test.tsx +0 -83
- package/src/ActionGroup/ActionGroup.tsx +0 -32
- package/src/ActionGroup/index.ts +0 -1
- package/src/Alert/Alert.stories.tsx +0 -32
- package/src/Alert/Alert.test.tsx +0 -82
- package/src/Alert/Alert.tsx +0 -52
- package/src/Alert/index.ts +0 -1
- package/src/Badge/Badge.stories.tsx +0 -38
- package/src/Badge/Badge.test.tsx +0 -65
- package/src/Badge/Badge.tsx +0 -37
- package/src/Badge/index.ts +0 -1
- package/src/Box.ts +0 -2
- package/src/Button/Button.stories.tsx +0 -57
- package/src/Button/Button.test.tsx +0 -149
- package/src/Button/Button.tsx +0 -64
- package/src/Button/index.ts +0 -1
- package/src/Card/Card.stories.tsx +0 -41
- package/src/Card/Card.test.tsx +0 -71
- package/src/Card/Card.tsx +0 -48
- package/src/Card/index.ts +0 -1
- package/src/Checkbox/Checkbox.stories.tsx +0 -78
- package/src/Checkbox/Checkbox.test.tsx +0 -166
- package/src/Checkbox/Checkbox.tsx +0 -101
- package/src/Checkbox/CheckboxIcons.tsx +0 -59
- package/src/Checkbox/index.ts +0 -1
- package/src/Column/Column.stories.tsx +0 -33
- package/src/Column/Column.test.tsx +0 -32
- package/src/Column/Column.tsx +0 -27
- package/src/Column/index.ts +0 -1
- package/src/Columns/Columns.stories.tsx +0 -75
- package/src/Columns/Columns.test.tsx +0 -113
- package/src/Columns/Columns.tsx +0 -69
- package/src/Columns/index.ts +0 -1
- package/src/Container/Container.stories.tsx +0 -14
- package/src/Container/Container.test.tsx +0 -26
- package/src/Container/Container.tsx +0 -13
- package/src/Container/index.ts +0 -1
- package/src/Dialog/Dialog.stories.tsx +0 -88
- package/src/Dialog/Dialog.test.tsx +0 -158
- package/src/Dialog/Dialog.tsx +0 -130
- package/src/Dialog/ModalDialog.tsx +0 -76
- package/src/Dialog/index.ts +0 -1
- package/src/Divider/Divider.stories.tsx +0 -30
- package/src/Divider/Divider.test.tsx +0 -72
- package/src/Divider/Divider.tsx +0 -33
- package/src/Divider/index.ts +0 -1
- package/src/Field/Field.stories.tsx +0 -110
- package/src/Field/Field.test.tsx +0 -130
- package/src/Field/Field.tsx +0 -56
- package/src/Field/index.ts +0 -1
- package/src/Image/Image.stories.tsx +0 -34
- package/src/Image/Image.test.tsx +0 -73
- package/src/Image/Image.tsx +0 -25
- package/src/Image/index.ts +0 -1
- package/src/Inline/Inline.stories.tsx +0 -39
- package/src/Inline/Inline.test.tsx +0 -99
- package/src/Inline/Inline.tsx +0 -38
- package/src/Inline/index.ts +0 -1
- package/src/Input/Input.stories.tsx +0 -54
- package/src/Input/Input.test.tsx +0 -74
- package/src/Input/Input.tsx +0 -25
- package/src/Input/index.ts +0 -1
- package/src/Label/Label.stories.tsx +0 -41
- package/src/Label/Label.test.tsx +0 -109
- package/src/Label/Label.tsx +0 -64
- package/src/Label/index.ts +0 -1
- package/src/Link/Link.stories.tsx +0 -35
- package/src/Link/Link.test.tsx +0 -97
- package/src/Link/Link.tsx +0 -43
- package/src/Link/index.ts +0 -1
- package/src/Menu/Menu.stories.tsx +0 -62
- package/src/Menu/Menu.test.tsx +0 -84
- package/src/Menu/Menu.tsx +0 -51
- package/src/Menu/index.ts +0 -1
- package/src/MenuItem/MenuItem.stories.tsx +0 -30
- package/src/MenuItem/MenuItem.test.tsx +0 -68
- package/src/MenuItem/MenuItem.tsx +0 -35
- package/src/MenuItem/index.ts +0 -1
- package/src/Message/Message.stories.tsx +0 -30
- package/src/Message/Message.test.tsx +0 -90
- package/src/Message/Message.tsx +0 -55
- package/src/Message/index.ts +0 -1
- package/src/Provider/MarigoldProvider.test.tsx +0 -136
- package/src/Provider/MarigoldProvider.tsx +0 -47
- package/src/Provider/index.ts +0 -4
- package/src/Radio/Radio.stories.tsx +0 -78
- package/src/Radio/Radio.test.tsx +0 -154
- package/src/Radio/Radio.tsx +0 -88
- package/src/Radio/RadioIcon.tsx +0 -49
- package/src/Radio/index.ts +0 -1
- package/src/Select/ListBox.tsx +0 -40
- package/src/Select/ListBoxSection.tsx +0 -40
- package/src/Select/Option.tsx +0 -48
- package/src/Select/Popover.tsx +0 -50
- package/src/Select/Select.stories.tsx +0 -81
- package/src/Select/Select.test.tsx +0 -349
- package/src/Select/Select.tsx +0 -174
- package/src/Select/index.ts +0 -1
- package/src/Slider/Slider.stories.tsx +0 -24
- package/src/Slider/Slider.test.tsx +0 -63
- package/src/Slider/Slider.tsx +0 -35
- package/src/Slider/index.ts +0 -1
- package/src/Stack/Stack.stories.tsx +0 -57
- package/src/Stack/Stack.test.tsx +0 -138
- package/src/Stack/Stack.tsx +0 -39
- package/src/Stack/index.ts +0 -1
- package/src/Text/Text.stories.tsx +0 -61
- package/src/Text/Text.test.tsx +0 -99
- package/src/Text/Text.tsx +0 -60
- package/src/Text/index.ts +0 -1
- package/src/Textarea/Textarea.stories.tsx +0 -64
- package/src/Textarea/Textarea.test.tsx +0 -95
- package/src/Textarea/Textarea.tsx +0 -62
- package/src/Textarea/index.ts +0 -1
- package/src/ValidationMessage/ValidationMessage.stories.tsx +0 -27
- package/src/ValidationMessage/ValidationMessage.test.tsx +0 -68
- package/src/ValidationMessage/ValidationMessage.tsx +0 -40
- package/src/ValidationMessage/index.ts +0 -1
- package/src/VisuallyHidden/VisuallyHidden.stories.tsx +0 -19
- package/src/VisuallyHidden/VisuallyHidden.test.tsx +0 -10
- package/src/VisuallyHidden/VisuallyHidden.tsx +0 -1
- package/src/VisuallyHidden/index.ts +0 -1
- package/src/index.ts +0 -34
- package/src/theme.ts +0 -50
- package/tsconfig.build.json +0 -3
package/src/Badge/Badge.test.tsx
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { ThemeProvider } from '@marigold/system';
|
|
4
|
-
import { Badge } from './Badge';
|
|
5
|
-
|
|
6
|
-
const theme = {
|
|
7
|
-
radii: {
|
|
8
|
-
none: 0,
|
|
9
|
-
larger: 8,
|
|
10
|
-
},
|
|
11
|
-
badge: {
|
|
12
|
-
__default: {
|
|
13
|
-
borderRadius: '8px',
|
|
14
|
-
},
|
|
15
|
-
fatBadge: {
|
|
16
|
-
borderRadius: '12px',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
test('supports default variant and themeSection', () => {
|
|
22
|
-
render(
|
|
23
|
-
<ThemeProvider theme={theme}>
|
|
24
|
-
<Badge title="badge" />
|
|
25
|
-
</ThemeProvider>
|
|
26
|
-
);
|
|
27
|
-
const badge = screen.getByTitle(/badge/);
|
|
28
|
-
|
|
29
|
-
expect(badge).toHaveStyle(`border-radius: 8px;`);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('renders correct HTML element', () => {
|
|
33
|
-
render(
|
|
34
|
-
<ThemeProvider theme={theme}>
|
|
35
|
-
<Badge title="badge" />
|
|
36
|
-
</ThemeProvider>
|
|
37
|
-
);
|
|
38
|
-
const badge = screen.getByTitle(/badge/);
|
|
39
|
-
|
|
40
|
-
expect(badge instanceof HTMLDivElement).toBeTruthy();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('supports other variant than default', () => {
|
|
44
|
-
render(
|
|
45
|
-
<ThemeProvider theme={theme}>
|
|
46
|
-
<Badge variant="fatBadge" title="badge" />
|
|
47
|
-
</ThemeProvider>
|
|
48
|
-
);
|
|
49
|
-
const badge = screen.getByTitle(/badge/);
|
|
50
|
-
|
|
51
|
-
expect(badge).toHaveStyle(`border-radius: 12px;`);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('accepts custom styles prop className', () => {
|
|
55
|
-
render(
|
|
56
|
-
<ThemeProvider theme={theme}>
|
|
57
|
-
<Badge className="custom-class-name" title="badge">
|
|
58
|
-
badge
|
|
59
|
-
</Badge>
|
|
60
|
-
</ThemeProvider>
|
|
61
|
-
);
|
|
62
|
-
const badge = screen.getByTitle(/badge/);
|
|
63
|
-
|
|
64
|
-
expect(badge.className).toMatch('custom-class-name');
|
|
65
|
-
});
|
package/src/Badge/Badge.tsx
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ComponentProps } from '@marigold/types';
|
|
3
|
-
import { Box } from '../Box';
|
|
4
|
-
|
|
5
|
-
// Theme Extension
|
|
6
|
-
// ---------------
|
|
7
|
-
export interface BadgeThemeExtension<Value> {
|
|
8
|
-
badge?: {
|
|
9
|
-
[key: string]: Value;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Props
|
|
14
|
-
// ---------------
|
|
15
|
-
export type BadgeProps = {
|
|
16
|
-
variant?: string;
|
|
17
|
-
bgColor?: string;
|
|
18
|
-
borderColor?: string;
|
|
19
|
-
} & ComponentProps<'div'>;
|
|
20
|
-
|
|
21
|
-
// Component
|
|
22
|
-
// ---------------
|
|
23
|
-
export const Badge: React.FC<BadgeProps> = ({
|
|
24
|
-
variant = '',
|
|
25
|
-
bgColor = 'transparent',
|
|
26
|
-
borderColor = 'transparent',
|
|
27
|
-
children,
|
|
28
|
-
...props
|
|
29
|
-
}) => (
|
|
30
|
-
<Box
|
|
31
|
-
css={{ bg: bgColor, borderColor: borderColor }}
|
|
32
|
-
variant={`badge.${variant}`}
|
|
33
|
-
{...props}
|
|
34
|
-
>
|
|
35
|
-
{children}
|
|
36
|
-
</Box>
|
|
37
|
-
);
|
package/src/Badge/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Badge';
|
package/src/Box.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Facebook } from '@marigold/icons';
|
|
4
|
-
import { Button } from './Button';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Components/Button',
|
|
8
|
-
parameters: {
|
|
9
|
-
actions: {
|
|
10
|
-
handles: ['click'],
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
argTypes: {
|
|
14
|
-
variant: {
|
|
15
|
-
control: {
|
|
16
|
-
type: 'select',
|
|
17
|
-
},
|
|
18
|
-
options: ['primary', 'secondary', 'ghost', 'text', 'menu', 'select'],
|
|
19
|
-
description: 'What the button looks like',
|
|
20
|
-
table: {
|
|
21
|
-
defaultValue: {
|
|
22
|
-
summary: 'primary',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
size: {
|
|
27
|
-
control: {
|
|
28
|
-
type: 'select',
|
|
29
|
-
},
|
|
30
|
-
options: ['large', 'small'],
|
|
31
|
-
description: 'How big the button is rendered',
|
|
32
|
-
table: {
|
|
33
|
-
defaultValue: {
|
|
34
|
-
summary: 'large',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
disabled: {
|
|
39
|
-
control: {
|
|
40
|
-
type: 'boolean',
|
|
41
|
-
},
|
|
42
|
-
options: [true, false],
|
|
43
|
-
description: 'Disable the button',
|
|
44
|
-
table: {
|
|
45
|
-
defaultValue: {
|
|
46
|
-
summary: 'false',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
} as Meta;
|
|
52
|
-
|
|
53
|
-
export const Basic: ComponentStory<typeof Button> = args => (
|
|
54
|
-
<Button {...args}>
|
|
55
|
-
<Facebook /> Like me
|
|
56
|
-
</Button>
|
|
57
|
-
);
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { ThemeProvider } from '@marigold/system';
|
|
4
|
-
import { Button } from './Button';
|
|
5
|
-
import { Facebook } from '@marigold/icons';
|
|
6
|
-
|
|
7
|
-
const theme = {
|
|
8
|
-
fonts: {
|
|
9
|
-
body: 'Arial',
|
|
10
|
-
fancy: 'Inter',
|
|
11
|
-
},
|
|
12
|
-
space: {
|
|
13
|
-
none: 0,
|
|
14
|
-
small: 2,
|
|
15
|
-
large: 16,
|
|
16
|
-
},
|
|
17
|
-
button: {
|
|
18
|
-
large: {
|
|
19
|
-
p: 'large',
|
|
20
|
-
},
|
|
21
|
-
small: {
|
|
22
|
-
p: 'large',
|
|
23
|
-
},
|
|
24
|
-
primary: {
|
|
25
|
-
fontFamily: 'fancy',
|
|
26
|
-
},
|
|
27
|
-
secondary: {
|
|
28
|
-
fontFamily: 'body',
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
test('supports default variant', () => {
|
|
34
|
-
render(
|
|
35
|
-
<ThemeProvider theme={theme}>
|
|
36
|
-
<Button>button</Button>
|
|
37
|
-
</ThemeProvider>
|
|
38
|
-
);
|
|
39
|
-
const button = screen.getByText(/button/);
|
|
40
|
-
|
|
41
|
-
expect(button).toHaveStyle(`font-family: Inter`);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('supports default size', () => {
|
|
45
|
-
render(
|
|
46
|
-
<ThemeProvider theme={theme}>
|
|
47
|
-
<Button>button</Button>
|
|
48
|
-
</ThemeProvider>
|
|
49
|
-
);
|
|
50
|
-
const button = screen.getByText(/button/);
|
|
51
|
-
|
|
52
|
-
expect(button).toHaveStyle(`padding: 16px`);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('accepts other variant than default', () => {
|
|
56
|
-
render(
|
|
57
|
-
<ThemeProvider theme={theme}>
|
|
58
|
-
<Button variant="secondary">button</Button>
|
|
59
|
-
</ThemeProvider>
|
|
60
|
-
);
|
|
61
|
-
const button = screen.getByText(/button/);
|
|
62
|
-
|
|
63
|
-
expect(button).toHaveStyle(`font-family: Arial`);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
test('accepts other size than default', () => {
|
|
67
|
-
render(
|
|
68
|
-
<ThemeProvider theme={theme}>
|
|
69
|
-
<Button size="small">button</Button>
|
|
70
|
-
</ThemeProvider>
|
|
71
|
-
);
|
|
72
|
-
const button = screen.getByText(/button/);
|
|
73
|
-
|
|
74
|
-
expect(button).toHaveStyle(`padding: 16px`);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
test('renders <button> element', () => {
|
|
78
|
-
render(
|
|
79
|
-
<ThemeProvider theme={theme}>
|
|
80
|
-
<Button>button</Button>
|
|
81
|
-
</ThemeProvider>
|
|
82
|
-
);
|
|
83
|
-
const button = screen.getByText(/button/);
|
|
84
|
-
|
|
85
|
-
expect(button instanceof HTMLButtonElement).toBeTruthy();
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test('accepts other button components', () => {
|
|
89
|
-
const CustomButton = React.forwardRef<
|
|
90
|
-
HTMLSpanElement,
|
|
91
|
-
{ children?: React.ReactNode }
|
|
92
|
-
>(() => <span>I am a Button!</span>);
|
|
93
|
-
|
|
94
|
-
render(
|
|
95
|
-
<ThemeProvider theme={theme}>
|
|
96
|
-
<Button as={CustomButton}>Button</Button>
|
|
97
|
-
</ThemeProvider>
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
const button = screen.getByText('I am a Button!');
|
|
101
|
-
expect(button).toBeTruthy();
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
test('add icon in button works as expected', () => {
|
|
105
|
-
render(
|
|
106
|
-
<ThemeProvider theme={theme}>
|
|
107
|
-
<Button>
|
|
108
|
-
<Facebook fill="red" size={30} title="facebook" />
|
|
109
|
-
iconbutton
|
|
110
|
-
</Button>
|
|
111
|
-
</ThemeProvider>
|
|
112
|
-
);
|
|
113
|
-
const button = screen.getByText(/iconbutton/);
|
|
114
|
-
const icon = screen.getByTitle(/facebook/);
|
|
115
|
-
|
|
116
|
-
expect(button instanceof HTMLButtonElement).toBeTruthy();
|
|
117
|
-
expect(button).toHaveStyle('display: inline-flex');
|
|
118
|
-
expect(button.firstChild instanceof SVGElement).toBeTruthy();
|
|
119
|
-
expect(icon.getAttribute('fill')).toEqual('red');
|
|
120
|
-
expect(icon.getAttribute('width')).toEqual('30');
|
|
121
|
-
});
|
|
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
|
-
|
|
138
|
-
test('accepts custom styles prop className', () => {
|
|
139
|
-
render(
|
|
140
|
-
<ThemeProvider theme={theme}>
|
|
141
|
-
<Button className="custom-class-name" title="button">
|
|
142
|
-
click
|
|
143
|
-
</Button>
|
|
144
|
-
</ThemeProvider>
|
|
145
|
-
);
|
|
146
|
-
const button = screen.getByTitle(/button/);
|
|
147
|
-
|
|
148
|
-
expect(button.className).toMatch('custom-class-name');
|
|
149
|
-
});
|
package/src/Button/Button.tsx
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, RefObject } from 'react';
|
|
2
|
-
import { useButton } from '@react-aria/button';
|
|
3
|
-
import {
|
|
4
|
-
PolymorphicComponentWithRef,
|
|
5
|
-
PolymorphicPropsWithRef,
|
|
6
|
-
} from '@marigold/types';
|
|
7
|
-
|
|
8
|
-
import { Box, BoxOwnProps } from '../Box';
|
|
9
|
-
|
|
10
|
-
// Theme Extension
|
|
11
|
-
// ---------------
|
|
12
|
-
export interface ButtonThemeExtension<Value> {
|
|
13
|
-
button?: {
|
|
14
|
-
[key: string]: Value;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Props
|
|
19
|
-
// ---------------
|
|
20
|
-
export type ButtonProps = PolymorphicPropsWithRef<BoxOwnProps, 'button'>;
|
|
21
|
-
|
|
22
|
-
// Component
|
|
23
|
-
// ---------------
|
|
24
|
-
export const Button: PolymorphicComponentWithRef<BoxOwnProps, 'button'> =
|
|
25
|
-
forwardRef(
|
|
26
|
-
(
|
|
27
|
-
{
|
|
28
|
-
as = 'button',
|
|
29
|
-
variant = 'primary',
|
|
30
|
-
size = 'large',
|
|
31
|
-
space = 'none',
|
|
32
|
-
disabled,
|
|
33
|
-
children,
|
|
34
|
-
className,
|
|
35
|
-
...props
|
|
36
|
-
},
|
|
37
|
-
ref
|
|
38
|
-
) => {
|
|
39
|
-
const { buttonProps } = useButton(
|
|
40
|
-
{
|
|
41
|
-
...props,
|
|
42
|
-
elementType: typeof as === 'string' ? as : 'span',
|
|
43
|
-
isDisabled: disabled,
|
|
44
|
-
},
|
|
45
|
-
ref as RefObject<HTMLSpanElement>
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<Box
|
|
50
|
-
{...buttonProps}
|
|
51
|
-
{...props}
|
|
52
|
-
as={as}
|
|
53
|
-
display="inline-flex"
|
|
54
|
-
alignItems="center"
|
|
55
|
-
variant={[`button.${variant}`, `button.${size}`]}
|
|
56
|
-
className={className}
|
|
57
|
-
ref={ref}
|
|
58
|
-
css={{ columnGap: space }}
|
|
59
|
-
>
|
|
60
|
-
{children}
|
|
61
|
-
</Box>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
);
|
package/src/Button/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Button';
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Card } from './Card';
|
|
4
|
-
import { Text } from '../Text';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Components/Card',
|
|
8
|
-
argTypes: {
|
|
9
|
-
variant: {
|
|
10
|
-
control: {
|
|
11
|
-
type: 'text',
|
|
12
|
-
},
|
|
13
|
-
table: {
|
|
14
|
-
defaultValue: {
|
|
15
|
-
summary: '__default',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
title: {
|
|
20
|
-
control: {
|
|
21
|
-
type: 'text',
|
|
22
|
-
},
|
|
23
|
-
description: 'card title',
|
|
24
|
-
},
|
|
25
|
-
width: {
|
|
26
|
-
control: {
|
|
27
|
-
type: 'text',
|
|
28
|
-
},
|
|
29
|
-
description: 'max width of the card',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
} as Meta;
|
|
33
|
-
|
|
34
|
-
export const Basic: ComponentStory<typeof Card> = args => (
|
|
35
|
-
<Card title="Card" {...args}>
|
|
36
|
-
<Text>
|
|
37
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
|
|
38
|
-
dignissim dapibus elit.
|
|
39
|
-
</Text>
|
|
40
|
-
</Card>
|
|
41
|
-
);
|
package/src/Card/Card.test.tsx
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { ThemeProvider } from '@marigold/system';
|
|
4
|
-
|
|
5
|
-
import { Card } from './Card';
|
|
6
|
-
|
|
7
|
-
const theme = {
|
|
8
|
-
space: {
|
|
9
|
-
none: 0,
|
|
10
|
-
small: 4,
|
|
11
|
-
medium: 8,
|
|
12
|
-
},
|
|
13
|
-
card: {
|
|
14
|
-
__default: {
|
|
15
|
-
p: 'medium',
|
|
16
|
-
},
|
|
17
|
-
custom: {
|
|
18
|
-
p: 'small',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
test('supports default variant', () => {
|
|
24
|
-
render(
|
|
25
|
-
<ThemeProvider theme={theme}>
|
|
26
|
-
<Card>card</Card>
|
|
27
|
-
</ThemeProvider>
|
|
28
|
-
);
|
|
29
|
-
const card = screen.getByText(/card/);
|
|
30
|
-
expect(card).toHaveStyle(`padding: 8px`);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('supports other variant than default', () => {
|
|
34
|
-
render(
|
|
35
|
-
<ThemeProvider theme={theme}>
|
|
36
|
-
<Card variant="custom">card</Card>
|
|
37
|
-
</ThemeProvider>
|
|
38
|
-
);
|
|
39
|
-
const card = screen.getByText(/card/);
|
|
40
|
-
expect(card).toHaveStyle(`padding: 4px`);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('accepts title prop', () => {
|
|
44
|
-
render(
|
|
45
|
-
<ThemeProvider theme={theme}>
|
|
46
|
-
<Card title="title">content</Card>
|
|
47
|
-
</ThemeProvider>
|
|
48
|
-
);
|
|
49
|
-
const title = screen.getByText(/title/);
|
|
50
|
-
expect(title).toBeDefined();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('accepts width prop', () => {
|
|
54
|
-
render(
|
|
55
|
-
<ThemeProvider theme={theme}>
|
|
56
|
-
<Card width="320px">content</Card>
|
|
57
|
-
</ThemeProvider>
|
|
58
|
-
);
|
|
59
|
-
const card = screen.getByText(/content/);
|
|
60
|
-
expect(card).toHaveStyle(`maxWidth: 320px`);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
test('renders correct HTMl element', () => {
|
|
64
|
-
render(
|
|
65
|
-
<ThemeProvider theme={theme}>
|
|
66
|
-
<Card>card</Card>
|
|
67
|
-
</ThemeProvider>
|
|
68
|
-
);
|
|
69
|
-
const card = screen.getByText(/card/);
|
|
70
|
-
expect(card instanceof HTMLDivElement).toBeTruthy();
|
|
71
|
-
});
|
package/src/Card/Card.tsx
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ResponsiveStyleValue } from '@marigold/system';
|
|
3
|
-
import { ComponentProps } from '@marigold/types';
|
|
4
|
-
|
|
5
|
-
import { Box } from '../Box';
|
|
6
|
-
|
|
7
|
-
// Theme Extension
|
|
8
|
-
// ---------------
|
|
9
|
-
export interface CardThemeExtension<Value> {
|
|
10
|
-
card?: {
|
|
11
|
-
[key: string]: Value;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Props
|
|
16
|
-
// ---------------
|
|
17
|
-
export type CardProps = {
|
|
18
|
-
title?: string;
|
|
19
|
-
width?: ResponsiveStyleValue<string>;
|
|
20
|
-
variant?: string;
|
|
21
|
-
} & ComponentProps<'div'>;
|
|
22
|
-
|
|
23
|
-
// Component
|
|
24
|
-
// ---------------
|
|
25
|
-
export const Card: React.FC<CardProps> = ({
|
|
26
|
-
variant = '',
|
|
27
|
-
title,
|
|
28
|
-
width,
|
|
29
|
-
className,
|
|
30
|
-
children,
|
|
31
|
-
...props
|
|
32
|
-
}) => {
|
|
33
|
-
return (
|
|
34
|
-
<Box
|
|
35
|
-
{...props}
|
|
36
|
-
variant={`card.${variant}`}
|
|
37
|
-
maxWidth={width}
|
|
38
|
-
className={className}
|
|
39
|
-
>
|
|
40
|
-
{title && (
|
|
41
|
-
<Box as="h2" variant="text.h2" pb="small">
|
|
42
|
-
{title}
|
|
43
|
-
</Box>
|
|
44
|
-
)}
|
|
45
|
-
{children}
|
|
46
|
-
</Box>
|
|
47
|
-
);
|
|
48
|
-
};
|
package/src/Card/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Card';
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
-
|
|
4
|
-
import { Checkbox } from './Checkbox';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Components/Checkbox',
|
|
8
|
-
parameters: {
|
|
9
|
-
actions: {
|
|
10
|
-
handles: ['click'],
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
argTypes: {
|
|
14
|
-
variant: {
|
|
15
|
-
control: {
|
|
16
|
-
type: 'text',
|
|
17
|
-
},
|
|
18
|
-
description: 'Checkbox variant',
|
|
19
|
-
defaultValue: '__default',
|
|
20
|
-
},
|
|
21
|
-
labelVariant: {
|
|
22
|
-
control: {
|
|
23
|
-
type: 'text',
|
|
24
|
-
},
|
|
25
|
-
description: 'Checkbox label variant',
|
|
26
|
-
defaultValue: 'inline',
|
|
27
|
-
},
|
|
28
|
-
label: {
|
|
29
|
-
control: {
|
|
30
|
-
type: 'text',
|
|
31
|
-
},
|
|
32
|
-
description: 'Label',
|
|
33
|
-
defaultValue: 'Checkbox Label',
|
|
34
|
-
},
|
|
35
|
-
required: {
|
|
36
|
-
control: {
|
|
37
|
-
type: 'boolean',
|
|
38
|
-
},
|
|
39
|
-
description: 'Required',
|
|
40
|
-
defaultValue: false,
|
|
41
|
-
},
|
|
42
|
-
disabled: {
|
|
43
|
-
control: {
|
|
44
|
-
type: 'boolean',
|
|
45
|
-
},
|
|
46
|
-
description: 'Disabled',
|
|
47
|
-
defaultValue: false,
|
|
48
|
-
},
|
|
49
|
-
error: {
|
|
50
|
-
control: {
|
|
51
|
-
type: 'boolean',
|
|
52
|
-
},
|
|
53
|
-
description: 'Error',
|
|
54
|
-
defaultValue: false,
|
|
55
|
-
},
|
|
56
|
-
errorMessage: {
|
|
57
|
-
control: {
|
|
58
|
-
type: 'text',
|
|
59
|
-
},
|
|
60
|
-
description: 'Error Message',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
} as Meta;
|
|
64
|
-
|
|
65
|
-
export const Basic: ComponentStory<typeof Checkbox> = ({
|
|
66
|
-
onChange,
|
|
67
|
-
checked,
|
|
68
|
-
...args
|
|
69
|
-
}) => {
|
|
70
|
-
const [isChecked, setChecked] = useState(false);
|
|
71
|
-
return (
|
|
72
|
-
<Checkbox
|
|
73
|
-
onChange={() => setChecked(!isChecked)}
|
|
74
|
-
checked={isChecked}
|
|
75
|
-
{...args}
|
|
76
|
-
/>
|
|
77
|
-
);
|
|
78
|
-
};
|