@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/Divider/Divider.tsx
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box } from '../Box';
|
|
3
|
-
|
|
4
|
-
// Theme Extension
|
|
5
|
-
// ---------------
|
|
6
|
-
export interface DividerThemeExtension<Value> {
|
|
7
|
-
divider?: {
|
|
8
|
-
[key: string]: Value;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Props
|
|
13
|
-
// ---------------
|
|
14
|
-
export type DividerProps = {
|
|
15
|
-
className?: string;
|
|
16
|
-
variant?: string;
|
|
17
|
-
title?: string; // Should only be used for testing.
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// Component
|
|
21
|
-
// ---------------
|
|
22
|
-
export const Divider: React.FC<DividerProps> = ({
|
|
23
|
-
variant = 'regular',
|
|
24
|
-
...props
|
|
25
|
-
}) => <Box {...props} as="hr" variant={`divider.${variant}`} />;
|
package/src/Divider/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Divider';
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Field } from './Field';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Components/Field',
|
|
7
|
-
argTypes: {
|
|
8
|
-
variant: {
|
|
9
|
-
control: {
|
|
10
|
-
type: 'text',
|
|
11
|
-
},
|
|
12
|
-
description: 'Field variant',
|
|
13
|
-
table: {
|
|
14
|
-
defaultValue: {
|
|
15
|
-
summary: '__default',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
labelVariant: {
|
|
20
|
-
control: {
|
|
21
|
-
type: 'text',
|
|
22
|
-
},
|
|
23
|
-
description: 'Field label variant',
|
|
24
|
-
table: {
|
|
25
|
-
defaultValue: {
|
|
26
|
-
summary: 'above',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
htmlFor: {
|
|
31
|
-
control: {
|
|
32
|
-
type: 'text',
|
|
33
|
-
},
|
|
34
|
-
defaultValue: 'id',
|
|
35
|
-
},
|
|
36
|
-
label: {
|
|
37
|
-
control: {
|
|
38
|
-
type: 'text',
|
|
39
|
-
},
|
|
40
|
-
defaultValue: 'Label',
|
|
41
|
-
},
|
|
42
|
-
error: {
|
|
43
|
-
control: {
|
|
44
|
-
type: 'boolean',
|
|
45
|
-
},
|
|
46
|
-
description: 'Error',
|
|
47
|
-
table: {
|
|
48
|
-
defaultValue: {
|
|
49
|
-
summary: false,
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
errorMessage: {
|
|
54
|
-
control: {
|
|
55
|
-
type: 'text',
|
|
56
|
-
},
|
|
57
|
-
description: 'Error Message',
|
|
58
|
-
},
|
|
59
|
-
required: {
|
|
60
|
-
control: {
|
|
61
|
-
type: 'boolean',
|
|
62
|
-
},
|
|
63
|
-
options: [true, false],
|
|
64
|
-
table: {
|
|
65
|
-
defaultValue: {
|
|
66
|
-
summary: false,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
disabled: {
|
|
71
|
-
control: {
|
|
72
|
-
type: 'boolean',
|
|
73
|
-
},
|
|
74
|
-
options: [true, false],
|
|
75
|
-
table: {
|
|
76
|
-
defaultValue: {
|
|
77
|
-
summary: false,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
type: {
|
|
82
|
-
control: {
|
|
83
|
-
type: 'select',
|
|
84
|
-
},
|
|
85
|
-
options: [
|
|
86
|
-
'date',
|
|
87
|
-
'datetime-local',
|
|
88
|
-
'email',
|
|
89
|
-
'month',
|
|
90
|
-
'number',
|
|
91
|
-
'password',
|
|
92
|
-
'search',
|
|
93
|
-
'tel',
|
|
94
|
-
'text',
|
|
95
|
-
'time',
|
|
96
|
-
'time',
|
|
97
|
-
'url',
|
|
98
|
-
'week',
|
|
99
|
-
],
|
|
100
|
-
defaultValue: 'text',
|
|
101
|
-
table: {
|
|
102
|
-
defaultValue: {
|
|
103
|
-
summary: 'text',
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
} as Meta;
|
|
109
|
-
|
|
110
|
-
export const Basic: ComponentStory<typeof Field> = args => <Field {...args} />;
|
package/src/Field/Field.test.tsx
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { ThemeProvider } from '@marigold/system';
|
|
4
|
-
import { Field } from './Field';
|
|
5
|
-
|
|
6
|
-
const theme = {
|
|
7
|
-
space: {
|
|
8
|
-
none: 0,
|
|
9
|
-
small: 4,
|
|
10
|
-
medium: 8,
|
|
11
|
-
},
|
|
12
|
-
label: {
|
|
13
|
-
above: {
|
|
14
|
-
fontSize: '14px',
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
input: {
|
|
18
|
-
__default: {
|
|
19
|
-
padding: 'small',
|
|
20
|
-
},
|
|
21
|
-
error: {
|
|
22
|
-
padding: 'medium',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
test('renders correct HTML element', () => {
|
|
28
|
-
render(
|
|
29
|
-
<ThemeProvider theme={theme}>
|
|
30
|
-
<Field htmlFor="myId" label="label" />
|
|
31
|
-
</ThemeProvider>
|
|
32
|
-
);
|
|
33
|
-
const field = screen.getByText(/label/);
|
|
34
|
-
|
|
35
|
-
expect(field instanceof HTMLLabelElement).toBeTruthy();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('supports default variant', () => {
|
|
39
|
-
render(
|
|
40
|
-
<ThemeProvider theme={theme}>
|
|
41
|
-
<Field htmlFor="myId" label="Name" data-testid="field" />
|
|
42
|
-
</ThemeProvider>
|
|
43
|
-
);
|
|
44
|
-
const field = screen.getByTestId(/field/);
|
|
45
|
-
expect(field).toHaveStyle(`padding: 4px`);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('supports other variant than default', () => {
|
|
49
|
-
render(
|
|
50
|
-
<ThemeProvider theme={theme}>
|
|
51
|
-
<Field htmlFor="myId" label="Name" variant="error" data-testid="field" />
|
|
52
|
-
</ThemeProvider>
|
|
53
|
-
);
|
|
54
|
-
const field = screen.getByTestId(/field/);
|
|
55
|
-
expect(field).toHaveStyle(`padding: 8px`);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test('supports default variantLabel', () => {
|
|
59
|
-
render(
|
|
60
|
-
<ThemeProvider theme={theme}>
|
|
61
|
-
<Field htmlFor="myId" label="Name" />
|
|
62
|
-
</ThemeProvider>
|
|
63
|
-
);
|
|
64
|
-
const label = screen.getByText(/Name/);
|
|
65
|
-
expect(label).toHaveStyle(`font-size: 14px`);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('supports other variantLabel than default', () => {
|
|
69
|
-
render(
|
|
70
|
-
<ThemeProvider theme={theme}>
|
|
71
|
-
<Field htmlFor="myId" label="Name" />
|
|
72
|
-
</ThemeProvider>
|
|
73
|
-
);
|
|
74
|
-
const label = screen.getByText(/Name/);
|
|
75
|
-
expect(label).toHaveStyle(`font-size: 14px`);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
test('supports label prop', () => {
|
|
79
|
-
render(<Field htmlFor="myId" label="Name" />);
|
|
80
|
-
const field = screen.getByText(/Name/);
|
|
81
|
-
|
|
82
|
-
expect(field).toBeDefined();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('supports htmlFor prop', () => {
|
|
86
|
-
render(<Field htmlFor="myId" label="Name" />);
|
|
87
|
-
const field = screen.getByText(/Name/);
|
|
88
|
-
|
|
89
|
-
expect(field).toHaveAttribute('for');
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
test('supports required prop', () => {
|
|
93
|
-
render(<Field htmlFor="myId" label="label" required />);
|
|
94
|
-
const fieldLabel = screen.getByText(/label/);
|
|
95
|
-
|
|
96
|
-
expect(fieldLabel.nextSibling).toBeDefined();
|
|
97
|
-
expect(fieldLabel.nextSibling instanceof SVGElement).toBeTruthy();
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test('supports error and errorMessage prop', () => {
|
|
101
|
-
render(
|
|
102
|
-
<Field htmlFor="myId" label="label" error errorMessage="Validation error" />
|
|
103
|
-
);
|
|
104
|
-
|
|
105
|
-
const errorMessage = screen.getByText(/Validation/);
|
|
106
|
-
expect(errorMessage).toBeDefined();
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
test('supports disabled prop', () => {
|
|
110
|
-
render(<Field htmlFor="myId" label="label" disabled />);
|
|
111
|
-
const fieldLabel = screen.getByText(/label/);
|
|
112
|
-
expect(fieldLabel.nextSibling).toHaveAttribute('disabled');
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
test('accepts custom styles prop className', () => {
|
|
116
|
-
render(
|
|
117
|
-
<ThemeProvider theme={theme}>
|
|
118
|
-
<Field
|
|
119
|
-
htmlFor="myId"
|
|
120
|
-
label="label"
|
|
121
|
-
className="custom-class-name"
|
|
122
|
-
title="field"
|
|
123
|
-
data-testid="field"
|
|
124
|
-
/>
|
|
125
|
-
</ThemeProvider>
|
|
126
|
-
);
|
|
127
|
-
const field = screen.getByTestId(/field/);
|
|
128
|
-
|
|
129
|
-
expect(field.className).toMatch('custom-class-name');
|
|
130
|
-
});
|
package/src/Field/Field.tsx
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Exclamation } from '@marigold/icons';
|
|
3
|
-
import { ComponentProps } from '@marigold/types';
|
|
4
|
-
|
|
5
|
-
import { Input } from '../Input';
|
|
6
|
-
import { Label } from '../Label';
|
|
7
|
-
import { ValidationMessage } from '../ValidationMessage';
|
|
8
|
-
|
|
9
|
-
// Props
|
|
10
|
-
// ---------------
|
|
11
|
-
export type FieldProps = {
|
|
12
|
-
variant?: string;
|
|
13
|
-
labelVariant?: string;
|
|
14
|
-
htmlFor: string;
|
|
15
|
-
label: string;
|
|
16
|
-
required?: boolean;
|
|
17
|
-
error?: boolean;
|
|
18
|
-
errorMessage?: string;
|
|
19
|
-
disabled?: boolean;
|
|
20
|
-
} & ComponentProps<'input'>;
|
|
21
|
-
|
|
22
|
-
// Component
|
|
23
|
-
// ---------------
|
|
24
|
-
export const Field: React.FC<FieldProps> = ({
|
|
25
|
-
type = 'text',
|
|
26
|
-
variant = '',
|
|
27
|
-
labelVariant = 'above',
|
|
28
|
-
htmlFor,
|
|
29
|
-
label,
|
|
30
|
-
required,
|
|
31
|
-
error,
|
|
32
|
-
errorMessage,
|
|
33
|
-
disabled,
|
|
34
|
-
...props
|
|
35
|
-
}) => {
|
|
36
|
-
return (
|
|
37
|
-
<>
|
|
38
|
-
<Label variant={labelVariant} htmlFor={htmlFor} required={required}>
|
|
39
|
-
{label}
|
|
40
|
-
</Label>
|
|
41
|
-
<Input
|
|
42
|
-
{...props}
|
|
43
|
-
type={type}
|
|
44
|
-
id={htmlFor}
|
|
45
|
-
disabled={disabled}
|
|
46
|
-
variant={variant}
|
|
47
|
-
/>
|
|
48
|
-
{error && errorMessage && (
|
|
49
|
-
<ValidationMessage>
|
|
50
|
-
<Exclamation size={16} />
|
|
51
|
-
{errorMessage}
|
|
52
|
-
</ValidationMessage>
|
|
53
|
-
)}
|
|
54
|
-
</>
|
|
55
|
-
);
|
|
56
|
-
};
|
package/src/Field/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Field';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Image } from './Image';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
title: 'Components/Image',
|
|
7
|
-
argTypes: {
|
|
8
|
-
variant: {
|
|
9
|
-
control: {
|
|
10
|
-
type: 'text',
|
|
11
|
-
},
|
|
12
|
-
description: 'there is only one variant',
|
|
13
|
-
table: {
|
|
14
|
-
defaultValue: {
|
|
15
|
-
summary: 'fullWidth',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
alt: {
|
|
20
|
-
control: {
|
|
21
|
-
type: 'text',
|
|
22
|
-
},
|
|
23
|
-
description: 'Description text for screenreaders',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
} as Meta;
|
|
27
|
-
|
|
28
|
-
export const Basic: ComponentStory<typeof Image> = args => (
|
|
29
|
-
<Image
|
|
30
|
-
src="https://www.reservix.net/_Resources/Persistent/0e8f5885125940fdb2bc2d54840f497782f56584/Reservix_Logo_dtp_web_rgb_font_black_180704.png"
|
|
31
|
-
alt="marigold_logo"
|
|
32
|
-
{...args}
|
|
33
|
-
/>
|
|
34
|
-
);
|
package/src/Image/Image.test.tsx
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { ThemeProvider } from '@marigold/system';
|
|
4
|
-
import { Image } from './Image';
|
|
5
|
-
|
|
6
|
-
const theme = {
|
|
7
|
-
colors: {
|
|
8
|
-
primary: 'hotpink',
|
|
9
|
-
},
|
|
10
|
-
image: {
|
|
11
|
-
fullWidth: {
|
|
12
|
-
alignItems: 'center',
|
|
13
|
-
},
|
|
14
|
-
logos: {
|
|
15
|
-
alignItems: 'right',
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
test('supports default variant and themeSection', () => {
|
|
21
|
-
render(
|
|
22
|
-
<ThemeProvider theme={theme}>
|
|
23
|
-
<Image title="images" />
|
|
24
|
-
</ThemeProvider>
|
|
25
|
-
);
|
|
26
|
-
const img = screen.getByTitle(/images/);
|
|
27
|
-
|
|
28
|
-
expect(img).toHaveStyle(`align-items: center`);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
test('accepts other variant than default', () => {
|
|
32
|
-
render(
|
|
33
|
-
<ThemeProvider theme={theme}>
|
|
34
|
-
<Image title="logos" variant="logos" />
|
|
35
|
-
</ThemeProvider>
|
|
36
|
-
);
|
|
37
|
-
const img = screen.getByTitle(/logos/);
|
|
38
|
-
|
|
39
|
-
expect(img).toHaveStyle(`align-items: right`);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('renders correct HTML element', () => {
|
|
43
|
-
render(
|
|
44
|
-
<ThemeProvider theme={theme}>
|
|
45
|
-
<Image title="default" />
|
|
46
|
-
</ThemeProvider>
|
|
47
|
-
);
|
|
48
|
-
const img = screen.getByTitle(/default/);
|
|
49
|
-
|
|
50
|
-
expect(img instanceof HTMLImageElement).toBeTruthy();
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test('accept alt', () => {
|
|
54
|
-
render(
|
|
55
|
-
<ThemeProvider theme={theme}>
|
|
56
|
-
<Image alt="altText" title="default" />
|
|
57
|
-
</ThemeProvider>
|
|
58
|
-
);
|
|
59
|
-
const img = screen.getByTitle(/default/);
|
|
60
|
-
|
|
61
|
-
expect(img.getAttribute('alt')).toEqual('altText');
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('accepts custom styles prop className', () => {
|
|
65
|
-
render(
|
|
66
|
-
<ThemeProvider theme={theme}>
|
|
67
|
-
<Image className="custom-class-name" title="image" />
|
|
68
|
-
</ThemeProvider>
|
|
69
|
-
);
|
|
70
|
-
const image = screen.getByTitle(/image/);
|
|
71
|
-
|
|
72
|
-
expect(image.className).toMatch('custom-class-name');
|
|
73
|
-
});
|
package/src/Image/Image.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 ImageThemeExtension<Value> {
|
|
8
|
-
image?: {
|
|
9
|
-
[key: string]: Value;
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Props
|
|
14
|
-
// ---------------
|
|
15
|
-
export type ImageProps = {
|
|
16
|
-
variant?: string;
|
|
17
|
-
children?: never;
|
|
18
|
-
} & ComponentProps<'img'>;
|
|
19
|
-
|
|
20
|
-
// Component
|
|
21
|
-
// ---------------
|
|
22
|
-
export const Image: React.FC<ImageProps> = ({
|
|
23
|
-
variant = 'fullWidth',
|
|
24
|
-
...props
|
|
25
|
-
}) => <Box {...props} as="img" variant={`image.${variant}`} />;
|
package/src/Image/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Image';
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Text } from '../Text';
|
|
4
|
-
import { Inline } from './Inline';
|
|
5
|
-
import { Check } from '@marigold/icons';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
title: 'Components/Inline',
|
|
9
|
-
argTypes: {
|
|
10
|
-
space: {
|
|
11
|
-
control: {
|
|
12
|
-
type: 'select',
|
|
13
|
-
},
|
|
14
|
-
options: [
|
|
15
|
-
'none',
|
|
16
|
-
'xxsmall',
|
|
17
|
-
'xsmall',
|
|
18
|
-
'small',
|
|
19
|
-
'medium',
|
|
20
|
-
'large',
|
|
21
|
-
'xlarge',
|
|
22
|
-
'xxlarge',
|
|
23
|
-
],
|
|
24
|
-
description: 'Responsive Style Value',
|
|
25
|
-
table: {
|
|
26
|
-
defaultValue: {
|
|
27
|
-
summary: 'none',
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
} as Meta;
|
|
33
|
-
|
|
34
|
-
export const Basic: ComponentStory<typeof Inline> = args => (
|
|
35
|
-
<Inline {...args}>
|
|
36
|
-
<Check />
|
|
37
|
-
<Text>Check</Text>
|
|
38
|
-
</Inline>
|
|
39
|
-
);
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { ThemeProvider } from '@marigold/system';
|
|
4
|
-
|
|
5
|
-
import { Inline } from './Inline';
|
|
6
|
-
import { Text } from '../Text';
|
|
7
|
-
|
|
8
|
-
// Setup
|
|
9
|
-
// ---------------
|
|
10
|
-
const theme = {
|
|
11
|
-
space: {
|
|
12
|
-
none: 0,
|
|
13
|
-
small: 2,
|
|
14
|
-
medium: 4,
|
|
15
|
-
large: 8,
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const getLeftPadding = (element: HTMLElement) =>
|
|
20
|
-
getComputedStyle(element).getPropertyValue('padding-left');
|
|
21
|
-
|
|
22
|
-
test('default space is "none"', () => {
|
|
23
|
-
render(
|
|
24
|
-
<ThemeProvider theme={theme}>
|
|
25
|
-
<Inline>
|
|
26
|
-
<Text>first</Text>
|
|
27
|
-
<Text>second</Text>
|
|
28
|
-
</Inline>
|
|
29
|
-
</ThemeProvider>
|
|
30
|
-
);
|
|
31
|
-
const first = screen.getByText(/first/).parentElement!;
|
|
32
|
-
const second = screen.getByText(/second/).parentElement!;
|
|
33
|
-
|
|
34
|
-
expect(getLeftPadding(first)).toEqual('');
|
|
35
|
-
expect(second).toHaveStyle(`padding-left: 0px`);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('accepts and uses spacing from theme', () => {
|
|
39
|
-
render(
|
|
40
|
-
<ThemeProvider theme={theme}>
|
|
41
|
-
<Inline space="small">
|
|
42
|
-
<Text>first</Text>
|
|
43
|
-
<Text>second</Text>
|
|
44
|
-
</Inline>
|
|
45
|
-
</ThemeProvider>
|
|
46
|
-
);
|
|
47
|
-
const first = screen.getByText(/first/);
|
|
48
|
-
const second = screen.getByText(/second/);
|
|
49
|
-
|
|
50
|
-
expect(getLeftPadding(first)).toEqual('');
|
|
51
|
-
expect(second.parentElement).toHaveStyle(`padding-left: 2px`);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test('supports nesting', () => {
|
|
55
|
-
render(
|
|
56
|
-
<ThemeProvider theme={theme}>
|
|
57
|
-
<Inline space="large">
|
|
58
|
-
<Inline space="small" data-testid="leftInline">
|
|
59
|
-
<Text>first</Text>
|
|
60
|
-
<Text>second</Text>
|
|
61
|
-
</Inline>
|
|
62
|
-
<Inline space="small" data-testid="rightInline">
|
|
63
|
-
<Text>third</Text>
|
|
64
|
-
<Text>fourth</Text>
|
|
65
|
-
</Inline>
|
|
66
|
-
</Inline>
|
|
67
|
-
</ThemeProvider>
|
|
68
|
-
);
|
|
69
|
-
const first = screen.getByText(/first/);
|
|
70
|
-
const second = screen.getByText(/second/);
|
|
71
|
-
const leftInline = screen.getByTestId('leftInline');
|
|
72
|
-
|
|
73
|
-
const third = screen.getByText(/third/);
|
|
74
|
-
const fourth = screen.getByText(/fourth/);
|
|
75
|
-
const rightInline = screen.getByTestId('rightInline');
|
|
76
|
-
|
|
77
|
-
expect(getLeftPadding(leftInline.parentElement!)).toEqual('');
|
|
78
|
-
expect(rightInline.parentElement).toHaveStyle(`padding-left: 8px`);
|
|
79
|
-
|
|
80
|
-
expect(getLeftPadding(first.parentElement!)).toEqual('');
|
|
81
|
-
expect(second.parentElement).toHaveStyle(`padding-left: 2px`);
|
|
82
|
-
|
|
83
|
-
expect(getLeftPadding(third.parentElement!)).toEqual('');
|
|
84
|
-
expect(fourth.parentElement).toHaveStyle(`padding-left: 2px`);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
test('renders div per default', () => {
|
|
88
|
-
render(
|
|
89
|
-
<ThemeProvider theme={theme}>
|
|
90
|
-
<Inline data-testid="inline">
|
|
91
|
-
<Text>first</Text>
|
|
92
|
-
<Text>second</Text>
|
|
93
|
-
</Inline>
|
|
94
|
-
</ThemeProvider>
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
const inline = screen.getByTestId('inline');
|
|
98
|
-
expect(inline instanceof HTMLDivElement).toBeTruthy();
|
|
99
|
-
});
|
package/src/Inline/Inline.tsx
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React, { Children } from 'react';
|
|
2
|
-
import flattenChildren from 'react-keyed-flatten-children';
|
|
3
|
-
|
|
4
|
-
import { ResponsiveStyleValue } from '@marigold/system';
|
|
5
|
-
|
|
6
|
-
import { Box } from '../Box';
|
|
7
|
-
|
|
8
|
-
export type InlineProps = {
|
|
9
|
-
space?: ResponsiveStyleValue<string>;
|
|
10
|
-
align?: 'top' | 'center' | 'bottom';
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const ALIGNMENT = {
|
|
14
|
-
top: 'flex-start',
|
|
15
|
-
center: 'center',
|
|
16
|
-
bottom: 'flex-end',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const Inline: React.FC<InlineProps> = ({
|
|
20
|
-
space = 'none',
|
|
21
|
-
align = 'center',
|
|
22
|
-
children,
|
|
23
|
-
...props
|
|
24
|
-
}) => (
|
|
25
|
-
<Box
|
|
26
|
-
display="inline-flex"
|
|
27
|
-
css={{ '> * + *': { pl: space } }}
|
|
28
|
-
alignItems={ALIGNMENT[align]}
|
|
29
|
-
{...props}
|
|
30
|
-
>
|
|
31
|
-
{Children.map(
|
|
32
|
-
flattenChildren(children) as unknown as React.ReactElement,
|
|
33
|
-
(child: React.ReactElement) => (
|
|
34
|
-
<Box>{React.cloneElement(child, {}, child.props.children)}</Box>
|
|
35
|
-
)
|
|
36
|
-
)}
|
|
37
|
-
</Box>
|
|
38
|
-
);
|
package/src/Inline/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Inline';
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
-
import { Input } from './Input';
|
|
4
|
-
import { Label } from '../Label';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: 'Components/Input',
|
|
8
|
-
argTypes: {
|
|
9
|
-
variant: {
|
|
10
|
-
control: {
|
|
11
|
-
type: 'text',
|
|
12
|
-
},
|
|
13
|
-
description: '?',
|
|
14
|
-
table: {
|
|
15
|
-
defaultValue: {
|
|
16
|
-
summary: '__default',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
type: {
|
|
21
|
-
control: {
|
|
22
|
-
type: 'select',
|
|
23
|
-
},
|
|
24
|
-
options: [
|
|
25
|
-
'date',
|
|
26
|
-
'datetime-local',
|
|
27
|
-
'email',
|
|
28
|
-
'month',
|
|
29
|
-
'number',
|
|
30
|
-
'password',
|
|
31
|
-
'search',
|
|
32
|
-
'tel',
|
|
33
|
-
'text',
|
|
34
|
-
'time',
|
|
35
|
-
'time',
|
|
36
|
-
'url',
|
|
37
|
-
'week',
|
|
38
|
-
],
|
|
39
|
-
defaultValue: 'text',
|
|
40
|
-
table: {
|
|
41
|
-
defaultValue: {
|
|
42
|
-
summary: 'text',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
} as Meta;
|
|
48
|
-
|
|
49
|
-
export const Basic: ComponentStory<typeof Input> = args => (
|
|
50
|
-
<Label htmlFor="input">
|
|
51
|
-
Label
|
|
52
|
-
<Input id="input" placeholder="Placeholder..." {...args} />
|
|
53
|
-
</Label>
|
|
54
|
-
);
|