@marigold/components 0.0.1 → 0.2.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/dist/ActionGroup/ActionGroup.d.ts +9 -0
- package/dist/ActionGroup/index.d.ts +1 -0
- package/dist/Alert/Alert.d.ts +20 -2
- package/dist/Badge/Badge.d.ts +8 -0
- package/dist/Badge/index.d.ts +1 -0
- package/dist/Box/Box.d.ts +47 -0
- package/dist/Box/index.d.ts +1 -0
- package/dist/Button/Button.d.ts +4 -3
- package/dist/Card/Card.d.ts +9 -0
- package/dist/Card/index.d.ts +1 -0
- package/dist/Checkbox/Checkbox.d.ts +14 -2
- package/dist/Checkbox/CheckboxIcons.d.ts +9 -0
- package/dist/Column/Column.d.ts +8 -0
- package/dist/Column/index.d.ts +1 -0
- package/dist/Columns/Columns.d.ts +10 -0
- package/dist/Columns/index.d.ts +1 -0
- package/dist/Container/Container.d.ts +6 -0
- package/dist/Container/index.d.ts +1 -0
- package/dist/Dialog/Dialog.d.ts +14 -0
- package/dist/Dialog/ModalDialog.d.ts +5 -0
- package/dist/Dialog/index.d.ts +1 -0
- package/dist/Divider/Divider.d.ts +7 -0
- package/dist/Divider/index.d.ts +1 -0
- package/dist/Field/Field.d.ts +11 -0
- package/dist/Field/index.d.ts +1 -0
- package/dist/Heading/Heading.d.ts +7 -5
- package/dist/Hidden/Hidden.d.ts +5 -0
- package/dist/Hidden/index.d.ts +1 -0
- package/dist/Image/Image.d.ts +7 -0
- package/dist/Image/index.d.ts +1 -0
- package/dist/Input/Input.d.ts +6 -0
- package/dist/Input/index.d.ts +1 -0
- package/dist/Label/Label.d.ts +8 -5
- package/dist/Link/Link.d.ts +7 -3
- package/dist/Menu/Menu.d.ts +12 -0
- package/dist/Menu/index.d.ts +1 -0
- package/dist/MenuItem/MenuItem.d.ts +7 -0
- package/dist/MenuItem/index.d.ts +1 -0
- package/dist/Message/Message.d.ts +7 -0
- package/dist/Message/index.d.ts +1 -0
- package/dist/Provider/MarigoldProvider.d.ts +3 -0
- package/dist/Provider/index.d.ts +3 -0
- package/dist/Radio/Radio.d.ts +14 -2
- package/dist/Radio/RadioIcons.d.ts +9 -0
- package/dist/Select/ListBox.d.ts +8 -0
- package/dist/Select/ListBoxSection.d.ts +8 -0
- package/dist/Select/Option.d.ts +8 -0
- package/dist/Select/Popover.d.ts +9 -0
- package/dist/Select/Select.d.ts +13 -3
- package/dist/Slider/Slider.d.ts +6 -3
- package/dist/Stack/Stack.d.ts +7 -0
- package/dist/Stack/index.d.ts +1 -0
- package/dist/Text/Text.d.ts +12 -3
- package/dist/Textarea/Textarea.d.ts +11 -3
- package/dist/ValidationMessage/ValidationMessage.d.ts +6 -0
- package/dist/ValidationMessage/index.d.ts +1 -0
- package/dist/components.cjs.development.js +1308 -195
- package/dist/components.cjs.development.js.map +1 -1
- package/dist/components.cjs.production.min.js +1 -1
- package/dist/components.cjs.production.min.js.map +1 -1
- package/dist/components.esm.js +1267 -185
- package/dist/components.esm.js.map +1 -1
- package/dist/index.d.ts +21 -4
- package/dist/theme.d.ts +24 -4
- package/package.json +24 -4
- package/src/ActionGroup/ActionGroup.stories.mdx +62 -0
- package/src/ActionGroup/ActionGroup.test.tsx +83 -0
- package/src/ActionGroup/ActionGroup.tsx +43 -0
- package/src/ActionGroup/index.ts +1 -0
- package/src/Alert/Alert.stories.mdx +30 -42
- package/src/Alert/Alert.test.tsx +37 -22
- package/src/Alert/Alert.tsx +31 -21
- package/src/Badge/Badge.stories.mdx +57 -0
- package/src/Badge/Badge.test.tsx +61 -0
- package/src/Badge/Badge.tsx +25 -0
- package/src/Badge/index.ts +1 -0
- package/src/Box/Box.stories.mdx +334 -0
- package/src/Box/Box.test.tsx +133 -0
- package/src/Box/Box.tsx +165 -0
- package/src/Box/index.ts +1 -0
- package/src/Button/Button.stories.mdx +58 -134
- package/src/Button/Button.test.tsx +65 -23
- package/src/Button/Button.tsx +48 -14
- package/src/Card/Card.stories.mdx +49 -0
- package/src/Card/Card.test.tsx +66 -0
- package/src/Card/Card.tsx +36 -0
- package/src/Card/index.ts +1 -0
- package/src/Checkbox/Checkbox.stories.mdx +79 -101
- package/src/Checkbox/Checkbox.test.tsx +73 -32
- package/src/Checkbox/Checkbox.tsx +114 -35
- package/src/Checkbox/CheckboxIcons.tsx +49 -0
- package/src/Column/Column.stories.mdx +49 -0
- package/src/Column/Column.test.tsx +32 -0
- package/src/Column/Column.tsx +27 -0
- package/src/Column/index.ts +1 -0
- package/src/Columns/Columns.stories.mdx +65 -0
- package/src/Columns/Columns.test.tsx +102 -0
- package/src/Columns/Columns.tsx +69 -0
- package/src/Columns/index.ts +1 -0
- package/src/Container/Container.stories.mdx +19 -0
- package/src/Container/Container.test.tsx +26 -0
- package/src/Container/Container.tsx +13 -0
- package/src/Container/index.ts +1 -0
- package/src/Dialog/Dialog.stories.mdx +73 -0
- package/src/Dialog/Dialog.test.tsx +87 -0
- package/src/Dialog/Dialog.tsx +84 -0
- package/src/Dialog/ModalDialog.tsx +47 -0
- package/src/Dialog/index.ts +1 -0
- package/src/Divider/Divider.stories.mdx +37 -0
- package/src/Divider/Divider.test.tsx +63 -0
- package/src/Divider/Divider.tsx +13 -0
- package/src/Divider/index.ts +1 -0
- package/src/Field/Field.stories.mdx +97 -0
- package/src/Field/Field.test.tsx +80 -0
- package/src/Field/Field.tsx +54 -0
- package/src/Field/index.ts +1 -0
- package/src/Heading/Heading.stories.mdx +36 -76
- package/src/Heading/Heading.test.tsx +31 -17
- package/src/Heading/Heading.tsx +15 -12
- package/src/Hidden/Hidden.stories.mdx +39 -0
- package/src/Hidden/Hidden.test.tsx +24 -0
- package/src/Hidden/Hidden.tsx +16 -0
- package/src/Hidden/index.ts +1 -0
- package/src/Image/Image.stories.mdx +36 -0
- package/src/Image/Image.test.tsx +70 -0
- package/src/Image/Image.tsx +13 -0
- package/src/Image/index.ts +1 -0
- package/src/Input/Input.stories.mdx +61 -0
- package/src/Input/Input.test.tsx +70 -0
- package/src/Input/Input.tsx +13 -0
- package/src/Input/index.ts +1 -0
- package/src/Label/Label.stories.mdx +50 -34
- package/src/Label/Label.test.tsx +45 -16
- package/src/Label/Label.tsx +26 -17
- package/src/Link/Link.stories.mdx +40 -31
- package/src/Link/Link.test.tsx +53 -28
- package/src/Link/Link.tsx +32 -14
- package/src/Menu/Menu.stories.mdx +81 -0
- package/src/Menu/Menu.test.tsx +79 -0
- package/src/Menu/Menu.tsx +41 -0
- package/src/Menu/index.ts +1 -0
- package/src/MenuItem/MenuItem.stories.mdx +37 -0
- package/src/MenuItem/MenuItem.test.tsx +63 -0
- package/src/MenuItem/MenuItem.tsx +23 -0
- package/src/MenuItem/index.ts +1 -0
- package/src/Message/Message.stories.mdx +44 -0
- package/src/Message/Message.test.tsx +87 -0
- package/src/Message/Message.tsx +43 -0
- package/src/Message/index.ts +1 -0
- package/src/Provider/MarigoldProvider.test.tsx +126 -0
- package/src/Provider/MarigoldProvider.tsx +29 -0
- package/src/Provider/index.ts +3 -0
- package/src/Radio/Radio.stories.mdx +80 -83
- package/src/Radio/Radio.test.tsx +63 -22
- package/src/Radio/Radio.tsx +110 -35
- package/src/Radio/RadioIcons.tsx +39 -0
- package/src/Select/ListBox.tsx +39 -0
- package/src/Select/ListBoxSection.tsx +40 -0
- package/src/Select/Option.tsx +48 -0
- package/src/Select/Popover.tsx +50 -0
- package/src/Select/Select.stories.mdx +72 -37
- package/src/Select/Select.test.tsx +271 -28
- package/src/Select/Select.tsx +158 -23
- package/src/Slider/Slider.stories.mdx +26 -54
- package/src/Slider/Slider.test.tsx +13 -13
- package/src/Slider/Slider.tsx +20 -18
- package/src/Stack/Stack.stories.mdx +51 -0
- package/src/Stack/Stack.test.tsx +129 -0
- package/src/Stack/Stack.tsx +39 -0
- package/src/Stack/index.ts +1 -0
- package/src/Text/Text.stories.mdx +53 -47
- package/src/Text/Text.test.tsx +55 -15
- package/src/Text/Text.tsx +44 -10
- package/src/Textarea/Textarea.stories.mdx +68 -21
- package/src/Textarea/Textarea.test.tsx +47 -16
- package/src/Textarea/Textarea.tsx +46 -14
- package/src/ValidationMessage/ValidationMessage.stories.mdx +36 -0
- package/src/ValidationMessage/ValidationMessage.test.tsx +63 -0
- package/src/ValidationMessage/ValidationMessage.tsx +28 -0
- package/src/ValidationMessage/index.ts +1 -0
- package/src/index.ts +22 -4
- package/src/theme.ts +24 -4
- package/dist/Svg/Svg.d.ts +0 -5
- package/dist/Svg/index.d.ts +0 -1
- package/dist/TextInput/TextInput.d.ts +0 -3
- package/dist/TextInput/index.d.ts +0 -1
- package/src/Svg/Svg.stories.mdx +0 -47
- package/src/Svg/Svg.test.tsx +0 -58
- package/src/Svg/Svg.tsx +0 -25
- package/src/Svg/index.ts +0 -1
- package/src/TextInput/TextInput.stories.mdx +0 -37
- package/src/TextInput/TextInput.test.tsx +0 -71
- package/src/TextInput/TextInput.tsx +0 -21
- package/src/TextInput/index.ts +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import {
|
|
4
|
-
import { Textarea } from '
|
|
3
|
+
import { ThemeProvider } from '@marigold/system';
|
|
4
|
+
import { Textarea } from '../Textarea';
|
|
5
5
|
|
|
6
6
|
const theme = {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
textarea: {
|
|
8
|
+
default: {
|
|
9
9
|
fontFamily: 'Inter Regular',
|
|
10
10
|
},
|
|
11
11
|
textarea2: {
|
|
@@ -16,9 +16,9 @@ const theme = {
|
|
|
16
16
|
|
|
17
17
|
test('supports default variant and themeSection', () => {
|
|
18
18
|
render(
|
|
19
|
-
<
|
|
19
|
+
<ThemeProvider theme={theme}>
|
|
20
20
|
<Textarea title="textarea" />
|
|
21
|
-
</
|
|
21
|
+
</ThemeProvider>
|
|
22
22
|
);
|
|
23
23
|
const textarea = screen.getByTitle(/textarea/);
|
|
24
24
|
|
|
@@ -27,9 +27,9 @@ test('supports default variant and themeSection', () => {
|
|
|
27
27
|
|
|
28
28
|
test('accepts other variant than default', () => {
|
|
29
29
|
render(
|
|
30
|
-
<
|
|
30
|
+
<ThemeProvider theme={theme}>
|
|
31
31
|
<Textarea variant="textarea2" title="textarea" />
|
|
32
|
-
</
|
|
32
|
+
</ThemeProvider>
|
|
33
33
|
);
|
|
34
34
|
const textarea = screen.getByTitle(/textarea/);
|
|
35
35
|
|
|
@@ -38,23 +38,54 @@ test('accepts other variant than default', () => {
|
|
|
38
38
|
|
|
39
39
|
test('renders correct HTML element', () => {
|
|
40
40
|
render(
|
|
41
|
-
<
|
|
41
|
+
<ThemeProvider theme={theme}>
|
|
42
42
|
<Textarea title="textarea" />
|
|
43
|
-
</
|
|
43
|
+
</ThemeProvider>
|
|
44
44
|
);
|
|
45
45
|
const textarea = screen.getByTitle(/textarea/);
|
|
46
46
|
|
|
47
47
|
expect(textarea instanceof HTMLTextAreaElement).toBeTruthy();
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
test('
|
|
50
|
+
test('supports label prop', () => {
|
|
51
51
|
render(
|
|
52
|
-
<
|
|
53
|
-
<Textarea
|
|
54
|
-
</
|
|
52
|
+
<ThemeProvider theme={theme}>
|
|
53
|
+
<Textarea label="test" htmlFor="myId" title="textarea" />
|
|
54
|
+
</ThemeProvider>
|
|
55
|
+
);
|
|
56
|
+
const textarea = screen.getByText(/test/);
|
|
57
|
+
|
|
58
|
+
expect(textarea instanceof HTMLLabelElement).toBeTruthy();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('supports error and errorMessage prop', () => {
|
|
62
|
+
render(
|
|
63
|
+
<ThemeProvider theme={theme}>
|
|
64
|
+
<Textarea error errorMessage="error" label="label" title="textarea" />
|
|
65
|
+
</ThemeProvider>
|
|
66
|
+
);
|
|
67
|
+
const textarea = screen.getByText(/error/);
|
|
68
|
+
expect(textarea).toBeDefined();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('supports required prop', () => {
|
|
72
|
+
render(
|
|
73
|
+
<ThemeProvider theme={theme}>
|
|
74
|
+
<Textarea label="test" htmlFor="myId" required title="textarea" />
|
|
75
|
+
</ThemeProvider>
|
|
76
|
+
);
|
|
77
|
+
const label = screen.getByText(/test/);
|
|
78
|
+
|
|
79
|
+
expect(label.nextSibling instanceof SVGElement).toBeTruthy();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
test('accepts custom styles prop className', () => {
|
|
83
|
+
render(
|
|
84
|
+
<ThemeProvider theme={theme}>
|
|
85
|
+
<Textarea className="custom-class-name" title="textarea" />
|
|
86
|
+
</ThemeProvider>
|
|
55
87
|
);
|
|
56
88
|
const textarea = screen.getByTitle(/textarea/);
|
|
57
89
|
|
|
58
|
-
expect(textarea).
|
|
59
|
-
expect(textarea).toHaveStyle(`font-family: Inter Regular`);
|
|
90
|
+
expect(textarea.className).toMatch('custom-class-name');
|
|
60
91
|
});
|
|
@@ -1,18 +1,50 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Exclamation } from '@marigold/icons';
|
|
3
|
+
import { ComponentProps } from '@marigold/types';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
import { ValidationMessage } from '../ValidationMessage';
|
|
6
|
+
import { Label } from '../Label';
|
|
7
|
+
import { Box } from '../Box';
|
|
5
8
|
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
export type TextareaProps = {
|
|
10
|
+
variant?: string;
|
|
11
|
+
label?: string;
|
|
12
|
+
htmlFor?: string;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
error?: boolean;
|
|
15
|
+
errorMessage?: string;
|
|
16
|
+
} & ComponentProps<'textarea'>;
|
|
17
|
+
|
|
18
|
+
export const Textarea: React.FC<TextareaProps> = ({
|
|
19
|
+
variant = 'default',
|
|
20
|
+
htmlFor = 'textarea',
|
|
21
|
+
label,
|
|
22
|
+
error,
|
|
23
|
+
errorMessage,
|
|
24
|
+
required,
|
|
25
|
+
className = '',
|
|
26
|
+
children,
|
|
27
|
+
...props
|
|
28
|
+
}) => (
|
|
29
|
+
<Box>
|
|
30
|
+
{label && (
|
|
31
|
+
<Label htmlFor={htmlFor} required={required}>
|
|
32
|
+
{label}
|
|
33
|
+
</Label>
|
|
34
|
+
)}
|
|
35
|
+
<Box
|
|
36
|
+
as="textarea"
|
|
37
|
+
{...props}
|
|
38
|
+
display="block"
|
|
39
|
+
variant={`textarea.${variant}`}
|
|
40
|
+
css={{ outlineColor: error && 'error' }}
|
|
41
|
+
className={className}
|
|
42
|
+
/>
|
|
43
|
+
{error && errorMessage && (
|
|
44
|
+
<ValidationMessage>
|
|
45
|
+
<Exclamation size={16} />
|
|
46
|
+
{errorMessage}
|
|
47
|
+
</ValidationMessage>
|
|
48
|
+
)}
|
|
49
|
+
</Box>
|
|
18
50
|
);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ArgsTable, Canvas, Meta, Story } from '@storybook/addon-docs';
|
|
2
|
+
import { ValidationMessage } from './ValidationMessage';
|
|
3
|
+
import { Exclamation } from '@marigold/icons';
|
|
4
|
+
|
|
5
|
+
<Meta
|
|
6
|
+
title="Components/ValidationMessage"
|
|
7
|
+
argTypes={{
|
|
8
|
+
variant: {
|
|
9
|
+
control: {
|
|
10
|
+
type: 'text',
|
|
11
|
+
},
|
|
12
|
+
description: '?',
|
|
13
|
+
table: {
|
|
14
|
+
defaultValue: {
|
|
15
|
+
summary: 'error',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
}}
|
|
20
|
+
/>
|
|
21
|
+
|
|
22
|
+
# ValidationMessage
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export const Template = args => (
|
|
26
|
+
<ValidationMessage {...args}>
|
|
27
|
+
<Exclamation />
|
|
28
|
+
Validation message
|
|
29
|
+
</ValidationMessage>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
<Canvas>
|
|
33
|
+
<Story name="Default">{Template.bind({})}</Story>
|
|
34
|
+
</Canvas>
|
|
35
|
+
|
|
36
|
+
<ArgsTable story="Default" />
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { ThemeProvider } from '@marigold/system';
|
|
4
|
+
import { ValidationMessage } from './ValidationMessage';
|
|
5
|
+
|
|
6
|
+
const theme = {
|
|
7
|
+
validation: {
|
|
8
|
+
error: {
|
|
9
|
+
p: '8px',
|
|
10
|
+
},
|
|
11
|
+
warning: {
|
|
12
|
+
p: '4px',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
test('supports default variant and themeSection', () => {
|
|
18
|
+
render(
|
|
19
|
+
<ThemeProvider theme={theme}>
|
|
20
|
+
<ValidationMessage title="error">error</ValidationMessage>
|
|
21
|
+
</ThemeProvider>
|
|
22
|
+
);
|
|
23
|
+
const validation = screen.getByTitle(/error/);
|
|
24
|
+
|
|
25
|
+
expect(validation).toHaveStyle(`padding: 8px`);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test('accepts other variant than default', () => {
|
|
29
|
+
render(
|
|
30
|
+
<ThemeProvider theme={theme}>
|
|
31
|
+
<ValidationMessage title="warning" variant="warning">
|
|
32
|
+
warning
|
|
33
|
+
</ValidationMessage>
|
|
34
|
+
</ThemeProvider>
|
|
35
|
+
);
|
|
36
|
+
const validation = screen.getByTitle(/warning/);
|
|
37
|
+
|
|
38
|
+
expect(validation).toHaveStyle(`padding: 4px`);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('renders correct HTML element', () => {
|
|
42
|
+
render(
|
|
43
|
+
<ThemeProvider theme={theme}>
|
|
44
|
+
<ValidationMessage title="error">error</ValidationMessage>
|
|
45
|
+
</ThemeProvider>
|
|
46
|
+
);
|
|
47
|
+
const validation = screen.getByTitle(/error/);
|
|
48
|
+
|
|
49
|
+
expect(validation instanceof HTMLSpanElement).toBeTruthy();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test('accepts custom styles prop className', () => {
|
|
53
|
+
render(
|
|
54
|
+
<ThemeProvider theme={theme}>
|
|
55
|
+
<ValidationMessage className="custom-class-name" title="validation">
|
|
56
|
+
validation
|
|
57
|
+
</ValidationMessage>
|
|
58
|
+
</ThemeProvider>
|
|
59
|
+
);
|
|
60
|
+
const validation = screen.getByTitle(/validation/);
|
|
61
|
+
|
|
62
|
+
expect(validation.className).toMatch('custom-class-name');
|
|
63
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ComponentProps } from '@marigold/types';
|
|
3
|
+
|
|
4
|
+
import { Box } from '../Box';
|
|
5
|
+
|
|
6
|
+
export type ValidationMessageProps = {
|
|
7
|
+
variant?: string;
|
|
8
|
+
} & ComponentProps<'span'>;
|
|
9
|
+
|
|
10
|
+
export const ValidationMessage: React.FC<ValidationMessageProps> = ({
|
|
11
|
+
variant = 'error',
|
|
12
|
+
children,
|
|
13
|
+
className,
|
|
14
|
+
...props
|
|
15
|
+
}) => {
|
|
16
|
+
return (
|
|
17
|
+
<Box
|
|
18
|
+
as="span"
|
|
19
|
+
display="flex"
|
|
20
|
+
alignItems="center"
|
|
21
|
+
variant={`validation.${variant}`}
|
|
22
|
+
className={className}
|
|
23
|
+
{...props}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</Box>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ValidationMessage';
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
|
-
export { Box, BoxProps, MarigoldProvider } from '@marigold/system';
|
|
2
1
|
export * from './theme';
|
|
3
2
|
|
|
3
|
+
export * from './ActionGroup';
|
|
4
|
+
export * from './Alert';
|
|
5
|
+
export * from './Badge';
|
|
6
|
+
export * from './Box';
|
|
4
7
|
export * from './Button';
|
|
8
|
+
export * from './Card';
|
|
5
9
|
export * from './Checkbox';
|
|
10
|
+
export * from './Column';
|
|
11
|
+
export * from './Columns';
|
|
12
|
+
export * from './Dialog';
|
|
13
|
+
export * from './Divider';
|
|
14
|
+
export * from './Field';
|
|
6
15
|
export * from './Heading';
|
|
16
|
+
export * from './Hidden';
|
|
17
|
+
export * from './Image';
|
|
7
18
|
export * from './Label';
|
|
8
19
|
export * from './Link';
|
|
20
|
+
export * from './Menu';
|
|
21
|
+
export * from './MenuItem';
|
|
22
|
+
export * from './Message';
|
|
23
|
+
export * from './Provider';
|
|
9
24
|
export * from './Radio';
|
|
10
25
|
export * from './Slider';
|
|
11
26
|
export * from './Select';
|
|
12
|
-
export * from './
|
|
27
|
+
export * from './Stack';
|
|
13
28
|
export * from './Text';
|
|
14
29
|
export * from './Textarea';
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
30
|
+
export * from './Input';
|
|
31
|
+
export * from './Container';
|
|
32
|
+
export * from './ValidationMessage';
|
|
33
|
+
|
|
34
|
+
export { Item, Section } from '@react-stately/collections';
|
package/src/theme.ts
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
export type CSSObject = object;
|
|
2
2
|
|
|
3
3
|
export type BaseTheme = {
|
|
4
|
-
breakpoints:
|
|
5
|
-
space:
|
|
4
|
+
breakpoints: string[];
|
|
5
|
+
space: {
|
|
6
|
+
none: number;
|
|
7
|
+
xxsmall: number;
|
|
8
|
+
xsmall: number;
|
|
9
|
+
small: number;
|
|
10
|
+
medium: number;
|
|
11
|
+
large: number;
|
|
12
|
+
xlarge: number;
|
|
13
|
+
xxlarge: number;
|
|
14
|
+
};
|
|
6
15
|
fonts: {
|
|
7
16
|
body: string;
|
|
8
17
|
heading: string;
|
|
9
18
|
};
|
|
10
|
-
fontSizes:
|
|
19
|
+
fontSizes: {
|
|
20
|
+
xxsmall: string;
|
|
21
|
+
xsmall: string;
|
|
22
|
+
small: string;
|
|
23
|
+
medium: string;
|
|
24
|
+
large: string;
|
|
25
|
+
xlarge: string;
|
|
26
|
+
};
|
|
11
27
|
fontWeights: {
|
|
12
28
|
body: number;
|
|
13
29
|
heading: number;
|
|
@@ -22,7 +38,11 @@ export type BaseTheme = {
|
|
|
22
38
|
background: string;
|
|
23
39
|
primary: string;
|
|
24
40
|
secondary: string;
|
|
25
|
-
|
|
41
|
+
disabled: string;
|
|
42
|
+
error: string;
|
|
43
|
+
warning: string;
|
|
44
|
+
info: string;
|
|
45
|
+
success: string;
|
|
26
46
|
[key: string]: string;
|
|
27
47
|
};
|
|
28
48
|
[key: string]: CSSObject;
|
package/dist/Svg/Svg.d.ts
DELETED
package/dist/Svg/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Svg';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './TextInput';
|
package/src/Svg/Svg.stories.mdx
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
|
|
2
|
-
import { Feedback } from '@marigold/icons';
|
|
3
|
-
import { Svg } from './Svg';
|
|
4
|
-
|
|
5
|
-
<Meta title="Components/Iconography/Svg" />
|
|
6
|
-
|
|
7
|
-
# SVG-Component
|
|
8
|
-
|
|
9
|
-
## Description
|
|
10
|
-
|
|
11
|
-
With the SVG component you can render a `svg` element.
|
|
12
|
-
By adding the `size` prop you can change to another size. `24` is the default size.
|
|
13
|
-
The `fill` prop is the second attribute and per default `currentcolor`.
|
|
14
|
-
Specific css style prop can also be added.
|
|
15
|
-
|
|
16
|
-
## Properties
|
|
17
|
-
|
|
18
|
-
| Property | Type | Default |
|
|
19
|
-
| :------- | :------- | :--------------- |
|
|
20
|
-
| `size` | `number` | `24` |
|
|
21
|
-
| `fill` | `string` | `'currentcolor'` |
|
|
22
|
-
|
|
23
|
-
## Import
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
import { Svg } from '@marigold/components';
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## Usage
|
|
30
|
-
|
|
31
|
-
<Preview>
|
|
32
|
-
<Story name="example1-svg">
|
|
33
|
-
<Svg>
|
|
34
|
-
<path d="M11.9634 17.6396C12.8179 17.6396 13.5991 17.4321 14.3071 17.0171C15.0151 16.602 15.5828 16.0344 16.01 15.3142C16.4373 14.594 16.6509 13.8127 16.6509 12.9705C16.6509 12.1282 16.4373 11.3469 16.01 10.6267C15.5828 9.90649 15.0151 9.33887 14.3071 8.92383C13.5991 8.50879 12.8179 8.30127 11.9634 8.30127C11.1089 8.30127 10.3276 8.50879 9.61963 8.92383C8.91162 9.33887 8.3501 9.90649 7.93506 10.6267C7.52002 11.3469 7.3125 12.1282 7.3125 12.9705C7.3125 13.8127 7.52002 14.594 7.93506 15.3142C8.3501 16.0344 8.91162 16.602 9.61963 17.0171C10.3276 17.4321 11.1089 17.6396 11.9634 17.6396ZM19.4341 5.48145C19.9468 5.48145 20.3862 5.66455 20.7524 6.03076C21.1187 6.39697 21.3018 6.83642 21.3018 7.34912V18.5552C21.3018 19.0679 21.1187 19.5073 20.7524 19.8735C20.3862 20.2397 19.9468 20.4229 19.4341 20.4229H4.49268C3.97998 20.4229 3.54053 20.2397 3.17432 19.8735C2.8081 19.5073 2.625 19.0679 2.625 18.5552V7.34912C2.625 6.83642 2.8081 6.39697 3.17432 6.03076C3.54053 5.66455 3.97998 5.48145 4.49268 5.48145H7.45898L9.18018 3.61377H14.7832L16.4678 5.48145H19.4341ZM11.9634 9.98584C12.7935 9.98584 13.5015 10.2788 14.0874 10.8647C14.6733 11.4507 14.9663 12.1526 14.9663 12.9705C14.9663 13.7883 14.6733 14.4902 14.0874 15.0762C13.5015 15.6621 12.7935 15.9551 11.9634 15.9551C11.1333 15.9551 10.4253 15.6621 9.83936 15.0762C9.25342 14.4902 8.96045 13.7883 8.96045 12.9705C8.96045 12.1526 9.25342 11.4507 9.83936 10.8647C10.4253 10.2788 11.1333 9.98584 11.9634 9.98584Z" />
|
|
35
|
-
</Svg>
|
|
36
|
-
</Story>
|
|
37
|
-
<Story name="example2-svg">
|
|
38
|
-
<Svg size={64}>
|
|
39
|
-
<path d="M15.2617 3H8.69638C7.33407 3 6.23438 4.09636 6.23438 5.45455V18.5455C6.23438 19.9036 7.33407 21 8.69638 21H15.2617C16.624 21 17.7237 19.9036 17.7237 18.5455V5.45455C17.7237 4.09636 16.624 3 15.2617 3V3ZM13.6204 19.3637H10.3377V18.5455H13.6204V19.3637V19.3637ZM16.2876 16.909H7.67054V5.4545H16.2876V16.909V16.909Z" />
|
|
40
|
-
</Svg>
|
|
41
|
-
</Story>
|
|
42
|
-
<Story name="example3-svg">
|
|
43
|
-
<Svg size={32} fill="orange">
|
|
44
|
-
<path d="M9.9 20.113V13.8415H14.1V20.113H19.35V11.751H22.5L12 2.34375L1.5 11.751H4.65V20.113H9.9Z" />
|
|
45
|
-
</Svg>
|
|
46
|
-
</Story>
|
|
47
|
-
</Preview>
|
package/src/Svg/Svg.test.tsx
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { Svg } from './Svg';
|
|
4
|
-
|
|
5
|
-
test('supports default fill color', () => {
|
|
6
|
-
render(
|
|
7
|
-
<Svg title="svg">
|
|
8
|
-
<path d="M9.9 20.113V13.8415H14" />
|
|
9
|
-
</Svg>
|
|
10
|
-
);
|
|
11
|
-
const svg = screen.getByTitle(/svg/);
|
|
12
|
-
|
|
13
|
-
expect(svg.getAttribute('fill')).toEqual('currentcolor');
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('supports default size', () => {
|
|
17
|
-
render(
|
|
18
|
-
<Svg title="svg">
|
|
19
|
-
<path d="M9.9 20.113V13.8415H14" />
|
|
20
|
-
</Svg>
|
|
21
|
-
);
|
|
22
|
-
const svg = screen.getByTitle(/svg/);
|
|
23
|
-
|
|
24
|
-
expect(svg.getAttribute('width')).toEqual('24');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('supports size prop', () => {
|
|
28
|
-
render(
|
|
29
|
-
<Svg title="svg" size={30}>
|
|
30
|
-
<path d="M9.9 20.113V13.8415H14" />
|
|
31
|
-
</Svg>
|
|
32
|
-
);
|
|
33
|
-
const svg = screen.getByTitle(/svg/);
|
|
34
|
-
|
|
35
|
-
expect(svg.getAttribute('width')).toEqual('30');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
test('supports fill prop', () => {
|
|
39
|
-
render(
|
|
40
|
-
<Svg title="svg" fill="#fafafa">
|
|
41
|
-
<path d="M9.9 20.113V13.8415H14" />
|
|
42
|
-
</Svg>
|
|
43
|
-
);
|
|
44
|
-
const svg = screen.getByTitle(/svg/);
|
|
45
|
-
|
|
46
|
-
expect(svg.getAttribute('fill')).toEqual('#fafafa');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('renders <svg> element', () => {
|
|
50
|
-
render(
|
|
51
|
-
<Svg title="svg">
|
|
52
|
-
<path d="M9.9 20.113V13.8415H14" />
|
|
53
|
-
</Svg>
|
|
54
|
-
);
|
|
55
|
-
const svg = screen.getByTitle(/svg/);
|
|
56
|
-
|
|
57
|
-
expect(svg instanceof SVGElement).toBeTruthy();
|
|
58
|
-
});
|
package/src/Svg/Svg.tsx
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, system } from '@marigold/system';
|
|
3
|
-
|
|
4
|
-
type SvgProps = {
|
|
5
|
-
size?: number;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const Svg = system<SvgProps, 'svg'>(
|
|
9
|
-
({ size = 24, fill = 'currentcolor', children, ...props }) => {
|
|
10
|
-
return (
|
|
11
|
-
<Box
|
|
12
|
-
as="svg"
|
|
13
|
-
width={size}
|
|
14
|
-
height={size}
|
|
15
|
-
viewBox="0 0 24 24"
|
|
16
|
-
fill={fill}
|
|
17
|
-
themeSection="icon"
|
|
18
|
-
variant="icon"
|
|
19
|
-
{...props}
|
|
20
|
-
>
|
|
21
|
-
{children}
|
|
22
|
-
</Box>
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
);
|
package/src/Svg/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Svg';
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Meta, Story, Preview } from '@storybook/addon-docs/blocks';
|
|
2
|
-
import { TextInput, Label } from '@marigold/components';
|
|
3
|
-
|
|
4
|
-
<Meta title="Components/Form/TextInput" />
|
|
5
|
-
|
|
6
|
-
# TextInput
|
|
7
|
-
|
|
8
|
-
## Description
|
|
9
|
-
|
|
10
|
-
Form input field for different types of text.
|
|
11
|
-
|
|
12
|
-
## Import
|
|
13
|
-
|
|
14
|
-
```tsx
|
|
15
|
-
import { TextInput } from '@marigold/components';
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Usage
|
|
19
|
-
|
|
20
|
-
<Preview>
|
|
21
|
-
<Story name="TextInput">
|
|
22
|
-
<div>
|
|
23
|
-
<Label htmlFor="input">
|
|
24
|
-
Label
|
|
25
|
-
<TextInput id="input" placeholder="Placeholder" />
|
|
26
|
-
</Label>
|
|
27
|
-
<Label htmlFor="input2">
|
|
28
|
-
Label
|
|
29
|
-
<TextInput id="input2" placeholder="Disabled" disabled />
|
|
30
|
-
</Label>
|
|
31
|
-
<Label htmlFor="input3">
|
|
32
|
-
Label
|
|
33
|
-
<TextInput id="input2" placeholder="0" type="number" />
|
|
34
|
-
</Label>
|
|
35
|
-
</div>
|
|
36
|
-
</Story>
|
|
37
|
-
</Preview>
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render, screen } from '@testing-library/react';
|
|
3
|
-
import { MarigoldProvider } from '@marigold/system';
|
|
4
|
-
import { TextInput } from '@marigold/components';
|
|
5
|
-
|
|
6
|
-
const theme = {
|
|
7
|
-
form: {
|
|
8
|
-
input: {
|
|
9
|
-
fontFamily: 'Inter',
|
|
10
|
-
},
|
|
11
|
-
input2: {
|
|
12
|
-
fontFamily: 'Roboto',
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
test('supports default variant and themeSection', () => {
|
|
18
|
-
render(
|
|
19
|
-
<MarigoldProvider theme={theme}>
|
|
20
|
-
<TextInput title="input" />
|
|
21
|
-
</MarigoldProvider>
|
|
22
|
-
);
|
|
23
|
-
const input = screen.getByTitle('input');
|
|
24
|
-
|
|
25
|
-
expect(input).toHaveStyle(`font-family: Inter`);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test('accepts other variant than default', () => {
|
|
29
|
-
render(
|
|
30
|
-
<MarigoldProvider theme={theme}>
|
|
31
|
-
<TextInput title="input" variant="input2" />
|
|
32
|
-
</MarigoldProvider>
|
|
33
|
-
);
|
|
34
|
-
const input = screen.getByTitle('input');
|
|
35
|
-
|
|
36
|
-
expect(input).toHaveStyle(`font-family: Roboto`);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test('renders correct HTML element', () => {
|
|
40
|
-
render(
|
|
41
|
-
<MarigoldProvider theme={theme}>
|
|
42
|
-
<TextInput title="input" />
|
|
43
|
-
</MarigoldProvider>
|
|
44
|
-
);
|
|
45
|
-
const input = screen.getByTitle('input');
|
|
46
|
-
|
|
47
|
-
expect(input instanceof HTMLInputElement).toBeTruthy();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('supports custom prop', () => {
|
|
51
|
-
render(
|
|
52
|
-
<MarigoldProvider theme={theme}>
|
|
53
|
-
<TextInput title="input" placeholder="placeholder" />
|
|
54
|
-
</MarigoldProvider>
|
|
55
|
-
);
|
|
56
|
-
const input = screen.getByTitle('input');
|
|
57
|
-
|
|
58
|
-
expect(input).toHaveAttribute('placeholder');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('variant styles cannot be overridden with CSS prop', () => {
|
|
62
|
-
render(
|
|
63
|
-
<MarigoldProvider theme={theme}>
|
|
64
|
-
<TextInput title="input" css={{ fontFamily: 'Oswald Regular' }} />
|
|
65
|
-
</MarigoldProvider>
|
|
66
|
-
);
|
|
67
|
-
const input = screen.getByTitle('input');
|
|
68
|
-
|
|
69
|
-
expect(input).not.toHaveStyle(`font-family: Oswald Regular`);
|
|
70
|
-
expect(input).toHaveStyle(`font-family: Inter`);
|
|
71
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Box, system } from '@marigold/system';
|
|
3
|
-
|
|
4
|
-
type TextInputProps = {};
|
|
5
|
-
|
|
6
|
-
export const TextInput = system<TextInputProps, 'input'>(
|
|
7
|
-
({ variant = 'input', type = 'text', children, ...props }) => {
|
|
8
|
-
return (
|
|
9
|
-
<Box
|
|
10
|
-
as="input"
|
|
11
|
-
type={type}
|
|
12
|
-
themeSection="form"
|
|
13
|
-
variant={variant}
|
|
14
|
-
{...props}
|
|
15
|
-
css={{
|
|
16
|
-
border: 0,
|
|
17
|
-
}}
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
);
|
package/src/TextInput/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './TextInput';
|