@automattic/vip-design-system 0.20.1 → 0.22.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/build/system/Avatar/Avatar.js +7 -3
- package/build/system/Badge/Badge.js +7 -3
- package/build/system/Box/Box.js +4 -3
- package/build/system/Code/Code.js +10 -4
- package/build/system/Flex/Flex.js +10 -5
- package/build/system/Form/Label.js +12 -4
- package/build/system/Form/Radio.js +7 -3
- package/build/system/Form/RadioBoxGroup.js +7 -3
- package/build/system/Form/Toggle.js +7 -3
- package/build/system/Form/ToggleGroup.js +7 -3
- package/build/system/Link/Link.js +7 -3
- package/build/system/Notice/Notice.js +2 -1
- package/build/system/Notification/Notification.js +6 -2
- package/build/system/OptionRow/OptionRow.js +5 -3
- package/build/system/ScreenReaderText/ScreenReaderText.js +16 -13
- package/build/system/Spinner/Spinner.js +7 -3
- package/build/system/Table/Table.js +22 -4
- package/build/system/Table/Table.stories.js +5 -1
- package/build/system/Tabs/Tabs.js +7 -3
- package/build/system/Text/Text.js +7 -3
- package/build/system/Wizard/Wizard.js +4 -2
- package/build/system/Wizard/WizardStep.js +6 -2
- package/build/system/Wizard/WizardStepHorizontal.js +6 -2
- package/package.json +1 -1
- package/src/system/Avatar/Avatar.js +54 -53
- package/src/system/Badge/Badge.js +24 -19
- package/src/system/Box/Box.js +2 -2
- package/src/system/Code/Code.js +81 -76
- package/src/system/Flex/Flex.js +6 -1
- package/src/system/Form/Label.js +10 -2
- package/src/system/Form/Radio.js +11 -3
- package/src/system/Form/RadioBoxGroup.js +52 -46
- package/src/system/Form/Toggle.js +50 -50
- package/src/system/Form/ToggleGroup.js +49 -43
- package/src/system/Link/Link.js +6 -2
- package/src/system/Notice/Notice.js +1 -1
- package/src/system/Notification/Notification.js +41 -34
- package/src/system/OptionRow/OptionRow.js +86 -78
- package/src/system/ScreenReaderText/ScreenReaderText.js +14 -17
- package/src/system/Spinner/Spinner.js +6 -2
- package/src/system/Table/Table.js +25 -10
- package/src/system/Table/Table.stories.jsx +4 -1
- package/src/system/Tabs/Tabs.js +6 -2
- package/src/system/Text/Text.js +6 -2
- package/src/system/Wizard/Wizard.js +49 -45
- package/src/system/Wizard/WizardStep.js +63 -57
- package/src/system/Wizard/WizardStepHorizontal.js +6 -2
|
@@ -10,24 +10,21 @@ import PropTypes from 'prop-types';
|
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
+
export const screenReaderTextClass = {
|
|
14
|
+
border: 'none',
|
|
15
|
+
clip: 'rect(1px, 1px, 1px, 1px)',
|
|
16
|
+
clipPath: 'inset(50%)',
|
|
17
|
+
height: '1px',
|
|
18
|
+
margin: '-1px',
|
|
19
|
+
overflow: 'hidden',
|
|
20
|
+
padding: '0',
|
|
21
|
+
position: 'absolute',
|
|
22
|
+
width: '1px',
|
|
23
|
+
wordWrap: 'normal !important',
|
|
24
|
+
};
|
|
25
|
+
|
|
13
26
|
export const ScreenReaderText = React.forwardRef( ( props, forwardRef ) => (
|
|
14
|
-
<span
|
|
15
|
-
className="screen-reader-text"
|
|
16
|
-
sx={ {
|
|
17
|
-
border: 'none',
|
|
18
|
-
clip: 'rect(1px, 1px, 1px, 1px)',
|
|
19
|
-
clipPath: 'inset(50%)',
|
|
20
|
-
height: '1px',
|
|
21
|
-
margin: '-1px',
|
|
22
|
-
overflow: 'hidden',
|
|
23
|
-
padding: '0',
|
|
24
|
-
position: 'absolute',
|
|
25
|
-
width: '1px',
|
|
26
|
-
wordWrap: 'normal !important',
|
|
27
|
-
} }
|
|
28
|
-
{ ...props }
|
|
29
|
-
ref={ forwardRef }
|
|
30
|
-
>
|
|
27
|
+
<span className="screen-reader-text" sx={ screenReaderTextClass } { ...props } ref={ forwardRef }>
|
|
31
28
|
{ props.children }
|
|
32
29
|
</span>
|
|
33
30
|
) );
|
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import { Spinner as ThemeSpinner } from 'theme-ui';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
import classNames from 'classnames';
|
|
9
10
|
|
|
10
|
-
const Spinner = ( { sx, className = null, ...props } ) => (
|
|
11
|
+
const Spinner = React.forwardRef( ( { sx, className = null, ...props }, forwardRef ) => (
|
|
11
12
|
<ThemeSpinner
|
|
12
13
|
strokeWidth={ 2 }
|
|
13
14
|
sx={ {
|
|
@@ -15,9 +16,12 @@ const Spinner = ( { sx, className = null, ...props } ) => (
|
|
|
15
16
|
color: 'primary',
|
|
16
17
|
} }
|
|
17
18
|
className={ classNames( 'vip-spinner-component', className ) }
|
|
19
|
+
ref={ forwardRef }
|
|
18
20
|
{ ...props }
|
|
19
21
|
/>
|
|
20
|
-
);
|
|
22
|
+
) );
|
|
23
|
+
|
|
24
|
+
Spinner.displayName = 'Spinner';
|
|
21
25
|
|
|
22
26
|
Spinner.propTypes = {
|
|
23
27
|
sx: PropTypes.object,
|
|
@@ -6,23 +6,38 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import classNames from 'classnames';
|
|
9
|
+
import { screenReaderTextClass } from '../ScreenReaderText/ScreenReaderText';
|
|
9
10
|
|
|
10
|
-
const Table = React.forwardRef(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const Table = React.forwardRef(
|
|
12
|
+
( { sx, className, children, caption = null, ...props }, forwardRef ) => {
|
|
13
|
+
if ( ! caption ) {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.warn( '[A11Y] Please, add a caption to your table.' );
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<table
|
|
20
|
+
sx={ { width: '100%', minWidth: 1024, ...sx } }
|
|
21
|
+
cellPadding={ 0 }
|
|
22
|
+
cellSpacing={ 0 }
|
|
23
|
+
className={ classNames( 'vip-table-component', className ) }
|
|
24
|
+
ref={ forwardRef }
|
|
25
|
+
{ ...props }
|
|
26
|
+
>
|
|
27
|
+
{ caption && <caption sx={ screenReaderTextClass }>{ caption }</caption> }
|
|
28
|
+
{ children }
|
|
29
|
+
</table>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
20
33
|
|
|
21
34
|
Table.displayName = 'Table';
|
|
22
35
|
|
|
23
36
|
Table.propTypes = {
|
|
24
37
|
sx: PropTypes.object,
|
|
25
38
|
className: PropTypes.any,
|
|
39
|
+
children: PropTypes.any,
|
|
40
|
+
caption: PropTypes.string.isRequired,
|
|
26
41
|
};
|
|
27
42
|
|
|
28
43
|
export { Table };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Internal dependencies
|
|
3
5
|
*/
|
|
@@ -9,7 +11,7 @@ export default {
|
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
export const Default = () => (
|
|
12
|
-
<Table>
|
|
14
|
+
<Table caption="Storybook Example">
|
|
13
15
|
<thead>
|
|
14
16
|
<TableRow head cells={ [ 'User', 'Command', 'Duration', 'Time' ] } />
|
|
15
17
|
</thead>
|
|
@@ -35,6 +37,7 @@ export const Default = () => (
|
|
|
35
37
|
11th Mar 2020, 16:49:22
|
|
36
38
|
</Text>,
|
|
37
39
|
] }
|
|
40
|
+
gbc
|
|
38
41
|
/>
|
|
39
42
|
<TableRow>
|
|
40
43
|
<TableCell sx={ { backgroundColor: 'lightgray' } }>
|
package/src/system/Tabs/Tabs.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import classNames from 'classnames';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
|
|
@@ -11,7 +12,7 @@ import PropTypes from 'prop-types';
|
|
|
11
12
|
*/
|
|
12
13
|
import { Flex } from '..';
|
|
13
14
|
|
|
14
|
-
const Tabs = ( { className = null, sx, ...props } ) => (
|
|
15
|
+
const Tabs = React.forwardRef( ( { className = null, sx, ...props }, forwardRef ) => (
|
|
15
16
|
<Flex
|
|
16
17
|
className={ classNames( 'vip-tabs-component', className ) }
|
|
17
18
|
sx={ {
|
|
@@ -22,9 +23,12 @@ const Tabs = ( { className = null, sx, ...props } ) => (
|
|
|
22
23
|
padding: 0,
|
|
23
24
|
...sx,
|
|
24
25
|
} }
|
|
26
|
+
ref={ forwardRef }
|
|
25
27
|
{ ...props }
|
|
26
28
|
/>
|
|
27
|
-
);
|
|
29
|
+
) );
|
|
30
|
+
|
|
31
|
+
Tabs.displayName = 'Tabs';
|
|
28
32
|
|
|
29
33
|
Tabs.propTypes = {
|
|
30
34
|
className: PropTypes.any,
|
package/src/system/Text/Text.js
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import { Text as ThemeText } from 'theme-ui';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
import classNames from 'classnames';
|
|
9
10
|
|
|
10
|
-
const Text = ( { sx, className = null, ...props } ) => (
|
|
11
|
+
const Text = React.forwardRef( ( { sx, className = null, ...props }, forwardRef ) => (
|
|
11
12
|
<ThemeText
|
|
12
13
|
as="p"
|
|
13
14
|
sx={ {
|
|
@@ -16,9 +17,12 @@ const Text = ( { sx, className = null, ...props } ) => (
|
|
|
16
17
|
...sx,
|
|
17
18
|
} }
|
|
18
19
|
className={ classNames( 'vip-text-component', className ) }
|
|
20
|
+
ref={ forwardRef }
|
|
19
21
|
{ ...props }
|
|
20
22
|
/>
|
|
21
|
-
);
|
|
23
|
+
) );
|
|
24
|
+
|
|
25
|
+
Text.displayName = 'Text';
|
|
22
26
|
|
|
23
27
|
Text.propTypes = {
|
|
24
28
|
sx: PropTypes.object,
|
|
@@ -13,51 +13,55 @@ import { MdArrowForward } from 'react-icons/md';
|
|
|
13
13
|
*/
|
|
14
14
|
import { Box, WizardStep, Flex, WizardStepHorizontal } from '..';
|
|
15
15
|
|
|
16
|
-
const Wizard = (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
16
|
+
const Wizard = React.forwardRef(
|
|
17
|
+
( { steps, activeStep, variant, completed = [], className = null, ...props }, forwardRef ) => {
|
|
18
|
+
return (
|
|
19
|
+
<Box className={ classNames( 'vip-wizard-component', className ) } ref={ forwardRef }>
|
|
20
|
+
{ variant === 'horizontal' ? (
|
|
21
|
+
<Box>
|
|
22
|
+
<Flex
|
|
23
|
+
sx={ {
|
|
24
|
+
flex: '0 0 auto',
|
|
25
|
+
} }
|
|
26
|
+
{ ...props }
|
|
27
|
+
>
|
|
28
|
+
{ steps.map( ( { title, subTitle, titleVariant }, index ) => (
|
|
29
|
+
<React.Fragment key={ index }>
|
|
30
|
+
<WizardStepHorizontal
|
|
31
|
+
active={ index === activeStep }
|
|
32
|
+
order={ index + 1 }
|
|
33
|
+
subTitle={ subTitle }
|
|
34
|
+
title={ title }
|
|
35
|
+
titleVariant={ titleVariant }
|
|
36
|
+
/>
|
|
37
|
+
{ index < steps.length - 1 && (
|
|
38
|
+
<MdArrowForward sx={ { mx: 2, color: 'grey.80' } } />
|
|
39
|
+
) }
|
|
40
|
+
</React.Fragment>
|
|
41
|
+
) ) }
|
|
42
|
+
</Flex>
|
|
43
|
+
{ steps[ activeStep ].children }
|
|
44
|
+
</Box>
|
|
45
|
+
) : (
|
|
46
|
+
steps.map( ( { title, subTitle, children }, index ) => (
|
|
47
|
+
<WizardStep
|
|
48
|
+
active={ index === activeStep }
|
|
49
|
+
complete={ completed.includes( index ) }
|
|
50
|
+
key={ index }
|
|
51
|
+
order={ index + 1 }
|
|
52
|
+
subTitle={ subTitle }
|
|
53
|
+
title={ title }
|
|
54
|
+
>
|
|
55
|
+
{ children }
|
|
56
|
+
</WizardStep>
|
|
57
|
+
) )
|
|
58
|
+
) }
|
|
59
|
+
</Box>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
Wizard.displayName = 'Wizard';
|
|
61
65
|
|
|
62
66
|
Wizard.propTypes = {
|
|
63
67
|
steps: PropTypes.array,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import { MdCheckCircle } from 'react-icons/md';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
|
|
@@ -11,69 +12,74 @@ import PropTypes from 'prop-types';
|
|
|
11
12
|
*/
|
|
12
13
|
import { Card, Heading, Text, Flex } from '..';
|
|
13
14
|
|
|
14
|
-
const WizardStep = (
|
|
15
|
-
|
|
15
|
+
const WizardStep = React.forwardRef(
|
|
16
|
+
( { title, subTitle, complete = false, children, active, order }, forwardRef ) => {
|
|
17
|
+
let borderLeftColor = 'border';
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
if ( complete ) {
|
|
20
|
+
borderLeftColor = 'success';
|
|
21
|
+
} else if ( active ) {
|
|
22
|
+
borderLeftColor = 'primary';
|
|
23
|
+
}
|
|
22
24
|
|
|
23
|
-
|
|
25
|
+
let color = 'muted';
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
if ( complete ) {
|
|
28
|
+
color = 'success';
|
|
29
|
+
} else if ( active ) {
|
|
30
|
+
color = 'heading';
|
|
31
|
+
}
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
33
|
+
return (
|
|
34
|
+
<Card
|
|
35
|
+
sx={ {
|
|
36
|
+
boxShadow: active ? 'low' : 'none',
|
|
37
|
+
borderLeft: '2px solid',
|
|
38
|
+
p: 4,
|
|
39
|
+
backgroundColor: active ? 'card' : 'transparent',
|
|
40
|
+
borderRadius: 0,
|
|
41
|
+
borderBottom: active ? 'none' : '1px solid',
|
|
42
|
+
'&:first-of-type': {
|
|
43
|
+
borderTopWidth: '1px',
|
|
44
|
+
borderTopStyle: 'solid',
|
|
45
|
+
borderTopColor: 'borders.2',
|
|
46
|
+
},
|
|
47
|
+
borderColor: active ? 'primary' : 'borders.2',
|
|
48
|
+
borderLeftColor: borderLeftColor,
|
|
49
|
+
} }
|
|
50
|
+
data-step={ order }
|
|
51
|
+
data-active={ active || undefined }
|
|
52
|
+
ref={ forwardRef }
|
|
53
|
+
>
|
|
54
|
+
{ typeof title === 'string' ? (
|
|
55
|
+
<Heading
|
|
56
|
+
variant="h4"
|
|
57
|
+
sx={ {
|
|
58
|
+
mb: 0,
|
|
59
|
+
display: 'flex',
|
|
60
|
+
alignItems: 'center',
|
|
61
|
+
color: color,
|
|
62
|
+
} }
|
|
63
|
+
>
|
|
64
|
+
<MdCheckCircle aria-hidden="true" sx={ { mr: 2 } } />
|
|
65
|
+
{ title }
|
|
66
|
+
</Heading>
|
|
67
|
+
) : (
|
|
68
|
+
<Flex sx={ { alignItems: 'center', color } }>
|
|
69
|
+
<MdCheckCircle aria-hidden="true" sx={ { mr: 2 } } />
|
|
70
|
+
{ title }
|
|
71
|
+
</Flex>
|
|
72
|
+
) }
|
|
70
73
|
|
|
71
|
-
|
|
74
|
+
{ subTitle && active && <Text sx={ { mb: 3 } }>{ subTitle }</Text> }
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
76
|
+
{ active && children }
|
|
77
|
+
</Card>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
WizardStep.displayName = 'WizardStep';
|
|
77
83
|
|
|
78
84
|
WizardStep.propTypes = {
|
|
79
85
|
active: PropTypes.bool,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
|
+
import React from 'react';
|
|
6
7
|
import { MdCheckCircle } from 'react-icons/md';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
|
|
@@ -11,7 +12,7 @@ import PropTypes from 'prop-types';
|
|
|
11
12
|
*/
|
|
12
13
|
import { Heading, Flex } from '..';
|
|
13
14
|
|
|
14
|
-
const WizardStepHorizontal = ( { title, active, order } ) => {
|
|
15
|
+
const WizardStepHorizontal = React.forwardRef( ( { title, active, order }, forwardRef ) => {
|
|
15
16
|
const color = active ? 'heading' : 'muted';
|
|
16
17
|
|
|
17
18
|
return typeof title === 'string' ? (
|
|
@@ -25,6 +26,7 @@ const WizardStepHorizontal = ( { title, active, order } ) => {
|
|
|
25
26
|
} }
|
|
26
27
|
data-step={ order }
|
|
27
28
|
data-active={ active || undefined }
|
|
29
|
+
ref={ forwardRef }
|
|
28
30
|
>
|
|
29
31
|
<MdCheckCircle aria-hidden="true" sx={ { mr: 2 } } />
|
|
30
32
|
{ title }
|
|
@@ -35,7 +37,9 @@ const WizardStepHorizontal = ( { title, active, order } ) => {
|
|
|
35
37
|
{ title }
|
|
36
38
|
</Flex>
|
|
37
39
|
);
|
|
38
|
-
};
|
|
40
|
+
} );
|
|
41
|
+
|
|
42
|
+
WizardStepHorizontal.displayName = 'WizardStepHorizontal';
|
|
39
43
|
|
|
40
44
|
WizardStepHorizontal.propTypes = {
|
|
41
45
|
active: PropTypes.bool,
|