@marigold/components 0.3.0 → 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 +66 -161
- package/dist/index.d.ts +364 -32
- package/dist/index.js +1421 -5
- package/dist/index.mjs +1369 -0
- package/package.json +31 -11
- 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 -18
- 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 -12
- 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 -21
- package/dist/Radio/RadioIcons.d.ts +0 -10
- 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 -1422
- 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 -1348
- 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.mdx +0 -97
- 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 -71
- package/src/Divider/Divider.tsx +0 -25
- 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 -42
- 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.mdx +0 -97
- package/src/Radio/Radio.test.tsx +0 -119
- package/src/Radio/Radio.tsx +0 -128
- package/src/Radio/RadioIcons.tsx +0 -39
- 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/Input/Input.test.tsx
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { ThemeProvider } from '@marigold/system';
|
|
4
|
-
import { Input } from './Input';
|
|
5
|
-
|
|
6
|
-
const theme = {
|
|
7
|
-
fonts: {
|
|
8
|
-
body: 'Inter',
|
|
9
|
-
forms: 'Roboto',
|
|
10
|
-
},
|
|
11
|
-
input: {
|
|
12
|
-
__default: {
|
|
13
|
-
fontFamily: 'body',
|
|
14
|
-
},
|
|
15
|
-
input2: {
|
|
16
|
-
fontFamily: 'forms',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
test('supports default variant and themeSection', () => {
|
|
22
|
-
render(
|
|
23
|
-
<ThemeProvider theme={theme}>
|
|
24
|
-
<Input title="input" />
|
|
25
|
-
</ThemeProvider>
|
|
26
|
-
);
|
|
27
|
-
const input = screen.getByTitle('input');
|
|
28
|
-
|
|
29
|
-
expect(input).toHaveStyle(`font-family: Inter`);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('accepts other variant than default', () => {
|
|
33
|
-
render(
|
|
34
|
-
<ThemeProvider theme={theme}>
|
|
35
|
-
<Input title="input" variant="input2" />
|
|
36
|
-
</ThemeProvider>
|
|
37
|
-
);
|
|
38
|
-
const input = screen.getByTitle('input');
|
|
39
|
-
|
|
40
|
-
expect(input).toHaveStyle(`font-family: Roboto`);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
test('renders correct HTML element', () => {
|
|
44
|
-
render(
|
|
45
|
-
<ThemeProvider theme={theme}>
|
|
46
|
-
<Input title="input" />
|
|
47
|
-
</ThemeProvider>
|
|
48
|
-
);
|
|
49
|
-
const input = screen.getByTitle('input');
|
|
50
|
-
|
|
51
|
-
expect(input instanceof HTMLInputElement).toBeTruthy();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('supports custom prop', () => {
|
|
55
|
-
render(
|
|
56
|
-
<ThemeProvider theme={theme}>
|
|
57
|
-
<Input title="input" placeholder="placeholder" />
|
|
58
|
-
</ThemeProvider>
|
|
59
|
-
);
|
|
60
|
-
const input = screen.getByTitle('input');
|
|
61
|
-
|
|
62
|
-
expect(input).toHaveAttribute('placeholder');
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test('accepts custom styles prop className', () => {
|
|
66
|
-
render(
|
|
67
|
-
<ThemeProvider theme={theme}>
|
|
68
|
-
<Input className="custom-class-name" title="input" />
|
|
69
|
-
</ThemeProvider>
|
|
70
|
-
);
|
|
71
|
-
const input = screen.getByTitle(/input/);
|
|
72
|
-
|
|
73
|
-
expect(input.className).toMatch('custom-class-name');
|
|
74
|
-
});
|
package/src/Input/Input.tsx
DELETED
|
@@ -1,25 +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 InputThemeExtension<Value> {
|
|
8
|
-
input?: {
|
|
9
|
-
[key: string]: Value;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Props
|
|
14
|
-
// ---------------
|
|
15
|
-
export type InputProps = {
|
|
16
|
-
variant?: string;
|
|
17
|
-
} & ComponentProps<'input'>;
|
|
18
|
-
|
|
19
|
-
// Component
|
|
20
|
-
// ---------------
|
|
21
|
-
export const Input: React.FC<InputProps> = ({
|
|
22
|
-
variant = '',
|
|
23
|
-
type = 'text',
|
|
24
|
-
...props
|
|
25
|
-
}) => <Box {...props} as="input" type={type} variant={`input.${variant}`} />;
|
package/src/Input/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Input';
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Label } from './Label';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Components/Label',
|
|
7
|
-
argTypes: {
|
|
8
|
-
variant: {
|
|
9
|
-
control: {
|
|
10
|
-
type: 'text',
|
|
11
|
-
},
|
|
12
|
-
description: '?',
|
|
13
|
-
table: {
|
|
14
|
-
defaultValue: {
|
|
15
|
-
summary: 'above',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
htmlFor: {
|
|
20
|
-
control: {
|
|
21
|
-
type: 'text',
|
|
22
|
-
},
|
|
23
|
-
defaultValue: 'input',
|
|
24
|
-
},
|
|
25
|
-
required: {
|
|
26
|
-
control: {
|
|
27
|
-
type: 'boolean',
|
|
28
|
-
},
|
|
29
|
-
description: 'Adds required Icon to label',
|
|
30
|
-
table: {
|
|
31
|
-
defaultValue: {
|
|
32
|
-
summary: false,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
} as Meta;
|
|
38
|
-
|
|
39
|
-
export const Basic: ComponentStory<typeof Label> = args => (
|
|
40
|
-
<Label {...args}>Label</Label>
|
|
41
|
-
);
|
package/src/Label/Label.test.tsx
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { ThemeProvider } from '@marigold/system';
|
|
4
|
-
import { Label } from './Label';
|
|
5
|
-
|
|
6
|
-
const theme = {
|
|
7
|
-
fonts: {
|
|
8
|
-
body: 'Inter Regular',
|
|
9
|
-
label: 'Oswald',
|
|
10
|
-
},
|
|
11
|
-
label: {
|
|
12
|
-
above: {
|
|
13
|
-
fontFamily: 'body',
|
|
14
|
-
},
|
|
15
|
-
myLabel: {
|
|
16
|
-
fontFamily: 'label',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
colors: {
|
|
20
|
-
text: 'black',
|
|
21
|
-
disabled: 'gray',
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
test('supports default variant and styles', () => {
|
|
26
|
-
render(
|
|
27
|
-
<ThemeProvider theme={theme}>
|
|
28
|
-
<Label htmlFor="labelId">label</Label>
|
|
29
|
-
</ThemeProvider>
|
|
30
|
-
);
|
|
31
|
-
const label = screen.getByText(/label/);
|
|
32
|
-
|
|
33
|
-
expect(label).toHaveStyle(`font-family: Inter Regular`);
|
|
34
|
-
expect(label).toHaveStyle(`color: black`);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('supports other variant than default', () => {
|
|
38
|
-
render(
|
|
39
|
-
<ThemeProvider theme={theme}>
|
|
40
|
-
<Label htmlFor="labelId" variant="myLabel">
|
|
41
|
-
label
|
|
42
|
-
</Label>
|
|
43
|
-
</ThemeProvider>
|
|
44
|
-
);
|
|
45
|
-
const label = screen.getByText(/label/);
|
|
46
|
-
|
|
47
|
-
expect(label).toHaveStyle(`font-family: Oswald`);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('supports htmlFor prop', () => {
|
|
51
|
-
render(
|
|
52
|
-
<ThemeProvider theme={theme}>
|
|
53
|
-
<Label htmlFor="labelId">label</Label>
|
|
54
|
-
</ThemeProvider>
|
|
55
|
-
);
|
|
56
|
-
const label = screen.getByText(/label/);
|
|
57
|
-
|
|
58
|
-
expect(label).toHaveAttribute('for');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('supports required prop', () => {
|
|
62
|
-
render(
|
|
63
|
-
<ThemeProvider theme={theme}>
|
|
64
|
-
<Label htmlFor="labelId" required>
|
|
65
|
-
label
|
|
66
|
-
</Label>
|
|
67
|
-
</ThemeProvider>
|
|
68
|
-
);
|
|
69
|
-
const label = screen.getByText(/label/);
|
|
70
|
-
const parent = label.parentElement;
|
|
71
|
-
|
|
72
|
-
expect(parent instanceof HTMLSpanElement).toBeTruthy();
|
|
73
|
-
});
|
|
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
|
-
|
|
87
|
-
test('renders <label> element', () => {
|
|
88
|
-
render(
|
|
89
|
-
<ThemeProvider theme={theme}>
|
|
90
|
-
<Label htmlFor="labelId">label</Label>
|
|
91
|
-
</ThemeProvider>
|
|
92
|
-
);
|
|
93
|
-
const label = screen.getByText(/label/);
|
|
94
|
-
|
|
95
|
-
expect(label instanceof HTMLLabelElement).toBeTruthy();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
test('accepts custom styles prop className', () => {
|
|
99
|
-
render(
|
|
100
|
-
<ThemeProvider theme={theme}>
|
|
101
|
-
<Label htmlFor="labelId" className="custom-class-name" title="label">
|
|
102
|
-
label
|
|
103
|
-
</Label>
|
|
104
|
-
</ThemeProvider>
|
|
105
|
-
);
|
|
106
|
-
const label = screen.getByTitle(/label/);
|
|
107
|
-
|
|
108
|
-
expect(label.className).toMatch('custom-class-name');
|
|
109
|
-
});
|
package/src/Label/Label.tsx
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { ComponentProps } from '@marigold/types';
|
|
4
|
-
import { Required } from '@marigold/icons';
|
|
5
|
-
import { ResponsiveStyleValue } from '@marigold/system';
|
|
6
|
-
|
|
7
|
-
import { Box } from '../Box';
|
|
8
|
-
|
|
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 = {
|
|
20
|
-
htmlFor?: string;
|
|
21
|
-
variant?: string;
|
|
22
|
-
required?: boolean;
|
|
23
|
-
color?: ResponsiveStyleValue<string>;
|
|
24
|
-
} & ComponentProps<'label'>;
|
|
25
|
-
|
|
26
|
-
export const LabelBase: React.FC<LabelProps> = ({
|
|
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> = ({
|
|
52
|
-
required,
|
|
53
|
-
children,
|
|
54
|
-
...props
|
|
55
|
-
}) => {
|
|
56
|
-
return required ? (
|
|
57
|
-
<Box as="span" display="inline-flex" alignItems="center">
|
|
58
|
-
<LabelBase {...props}>{children}</LabelBase>
|
|
59
|
-
{required && <Box as={Required} size={16} css={{ color: 'error' }} />}
|
|
60
|
-
</Box>
|
|
61
|
-
) : (
|
|
62
|
-
<LabelBase {...props}>{children}</LabelBase>
|
|
63
|
-
);
|
|
64
|
-
};
|
package/src/Label/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Label';
|
|
@@ -1,35 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { ThemeProvider } from '@marigold/system';
|
|
4
|
-
import { Link } from './Link';
|
|
5
|
-
|
|
6
|
-
const theme = {
|
|
7
|
-
fonts: {
|
|
8
|
-
link: 'Inter',
|
|
9
|
-
body: 'Oswald',
|
|
10
|
-
},
|
|
11
|
-
text: {
|
|
12
|
-
link: {
|
|
13
|
-
fontFamily: 'link',
|
|
14
|
-
},
|
|
15
|
-
second: {
|
|
16
|
-
fontFamily: 'body',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
test('uses `text.link` as default variant', () => {
|
|
22
|
-
render(
|
|
23
|
-
<ThemeProvider theme={theme}>
|
|
24
|
-
<Link href="#!">Link</Link>
|
|
25
|
-
</ThemeProvider>
|
|
26
|
-
);
|
|
27
|
-
const link = screen.getByText(/Link/);
|
|
28
|
-
|
|
29
|
-
expect(link).toHaveStyle(`font-family: Inter`);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('allows to change variants via `variant` prop (with "text" prefix)', () => {
|
|
33
|
-
render(
|
|
34
|
-
<ThemeProvider theme={theme}>
|
|
35
|
-
<Link href="#!" variant="second">
|
|
36
|
-
Link
|
|
37
|
-
</Link>
|
|
38
|
-
</ThemeProvider>
|
|
39
|
-
);
|
|
40
|
-
const link = screen.getByText(/Link/);
|
|
41
|
-
|
|
42
|
-
expect(link).toHaveStyle(`font-family: Oswald`);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('renders a <a> element by default', () => {
|
|
46
|
-
render(
|
|
47
|
-
<ThemeProvider theme={theme}>
|
|
48
|
-
<Link href="#!">Link</Link>
|
|
49
|
-
</ThemeProvider>
|
|
50
|
-
);
|
|
51
|
-
const link = screen.getByText(/Link/);
|
|
52
|
-
|
|
53
|
-
expect(link instanceof HTMLAnchorElement).toBeTruthy();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test('accepts custom className', () => {
|
|
57
|
-
render(
|
|
58
|
-
<ThemeProvider theme={theme}>
|
|
59
|
-
<Link href="#!" className="custom-class-name">
|
|
60
|
-
Link
|
|
61
|
-
</Link>
|
|
62
|
-
</ThemeProvider>
|
|
63
|
-
);
|
|
64
|
-
const link = screen.getByText(/Link/);
|
|
65
|
-
|
|
66
|
-
expect(link.className).toMatch('custom-class-name');
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
test('accepts other routing components', () => {
|
|
70
|
-
const RouterLink = React.forwardRef<
|
|
71
|
-
HTMLSpanElement,
|
|
72
|
-
{ to: string; children?: React.ReactNode }
|
|
73
|
-
>(() => <span>I am a Router Link!</span>);
|
|
74
|
-
|
|
75
|
-
render(
|
|
76
|
-
<ThemeProvider theme={theme}>
|
|
77
|
-
<Link as={RouterLink} to="/Home">
|
|
78
|
-
Link
|
|
79
|
-
</Link>
|
|
80
|
-
</ThemeProvider>
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const link = screen.getByText('I am a Router Link!');
|
|
84
|
-
expect(link).toBeTruthy();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test('a link can be disabled via aria attributes', () => {
|
|
88
|
-
render(
|
|
89
|
-
<ThemeProvider theme={theme}>
|
|
90
|
-
<Link href="#!" disabled={true}>
|
|
91
|
-
Link
|
|
92
|
-
</Link>
|
|
93
|
-
</ThemeProvider>
|
|
94
|
-
);
|
|
95
|
-
const link = screen.getByText(/Link/);
|
|
96
|
-
expect(link.getAttribute('aria-disabled')).toEqual('true');
|
|
97
|
-
});
|
package/src/Link/Link.tsx
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import { useLink } from '@react-aria/link';
|
|
3
|
-
import { PolymorphicComponent, PolymorphicProps } from '@marigold/types';
|
|
4
|
-
|
|
5
|
-
import { Text, TextOwnProps } from '../Text';
|
|
6
|
-
|
|
7
|
-
// Theme Extension
|
|
8
|
-
// ---------------
|
|
9
|
-
export interface LinkThemeExtension<Value> {
|
|
10
|
-
link?: Value;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Props
|
|
14
|
-
// ---------------
|
|
15
|
-
export type LinkOwnProps = { disabled?: boolean } & TextOwnProps;
|
|
16
|
-
export type LinkProps = PolymorphicProps<LinkOwnProps, 'a'>;
|
|
17
|
-
|
|
18
|
-
// Component
|
|
19
|
-
// ---------------
|
|
20
|
-
export const Link = (({
|
|
21
|
-
as = 'a',
|
|
22
|
-
variant = 'link',
|
|
23
|
-
children,
|
|
24
|
-
disabled,
|
|
25
|
-
...props
|
|
26
|
-
}: LinkProps) => {
|
|
27
|
-
const ref = useRef<any>();
|
|
28
|
-
const { linkProps } = useLink(
|
|
29
|
-
{
|
|
30
|
-
...props,
|
|
31
|
-
elementType: typeof as === 'string' ? as : 'span',
|
|
32
|
-
isDisabled: disabled,
|
|
33
|
-
},
|
|
34
|
-
ref
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<Text {...props} {...linkProps} as={as} variant={variant} ref={ref}>
|
|
39
|
-
{children}
|
|
40
|
-
</Text>
|
|
41
|
-
);
|
|
42
|
-
}) as PolymorphicComponent<LinkOwnProps, 'a'>;
|
package/src/Link/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Link';
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
2
|
-
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Menu } from './Menu';
|
|
4
|
-
import { MenuItem } from '../MenuItem';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Components/Menu',
|
|
8
|
-
parameters: {
|
|
9
|
-
actions: {
|
|
10
|
-
handles: ['click'],
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
argTypes: {
|
|
14
|
-
variant: {
|
|
15
|
-
control: {
|
|
16
|
-
type: 'text',
|
|
17
|
-
},
|
|
18
|
-
description: '?',
|
|
19
|
-
table: {
|
|
20
|
-
defaultValue: {
|
|
21
|
-
summary: 'default',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
label: {
|
|
26
|
-
control: {
|
|
27
|
-
type: 'text',
|
|
28
|
-
},
|
|
29
|
-
description: 'Menu label on hover',
|
|
30
|
-
defaultValue: 'Menu',
|
|
31
|
-
},
|
|
32
|
-
show: {
|
|
33
|
-
control: {
|
|
34
|
-
type: 'boolean',
|
|
35
|
-
},
|
|
36
|
-
options: [true, false],
|
|
37
|
-
description: 'Show what',
|
|
38
|
-
table: {
|
|
39
|
-
defaultValue: {
|
|
40
|
-
summary: false,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
onClick: {
|
|
45
|
-
control: {
|
|
46
|
-
type: 'text',
|
|
47
|
-
},
|
|
48
|
-
description: 'Function to show menu or toggle something',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
} as Meta;
|
|
52
|
-
|
|
53
|
-
export const Basic: ComponentStory<typeof Menu> = ({ onClick, ...args }) => {
|
|
54
|
-
const [showMenu, setShowMenu] = useState(false);
|
|
55
|
-
return (
|
|
56
|
-
<Menu onClick={() => setShowMenu(!showMenu)} show={showMenu} {...args}>
|
|
57
|
-
<MenuItem href="#">Home</MenuItem>
|
|
58
|
-
<MenuItem href="#">Tickets</MenuItem>
|
|
59
|
-
<MenuItem href="#">Logout</MenuItem>
|
|
60
|
-
</Menu>
|
|
61
|
-
);
|
|
62
|
-
};
|
package/src/Menu/Menu.test.tsx
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { ThemeProvider } from '@marigold/system';
|
|
4
|
-
import { Menu } from './Menu';
|
|
5
|
-
import { MenuItem } from '../MenuItem';
|
|
6
|
-
|
|
7
|
-
const theme = {
|
|
8
|
-
space: {
|
|
9
|
-
none: 0,
|
|
10
|
-
small: 4,
|
|
11
|
-
medium: 8,
|
|
12
|
-
},
|
|
13
|
-
menu: {
|
|
14
|
-
default: {
|
|
15
|
-
padding: 'small',
|
|
16
|
-
},
|
|
17
|
-
custom: {
|
|
18
|
-
padding: 'medium',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
test('supports default variant and themeSection', () => {
|
|
24
|
-
render(
|
|
25
|
-
<ThemeProvider theme={theme}>
|
|
26
|
-
<Menu title="menu" onClick={() => {}}>
|
|
27
|
-
<MenuItem href="#">Home</MenuItem>
|
|
28
|
-
</Menu>
|
|
29
|
-
</ThemeProvider>
|
|
30
|
-
);
|
|
31
|
-
const menu = screen.getByTitle(/menu/);
|
|
32
|
-
|
|
33
|
-
expect(menu).toHaveStyle(`padding: 4px`);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test('accepts other variant than default', () => {
|
|
37
|
-
render(
|
|
38
|
-
<ThemeProvider theme={theme}>
|
|
39
|
-
<Menu variant="custom" title="menu" onClick={() => {}}>
|
|
40
|
-
<MenuItem href="#">Home</MenuItem>
|
|
41
|
-
</Menu>
|
|
42
|
-
</ThemeProvider>
|
|
43
|
-
);
|
|
44
|
-
const menu = screen.getByTitle(/menu/);
|
|
45
|
-
|
|
46
|
-
expect(menu).toHaveStyle(`padding: 8px`);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('supports show prop', () => {
|
|
50
|
-
render(
|
|
51
|
-
<ThemeProvider theme={theme}>
|
|
52
|
-
<Menu show={true} title="menu" onClick={() => {}}>
|
|
53
|
-
<MenuItem href="#">Home</MenuItem>
|
|
54
|
-
</Menu>
|
|
55
|
-
</ThemeProvider>
|
|
56
|
-
);
|
|
57
|
-
const menu = screen.getByTitle(/menu/);
|
|
58
|
-
|
|
59
|
-
expect(menu).toHaveStyle(`display: block`);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
test('renders correct HTML element', () => {
|
|
63
|
-
render(
|
|
64
|
-
<ThemeProvider theme={theme}>
|
|
65
|
-
<Menu title="menu" onClick={() => {}}>
|
|
66
|
-
<MenuItem href="#">Home</MenuItem>
|
|
67
|
-
</Menu>
|
|
68
|
-
</ThemeProvider>
|
|
69
|
-
);
|
|
70
|
-
const menu = screen.getByTitle(/menu/);
|
|
71
|
-
|
|
72
|
-
expect(menu instanceof HTMLDivElement).toBeTruthy();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
test('accepts custom styles prop className', () => {
|
|
76
|
-
render(
|
|
77
|
-
<Menu title="menu" onClick={() => {}} className="custom-class-name">
|
|
78
|
-
<MenuItem href="#">Home</MenuItem>
|
|
79
|
-
</Menu>
|
|
80
|
-
);
|
|
81
|
-
const menu = screen.getByTitle(/menu/);
|
|
82
|
-
|
|
83
|
-
expect(menu.className).toMatch('custom-class-name');
|
|
84
|
-
});
|
package/src/Menu/Menu.tsx
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ComponentProps } from '@marigold/types';
|
|
3
|
-
|
|
4
|
-
import { Button } from '../Button';
|
|
5
|
-
import { Box } from '../Box';
|
|
6
|
-
|
|
7
|
-
// Theme Extension
|
|
8
|
-
// ---------------
|
|
9
|
-
export interface MenuThemeExtension<Value> {
|
|
10
|
-
menu?: Value;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Props
|
|
14
|
-
// ---------------
|
|
15
|
-
export type MenuProps = {
|
|
16
|
-
variant?: string;
|
|
17
|
-
label?: string;
|
|
18
|
-
onClick: ComponentProps<typeof Button>['onClick'];
|
|
19
|
-
show?: boolean;
|
|
20
|
-
className?: string;
|
|
21
|
-
title?: string; // For testing
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
// Component
|
|
25
|
-
// ---------------
|
|
26
|
-
export const Menu: React.FC<MenuProps> = ({
|
|
27
|
-
variant = 'default',
|
|
28
|
-
label = 'Menu',
|
|
29
|
-
onClick,
|
|
30
|
-
show = false,
|
|
31
|
-
children,
|
|
32
|
-
...props
|
|
33
|
-
}) => {
|
|
34
|
-
return (
|
|
35
|
-
<Box variant={`menu.${variant}`} {...props}>
|
|
36
|
-
<Button onClick={onClick} variant="menu">
|
|
37
|
-
{label}
|
|
38
|
-
</Button>
|
|
39
|
-
{show ? (
|
|
40
|
-
<Box
|
|
41
|
-
display="block"
|
|
42
|
-
position="absolute"
|
|
43
|
-
minWidth="120px"
|
|
44
|
-
borderRadius="2px"
|
|
45
|
-
>
|
|
46
|
-
{children}
|
|
47
|
-
</Box>
|
|
48
|
-
) : null}
|
|
49
|
-
</Box>
|
|
50
|
-
);
|
|
51
|
-
};
|
package/src/Menu/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Menu';
|