@moda/om 16.2.0 → 17.0.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 +26 -0
- package/dist/index.cjs.js +349 -299
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +348 -298
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Expandable/Expandable.d.ts +1 -0
- package/dist/src/components/Select/Select.d.ts +1 -0
- package/dist/src/components/Select/SelectOption.d.ts +1 -0
- package/dist/src/components/Select/SelectOptions.d.ts +1 -0
- package/dist/styles.css +1 -1
- package/package.json +18 -8
- package/src/components/AspectRatioBox/AspectRatioBox.tsx +4 -4
- package/src/components/AspectRatioBox/index.ts +1 -1
- package/src/components/Badge/Badge.stories.tsx +5 -5
- 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 +10 -9
- package/src/components/Breakpoint/Breakpoint.test.tsx +2 -2
- package/src/components/Breakpoint/generateMediaQuery.ts +5 -4
- package/src/components/Button/Button.stories.tsx +4 -4
- package/src/components/Checkbox/Checkbox.stories.tsx +5 -5
- package/src/components/Checkbox/Checkbox.test.tsx +3 -3
- package/src/components/Checkbox/Checkbox.tsx +4 -4
- package/src/components/Clickable/Clickable.stories.tsx +3 -3
- 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/ControlLink/ControlLink.stories.tsx +1 -1
- package/src/components/ControlLink/index.ts +1 -1
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.stories.tsx +1 -1
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.test.tsx +4 -4
- package/src/components/CreditCardNumberInput/CreditCardNumberInput.tsx +1 -0
- package/src/components/DefinitionList/DefinitionList.stories.tsx +3 -3
- package/src/components/DefinitionList/DefinitionList.test.tsx +1 -1
- package/src/components/Divider/Divider.stories.tsx +4 -4
- 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 +8 -8
- package/src/components/Expandable/Expandable.test.tsx +1 -1
- package/src/components/Expandable/Expandable.tsx +12 -5
- package/src/components/Field/Field.stories.tsx +4 -4
- package/src/components/Field/Field.test.tsx +7 -7
- package/src/components/Field/Field.tsx +5 -5
- package/src/components/Field/index.ts +1 -0
- package/src/components/Loading/Loading.test.tsx +1 -1
- package/src/components/Loading/Loading.tsx +2 -1
- package/src/components/Modal/Modal.test.tsx +2 -2
- package/src/components/ModalOverlay/ModalOverlay.test.tsx +2 -2
- package/src/components/ModalOverlay/ModalOverlay.tsx +2 -2
- package/src/components/Overlay/Overlay.stories.tsx +1 -1
- 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 +10 -7
- package/src/components/PromoBanner/PromoBanner.stories.tsx +9 -9
- package/src/components/PromoBanner/PromoBanner.tsx +1 -1
- package/src/components/RadioButton/RadioButton.stories.tsx +2 -2
- 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 +7 -7
- package/src/components/Select/Select.stories.tsx +15 -14
- package/src/components/Select/Select.test.tsx +13 -13
- package/src/components/Select/Select.tsx +11 -7
- package/src/components/Select/SelectOption.tsx +5 -2
- package/src/components/Select/SelectOptions.tsx +8 -5
- package/src/components/SelectableButton/SelectableButton.stories.tsx +1 -1
- package/src/components/Shape/ArcWindow.tsx +10 -10
- package/src/components/Shape/Bradley.tsx +4 -4
- package/src/components/Shape/Brancusi.tsx +4 -4
- package/src/components/Shape/Circle.tsx +10 -10
- package/src/components/Shape/Diamond.tsx +10 -10
- package/src/components/Shape/Keyhole.tsx +4 -4
- package/src/components/Shape/Mirror.tsx +4 -4
- package/src/components/Shape/Oval.tsx +4 -4
- package/src/components/Shape/Triangle.tsx +7 -7
- package/src/components/Shape/Window.tsx +4 -4
- package/src/components/Stack/Stack.stories.tsx +3 -3
- 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/Tabs/Tabs.tsx +7 -1
- package/src/components/Tag/Tag.tsx +6 -5
- 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 +6 -6
- package/src/components/VerticalDivider/VerticalDivider.stories.tsx +3 -3
- package/src/components/VerticalDivider/VerticalDivider.test.tsx +2 -2
- package/src/hooks/useKeyboardListNavigation.spec.ts +2 -1
- package/src/hooks/useKeyboardListNavigation.ts +2 -0
- package/src/hooks/useUpdateEffect.ts +1 -0
- package/src/index.ts +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 +5 -6
- 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 +3 -2
- package/src/utilities/States/States.tsx +4 -3
- package/src/utilities/States/StatesProps.tsx +5 -2
- package/src/utilities/States/isRenderProps.ts +1 -0
- package/src/utilities/States/stringifyProps.tsx +1 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
3
|
import { States } from 'storybook-states';
|
|
4
|
-
import { Clickable, ClickableProps } from './Clickable';
|
|
5
4
|
import { BrowserRouter } from 'react-router-dom';
|
|
5
|
+
import { Clickable, ClickableProps } from './Clickable';
|
|
6
6
|
|
|
7
7
|
export default { title: 'Components/Clickable' };
|
|
8
8
|
|
|
@@ -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
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { action } from '@storybook/addon-actions';
|
|
3
3
|
import { States } from 'storybook-states';
|
|
4
|
-
import { ControlLink, ControlLinkProps } from './ControlLink';
|
|
5
4
|
import { BrowserRouter } from 'react-router-dom';
|
|
5
|
+
import { ControlLink, ControlLinkProps } from './ControlLink';
|
|
6
6
|
|
|
7
7
|
export default { title: 'Components/ControlLink' };
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './ControlLink';
|
|
1
|
+
export * from './ControlLink';
|
|
@@ -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');
|
|
@@ -62,6 +62,7 @@ export const CreditCardNumberInput: React.FC<CreditCardNumberInputProps> = ({
|
|
|
62
62
|
);
|
|
63
63
|
|
|
64
64
|
// TODO: get rid of the any, the types of react-input-mask are incorrect here, it should expect a function as a child, but it expects a ReactNode
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
65
66
|
const renderInputField: any = (inputProps: CreditCardNumberInputFieldProps) => (
|
|
66
67
|
<CreditCardNumberInputField {...rest} {...inputProps} />
|
|
67
68
|
);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { States } from 'storybook-states';
|
|
3
|
-
import { DefinitionList, DefinitionListProps } from './DefinitionList';
|
|
4
3
|
import { Text } from '../Text';
|
|
4
|
+
import { DefinitionList, DefinitionListProps } from './DefinitionList';
|
|
5
5
|
|
|
6
6
|
export default { title: 'Components/DefinitionList' };
|
|
7
7
|
|
|
@@ -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
|
});
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { States } from 'storybook-states';
|
|
3
|
-
import { Divider, NoLineDivider, TwoLineDivider } from './';
|
|
4
3
|
import { DividerProps } from './Divider';
|
|
4
|
+
import { Divider, NoLineDivider, TwoLineDivider } from './';
|
|
5
5
|
|
|
6
6
|
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}
|
|
@@ -7,7 +7,7 @@ export default { title: 'Components/Expandable' };
|
|
|
7
7
|
|
|
8
8
|
export const Default = () => (
|
|
9
9
|
<States<Partial<ExpandableProps>> states={[{}, { expanded: true }]}>
|
|
10
|
-
<Expandable name=
|
|
10
|
+
<Expandable name="Editor’s Note">
|
|
11
11
|
Mark Cross’ ‘Cole’ duffle bag is crafted from textured grain leather with ample space for your
|
|
12
12
|
long-haul travels. It opens to reveal red twill lining and ample compartments for your
|
|
13
13
|
essentials. It has polished silver-tone palladium hardware and is stamped with the label’s
|
|
@@ -20,7 +20,7 @@ export const Default = () => (
|
|
|
20
20
|
// Push content into the DOM only after epanding component
|
|
21
21
|
export const VirtualizeContent = () => (
|
|
22
22
|
<States<Partial<ExpandableProps>> states={[{}, { expanded: false, virtual: true }]}>
|
|
23
|
-
<Expandable name=
|
|
23
|
+
<Expandable name="Editor’s Note">
|
|
24
24
|
Mark Cross’ ‘Cole’ duffle bag is crafted from textured grain leather with ample space for your
|
|
25
25
|
long-haul travels. It opens to reveal red twill lining and ample compartments for your
|
|
26
26
|
essentials. It has polished silver-tone palladium hardware and is stamped with the label’s
|
|
@@ -32,7 +32,7 @@ export const VirtualizeContent = () => (
|
|
|
32
32
|
|
|
33
33
|
export const ChevronIcon = () => (
|
|
34
34
|
<States<Partial<ExpandableProps>> states={[{}, { expanded: true }]}>
|
|
35
|
-
<Expandable icon=
|
|
35
|
+
<Expandable icon="chevron" name="Editor’s Note">
|
|
36
36
|
Mark Cross’ ‘Cole’ duffle bag is crafted from textured grain leather with ample space for your
|
|
37
37
|
long-haul travels. It opens to reveal red twill lining and ample compartments for your
|
|
38
38
|
essentials. It has polished silver-tone palladium hardware and is stamped with the label’s
|
|
@@ -45,14 +45,14 @@ export const ChevronIcon = () => (
|
|
|
45
45
|
export const Stacked = () => (
|
|
46
46
|
<States>
|
|
47
47
|
<Stack space={0}>
|
|
48
|
-
<Expandable name=
|
|
48
|
+
<Expandable name="Editor’s Note" expanded>
|
|
49
49
|
<p>
|
|
50
50
|
Acne Studios’ ‘1996’ jeans are fitted with a high-rise waist and straight-leg silhouette.
|
|
51
51
|
Designed in a dark-blue wash, this five-pocket style is detailed with contrast
|
|
52
52
|
top-stitching to mirror vintage pairs.
|
|
53
53
|
</p>
|
|
54
54
|
</Expandable>
|
|
55
|
-
<Expandable name=
|
|
55
|
+
<Expandable name="Product Details">
|
|
56
56
|
<ul>
|
|
57
57
|
<li>Belt loops, five-pocket style</li>
|
|
58
58
|
<li>Button and concealed zip fastening at front</li>
|
|
@@ -61,7 +61,7 @@ export const Stacked = () => (
|
|
|
61
61
|
</ul>
|
|
62
62
|
<p>Made in Italy Product Code 684196</p>
|
|
63
63
|
</Expandable>
|
|
64
|
-
<Expandable name=
|
|
64
|
+
<Expandable name="Size & Fit">
|
|
65
65
|
<ul>
|
|
66
66
|
<li>
|
|
67
67
|
Model measurements: height 6'2"/188cm - neck 15.5"/39cm - waist
|
|
@@ -72,11 +72,11 @@ export const Stacked = () => (
|
|
|
72
72
|
<li>We suggest taking your normal size</li>
|
|
73
73
|
</ul>
|
|
74
74
|
<p>
|
|
75
|
-
Questions? Please contact <a href=
|
|
75
|
+
Questions? Please contact <a href="mailto:care@modaoperandi.com">care@modaoperandi.com</a>
|
|
76
76
|
.
|
|
77
77
|
</p>
|
|
78
78
|
</Expandable>
|
|
79
|
-
<Expandable name=
|
|
79
|
+
<Expandable name="Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit...">
|
|
80
80
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed condimentum laoreet urna nec
|
|
81
81
|
consequat. Morbi et volutpat nulla, a vehicula nisl. Nullam tincidunt ac neque ornare
|
|
82
82
|
mattis. Donec eget dapibus enim. Aliquam ut tortor pretium dui pretium tincidunt. Donec quis
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useCallback, useState, ReactNode } from 'react';
|
|
1
|
+
import React, { useEffect, useCallback, useState, ReactNode } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import ChevronDownIcon from '@moda/icons/chevron-down-12';
|
|
4
4
|
import ChevronUpIcon from '@moda/icons/chevron-up-12';
|
|
@@ -7,6 +7,7 @@ import './Expandable.scss';
|
|
|
7
7
|
|
|
8
8
|
export type ExpandableProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
9
9
|
name: string | ReactNode;
|
|
10
|
+
defaultExpanded?: boolean;
|
|
10
11
|
expanded?: boolean;
|
|
11
12
|
children: ReactNode;
|
|
12
13
|
icon?: 'chevron' | 'plus-minus';
|
|
@@ -21,10 +22,16 @@ export const Expandable: React.FC<ExpandableProps> = ({
|
|
|
21
22
|
virtual = false,
|
|
22
23
|
icon = 'plus-minus',
|
|
23
24
|
'data-testid': dataTestId,
|
|
24
|
-
|
|
25
|
+
defaultExpanded = false,
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
27
|
+
expanded: __expanded__,
|
|
25
28
|
...rest
|
|
26
29
|
}) => {
|
|
27
|
-
const [expanded, setExpanded] = useState(
|
|
30
|
+
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (__expanded__ != null && __expanded__ !== expanded) setExpanded(__expanded__);
|
|
34
|
+
}, [expanded, __expanded__]);
|
|
28
35
|
|
|
29
36
|
const handleClick = useCallback(() => setExpanded(expanded => !expanded), []);
|
|
30
37
|
|
|
@@ -43,14 +50,14 @@ export const Expandable: React.FC<ExpandableProps> = ({
|
|
|
43
50
|
{name}
|
|
44
51
|
|
|
45
52
|
{icon !== 'plus-minus' && (
|
|
46
|
-
<div className=
|
|
53
|
+
<div className="Expandable__icon">
|
|
47
54
|
{icon === 'chevron' && expanded && <ChevronUpIcon />}
|
|
48
55
|
{icon === 'chevron' && !expanded && <ChevronDownIcon />}
|
|
49
56
|
</div>
|
|
50
57
|
)}
|
|
51
58
|
</Clickable>
|
|
52
59
|
|
|
53
|
-
<div className=
|
|
60
|
+
<div className="Expandable__contents">{expanded || !virtual ? children : null}</div>
|
|
54
61
|
</div>
|
|
55
62
|
);
|
|
56
63
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { States } from 'storybook-states';
|
|
3
|
-
import {
|
|
3
|
+
import { action } from '@storybook/addon-actions';
|
|
4
4
|
import { Textarea } from '../Textarea';
|
|
5
5
|
import { Select } from '../Select';
|
|
6
|
-
import {
|
|
6
|
+
import { Field, FieldProps } from './Field';
|
|
7
7
|
|
|
8
8
|
export default { title: 'Components/Field' };
|
|
9
9
|
|
|
@@ -19,7 +19,7 @@ export const Default = () => (
|
|
|
19
19
|
{ label: 'Name of input', error: 'Something went wrong' }
|
|
20
20
|
]}
|
|
21
21
|
>
|
|
22
|
-
<Field placeholder=
|
|
22
|
+
<Field placeholder="An input" />
|
|
23
23
|
</States>
|
|
24
24
|
);
|
|
25
25
|
|
|
@@ -36,7 +36,7 @@ export const AribitraryChildren = () => (
|
|
|
36
36
|
]}
|
|
37
37
|
>
|
|
38
38
|
<Field>
|
|
39
|
-
<Textarea placeholder=
|
|
39
|
+
<Textarea placeholder="A textarea" />
|
|
40
40
|
</Field>
|
|
41
41
|
</States>
|
|
42
42
|
);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { render, screen } from '@testing-library/react';
|
|
3
3
|
|
|
4
|
-
import { Field } from './Field';
|
|
5
4
|
import { Select } from '../Select';
|
|
5
|
+
import { Field } from './Field';
|
|
6
6
|
|
|
7
7
|
describe('Field', () => {
|
|
8
8
|
it('renders correctly', () => {
|
|
9
|
-
render(<Field placeholder=
|
|
9
|
+
render(<Field placeholder="Placeholder" defaultValue="Hello" />);
|
|
10
10
|
|
|
11
11
|
expect(screen.getByRole('textbox')).toBeVisible();
|
|
12
12
|
expect(screen.getByRole('textbox')).toHaveAttribute('placeholder', 'Placeholder');
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
it('renders with a label', () => {
|
|
16
|
-
render(<Field placeholder=
|
|
16
|
+
render(<Field placeholder="Placeholder" defaultValue="Hello" label="Label" />);
|
|
17
17
|
|
|
18
18
|
expect(screen.getByRole('textbox')).toBeVisible();
|
|
19
19
|
expect(screen.getByRole('textbox')).toHaveAttribute('placeholder', 'Placeholder');
|
|
@@ -21,7 +21,7 @@ describe('Field', () => {
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it('renders with an error', () => {
|
|
24
|
-
render(<Field placeholder=
|
|
24
|
+
render(<Field placeholder="Placeholder" defaultValue="Hello" label="Label" error="Error" />);
|
|
25
25
|
|
|
26
26
|
expect(screen.getByRole('textbox')).toBeVisible();
|
|
27
27
|
expect(screen.getByRole('textbox')).toHaveClass('TextInput--error');
|
|
@@ -37,7 +37,7 @@ describe('Field', () => {
|
|
|
37
37
|
|
|
38
38
|
render(
|
|
39
39
|
<Field>
|
|
40
|
-
<Select idRef=
|
|
40
|
+
<Select idRef="1" name="name-1" label="Sort by" options={options} />
|
|
41
41
|
</Field>
|
|
42
42
|
);
|
|
43
43
|
|
|
@@ -46,7 +46,7 @@ describe('Field', () => {
|
|
|
46
46
|
|
|
47
47
|
it('renders with a className', () => {
|
|
48
48
|
render(
|
|
49
|
-
<Field className=
|
|
49
|
+
<Field className="Custom" placeholder="Placeholder" defaultValue="Hello" label="Label" />
|
|
50
50
|
);
|
|
51
51
|
|
|
52
52
|
expect(screen.getByRole('textbox')).toBeVisible();
|
|
@@ -56,7 +56,7 @@ describe('Field', () => {
|
|
|
56
56
|
|
|
57
57
|
it('supports custom children', () => {
|
|
58
58
|
render(
|
|
59
|
-
<Field placeholder=
|
|
59
|
+
<Field placeholder="Placeholder" defaultValue="Hello" label="Label">
|
|
60
60
|
<textarea />
|
|
61
61
|
</Field>
|
|
62
62
|
);
|
|
@@ -17,10 +17,10 @@ export const Field = React.forwardRef(
|
|
|
17
17
|
) => {
|
|
18
18
|
return (
|
|
19
19
|
<label className={classNames('Field', className)}>
|
|
20
|
-
{label && <span className=
|
|
20
|
+
{label && <span className="Field__label">{label}</span>}
|
|
21
21
|
|
|
22
22
|
{/* TODO: Codify some kind of IconWrapper component */}
|
|
23
|
-
<span className=
|
|
23
|
+
<span className="Field__context">
|
|
24
24
|
{children ? (
|
|
25
25
|
<>
|
|
26
26
|
{React.cloneElement(children, {
|
|
@@ -34,7 +34,7 @@ export const Field = React.forwardRef(
|
|
|
34
34
|
})}
|
|
35
35
|
|
|
36
36
|
{error && (
|
|
37
|
-
<span className=
|
|
37
|
+
<span className="Field__icon">
|
|
38
38
|
<WarningIcon />
|
|
39
39
|
</span>
|
|
40
40
|
)}
|
|
@@ -49,7 +49,7 @@ export const Field = React.forwardRef(
|
|
|
49
49
|
{...rest}
|
|
50
50
|
/>
|
|
51
51
|
{error && (
|
|
52
|
-
<span className=
|
|
52
|
+
<span className="Field__icon">
|
|
53
53
|
<WarningIcon />
|
|
54
54
|
</span>
|
|
55
55
|
)}
|
|
@@ -57,7 +57,7 @@ export const Field = React.forwardRef(
|
|
|
57
57
|
)}
|
|
58
58
|
</span>
|
|
59
59
|
|
|
60
|
-
{error && <span className=
|
|
60
|
+
{error && <span className="Field__error">{error}</span>}
|
|
61
61
|
</label>
|
|
62
62
|
);
|
|
63
63
|
}
|
|
@@ -11,9 +11,10 @@ const FRAMES = [Triangle, Diamond, ArcWindow, Circle];
|
|
|
11
11
|
|
|
12
12
|
export const Loading: React.FC<LoadingProps> = ({ className, ...rest }) => {
|
|
13
13
|
const { index, handleNext } = useCursor({ max: FRAMES.length });
|
|
14
|
+
const ONE_SECOND_INTERVAL = 1000;
|
|
14
15
|
|
|
15
16
|
useEffect(() => {
|
|
16
|
-
const interval = setInterval(handleNext,
|
|
17
|
+
const interval = setInterval(handleNext, ONE_SECOND_INTERVAL);
|
|
17
18
|
return () => clearInterval(interval);
|
|
18
19
|
}, [handleNext]);
|
|
19
20
|
|
|
@@ -14,8 +14,8 @@ describe('Modal', () => {
|
|
|
14
14
|
const onClose = jest.fn();
|
|
15
15
|
const onClickButton = jest.fn();
|
|
16
16
|
render(
|
|
17
|
-
<Modal data-testid=
|
|
18
|
-
<button data-testid=
|
|
17
|
+
<Modal data-testid="modal" onClose={onClose}>
|
|
18
|
+
<button data-testid="button" onClick={onClickButton}>
|
|
19
19
|
Click Me
|
|
20
20
|
</button>
|
|
21
21
|
</Modal>
|
|
@@ -8,11 +8,11 @@ const ModalComponent: React.FC = () => {
|
|
|
8
8
|
const [showModal, setShowModal] = useState(false);
|
|
9
9
|
|
|
10
10
|
return showModal ? (
|
|
11
|
-
<ModalOverlay data-testid=
|
|
11
|
+
<ModalOverlay data-testid="modal" onClose={() => setShowModal(false)}>
|
|
12
12
|
Modal Content
|
|
13
13
|
</ModalOverlay>
|
|
14
14
|
) : (
|
|
15
|
-
<button data-testid=
|
|
15
|
+
<button data-testid="button" onClick={() => setShowModal(true)}>
|
|
16
16
|
Click Me
|
|
17
17
|
</button>
|
|
18
18
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { useEffect, useMemo } from 'react';
|
|
2
|
-
import { Modal, ModalProps } from '../Modal';
|
|
3
|
-
import { OverlayProps, Overlay } from '../Overlay';
|
|
4
2
|
import classNames from 'classnames';
|
|
5
3
|
import { createPortal } from 'react-dom';
|
|
4
|
+
import { Modal, ModalProps } from '../Modal';
|
|
5
|
+
import { OverlayProps, Overlay } from '../Overlay';
|
|
6
6
|
|
|
7
7
|
import './ModalOverlay.scss';
|
|
8
8
|
|