@marigold/components 0.2.0 → 0.3.3
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 +180 -0
- package/dist/ActionGroup/ActionGroup.d.ts +1 -2
- package/dist/ActionGroup/ActionGroup.stories.d.ts +5 -0
- package/dist/Alert/Alert.d.ts +7 -1
- package/dist/Alert/Alert.stories.d.ts +5 -0
- package/dist/Badge/Badge.d.ts +5 -0
- package/dist/Badge/Badge.stories.d.ts +5 -0
- package/dist/Box.d.ts +2 -0
- package/dist/Button/Button.d.ts +5 -0
- package/dist/Button/Button.stories.d.ts +5 -0
- package/dist/Card/Card.d.ts +5 -0
- package/dist/Card/Card.stories.d.ts +5 -0
- package/dist/Checkbox/Checkbox.d.ts +10 -5
- package/dist/Checkbox/Checkbox.stories.d.ts +5 -0
- package/dist/Checkbox/CheckboxIcons.d.ts +9 -9
- package/dist/Column/Column.stories.d.ts +5 -0
- package/dist/Columns/Columns.d.ts +2 -2
- package/dist/Columns/Columns.stories.d.ts +5 -0
- package/dist/Container/Container.stories.d.ts +5 -0
- package/dist/Dialog/Dialog.d.ts +5 -2
- package/dist/Dialog/Dialog.stories.d.ts +5 -0
- package/dist/Dialog/ModalDialog.d.ts +4 -1
- package/dist/Divider/Divider.d.ts +7 -3
- package/dist/Divider/Divider.stories.d.ts +5 -0
- package/dist/Field/Field.d.ts +2 -0
- package/dist/Field/Field.stories.d.ts +5 -0
- package/dist/Image/Image.d.ts +5 -0
- package/dist/Image/Image.stories.d.ts +5 -0
- package/dist/Inline/Inline.d.ts +7 -0
- package/dist/Inline/Inline.stories.d.ts +5 -0
- package/dist/Inline/index.d.ts +1 -0
- package/dist/Input/Input.d.ts +5 -0
- package/dist/Input/Input.stories.d.ts +5 -0
- package/dist/Label/Label.d.ts +12 -1
- package/dist/Label/Label.stories.d.ts +5 -0
- package/dist/Link/Link.d.ts +3 -0
- package/dist/Link/Link.stories.d.ts +5 -0
- package/dist/Menu/Menu.d.ts +3 -0
- package/dist/Menu/Menu.stories.d.ts +5 -0
- package/dist/MenuItem/MenuItem.d.ts +5 -0
- package/dist/MenuItem/MenuItem.stories.d.ts +5 -0
- package/dist/Message/Message.d.ts +5 -0
- package/dist/Message/Message.stories.d.ts +5 -0
- package/dist/Provider/MarigoldProvider.d.ts +11 -3
- package/dist/Provider/index.d.ts +1 -1
- package/dist/Radio/Radio.d.ts +9 -5
- package/dist/Radio/Radio.stories.d.ts +5 -0
- package/dist/Radio/RadioIcon.d.ts +9 -0
- package/dist/Select/ListBox.d.ts +1 -0
- package/dist/Select/ListBoxSection.d.ts +1 -0
- package/dist/Select/Option.d.ts +1 -0
- package/dist/Select/Select.d.ts +15 -1
- package/dist/Select/Select.stories.d.ts +5 -0
- package/dist/Slider/Slider.d.ts +5 -0
- package/dist/Slider/Slider.stories.d.ts +5 -0
- package/dist/Stack/Stack.stories.d.ts +5 -0
- package/dist/Text/Text.d.ts +5 -0
- package/dist/Text/Text.stories.d.ts +5 -0
- package/dist/Textarea/Textarea.d.ts +5 -0
- package/dist/Textarea/Textarea.stories.d.ts +5 -0
- package/dist/ValidationMessage/ValidationMessage.d.ts +5 -0
- package/dist/ValidationMessage/ValidationMessage.stories.d.ts +5 -0
- package/dist/VisuallyHidden/VisuallyHidden.d.ts +1 -0
- package/dist/VisuallyHidden/VisuallyHidden.stories.d.ts +5 -0
- package/dist/VisuallyHidden/index.d.ts +1 -0
- package/dist/components.cjs.development.js +536 -580
- 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 +481 -535
- package/dist/components.esm.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/theme.d.ts +23 -48
- package/package.json +8 -4
- package/src/ActionGroup/ActionGroup.stories.tsx +47 -0
- package/src/ActionGroup/ActionGroup.test.tsx +36 -36
- package/src/ActionGroup/ActionGroup.tsx +17 -28
- package/src/Alert/Alert.stories.tsx +32 -0
- package/src/Alert/Alert.test.tsx +4 -1
- package/src/Alert/Alert.tsx +18 -3
- package/src/Badge/Badge.stories.tsx +38 -0
- package/src/Badge/Badge.test.tsx +5 -1
- package/src/Badge/Badge.tsx +13 -1
- package/src/Box.ts +2 -0
- package/src/Button/{Button.stories.mdx → Button.stories.tsx} +10 -17
- package/src/Button/Button.test.tsx +34 -11
- package/src/Button/Button.tsx +17 -3
- package/src/Card/{Card.stories.mdx → Card.stories.tsx} +9 -17
- package/src/Card/Card.test.tsx +8 -3
- package/src/Card/Card.tsx +13 -1
- package/src/Checkbox/{Checkbox.stories.mdx → Checkbox.stories.tsx} +31 -39
- package/src/Checkbox/Checkbox.test.tsx +77 -8
- package/src/Checkbox/Checkbox.tsx +70 -90
- package/src/Checkbox/CheckboxIcons.tsx +51 -41
- package/src/Column/Column.stories.tsx +33 -0
- package/src/Column/Column.tsx +0 -0
- package/src/Columns/Columns.stories.tsx +75 -0
- package/src/Columns/Columns.test.tsx +34 -23
- package/src/Columns/Columns.tsx +30 -30
- package/src/Container/Container.stories.tsx +14 -0
- package/src/Container/Container.tsx +0 -0
- package/src/Dialog/{Dialog.stories.mdx → Dialog.stories.tsx} +33 -18
- package/src/Dialog/Dialog.test.tsx +91 -20
- package/src/Dialog/Dialog.tsx +63 -17
- package/src/Dialog/ModalDialog.tsx +33 -4
- package/src/Divider/Divider.stories.tsx +30 -0
- package/src/Divider/Divider.test.tsx +32 -23
- package/src/Divider/Divider.tsx +27 -7
- package/src/Field/{Field.stories.mdx → Field.stories.tsx} +33 -20
- package/src/Field/Field.test.tsx +55 -5
- package/src/Field/Field.tsx +10 -8
- package/src/Image/Image.stories.tsx +34 -0
- package/src/Image/Image.test.tsx +4 -1
- package/src/Image/Image.tsx +13 -1
- package/src/Inline/Inline.stories.tsx +39 -0
- package/src/Inline/Inline.test.tsx +99 -0
- package/src/Inline/Inline.tsx +38 -0
- package/src/Inline/index.ts +1 -0
- package/src/Input/{Input.stories.mdx → Input.stories.tsx} +10 -17
- package/src/Input/Input.test.tsx +7 -3
- package/src/Input/Input.tsx +13 -1
- package/src/Label/{Label.stories.mdx → Label.stories.tsx} +10 -21
- package/src/Label/Label.test.tsx +25 -4
- package/src/Label/Label.tsx +42 -9
- package/src/Link/Link.stories.tsx +35 -0
- package/src/Link/Link.test.tsx +6 -2
- package/src/Link/Link.tsx +12 -1
- package/src/Menu/{Menu.stories.mdx → Menu.stories.tsx} +13 -32
- package/src/Menu/Menu.test.tsx +7 -2
- package/src/Menu/Menu.tsx +10 -0
- package/src/MenuItem/MenuItem.stories.tsx +30 -0
- package/src/MenuItem/MenuItem.test.tsx +7 -2
- package/src/MenuItem/MenuItem.tsx +12 -0
- package/src/Message/Message.stories.tsx +30 -0
- package/src/Message/Message.test.tsx +4 -1
- package/src/Message/Message.tsx +17 -5
- package/src/Provider/MarigoldProvider.test.tsx +65 -55
- package/src/Provider/MarigoldProvider.tsx +37 -19
- package/src/Provider/index.ts +2 -1
- package/src/Radio/{Radio.stories.mdx → Radio.stories.tsx} +31 -39
- package/src/Radio/Radio.test.tsx +78 -9
- package/src/Radio/Radio.tsx +58 -87
- package/src/Radio/RadioIcon.tsx +49 -0
- package/src/Select/ListBox.tsx +1 -0
- package/src/Select/{Select.stories.mdx → Select.stories.tsx} +23 -20
- package/src/Select/Select.test.tsx +39 -1
- package/src/Select/Select.tsx +24 -13
- package/src/Slider/Slider.stories.tsx +24 -0
- package/src/Slider/Slider.test.tsx +10 -6
- package/src/Slider/Slider.tsx +25 -13
- package/src/Stack/Stack.stories.tsx +57 -0
- package/src/Stack/Stack.test.tsx +16 -7
- package/src/Stack/Stack.tsx +0 -0
- package/src/Text/{Text.stories.mdx → Text.stories.tsx} +20 -19
- package/src/Text/Text.test.tsx +2 -2
- package/src/Text/Text.tsx +12 -0
- package/src/Textarea/{Textarea.stories.mdx → Textarea.stories.tsx} +14 -24
- package/src/Textarea/Textarea.test.tsx +7 -3
- package/src/Textarea/Textarea.tsx +13 -1
- package/src/ValidationMessage/{ValidationMessage.stories.mdx → ValidationMessage.stories.tsx} +8 -17
- package/src/ValidationMessage/ValidationMessage.test.tsx +7 -2
- package/src/ValidationMessage/ValidationMessage.tsx +12 -0
- package/src/VisuallyHidden/VisuallyHidden.stories.tsx +19 -0
- package/src/VisuallyHidden/VisuallyHidden.test.tsx +10 -0
- package/src/VisuallyHidden/VisuallyHidden.tsx +1 -0
- package/src/VisuallyHidden/index.ts +1 -0
- package/src/index.ts +2 -2
- package/src/theme.ts +49 -48
- package/dist/Box/Box.d.ts +0 -47
- package/dist/Box/index.d.ts +0 -1
- package/dist/Heading/Heading.d.ts +0 -7
- package/dist/Heading/index.d.ts +0 -1
- package/dist/Hidden/Hidden.d.ts +0 -5
- package/dist/Hidden/index.d.ts +0 -1
- package/dist/Radio/RadioIcons.d.ts +0 -9
- package/src/ActionGroup/ActionGroup.stories.mdx +0 -62
- package/src/Alert/Alert.stories.mdx +0 -35
- package/src/Badge/Badge.stories.mdx +0 -57
- package/src/Box/Box.stories.mdx +0 -334
- package/src/Box/Box.test.tsx +0 -133
- package/src/Box/Box.tsx +0 -165
- package/src/Box/index.ts +0 -1
- package/src/Column/Column.stories.mdx +0 -49
- package/src/Columns/Columns.stories.mdx +0 -65
- package/src/Container/Container.stories.mdx +0 -19
- package/src/Divider/Divider.stories.mdx +0 -37
- package/src/Heading/Heading.stories.mdx +0 -39
- package/src/Heading/Heading.test.tsx +0 -77
- package/src/Heading/Heading.tsx +0 -19
- package/src/Heading/index.ts +0 -1
- package/src/Hidden/Hidden.stories.mdx +0 -39
- package/src/Hidden/Hidden.test.tsx +0 -24
- package/src/Hidden/Hidden.tsx +0 -16
- package/src/Hidden/index.ts +0 -1
- package/src/Image/Image.stories.mdx +0 -36
- package/src/Link/Link.stories.mdx +0 -45
- package/src/MenuItem/MenuItem.stories.mdx +0 -37
- package/src/Message/Message.stories.mdx +0 -44
- package/src/Radio/RadioIcons.tsx +0 -39
- package/src/Slider/Slider.stories.mdx +0 -31
- package/src/Stack/Stack.stories.mdx +0 -51
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { conditional, State, SVG } from '@marigold/system';
|
|
3
|
+
|
|
4
|
+
import { Box } from '../Box';
|
|
5
|
+
|
|
6
|
+
// Radio Icon
|
|
7
|
+
// ---------------
|
|
8
|
+
export type RadioIconProps = {
|
|
9
|
+
variant?: string;
|
|
10
|
+
checked?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
error?: boolean;
|
|
13
|
+
children?: never;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const RadioIcon: React.FC<RadioIconProps> = ({
|
|
17
|
+
variant = '',
|
|
18
|
+
checked = false,
|
|
19
|
+
disabled = false,
|
|
20
|
+
error = false,
|
|
21
|
+
}) => {
|
|
22
|
+
const conditionalStates: State = disabled
|
|
23
|
+
? {
|
|
24
|
+
disabled: disabled,
|
|
25
|
+
}
|
|
26
|
+
: {
|
|
27
|
+
checked: checked,
|
|
28
|
+
error: error,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<SVG
|
|
33
|
+
width="16"
|
|
34
|
+
height="32"
|
|
35
|
+
viewBox="0 0 16 32"
|
|
36
|
+
fill="none"
|
|
37
|
+
aria-hidden="true"
|
|
38
|
+
>
|
|
39
|
+
<Box
|
|
40
|
+
variant={conditional(`radio.${variant}`, conditionalStates)}
|
|
41
|
+
as="circle"
|
|
42
|
+
cx="8"
|
|
43
|
+
cy="16"
|
|
44
|
+
r="7.5"
|
|
45
|
+
/>
|
|
46
|
+
{checked && <circle fill="white" cx="8" cy="16" r="3" />}
|
|
47
|
+
</SVG>
|
|
48
|
+
);
|
|
49
|
+
};
|
package/src/Select/ListBox.tsx
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
2
3
|
import { Select } from './Select';
|
|
3
4
|
import { Item } from '@marigold/components';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
title
|
|
7
|
-
argTypes
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Select',
|
|
8
|
+
argTypes: {
|
|
9
|
+
label: {
|
|
10
|
+
control: {
|
|
11
|
+
type: 'text',
|
|
12
|
+
},
|
|
13
|
+
table: {
|
|
14
|
+
defaultValue: {
|
|
15
|
+
summary: 'Select label',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultValue: 'Favorite Color',
|
|
19
|
+
},
|
|
8
20
|
placeholder: {
|
|
9
21
|
control: {
|
|
10
22
|
type: 'text',
|
|
@@ -57,22 +69,13 @@ import { Item } from '@marigold/components';
|
|
|
57
69
|
width: {
|
|
58
70
|
control: 'number',
|
|
59
71
|
},
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
# Select
|
|
72
|
+
},
|
|
73
|
+
} as Meta;
|
|
64
74
|
|
|
65
|
-
export const
|
|
66
|
-
<Select
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<Item>Yellow</Item> */}
|
|
75
|
+
export const Basic: ComponentStory<typeof Select> = args => (
|
|
76
|
+
<Select {...args}>
|
|
77
|
+
<Item>Red</Item>
|
|
78
|
+
<Item>Orange</Item>
|
|
79
|
+
<Item>Yellow</Item>
|
|
71
80
|
</Select>
|
|
72
81
|
);
|
|
73
|
-
|
|
74
|
-
<Canvas>
|
|
75
|
-
<Story name="Default">{Template.bind({})}</Story>
|
|
76
|
-
</Canvas>
|
|
77
|
-
|
|
78
|
-
<ArgsTable story="Default" />
|
|
@@ -6,14 +6,28 @@ import { Item, MarigoldProvider, Section } from '..';
|
|
|
6
6
|
import { Select } from './Select';
|
|
7
7
|
|
|
8
8
|
const theme = {
|
|
9
|
+
colors: {
|
|
10
|
+
red: 'red',
|
|
11
|
+
},
|
|
12
|
+
fonts: {
|
|
13
|
+
body: 'Inter',
|
|
14
|
+
},
|
|
9
15
|
button: {
|
|
10
16
|
select: {
|
|
11
|
-
fontFamily: '
|
|
17
|
+
fontFamily: 'body',
|
|
12
18
|
errorOpened: {
|
|
13
19
|
color: 'red',
|
|
14
20
|
},
|
|
15
21
|
},
|
|
16
22
|
},
|
|
23
|
+
label: {
|
|
24
|
+
above: {
|
|
25
|
+
fontSize: '8px',
|
|
26
|
+
},
|
|
27
|
+
inline: {
|
|
28
|
+
fontSize: '14px',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
17
31
|
};
|
|
18
32
|
|
|
19
33
|
test('supports button select variant', () => {
|
|
@@ -29,6 +43,30 @@ test('supports button select variant', () => {
|
|
|
29
43
|
expect(select).toHaveStyle(`font-family: Inter`);
|
|
30
44
|
});
|
|
31
45
|
|
|
46
|
+
test('supports default labelVariant', () => {
|
|
47
|
+
render(
|
|
48
|
+
<MarigoldProvider theme={theme}>
|
|
49
|
+
<Select label="MyLabel" data-testid="selectId">
|
|
50
|
+
<Item>1</Item>
|
|
51
|
+
</Select>
|
|
52
|
+
</MarigoldProvider>
|
|
53
|
+
);
|
|
54
|
+
const label = screen.getAllByText('MyLabel');
|
|
55
|
+
expect(label[0]).toHaveStyle(`font-size: 8px`);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('supports other labelVariant than default', () => {
|
|
59
|
+
render(
|
|
60
|
+
<MarigoldProvider theme={theme}>
|
|
61
|
+
<Select label="MyLabel" data-testid="selectId" labelVariant="inline">
|
|
62
|
+
<Item>1</Item>
|
|
63
|
+
</Select>
|
|
64
|
+
</MarigoldProvider>
|
|
65
|
+
);
|
|
66
|
+
const label = screen.getAllByText('MyLabel');
|
|
67
|
+
expect(label[0]).toHaveStyle(`font-size: 14px`);
|
|
68
|
+
});
|
|
69
|
+
|
|
32
70
|
test('accepts custom styles prop className', () => {
|
|
33
71
|
render(
|
|
34
72
|
<MarigoldProvider theme={theme}>
|
package/src/Select/Select.tsx
CHANGED
|
@@ -19,7 +19,25 @@ import { ValidationMessage } from '../ValidationMessage';
|
|
|
19
19
|
import { ListBox } from './ListBox';
|
|
20
20
|
import { Popover } from './Popover';
|
|
21
21
|
|
|
22
|
+
// Theme Extension
|
|
23
|
+
// ---------------
|
|
24
|
+
export interface SelectThemeExtension<Value> {
|
|
25
|
+
select?: {
|
|
26
|
+
__default: Value;
|
|
27
|
+
disabled?: Value;
|
|
28
|
+
listbox?: {
|
|
29
|
+
__default: Value;
|
|
30
|
+
error?: Value;
|
|
31
|
+
};
|
|
32
|
+
section?: Value;
|
|
33
|
+
option?: Value;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Props
|
|
38
|
+
// ---------------
|
|
22
39
|
export type SelectProps = {
|
|
40
|
+
labelVariant?: string;
|
|
23
41
|
placeholder?: string;
|
|
24
42
|
disabled?: boolean;
|
|
25
43
|
required?: boolean;
|
|
@@ -30,7 +48,10 @@ export type SelectProps = {
|
|
|
30
48
|
AriaSelectProps<object> &
|
|
31
49
|
SingleSelection;
|
|
32
50
|
|
|
51
|
+
// Component
|
|
52
|
+
// ---------------
|
|
33
53
|
export const Select = ({
|
|
54
|
+
labelVariant = 'above',
|
|
34
55
|
placeholder = 'Select an option',
|
|
35
56
|
disabled,
|
|
36
57
|
required,
|
|
@@ -75,11 +96,7 @@ export const Select = ({
|
|
|
75
96
|
<Box position="relative" display="inline-block" width={width && width}>
|
|
76
97
|
{props.label && (
|
|
77
98
|
<Box>
|
|
78
|
-
<Label
|
|
79
|
-
{...labelProps}
|
|
80
|
-
htmlFor={labelProps.id}
|
|
81
|
-
variant={disabled ? 'disabled' : 'above'}
|
|
82
|
-
>
|
|
99
|
+
<Label {...labelProps} htmlFor={labelProps.id} variant={labelVariant}>
|
|
83
100
|
{required ? (
|
|
84
101
|
<Box as="span" display="inline-flex" alignItems="center">
|
|
85
102
|
{props.label}
|
|
@@ -122,11 +139,7 @@ export const Select = ({
|
|
|
122
139
|
{state.selectedItem ? state.selectedItem.rendered : placeholder}
|
|
123
140
|
</Box>
|
|
124
141
|
{state.isOpen && !disabled ? (
|
|
125
|
-
<Box
|
|
126
|
-
as={ArrowUp}
|
|
127
|
-
size={16}
|
|
128
|
-
css={{ fill: disabled ? 'disabled' : 'text' }}
|
|
129
|
-
/>
|
|
142
|
+
<Box as={ArrowUp} size={16} css={{ fill: 'text' }} />
|
|
130
143
|
) : (
|
|
131
144
|
<Box
|
|
132
145
|
as={ArrowDown}
|
|
@@ -141,9 +154,7 @@ export const Select = ({
|
|
|
141
154
|
{...overlayProps}
|
|
142
155
|
{...positionProps}
|
|
143
156
|
css={{
|
|
144
|
-
width:
|
|
145
|
-
? width
|
|
146
|
-
: triggerRef.current && triggerRef.current.offsetWidth + 'px',
|
|
157
|
+
width: triggerRef.current && triggerRef.current.offsetWidth + 'px',
|
|
147
158
|
}}
|
|
148
159
|
ref={overlayRef as Ref<HTMLDivElement>}
|
|
149
160
|
isOpen={state.isOpen}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
+
import { Slider } from './Slider';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/Slider',
|
|
7
|
+
argTypes: {
|
|
8
|
+
variant: {
|
|
9
|
+
control: {
|
|
10
|
+
type: 'text',
|
|
11
|
+
},
|
|
12
|
+
description: 'Style',
|
|
13
|
+
table: {
|
|
14
|
+
defaultValue: {
|
|
15
|
+
summary: '__default',
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
} as Meta;
|
|
21
|
+
|
|
22
|
+
export const Basic: ComponentStory<typeof Slider> = args => (
|
|
23
|
+
<Slider name="vol" min="0" max="50" {...args} />
|
|
24
|
+
);
|
|
@@ -4,12 +4,16 @@ import { ThemeProvider } from '@marigold/system';
|
|
|
4
4
|
import { Slider } from './Slider';
|
|
5
5
|
|
|
6
6
|
const theme = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
fonts: {
|
|
8
|
+
regular: 'Oswald Regular',
|
|
9
|
+
body: 'Inter',
|
|
10
|
+
},
|
|
11
|
+
slider: {
|
|
12
|
+
__default: {
|
|
13
|
+
fontFamily: 'regular',
|
|
10
14
|
},
|
|
11
|
-
|
|
12
|
-
fontFamily: '
|
|
15
|
+
special: {
|
|
16
|
+
fontFamily: 'body',
|
|
13
17
|
},
|
|
14
18
|
},
|
|
15
19
|
};
|
|
@@ -28,7 +32,7 @@ test('supports default variant and themeSection', () => {
|
|
|
28
32
|
test('accepts other variant than default', () => {
|
|
29
33
|
render(
|
|
30
34
|
<ThemeProvider theme={theme}>
|
|
31
|
-
<Slider variant="
|
|
35
|
+
<Slider variant="special" title="slider" />
|
|
32
36
|
</ThemeProvider>
|
|
33
37
|
);
|
|
34
38
|
const slider = screen.getByTitle(/slider/);
|
package/src/Slider/Slider.tsx
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { useStyles } from '@marigold/system';
|
|
3
2
|
import { ComponentProps } from '@marigold/types';
|
|
4
3
|
|
|
4
|
+
import { Box } from '../Box';
|
|
5
|
+
|
|
6
|
+
// Theme Extension
|
|
7
|
+
// ---------------
|
|
8
|
+
export interface SliderThemeExtension<Value> {
|
|
9
|
+
slider?: {
|
|
10
|
+
[key: string]: Value;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Props
|
|
15
|
+
// ---------------
|
|
5
16
|
export type SliderProps = {
|
|
6
17
|
variant?: string;
|
|
7
18
|
} & ComponentProps<'input'>;
|
|
8
19
|
|
|
20
|
+
// Component
|
|
21
|
+
// ---------------
|
|
9
22
|
export const Slider: React.FC<SliderProps> = ({
|
|
10
|
-
variant = '
|
|
23
|
+
variant = '',
|
|
11
24
|
className,
|
|
12
25
|
...props
|
|
13
|
-
}) =>
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
className
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
26
|
+
}) => (
|
|
27
|
+
<Box
|
|
28
|
+
as="input"
|
|
29
|
+
type="range"
|
|
30
|
+
css={{ verticalAlign: 'middle' }}
|
|
31
|
+
variant={`slider.${variant}`}
|
|
32
|
+
className={className}
|
|
33
|
+
{...props}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
+
import { Stack } from './Stack';
|
|
4
|
+
import { Text } from '../Text';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Components/Stack',
|
|
8
|
+
argTypes: {
|
|
9
|
+
space: {
|
|
10
|
+
control: {
|
|
11
|
+
type: 'select',
|
|
12
|
+
},
|
|
13
|
+
options: [
|
|
14
|
+
'none',
|
|
15
|
+
'xxsmall',
|
|
16
|
+
'xsmall',
|
|
17
|
+
'small',
|
|
18
|
+
'medium',
|
|
19
|
+
'large',
|
|
20
|
+
'xlarge',
|
|
21
|
+
'xxlarge',
|
|
22
|
+
],
|
|
23
|
+
description: 'Responsive Style Value',
|
|
24
|
+
table: {
|
|
25
|
+
defaultValue: {
|
|
26
|
+
summary: 'none',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
align: {
|
|
31
|
+
control: {
|
|
32
|
+
type: 'select',
|
|
33
|
+
},
|
|
34
|
+
options: ['left', 'right', 'center'],
|
|
35
|
+
description: 'HTML element style',
|
|
36
|
+
table: {
|
|
37
|
+
defaultValue: {
|
|
38
|
+
summary: 'left',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
} as Meta;
|
|
44
|
+
|
|
45
|
+
export const Basic: ComponentStory<typeof Stack> = args => (
|
|
46
|
+
<Stack {...args}>
|
|
47
|
+
<Text as="h2" variant="headline2">
|
|
48
|
+
Heading
|
|
49
|
+
</Text>
|
|
50
|
+
<Text>
|
|
51
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
|
|
52
|
+
dignissim dapibus elit, vel egestas felis pharetra non. Cras malesuada,
|
|
53
|
+
massa nec ultricies efficitur, lectus ante consequat magna, a porttitor
|
|
54
|
+
massa ex ut quam.
|
|
55
|
+
</Text>
|
|
56
|
+
</Stack>
|
|
57
|
+
);
|
package/src/Stack/Stack.test.tsx
CHANGED
|
@@ -16,20 +16,26 @@ const theme = {
|
|
|
16
16
|
},
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
+
const getTopPadding = (element: HTMLElement) =>
|
|
20
|
+
getComputedStyle(element).getPropertyValue('padding-top');
|
|
21
|
+
|
|
19
22
|
test('default space is "none"', () => {
|
|
20
23
|
render(
|
|
21
24
|
<ThemeProvider theme={theme}>
|
|
22
25
|
<Stack>
|
|
23
26
|
<Text>first</Text>
|
|
24
27
|
<Text>second</Text>
|
|
28
|
+
<Text>third</Text>
|
|
25
29
|
</Stack>
|
|
26
30
|
</ThemeProvider>
|
|
27
31
|
);
|
|
28
|
-
const first = screen.getByText(/first/)
|
|
29
|
-
const second = screen.getByText(/second/)
|
|
32
|
+
const first = screen.getByText(/first/).parentElement!;
|
|
33
|
+
const second = screen.getByText(/second/).parentElement!;
|
|
34
|
+
const third = screen.getByText(/third/).parentElement!;
|
|
30
35
|
|
|
31
|
-
expect(first).
|
|
36
|
+
expect(getTopPadding(first)).toEqual('');
|
|
32
37
|
expect(second).toHaveStyle(`padding-top: 0px`);
|
|
38
|
+
expect(third).toHaveStyle(`padding-top: 0px`);
|
|
33
39
|
});
|
|
34
40
|
|
|
35
41
|
test('accepts and uses spacing from theme', () => {
|
|
@@ -38,14 +44,17 @@ test('accepts and uses spacing from theme', () => {
|
|
|
38
44
|
<Stack space="small">
|
|
39
45
|
<Text>first</Text>
|
|
40
46
|
<Text>second</Text>
|
|
47
|
+
<Text>third</Text>
|
|
41
48
|
</Stack>
|
|
42
49
|
</ThemeProvider>
|
|
43
50
|
);
|
|
44
51
|
const first = screen.getByText(/first/);
|
|
45
52
|
const second = screen.getByText(/second/);
|
|
53
|
+
const third = screen.getByText(/third/);
|
|
46
54
|
|
|
47
|
-
expect(first
|
|
55
|
+
expect(getTopPadding(first)).toEqual('');
|
|
48
56
|
expect(second.parentElement).toHaveStyle(`padding-top: 2px`);
|
|
57
|
+
expect(third.parentElement).toHaveStyle(`padding-top: 2px`);
|
|
49
58
|
});
|
|
50
59
|
|
|
51
60
|
test('aligns children left by default', () => {
|
|
@@ -104,13 +113,13 @@ test('supports nesting', () => {
|
|
|
104
113
|
const fourth = screen.getByText(/fourth/);
|
|
105
114
|
const lowerStack = screen.getByTestId('lowerStack');
|
|
106
115
|
|
|
107
|
-
expect(upperStack.parentElement).
|
|
116
|
+
expect(getTopPadding(upperStack.parentElement!)).toEqual('');
|
|
108
117
|
expect(lowerStack.parentElement).toHaveStyle(`padding-top: 8px`);
|
|
109
118
|
|
|
110
|
-
expect(first.parentElement).
|
|
119
|
+
expect(getTopPadding(first.parentElement!)).toEqual('');
|
|
111
120
|
expect(second.parentElement).toHaveStyle(`padding-top: 2px`);
|
|
112
121
|
|
|
113
|
-
expect(third.parentElement).
|
|
122
|
+
expect(getTopPadding(third.parentElement!)).toEqual('');
|
|
114
123
|
expect(fourth.parentElement).toHaveStyle(`padding-top: 2px`);
|
|
115
124
|
});
|
|
116
125
|
|
package/src/Stack/Stack.tsx
CHANGED
|
File without changes
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
2
3
|
import { Text } from './Text';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
title
|
|
6
|
-
argTypes
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/Text',
|
|
7
|
+
argTypes: {
|
|
7
8
|
as: {
|
|
8
9
|
control: {
|
|
9
10
|
type: 'select',
|
|
10
11
|
},
|
|
11
|
-
options: ['span', 'p'],
|
|
12
|
-
description: 'Set
|
|
12
|
+
options: ['span', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
|
|
13
|
+
description: 'Set HTML element',
|
|
13
14
|
table: {
|
|
14
15
|
defaultValue: {
|
|
15
16
|
summary: 'span',
|
|
@@ -20,8 +21,16 @@ import { Text } from './Text';
|
|
|
20
21
|
control: {
|
|
21
22
|
type: 'select',
|
|
22
23
|
},
|
|
23
|
-
options: [
|
|
24
|
-
|
|
24
|
+
options: [
|
|
25
|
+
'body',
|
|
26
|
+
'headline1',
|
|
27
|
+
'headline2',
|
|
28
|
+
'headline3',
|
|
29
|
+
'headline4',
|
|
30
|
+
'headline5',
|
|
31
|
+
'headline6',
|
|
32
|
+
],
|
|
33
|
+
description: 'CHoose between body and different headlines',
|
|
25
34
|
table: {
|
|
26
35
|
defaultValue: {
|
|
27
36
|
summary: 'body',
|
|
@@ -39,12 +48,10 @@ import { Text } from './Text';
|
|
|
39
48
|
},
|
|
40
49
|
},
|
|
41
50
|
},
|
|
42
|
-
}
|
|
43
|
-
|
|
51
|
+
},
|
|
52
|
+
} as Meta;
|
|
44
53
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export const Template = args => (
|
|
54
|
+
export const Basic: ComponentStory<typeof Text> = args => (
|
|
48
55
|
<Text {...args}>
|
|
49
56
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse
|
|
50
57
|
dignissim dapibus elit, vel egestas felis pharetra non. Cras malesuada,
|
|
@@ -52,9 +59,3 @@ export const Template = args => (
|
|
|
52
59
|
massa ex ut quam.
|
|
53
60
|
</Text>
|
|
54
61
|
);
|
|
55
|
-
|
|
56
|
-
<Canvas>
|
|
57
|
-
<Story name="Default">{Template.bind({})}</Story>
|
|
58
|
-
</Canvas>
|
|
59
|
-
|
|
60
|
-
<ArgsTable story="Default" />
|
package/src/Text/Text.test.tsx
CHANGED
|
@@ -15,7 +15,7 @@ const theme = {
|
|
|
15
15
|
body: {
|
|
16
16
|
fontFamily: 'Oswald Regular',
|
|
17
17
|
},
|
|
18
|
-
|
|
18
|
+
headline1: {
|
|
19
19
|
fontFamily: 'Inter',
|
|
20
20
|
},
|
|
21
21
|
},
|
|
@@ -35,7 +35,7 @@ test('uses `text.body` as default variant', () => {
|
|
|
35
35
|
test('allows to change variants via `variant` prop (with "text" prefix)', () => {
|
|
36
36
|
render(
|
|
37
37
|
<ThemeProvider theme={theme}>
|
|
38
|
-
<Text variant="
|
|
38
|
+
<Text variant="headline1">text</Text>
|
|
39
39
|
</ThemeProvider>
|
|
40
40
|
);
|
|
41
41
|
const text = screen.getByText(/text/);
|
package/src/Text/Text.tsx
CHANGED
|
@@ -7,6 +7,16 @@ import {
|
|
|
7
7
|
|
|
8
8
|
import { Box, BoxOwnProps } from '../Box';
|
|
9
9
|
|
|
10
|
+
// Theme Extension
|
|
11
|
+
// ---------------
|
|
12
|
+
export interface TextThemeExtension<Value> {
|
|
13
|
+
text?: {
|
|
14
|
+
[key: string]: Value;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Props
|
|
19
|
+
// ---------------
|
|
10
20
|
export type TextOwnProps = {
|
|
11
21
|
align?: ResponsiveStyleValue<string>;
|
|
12
22
|
color?: ResponsiveStyleValue<string>;
|
|
@@ -17,6 +27,8 @@ export type TextOwnProps = {
|
|
|
17
27
|
|
|
18
28
|
export type TextProps = PolymorphicPropsWithRef<TextOwnProps, 'span'>;
|
|
19
29
|
|
|
30
|
+
// Component
|
|
31
|
+
// ---------------
|
|
20
32
|
export const Text: PolymorphicComponentWithRef<TextOwnProps, 'span'> =
|
|
21
33
|
forwardRef(
|
|
22
34
|
(
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Meta, ComponentStory } from '@storybook/react';
|
|
3
|
+
import { Textarea } from '.';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
title
|
|
6
|
-
argTypes
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/Textarea',
|
|
7
|
+
argTypes: {
|
|
7
8
|
variant: {
|
|
8
9
|
control: {
|
|
9
10
|
type: 'text',
|
|
10
11
|
},
|
|
11
12
|
table: {
|
|
12
13
|
defaultValue: {
|
|
13
|
-
summary: '
|
|
14
|
+
summary: '__default',
|
|
14
15
|
},
|
|
15
16
|
},
|
|
16
17
|
},
|
|
@@ -18,18 +19,15 @@ import { Textarea } from '../Textarea';
|
|
|
18
19
|
control: {
|
|
19
20
|
type: 'text',
|
|
20
21
|
},
|
|
21
|
-
description: '
|
|
22
|
+
description: 'Label text',
|
|
23
|
+
defaultValue: 'Textarea Label',
|
|
22
24
|
},
|
|
23
25
|
htmlFor: {
|
|
24
26
|
control: {
|
|
25
27
|
type: 'text',
|
|
26
28
|
},
|
|
27
29
|
description: 'Bind to label',
|
|
28
|
-
|
|
29
|
-
defaultValue: {
|
|
30
|
-
summary: 'textarea',
|
|
31
|
-
},
|
|
32
|
-
},
|
|
30
|
+
defaultValue: 'textareaId',
|
|
33
31
|
},
|
|
34
32
|
error: {
|
|
35
33
|
control: {
|
|
@@ -58,17 +56,9 @@ import { Textarea } from '../Textarea';
|
|
|
58
56
|
},
|
|
59
57
|
},
|
|
60
58
|
},
|
|
61
|
-
}
|
|
62
|
-
|
|
59
|
+
},
|
|
60
|
+
} as Meta;
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
export const Template = args => (
|
|
67
|
-
<Textarea placeholder="Placeholder..." label="Textarea Label" {...args} />
|
|
62
|
+
export const Basic: ComponentStory<typeof Textarea> = args => (
|
|
63
|
+
<Textarea placeholder="Placeholder..." {...args} />
|
|
68
64
|
);
|
|
69
|
-
|
|
70
|
-
<Canvas>
|
|
71
|
-
<Story name="Default">{Template.bind({})}</Story>
|
|
72
|
-
</Canvas>
|
|
73
|
-
|
|
74
|
-
<ArgsTable story="Default" />
|
|
@@ -4,12 +4,16 @@ import { ThemeProvider } from '@marigold/system';
|
|
|
4
4
|
import { Textarea } from '../Textarea';
|
|
5
5
|
|
|
6
6
|
const theme = {
|
|
7
|
+
fonts: {
|
|
8
|
+
body: 'Inter Regular',
|
|
9
|
+
fancy: 'Roboto',
|
|
10
|
+
},
|
|
7
11
|
textarea: {
|
|
8
|
-
|
|
9
|
-
fontFamily: '
|
|
12
|
+
__default: {
|
|
13
|
+
fontFamily: 'body',
|
|
10
14
|
},
|
|
11
15
|
textarea2: {
|
|
12
|
-
fontFamily: '
|
|
16
|
+
fontFamily: 'fancy',
|
|
13
17
|
},
|
|
14
18
|
},
|
|
15
19
|
};
|