@automattic/vip-design-system 0.9.4 → 0.10.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/.github/workflows/nodejs.yaml +1 -1
- package/README.md +4 -4
- package/build/system/Avatar/Avatar.js +9 -3
- package/build/system/Badge/Badge.js +9 -3
- package/build/system/BlankState/BlankState.js +8 -2
- package/build/system/Box/Box.js +12 -2
- package/build/system/Button/Button.js +6 -2
- package/build/system/Card/Card.js +8 -3
- package/build/system/Code/Code.js +8 -3
- package/build/system/ConfirmationDialog/ConfirmationDialog.js +8 -2
- package/build/system/Dialog/Dialog.js +1 -0
- package/build/system/Form/AsyncSearchSelect.js +38 -0
- package/build/system/Form/SearchSelect.js +47 -11
- package/build/system/Form/Select.js +22 -2
- package/build/system/Form/Select.test.js +52 -0
- package/build/system/Form/Toggle.js +8 -2
- package/build/system/Heading/Heading.js +9 -3
- package/build/system/Notice/Notice.js +9 -3
- package/build/system/Notification/Notification.js +1 -0
- package/build/system/OptionRow/OptionRow.js +13 -3
- package/build/system/OptionRow/OptionRow.test.js +46 -0
- package/build/system/Progress/Progress.js +9 -3
- package/build/system/ResourceList/ResourceList.js +1 -0
- package/build/system/Spinner/Spinner.js +9 -3
- package/build/system/Tabs/TabItem.js +1 -0
- package/build/system/Tabs/Tabs.js +10 -4
- package/build/system/Text/Text.js +9 -3
- package/build/system/Time/index.js +9 -3
- package/build/system/Timeline/Timeline.js +77 -0
- package/build/system/Timeline/index.js +2 -66
- package/build/system/Wizard/Wizard.js +10 -2
- package/build/system/Wizard/WizardStep.js +6 -2
- package/build/system/Wizard/WizardStepHorizontal.js +6 -2
- package/package.json +4 -2
- package/src/system/Avatar/Avatar.js +4 -0
- package/src/system/Badge/Badge.js +4 -1
- package/src/system/BlankState/BlankState.js +4 -1
- package/src/system/Box/Box.js +6 -1
- package/src/system/Button/Button.js +3 -0
- package/src/system/Card/Card.js +4 -1
- package/src/system/Code/Code.js +4 -1
- package/src/system/ConfirmationDialog/ConfirmationDialog.js +4 -2
- package/src/system/Dialog/Dialog.js +1 -1
- package/src/system/Form/AsyncSearchSelect.js +29 -0
- package/src/system/Form/SearchSelect.js +43 -3
- package/src/system/Form/Select.js +16 -3
- package/src/system/Form/Select.stories.js +30 -0
- package/src/system/Form/Select.test.js +37 -0
- package/src/system/Form/Toggle.js +4 -2
- package/src/system/Heading/Heading.js +4 -1
- package/src/system/Notice/Notice.js +4 -1
- package/src/system/Notification/Notification.js +1 -0
- package/src/system/OptionRow/OptionRow.js +7 -0
- package/src/system/OptionRow/OptionRow.stories.js +1 -0
- package/src/system/OptionRow/OptionRow.test.js +27 -0
- package/src/system/Progress/Progress.js +4 -1
- package/src/system/ResourceList/ResourceList.js +1 -1
- package/src/system/Spinner/Spinner.js +4 -1
- package/src/system/Tabs/TabItem.js +1 -0
- package/src/system/Tabs/Tabs.js +5 -2
- package/src/system/Text/Text.js +4 -1
- package/src/system/Time/index.js +4 -1
- package/src/system/Timeline/Timeline.js +48 -0
- package/src/system/Timeline/Timeline.stories.js +34 -0
- package/src/system/Timeline/index.js +2 -41
- package/src/system/Wizard/Wizard.js +6 -2
- package/src/system/Wizard/Wizard.stories.js +1 -1
- package/src/system/Wizard/WizardStep.js +5 -2
- package/src/system/Wizard/WizardStepHorizontal.js +4 -1
package/src/system/Text/Text.js
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Text as ThemeText } from 'theme-ui';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
+
import classNames from 'classnames';
|
|
8
9
|
|
|
9
|
-
const Text = ( { sx, ...props } ) => (
|
|
10
|
+
const Text = ( { sx, className = null, ...props } ) => (
|
|
10
11
|
<ThemeText
|
|
11
12
|
as="p"
|
|
12
13
|
sx={{
|
|
@@ -14,12 +15,14 @@ const Text = ( { sx, ...props } ) => (
|
|
|
14
15
|
marginBottom: 2,
|
|
15
16
|
...sx,
|
|
16
17
|
}}
|
|
18
|
+
className={ classNames( 'vip-text-component', className ) }
|
|
17
19
|
{...props}
|
|
18
20
|
/>
|
|
19
21
|
);
|
|
20
22
|
|
|
21
23
|
Text.propTypes = {
|
|
22
24
|
sx: PropTypes.object,
|
|
25
|
+
className: PropTypes.any,
|
|
23
26
|
};
|
|
24
27
|
|
|
25
28
|
export { Text };
|
package/src/system/Time/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { Text } from 'theme-ui';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
+
import classNames from 'classnames';
|
|
8
9
|
|
|
9
10
|
const formatter = new Intl.RelativeTimeFormat( undefined, {
|
|
10
11
|
numeric: 'auto',
|
|
@@ -31,7 +32,7 @@ function formatTimeAgo( date ) {
|
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
|
|
34
|
-
const Time = ( { time, relativeTime = false, timeOnly = false, ...props } ) => {
|
|
35
|
+
const Time = ( { time, relativeTime = false, timeOnly = false, className = null, ...props } ) => {
|
|
35
36
|
let formattedTime;
|
|
36
37
|
if ( relativeTime ) {
|
|
37
38
|
formattedTime = formatTimeAgo( time );
|
|
@@ -46,6 +47,7 @@ const Time = ( { time, relativeTime = false, timeOnly = false, ...props } ) => {
|
|
|
46
47
|
title={time.toLocaleString( 'sv', { timeZoneName: 'short' } )}
|
|
47
48
|
datetime={time}
|
|
48
49
|
as="time"
|
|
50
|
+
className={ classNames( 'vip-time-component', className ) }
|
|
49
51
|
{...props}
|
|
50
52
|
>
|
|
51
53
|
{formattedTime}
|
|
@@ -57,6 +59,7 @@ Time.propTypes = {
|
|
|
57
59
|
time: PropTypes.string,
|
|
58
60
|
timeOnly: PropTypes.bool,
|
|
59
61
|
relativeTime: PropTypes.bool,
|
|
62
|
+
className: PropTypes.any,
|
|
60
63
|
};
|
|
61
64
|
|
|
62
65
|
export { Time };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { Flex } from 'theme-ui';
|
|
7
|
+
import { MdWatchLater } from 'react-icons/md';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import classNames from 'classnames';
|
|
10
|
+
|
|
11
|
+
const VerticalLine = () => {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
sx={ {
|
|
15
|
+
borderLeft: '2px solid',
|
|
16
|
+
borderColor: 'border',
|
|
17
|
+
height: 'calc( 50% - 16px )',
|
|
18
|
+
borderRadius: '2px',
|
|
19
|
+
} }>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const Timeline = ( { time, first = false, last = false, className = null, ...props } ) => (
|
|
25
|
+
<Flex className={ classNames( 'vip-timeline-component', className ) } { ...props }>
|
|
26
|
+
<Flex sx={ { flexDirection: 'column', justifyContent: 'space-evenly', alignItems: 'center' } }>
|
|
27
|
+
{ ! first && (
|
|
28
|
+
<VerticalLine />
|
|
29
|
+
) }
|
|
30
|
+
<MdWatchLater aria-hidden sx={ { color: 'border' } } size={ 18 }/>
|
|
31
|
+
{ ! last && (
|
|
32
|
+
<VerticalLine />
|
|
33
|
+
) }
|
|
34
|
+
</Flex>
|
|
35
|
+
<Flex sx={ { alignItems: 'center', ml: 2 } }>
|
|
36
|
+
{ time }
|
|
37
|
+
</Flex>
|
|
38
|
+
</Flex>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
Timeline.propTypes = {
|
|
42
|
+
first: PropTypes.bool,
|
|
43
|
+
time: PropTypes.node,
|
|
44
|
+
last: PropTypes.bool,
|
|
45
|
+
className: PropTypes.any,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export { Timeline };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Timeline } from '..';
|
|
10
|
+
import { Link } from '../Link';
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'Timeline',
|
|
14
|
+
component: Timeline,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const Default = () => {
|
|
18
|
+
return (
|
|
19
|
+
<React.Fragment>
|
|
20
|
+
<Timeline
|
|
21
|
+
time="13:00"
|
|
22
|
+
title="21:00 UTC"
|
|
23
|
+
/>
|
|
24
|
+
<Timeline
|
|
25
|
+
time={ <Link>14:00</Link> }
|
|
26
|
+
title="22:00 UTC"
|
|
27
|
+
/>
|
|
28
|
+
<Timeline
|
|
29
|
+
time="15:00"
|
|
30
|
+
title="23:00 UTC"
|
|
31
|
+
/>
|
|
32
|
+
</React.Fragment>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -1,46 +1,7 @@
|
|
|
1
|
-
/** @jsxImportSource theme-ui */
|
|
2
1
|
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* Internal dependencies
|
|
5
4
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { MdWatchLater } from 'react-icons/md';
|
|
8
|
-
import PropTypes from 'prop-types';
|
|
9
|
-
|
|
10
|
-
const VerticalLine = () => {
|
|
11
|
-
return (
|
|
12
|
-
<div
|
|
13
|
-
sx={ {
|
|
14
|
-
borderLeft: '2px solid',
|
|
15
|
-
borderColor: 'border',
|
|
16
|
-
height: 'calc( 50% - 16px )',
|
|
17
|
-
borderRadius: '2px',
|
|
18
|
-
} }>
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const Timeline = ( { time, first = false, last = false, ...props } ) => (
|
|
24
|
-
<Flex { ...props }>
|
|
25
|
-
<Flex sx={ { flexDirection: 'column', justifyContent: 'space-evenly', alignItems: 'center' } }>
|
|
26
|
-
{ ! first && (
|
|
27
|
-
<VerticalLine />
|
|
28
|
-
) }
|
|
29
|
-
<MdWatchLater sx={ { color: 'border' } } size={ 18 }/>
|
|
30
|
-
{ ! last && (
|
|
31
|
-
<VerticalLine />
|
|
32
|
-
) }
|
|
33
|
-
</Flex>
|
|
34
|
-
<Flex sx={ { alignItems: 'center', ml: 2 } }>
|
|
35
|
-
<span>{ time }</span>
|
|
36
|
-
</Flex>
|
|
37
|
-
</Flex>
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
Timeline.propTypes = {
|
|
41
|
-
first: PropTypes.bool,
|
|
42
|
-
time: PropTypes.string,
|
|
43
|
-
last: PropTypes.bool,
|
|
44
|
-
};
|
|
5
|
+
import { Timeline } from './Timeline';
|
|
45
6
|
|
|
46
7
|
export { Timeline };
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
+
import classNames from 'classnames';
|
|
8
9
|
import { MdArrowForward } from 'react-icons/md';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -12,9 +13,9 @@ import { MdArrowForward } from 'react-icons/md';
|
|
|
12
13
|
*/
|
|
13
14
|
import { Box, WizardStep, Flex, WizardStepHorizontal } from '..';
|
|
14
15
|
|
|
15
|
-
const Wizard = ( { steps, activeStep, variant, completed = [], ...props } ) => {
|
|
16
|
+
const Wizard = ( { steps, activeStep, variant, completed = [], className = null, ...props } ) => {
|
|
16
17
|
return (
|
|
17
|
-
<Box>
|
|
18
|
+
<Box className={ classNames( 'vip-wizard-component', className ) }>
|
|
18
19
|
{variant === 'horizontal' ? (
|
|
19
20
|
<Box>
|
|
20
21
|
<Flex
|
|
@@ -26,6 +27,7 @@ const Wizard = ( { steps, activeStep, variant, completed = [], ...props } ) => {
|
|
|
26
27
|
{steps.map( ( { title, subTitle }, index ) => (
|
|
27
28
|
<React.Fragment key={index}>
|
|
28
29
|
<WizardStepHorizontal
|
|
30
|
+
order={index + 1}
|
|
29
31
|
active={index === activeStep}
|
|
30
32
|
title={title}
|
|
31
33
|
subTitle={subTitle}
|
|
@@ -44,6 +46,7 @@ const Wizard = ( { steps, activeStep, variant, completed = [], ...props } ) => {
|
|
|
44
46
|
subTitle={subTitle}
|
|
45
47
|
complete={completed.includes( index )}
|
|
46
48
|
key={index}
|
|
49
|
+
order={index + 1}
|
|
47
50
|
>
|
|
48
51
|
{children}
|
|
49
52
|
</WizardStep>
|
|
@@ -58,6 +61,7 @@ Wizard.propTypes = {
|
|
|
58
61
|
activeStep: PropTypes.number,
|
|
59
62
|
variant: PropTypes.string,
|
|
60
63
|
completed: PropTypes.array,
|
|
64
|
+
className: PropTypes.any,
|
|
61
65
|
};
|
|
62
66
|
|
|
63
67
|
export { Wizard };
|
|
@@ -11,7 +11,7 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
*/
|
|
12
12
|
import { Card, Heading, Text } from '..';
|
|
13
13
|
|
|
14
|
-
const WizardStep = ( { title, subTitle, complete = false, children, active } ) => {
|
|
14
|
+
const WizardStep = ( { title, subTitle, complete = false, children, active, order } ) => {
|
|
15
15
|
let borderLeftColor = 'border';
|
|
16
16
|
|
|
17
17
|
if ( complete ) {
|
|
@@ -44,6 +44,8 @@ const WizardStep = ( { title, subTitle, complete = false, children, active } ) =
|
|
|
44
44
|
borderColor: active ? 'primary' : 'border',
|
|
45
45
|
borderLeftColor: borderLeftColor,
|
|
46
46
|
}}
|
|
47
|
+
data-step={ order }
|
|
48
|
+
data-active={ active || undefined }
|
|
47
49
|
>
|
|
48
50
|
<Heading
|
|
49
51
|
variant="h4"
|
|
@@ -69,7 +71,8 @@ WizardStep.propTypes = {
|
|
|
69
71
|
subTitle: PropTypes.node,
|
|
70
72
|
complete: PropTypes.bool,
|
|
71
73
|
active: PropTypes.bool,
|
|
72
|
-
children: PropTypes.node
|
|
74
|
+
children: PropTypes.node,
|
|
75
|
+
order: PropTypes.number.isRequired,
|
|
73
76
|
};
|
|
74
77
|
|
|
75
78
|
export { WizardStep };
|
|
@@ -11,7 +11,7 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
*/
|
|
12
12
|
import { Heading } from '..';
|
|
13
13
|
|
|
14
|
-
const WizardStepHorizontal = ( { title, active } ) => {
|
|
14
|
+
const WizardStepHorizontal = ( { title, active, order } ) => {
|
|
15
15
|
return (
|
|
16
16
|
<Heading
|
|
17
17
|
variant="h4"
|
|
@@ -21,6 +21,8 @@ const WizardStepHorizontal = ( { title, active } ) => {
|
|
|
21
21
|
alignItems: 'center',
|
|
22
22
|
color: active ? 'heading' : 'muted',
|
|
23
23
|
}}
|
|
24
|
+
data-step={ order }
|
|
25
|
+
data-active={ active || undefined }
|
|
24
26
|
>
|
|
25
27
|
<MdCheckCircle sx={{ mr: 2 }} />
|
|
26
28
|
{title}
|
|
@@ -32,6 +34,7 @@ WizardStepHorizontal.propTypes = {
|
|
|
32
34
|
title: PropTypes.node,
|
|
33
35
|
subTitle: PropTypes.node,
|
|
34
36
|
active: PropTypes.bool,
|
|
37
|
+
order: PropTypes.number.isRequired,
|
|
35
38
|
};
|
|
36
39
|
|
|
37
40
|
export { WizardStepHorizontal };
|