@moda/om 17.7.0 → 17.9.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 +14 -0
- package/dist/index.cjs.js +4601 -4557
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +4601 -4557
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Breakpoint/Breakpoint.d.ts +2 -4
- package/package.json +1 -1
- package/src/components/AspectRatioBox/AspectRatioBox.tsx +2 -2
- package/src/components/Badge/Badge.stories.tsx +6 -6
- package/src/components/Badge/Badge.test.tsx +1 -1
- package/src/components/Breadcrumbs/Breadcrumb/Breadcrumb.tsx +6 -6
- package/src/components/Breadcrumbs/Breadcrumbs.stories.tsx +6 -6
- package/src/components/Breadcrumbs/Breadcrumbs.test.tsx +2 -2
- package/src/components/Breadcrumbs/Breadcrumbs.tsx +1 -1
- package/src/components/Breakpoint/Breakpoint.stories.tsx +9 -9
- package/src/components/Breakpoint/Breakpoint.test.tsx +2 -2
- package/src/components/Breakpoint/Breakpoint.tsx +11 -4
- package/src/components/Button/Button.stories.tsx +2 -2
- package/src/components/Checkbox/Checkbox.stories.tsx +4 -4
- package/src/components/Checkbox/Checkbox.test.tsx +3 -3
- package/src/components/Checkbox/Checkbox.tsx +4 -4
- package/src/components/Clickable/Clickable.stories.tsx +2 -2
- package/src/components/ColorSwatch/ColorSwatch.stories.tsx +11 -11
- package/src/components/ColorSwatch/ColorSwatch.test.tsx +1 -1
- package/src/components/ColorSwatch/ColorSwatch.tsx +1 -1
- package/src/components/Constrain/Constrain.stories.tsx +1 -1
- package/src/components/Constrain/ExceedConstrain.stories.tsx +2 -2
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.stories.tsx +1 -1
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.test.tsx +4 -4
- package/src/components/DefinitionList/DefinitionList.stories.tsx +2 -2
- package/src/components/DefinitionList/DefinitionList.test.tsx +1 -1
- package/src/components/Divider/Divider.stories.tsx +3 -3
- package/src/components/Divider/Divider.test.tsx +1 -1
- package/src/components/Divider/Divider.tsx +1 -1
- package/src/components/Divider/NoLineDivider.tsx +1 -1
- package/src/components/Divider/TwoLineDivider.tsx +1 -1
- package/src/components/Expandable/Expandable.stories.tsx +9 -9
- package/src/components/Expandable/Expandable.test.tsx +1 -1
- package/src/components/Expandable/Expandable.tsx +3 -3
- package/src/components/Field/Field.stories.tsx +2 -2
- package/src/components/Field/Field.test.tsx +6 -6
- package/src/components/Field/Field.tsx +5 -5
- package/src/components/Loading/Loading.test.tsx +1 -1
- package/src/components/LoadingBalls/LoadingBalls.tsx +28 -28
- package/src/components/Modal/Modal.test.tsx +2 -2
- package/src/components/ModalOverlay/ModalOverlay.test.tsx +2 -2
- package/src/components/Paginator/Paginator.tsx +3 -3
- package/src/components/PasswordInput/PasswordInput.stories.tsx +1 -1
- package/src/components/PasswordInput/PasswordInput.tsx +6 -6
- package/src/components/Popover/Popover.stories.tsx +1 -1
- package/src/components/Popover/Popover.tsx +3 -3
- package/src/components/PromoBanner/PromoBanner.stories.tsx +9 -9
- package/src/components/PromoBanner/PromoBanner.tsx +1 -1
- package/src/components/RadioButton/RadioButton.stories.tsx +1 -1
- package/src/components/RadioButton/RadioButton.tsx +4 -4
- package/src/components/SearchInput/SearchInput.stories.tsx +2 -2
- package/src/components/SearchInput/SearchInput.test.tsx +1 -1
- package/src/components/SearchInput/SearchInput.tsx +3 -3
- package/src/components/Select/MultiSelect.tsx +5 -5
- package/src/components/Select/Select.stories.tsx +9 -9
- package/src/components/Select/Select.test.tsx +13 -13
- package/src/components/Select/Select.tsx +7 -7
- package/src/components/Select/SelectOption.tsx +1 -1
- package/src/components/Select/SelectOptions.tsx +5 -5
- package/src/components/Shape/ArcWindow.tsx +10 -10
- package/src/components/Shape/Bradley.tsx +3 -3
- package/src/components/Shape/Brancusi.tsx +3 -3
- package/src/components/Shape/Circle.tsx +10 -10
- package/src/components/Shape/Diamond.tsx +10 -10
- package/src/components/Shape/Keyhole.tsx +3 -3
- package/src/components/Shape/Mirror.tsx +3 -3
- package/src/components/Shape/Oval.tsx +3 -3
- package/src/components/Shape/Triangle.tsx +7 -7
- package/src/components/Shape/Window.tsx +3 -3
- package/src/components/SlidingPane/SlidingPane.stories.tsx +3 -3
- package/src/components/SlidingPane/SlidingPane.tsx +26 -24
- package/src/components/Stack/Stack.test.tsx +1 -1
- package/src/components/Tabs/TabList.tsx +1 -1
- package/src/components/Tabs/TabPanel.tsx +1 -1
- package/src/components/Tabs/TabPanels.tsx +1 -1
- package/src/components/Tabs/Tabs.stories.tsx +2 -2
- package/src/components/Tabs/Tabs.test.tsx +2 -2
- package/src/components/Tag/Tag.tsx +1 -1
- package/src/components/Text/Text.stories.tsx +5 -5
- package/src/components/Text/Text.test.tsx +1 -1
- package/src/components/TextInput/TextInput.stories.tsx +1 -1
- package/src/components/TextInput/TextInput.test.tsx +1 -1
- package/src/components/Textarea/Textarea.stories.tsx +1 -1
- package/src/components/Textarea/Textarea.test.tsx +3 -3
- package/src/components/Toast/Toast.stories.tsx +1 -1
- package/src/components/Toast/Toast.test.tsx +1 -1
- package/src/components/Toast/Toast.tsx +5 -5
- package/src/components/VerticalDivider/VerticalDivider.stories.tsx +2 -2
- package/src/components/VerticalDivider/VerticalDivider.test.tsx +2 -2
- package/src/mixins/font-smoothing/font-smoothing.stories.tsx +8 -8
- package/src/mixins/overflow-scroll/overflow-scroll.stories.tsx +2 -2
- package/src/mixins/stack/stack.stories.tsx +2 -2
- package/src/mixins/thin-underline/thin-underline.stories.tsx +1 -1
- package/src/mixins/visually-hidden/visually-hidden.stories.tsx +1 -1
- package/src/utilities/States/State.tsx +2 -2
- package/src/utilities/States/States.tsx +1 -1
- package/src/utilities/States/StatesProps.tsx +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
2
|
import './Breakpoint.scss';
|
|
3
3
|
declare type At = {
|
|
4
4
|
at: string;
|
|
@@ -9,8 +9,6 @@ declare type GreaterThan = {
|
|
|
9
9
|
declare type LessThan = {
|
|
10
10
|
lt: string;
|
|
11
11
|
};
|
|
12
|
-
export declare type BreakpointProps = (At | GreaterThan | LessThan) &
|
|
13
|
-
children?: React.ReactNode;
|
|
14
|
-
};
|
|
12
|
+
export declare type BreakpointProps = (At | GreaterThan | LessThan) & HTMLAttributes<HTMLDivElement>;
|
|
15
13
|
export declare const Breakpoint: React.FC<BreakpointProps>;
|
|
16
14
|
export {};
|
package/package.json
CHANGED
|
@@ -50,8 +50,8 @@ export const AspectRatioBox = React.forwardRef(
|
|
|
50
50
|
style={{ maxWidth: `${width}px` }}
|
|
51
51
|
{...rest}
|
|
52
52
|
>
|
|
53
|
-
<div className=
|
|
54
|
-
<div className=
|
|
53
|
+
<div className='AspectRatioBox__wrapper' style={{ paddingBottom }} />
|
|
54
|
+
<div className='AspectRatioBox__content'>{children}</div>
|
|
55
55
|
</div>
|
|
56
56
|
);
|
|
57
57
|
}
|
|
@@ -8,27 +8,27 @@ export default { title: 'Components/Badge' };
|
|
|
8
8
|
export const Themes = () => (
|
|
9
9
|
<>
|
|
10
10
|
<States>
|
|
11
|
-
<Badge theme=
|
|
11
|
+
<Badge theme='forest-green'>BESTSELLER</Badge>
|
|
12
12
|
</States>
|
|
13
13
|
|
|
14
14
|
<States>
|
|
15
|
-
<Badge theme=
|
|
15
|
+
<Badge theme='klein-blue'>TRENDING</Badge>
|
|
16
16
|
</States>
|
|
17
17
|
|
|
18
18
|
<States>
|
|
19
|
-
<Badge theme=
|
|
19
|
+
<Badge theme='brick'>Fall Essential</Badge>
|
|
20
20
|
</States>
|
|
21
21
|
|
|
22
22
|
<States>
|
|
23
|
-
<Badge theme=
|
|
23
|
+
<Badge theme='noise'>Runs small we recommend sizing up one size.</Badge>
|
|
24
24
|
</States>
|
|
25
25
|
|
|
26
26
|
<States>
|
|
27
|
-
<Badge theme=
|
|
27
|
+
<Badge theme='dark-fuchsia'>25% off with Code FALL-25</Badge>
|
|
28
28
|
</States>
|
|
29
29
|
|
|
30
30
|
<States>
|
|
31
|
-
<Badge theme=
|
|
31
|
+
<Badge theme='dark-fuchsia'>30% off with Code TREAT30</Badge>
|
|
32
32
|
</States>
|
|
33
33
|
</>
|
|
34
34
|
);
|
|
@@ -10,7 +10,7 @@ describe('Badge', () => {
|
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
it('supports custom themes and children', () => {
|
|
13
|
-
render(<Badge theme=
|
|
13
|
+
render(<Badge theme='klein-blue'>Custom Text - 2</Badge>);
|
|
14
14
|
expect(screen.getByText('Custom Text - 2')).toHaveClass('Badge--klein-blue');
|
|
15
15
|
});
|
|
16
16
|
});
|
|
@@ -18,17 +18,17 @@ export const Breadcrumb: React.FC<BreadcrumbProps> = ({
|
|
|
18
18
|
}) => (
|
|
19
19
|
<li
|
|
20
20
|
className={classNames('Breadcrumb', className)}
|
|
21
|
-
itemProp=
|
|
21
|
+
itemProp='itemListElement'
|
|
22
22
|
itemScope
|
|
23
|
-
itemType=
|
|
23
|
+
itemType='http://schema.org/ListItem'
|
|
24
24
|
>
|
|
25
25
|
{rest.to || rest.href ? (
|
|
26
|
-
<ControlLink itemProp=
|
|
27
|
-
<span itemProp=
|
|
26
|
+
<ControlLink itemProp='item' {...rest}>
|
|
27
|
+
<span itemProp='name'>{children}</span>
|
|
28
28
|
</ControlLink>
|
|
29
29
|
) : (
|
|
30
|
-
<span itemProp=
|
|
30
|
+
<span itemProp='name'>{children}</span>
|
|
31
31
|
)}
|
|
32
|
-
{position != null && <meta itemProp=
|
|
32
|
+
{position != null && <meta itemProp='position' content={String(position)} />}
|
|
33
33
|
</li>
|
|
34
34
|
);
|
|
@@ -8,9 +8,9 @@ export default { title: 'Components/Breadcrumbs' };
|
|
|
8
8
|
export const Default = () => (
|
|
9
9
|
<States<BreadcrumbsProps>>
|
|
10
10
|
<Breadcrumbs>
|
|
11
|
-
<Breadcrumb href=
|
|
12
|
-
<Breadcrumb href=
|
|
13
|
-
<Breadcrumb href=
|
|
11
|
+
<Breadcrumb href='#men'>Men</Breadcrumb>
|
|
12
|
+
<Breadcrumb href='#clothing'>Clothing</Breadcrumb>
|
|
13
|
+
<Breadcrumb href='#coats-jackets'>Coats & Jackets</Breadcrumb>
|
|
14
14
|
<Breadcrumb>Zippy Safari Straight-Leg Wool Jumpsuit</Breadcrumb>
|
|
15
15
|
</Breadcrumbs>
|
|
16
16
|
</States>
|
|
@@ -19,9 +19,9 @@ export const Default = () => (
|
|
|
19
19
|
export const Mobile = () => (
|
|
20
20
|
<States<BreadcrumbsProps>>
|
|
21
21
|
<Breadcrumbs>
|
|
22
|
-
<Breadcrumb href=
|
|
23
|
-
<Breadcrumb href=
|
|
24
|
-
<Breadcrumb href=
|
|
22
|
+
<Breadcrumb href='#men'>Men</Breadcrumb>
|
|
23
|
+
<Breadcrumb href='#clothing'>Clothing</Breadcrumb>
|
|
24
|
+
<Breadcrumb href='#coats-jackets'>Coats & Jackets</Breadcrumb>
|
|
25
25
|
<Breadcrumb>Zippy Safari Straight-Leg Wool Jumpsuit</Breadcrumb>
|
|
26
26
|
</Breadcrumbs>
|
|
27
27
|
</States>
|
|
@@ -7,8 +7,8 @@ describe('Breadcrumbs', () => {
|
|
|
7
7
|
it('wraps elements with microdata tags', () => {
|
|
8
8
|
render(
|
|
9
9
|
<Breadcrumbs>
|
|
10
|
-
<Breadcrumb href=
|
|
11
|
-
<Breadcrumb href=
|
|
10
|
+
<Breadcrumb href='/one'>One</Breadcrumb>
|
|
11
|
+
<Breadcrumb href='/two'>Two</Breadcrumb>
|
|
12
12
|
<Breadcrumb>Three</Breadcrumb>
|
|
13
13
|
</Breadcrumbs>
|
|
14
14
|
);
|
|
@@ -11,7 +11,7 @@ export const Breadcrumbs: React.FC<BreadcrumbsProps> = ({ children, className, .
|
|
|
11
11
|
return (
|
|
12
12
|
<ol
|
|
13
13
|
itemScope
|
|
14
|
-
itemType=
|
|
14
|
+
itemType='http://schema.org/BreadcrumbList'
|
|
15
15
|
className={classNames('Breadcrumbs', className)}
|
|
16
16
|
{...rest}
|
|
17
17
|
>
|
|
@@ -67,15 +67,15 @@ export const Values = () => (
|
|
|
67
67
|
return (
|
|
68
68
|
<>
|
|
69
69
|
<Breakpoint key={`at:${name}`} at={name}>
|
|
70
|
-
<Debug name={name} width={width} mode=
|
|
70
|
+
<Debug name={name} width={width} mode='at' />
|
|
71
71
|
</Breakpoint>
|
|
72
72
|
|
|
73
73
|
<Breakpoint key={`gt:${name}`} gt={name}>
|
|
74
|
-
<Debug name={name} width={width} mode=
|
|
74
|
+
<Debug name={name} width={width} mode='gt' />
|
|
75
75
|
</Breakpoint>
|
|
76
76
|
|
|
77
77
|
<Breakpoint key={`lt:${name}`} lt={name}>
|
|
78
|
-
<Debug name={name} width={width} mode=
|
|
78
|
+
<Debug name={name} width={width} mode='lt' />
|
|
79
79
|
</Breakpoint>
|
|
80
80
|
</>
|
|
81
81
|
);
|
|
@@ -89,21 +89,21 @@ export const Simple = () => (
|
|
|
89
89
|
<Display key={width} width={width} />
|
|
90
90
|
))}
|
|
91
91
|
|
|
92
|
-
<Breakpoint lt=
|
|
93
|
-
<Breakpoint gt=
|
|
92
|
+
<Breakpoint lt='sm'>Only displays on small screens</Breakpoint>
|
|
93
|
+
<Breakpoint gt='sm'>Only displays on large screens</Breakpoint>
|
|
94
94
|
</>
|
|
95
95
|
);
|
|
96
96
|
|
|
97
97
|
export const WithEvents = () => (
|
|
98
98
|
<>
|
|
99
|
-
<Breakpoint lt=
|
|
99
|
+
<Breakpoint lt='sm'>
|
|
100
100
|
Only displays on smaller screens
|
|
101
|
-
<Watcher from=
|
|
101
|
+
<Watcher from='sm' />
|
|
102
102
|
</Breakpoint>
|
|
103
103
|
|
|
104
|
-
<Breakpoint gt=
|
|
104
|
+
<Breakpoint gt='sm'>
|
|
105
105
|
Only displays on large screens
|
|
106
|
-
<Watcher from=
|
|
106
|
+
<Watcher from='lg' />
|
|
107
107
|
</Breakpoint>
|
|
108
108
|
</>
|
|
109
109
|
);
|
|
@@ -7,8 +7,8 @@ describe('Breakpoint', () => {
|
|
|
7
7
|
it('renders correctly', () => {
|
|
8
8
|
render(
|
|
9
9
|
<>
|
|
10
|
-
<Breakpoint gt=
|
|
11
|
-
<Breakpoint lt=
|
|
10
|
+
<Breakpoint gt='md'>Visible on mobile</Breakpoint>
|
|
11
|
+
<Breakpoint lt='md'>Visible on desktop</Breakpoint>
|
|
12
12
|
</>
|
|
13
13
|
);
|
|
14
14
|
expect(screen.getByText('Visible on desktop')).toBeVisible();
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { HTMLAttributes } from 'react';
|
|
2
|
+
import { omit } from 'ramda';
|
|
3
|
+
import classNames from 'classnames';
|
|
2
4
|
import { useBreakpoint, discriminate } from '../../hooks/useBreakpoint';
|
|
3
5
|
|
|
4
6
|
import './Breakpoint.scss';
|
|
@@ -7,13 +9,18 @@ type At = { at: string };
|
|
|
7
9
|
type GreaterThan = { gt: string };
|
|
8
10
|
type LessThan = { lt: string };
|
|
9
11
|
|
|
10
|
-
export type BreakpointProps = (At | GreaterThan | LessThan) &
|
|
12
|
+
export type BreakpointProps = (At | GreaterThan | LessThan) & HTMLAttributes<HTMLDivElement>;
|
|
11
13
|
|
|
12
|
-
export const Breakpoint: React.FC<BreakpointProps> = ({ children, ...rest }) => {
|
|
14
|
+
export const Breakpoint: React.FC<BreakpointProps> = ({ children, className, ...rest }) => {
|
|
13
15
|
const { mode, breakpoint } = discriminate(rest);
|
|
14
16
|
const { matches } = useBreakpoint(rest);
|
|
15
17
|
|
|
16
18
|
return matches ? (
|
|
17
|
-
<div
|
|
19
|
+
<div
|
|
20
|
+
className={classNames('Breakpoint', `Breakpoint--${mode}-${breakpoint}`, className)}
|
|
21
|
+
{...omit(['at', 'gt', 'lt'], rest)}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</div>
|
|
18
25
|
) : null;
|
|
19
26
|
};
|
|
@@ -41,7 +41,7 @@ export const SecondaryChip = () => (
|
|
|
41
41
|
|
|
42
42
|
export const PrimaryWithHref = () => (
|
|
43
43
|
<States<ButtonProps> states={[{}, { hover: true }, { focus: true }, { disabled: true }]}>
|
|
44
|
-
<Button href=
|
|
44
|
+
<Button href='#href' onClick={action('clicked')}>
|
|
45
45
|
Add to Cart
|
|
46
46
|
</Button>
|
|
47
47
|
</States>
|
|
@@ -50,7 +50,7 @@ export const PrimaryWithHref = () => (
|
|
|
50
50
|
export const PrimaryAsReactRouterLink = () => (
|
|
51
51
|
<BrowserRouter>
|
|
52
52
|
<States<ButtonProps> states={[{}, { hover: true }, { focus: true }, { disabled: true }]}>
|
|
53
|
-
<Button to=
|
|
53
|
+
<Button to='#href' onClick={action('clicked')}>
|
|
54
54
|
Add to Cart
|
|
55
55
|
</Button>
|
|
56
56
|
</States>
|
|
@@ -20,7 +20,7 @@ export const Default = () => (
|
|
|
20
20
|
{ children: 'Disabled', checked: true, disabled: true },
|
|
21
21
|
{ children: 'Filtering/Circle', checkIcon: 'circle' },
|
|
22
22
|
{ children: 'Disabled', checkIcon: 'circle', checked: true, disabled: true },
|
|
23
|
-
{ children: <Text color=
|
|
23
|
+
{ children: <Text color='code-red'>Important!</Text> }
|
|
24
24
|
]}
|
|
25
25
|
>
|
|
26
26
|
<Checkbox />
|
|
@@ -33,11 +33,11 @@ export const Check = () => {
|
|
|
33
33
|
return (
|
|
34
34
|
<States>
|
|
35
35
|
<Stack space={2}>
|
|
36
|
-
<Text color=
|
|
36
|
+
<Text color='burnt-orange'>{checked ? 'Remembering' : 'Forgetting'}</Text>
|
|
37
37
|
|
|
38
38
|
<Checkbox
|
|
39
|
-
id=
|
|
40
|
-
name=
|
|
39
|
+
id='rememberMe'
|
|
40
|
+
name='rememberMe'
|
|
41
41
|
checked={checked}
|
|
42
42
|
onChange={(event: React.ChangeEvent<HTMLInputElement>) => {
|
|
43
43
|
check(event.target.checked);
|
|
@@ -8,7 +8,7 @@ describe('Checkbox', () => {
|
|
|
8
8
|
it('works correctly with checked attribute (controlled)', async () => {
|
|
9
9
|
const handleChange = jest.fn();
|
|
10
10
|
const { rerender } = render(
|
|
11
|
-
<Checkbox data-testid=
|
|
11
|
+
<Checkbox data-testid='checkbox' checked onChange={handleChange} />
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
expect(screen.getByRole('checkbox') as HTMLInputElement).toBeChecked();
|
|
@@ -18,14 +18,14 @@ describe('Checkbox', () => {
|
|
|
18
18
|
expect(handleChange).toBeCalled();
|
|
19
19
|
expect(screen.getByRole('checkbox') as HTMLInputElement).toBeChecked();
|
|
20
20
|
|
|
21
|
-
rerender(<Checkbox data-testid=
|
|
21
|
+
rerender(<Checkbox data-testid='checkbox' checked={false} onChange={handleChange} />);
|
|
22
22
|
|
|
23
23
|
expect(screen.getByRole('checkbox') as HTMLInputElement).not.toBeChecked();
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
it('works correctly with defaultChecked attribute (uncontrolled)', async () => {
|
|
27
27
|
const handleChange = jest.fn();
|
|
28
|
-
render(<Checkbox data-testid=
|
|
28
|
+
render(<Checkbox data-testid='checkbox' defaultChecked={false} onChange={handleChange} />);
|
|
29
29
|
|
|
30
30
|
expect(screen.getByRole('checkbox') as HTMLInputElement).not.toBeChecked();
|
|
31
31
|
|
|
@@ -47,7 +47,7 @@ export const Checkbox: React.FC<CheckboxProps> = ({
|
|
|
47
47
|
|
|
48
48
|
return (
|
|
49
49
|
<label
|
|
50
|
-
role=
|
|
50
|
+
role='button'
|
|
51
51
|
tabIndex={0}
|
|
52
52
|
className={classNames('Checkbox', className, {
|
|
53
53
|
'Checkbox--disabled': disabled
|
|
@@ -71,8 +71,8 @@ export const Checkbox: React.FC<CheckboxProps> = ({
|
|
|
71
71
|
|
|
72
72
|
<input
|
|
73
73
|
tabIndex={-1}
|
|
74
|
-
className=
|
|
75
|
-
type=
|
|
74
|
+
className='Checkbox__input'
|
|
75
|
+
type='checkbox'
|
|
76
76
|
checked={isChecked}
|
|
77
77
|
value={value}
|
|
78
78
|
onChange={handleChange}
|
|
@@ -81,7 +81,7 @@ export const Checkbox: React.FC<CheckboxProps> = ({
|
|
|
81
81
|
{...rest}
|
|
82
82
|
/>
|
|
83
83
|
|
|
84
|
-
{children && <span className=
|
|
84
|
+
{children && <span className='Checkbox__label'>{children}</span>}
|
|
85
85
|
</label>
|
|
86
86
|
);
|
|
87
87
|
};
|
|
@@ -16,14 +16,14 @@ export const Button = () => (
|
|
|
16
16
|
|
|
17
17
|
export const Anchor = () => (
|
|
18
18
|
<States<ClickableProps>>
|
|
19
|
-
<Clickable href=
|
|
19
|
+
<Clickable href='#'>Useful to extend in place of <a/>. Click me.</Clickable>
|
|
20
20
|
</States>
|
|
21
21
|
);
|
|
22
22
|
|
|
23
23
|
export const Link = () => (
|
|
24
24
|
<BrowserRouter>
|
|
25
25
|
<States<ClickableProps>>
|
|
26
|
-
<Clickable to=
|
|
26
|
+
<Clickable to='#href'>Useful to extend in place of <Link/>. Click me.</Clickable>
|
|
27
27
|
</States>
|
|
28
28
|
</BrowserRouter>
|
|
29
29
|
);
|
|
@@ -20,33 +20,33 @@ const STATES = [
|
|
|
20
20
|
|
|
21
21
|
export const Default = () => (
|
|
22
22
|
<States<Partial<ColorSwatchProps>> states={STATES}>
|
|
23
|
-
<ColorSwatch color=
|
|
23
|
+
<ColorSwatch color='yellow' onClick={action('onClick')} />
|
|
24
24
|
</States>
|
|
25
25
|
);
|
|
26
26
|
|
|
27
27
|
export const Small = () => (
|
|
28
28
|
<States<Partial<ColorSwatchProps>> states={STATES}>
|
|
29
|
-
<ColorSwatch size=
|
|
29
|
+
<ColorSwatch size='small' color='yellow' onClick={action('onClick')} />
|
|
30
30
|
</States>
|
|
31
31
|
);
|
|
32
32
|
|
|
33
33
|
export const White = () => (
|
|
34
34
|
<States<Partial<ColorSwatchProps>> states={STATES}>
|
|
35
|
-
<ColorSwatch size=
|
|
35
|
+
<ColorSwatch size='small' color='white' onClick={action('onClick')} />
|
|
36
36
|
</States>
|
|
37
37
|
);
|
|
38
38
|
|
|
39
39
|
export const Swatches = () => (
|
|
40
40
|
<States<ColorSwatchProps>>
|
|
41
|
-
<Stack space={1} direction=
|
|
42
|
-
<ColorSwatch onClick={action('onClick')} color=
|
|
43
|
-
<ColorSwatch onClick={action('onClick')} color=
|
|
44
|
-
<ColorSwatch onClick={action('onClick')} color=
|
|
45
|
-
<ColorSwatch onClick={action('onClick')} color=
|
|
41
|
+
<Stack space={1} direction='horizontal'>
|
|
42
|
+
<ColorSwatch onClick={action('onClick')} color='red' />
|
|
43
|
+
<ColorSwatch onClick={action('onClick')} color='white' />
|
|
44
|
+
<ColorSwatch onClick={action('onClick')} color='bronze' soldOut disabled />
|
|
45
|
+
<ColorSwatch onClick={action('onClick')} color='nude' onSale />
|
|
46
46
|
<ColorSwatch
|
|
47
47
|
onClick={action('onClick')}
|
|
48
|
-
backgroundUrl=
|
|
49
|
-
color=
|
|
48
|
+
backgroundUrl='https://www.modaoperandi.com/assets/images/products/730581/340267/sw/prada-animal-leopard-print-shell-shoulder-bag.jpg?_v=1581323237'
|
|
49
|
+
color='nude'
|
|
50
50
|
onSale
|
|
51
51
|
onMouseEnter={action('onMouseEnter')}
|
|
52
52
|
onMouseLeave={action('onMouseLeave')}
|
|
@@ -56,7 +56,7 @@ export const Swatches = () => (
|
|
|
56
56
|
);
|
|
57
57
|
|
|
58
58
|
export const Constrained = () => (
|
|
59
|
-
<Stack direction=
|
|
59
|
+
<Stack direction='horizontal' space={3}>
|
|
60
60
|
{Object.keys(SKU_COLORS).map(color => (
|
|
61
61
|
<ColorSwatch key={color} onClick={action('onClick')} color={color} />
|
|
62
62
|
))}
|
|
@@ -26,7 +26,7 @@ const Constrained = () => {
|
|
|
26
26
|
return (
|
|
27
27
|
<Constrain>
|
|
28
28
|
<div ref={ref} style={{ backgroundColor: 'black', color: 'white', padding: '1rem' }}>
|
|
29
|
-
<Text color=
|
|
29
|
+
<Text color='snow'>
|
|
30
30
|
window: {windowWidth}px
|
|
31
31
|
<br />
|
|
32
32
|
constrained: {constrainWidth}px
|
|
@@ -10,10 +10,10 @@ const Constrained = () => {
|
|
|
10
10
|
return (
|
|
11
11
|
<Constrain>
|
|
12
12
|
<div style={{ backgroundColor: 'black', color: 'white', padding: '1rem' }}>
|
|
13
|
-
<Text color=
|
|
13
|
+
<Text color='snow'>This div is constrained.</Text>
|
|
14
14
|
</div>
|
|
15
15
|
<ExceedConstrain style={{ backgroundColor: 'gray', color: 'white', padding: '1rem' }}>
|
|
16
|
-
<Text color=
|
|
16
|
+
<Text color='snow'>This exceeds the constrain.</Text>
|
|
17
17
|
</ExceedConstrain>
|
|
18
18
|
</Constrain>
|
|
19
19
|
);
|
|
@@ -5,14 +5,14 @@ import { CreditCardNumberInput } from './CreditCardNumberInput';
|
|
|
5
5
|
|
|
6
6
|
describe('credit card number input', () => {
|
|
7
7
|
it('renders without errors', () => {
|
|
8
|
-
render(<CreditCardNumberInput label=
|
|
8
|
+
render(<CreditCardNumberInput label='Card Number' />);
|
|
9
9
|
const input = screen.getByLabelText('Card Number');
|
|
10
10
|
expect(input).toBeInTheDocument();
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
// TODO: userEvent.type does not work here for some reason
|
|
14
14
|
xit('does not allow non-numeric characters', async () => {
|
|
15
|
-
render(<CreditCardNumberInput label=
|
|
15
|
+
render(<CreditCardNumberInput label='Card Number' />);
|
|
16
16
|
const input = screen.getByLabelText('Card Number') as HTMLInputElement;
|
|
17
17
|
|
|
18
18
|
await userEvent.type(input, 'foo1234');
|
|
@@ -22,7 +22,7 @@ describe('credit card number input', () => {
|
|
|
22
22
|
|
|
23
23
|
// TODO: userEvent.type does not work here for some reason
|
|
24
24
|
xit('puts spaces between the numbers', async () => {
|
|
25
|
-
render(<CreditCardNumberInput label=
|
|
25
|
+
render(<CreditCardNumberInput label='Card Number' />);
|
|
26
26
|
const input = screen.getByLabelText('Card Number') as HTMLInputElement;
|
|
27
27
|
|
|
28
28
|
await userEvent.type(input, '5510000000000000');
|
|
@@ -32,7 +32,7 @@ describe('credit card number input', () => {
|
|
|
32
32
|
|
|
33
33
|
// TODO: userEvent.type does not work here for some reason
|
|
34
34
|
xit('does not allow more characters than required', async () => {
|
|
35
|
-
render(<CreditCardNumberInput label=
|
|
35
|
+
render(<CreditCardNumberInput label='Card Number' />);
|
|
36
36
|
const input = screen.getByLabelText('Card Number') as HTMLInputElement;
|
|
37
37
|
|
|
38
38
|
await userEvent.type(input, '5510000000000000251');
|
|
@@ -14,13 +14,13 @@ export const Default = () => (
|
|
|
14
14
|
term: 'Size',
|
|
15
15
|
children: (
|
|
16
16
|
<>
|
|
17
|
-
US 2 — <Text color=
|
|
17
|
+
US 2 — <Text color='code-red'>Only 2 Left</Text>
|
|
18
18
|
</>
|
|
19
19
|
)
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
term: 'Supports',
|
|
23
|
-
children: <a href=
|
|
23
|
+
children: <a href='#link'>Links</a>
|
|
24
24
|
}
|
|
25
25
|
]}
|
|
26
26
|
>
|
|
@@ -5,7 +5,7 @@ import { DefinitionList } from './DefinitionList';
|
|
|
5
5
|
|
|
6
6
|
describe('DefinitionList', () => {
|
|
7
7
|
it('renders correctly', () => {
|
|
8
|
-
render(<DefinitionList term=
|
|
8
|
+
render(<DefinitionList term='Foo'>Bar</DefinitionList>);
|
|
9
9
|
expect(screen.getByText('Foo')).toBeVisible();
|
|
10
10
|
expect(screen.getByText('Bar')).toBeVisible();
|
|
11
11
|
});
|
|
@@ -7,19 +7,19 @@ export default { title: 'Components/Divider' };
|
|
|
7
7
|
|
|
8
8
|
export const Default = () => (
|
|
9
9
|
<States<Partial<DividerProps>> states={[{}, { type: 'no-line' }, { type: 'two-line' }]}>
|
|
10
|
-
<Divider text=
|
|
10
|
+
<Divider text='Moda Operandi' />
|
|
11
11
|
</States>
|
|
12
12
|
);
|
|
13
13
|
|
|
14
14
|
export const WithNoLine = () => (
|
|
15
15
|
<States>
|
|
16
|
-
<NoLineDivider text=
|
|
16
|
+
<NoLineDivider text='Divider with No Line' />
|
|
17
17
|
</States>
|
|
18
18
|
);
|
|
19
19
|
|
|
20
20
|
export const WithDoubleLine = () => (
|
|
21
21
|
<States>
|
|
22
|
-
<TwoLineDivider text=
|
|
22
|
+
<TwoLineDivider text='Divider with Double Line' />
|
|
23
23
|
</States>
|
|
24
24
|
);
|
|
25
25
|
|
|
@@ -5,7 +5,7 @@ import { Divider } from './Divider';
|
|
|
5
5
|
|
|
6
6
|
describe('Divider', () => {
|
|
7
7
|
it('renders correctly', () => {
|
|
8
|
-
render(<Divider style={{ padding: '30px 0' }} text=
|
|
8
|
+
render(<Divider style={{ padding: '30px 0' }} text='Hello' />);
|
|
9
9
|
expect(screen.getByText('Hello')).toBeVisible();
|
|
10
10
|
// eslint-disable-next-line testing-library/no-node-access
|
|
11
11
|
expect(screen.getByText('Hello').parentNode).toHaveStyle('padding: 30px 0px;');
|
|
@@ -29,7 +29,7 @@ export const Divider: React.FC<DividerProps> = ({
|
|
|
29
29
|
<div className={classNames('Divider', type ? `Divider--${type}` : '', className)} {...rest}>
|
|
30
30
|
{text && (
|
|
31
31
|
<Text
|
|
32
|
-
className=
|
|
32
|
+
className='Divider__text'
|
|
33
33
|
treatment={treatment ?? defaultTreatment}
|
|
34
34
|
color={color}
|
|
35
35
|
family={family ?? defaultFamily}
|