@automattic/vip-design-system 0.19.0 → 0.19.1
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/BlankState/BlankState.stories.js +1 -1
- package/build/system/ConfirmationDialog/ConfirmationDialog.stories.js +1 -1
- package/build/system/Dialog/Dialog.stories.js +1 -1
- package/build/system/Form/Input.js +5 -3
- package/build/system/Link/Link.js +8 -6
- package/build/system/NewDialog/DialogClose.js +1 -1
- package/build/system/NewForm/Form.js +34 -0
- package/build/system/NewForm/FormSelect.js +117 -0
- package/build/system/NewForm/FormSelect.stories.js +120 -0
- package/build/system/NewForm/FormSelect.test.js +71 -0
- package/build/system/NewForm/FormSelectArrow.js +39 -0
- package/build/system/NewForm/FormSelectContent.js +55 -0
- package/build/system/NewForm/FormSelectInline.js +33 -0
- package/build/system/NewForm/index.js +18 -0
- package/build/system/Notice/Notice.js +0 -1
- package/build/system/OptionRow/OptionRow.js +2 -2
- package/build/system/ResourceList/ResourceList.js +1 -1
- package/build/system/Table/TableCell.js +1 -1
- package/build/system/Tabs/TabItem.js +3 -2
- package/build/system/Wizard/Wizard.js +10 -6
- package/build/system/Wizard/Wizard.stories.js +24 -2
- package/build/system/Wizard/WizardStep.js +18 -12
- package/build/system/Wizard/WizardStepHorizontal.js +8 -5
- package/build/system/index.js +5 -1
- package/build/system/theme/index.js +17 -4
- package/package.json +1 -1
- package/src/system/BlankState/BlankState.stories.jsx +1 -1
- package/src/system/ConfirmationDialog/ConfirmationDialog.stories.jsx +1 -1
- package/src/system/Dialog/Dialog.stories.jsx +1 -1
- package/src/system/Form/Input.js +2 -4
- package/src/system/Link/Link.js +8 -6
- package/src/system/NewDialog/DialogClose.js +1 -1
- package/src/system/NewForm/Form.js +19 -0
- package/src/system/NewForm/FormSelect.js +91 -0
- package/src/system/NewForm/FormSelect.stories.jsx +96 -0
- package/src/system/NewForm/FormSelect.test.js +34 -0
- package/src/system/NewForm/FormSelectArrow.js +27 -0
- package/src/system/NewForm/FormSelectContent.js +37 -0
- package/src/system/NewForm/FormSelectInline.js +31 -0
- package/src/system/NewForm/index.js +13 -0
- package/src/system/Notice/Notice.js +0 -1
- package/src/system/OptionRow/OptionRow.js +2 -2
- package/src/system/ResourceList/ResourceList.js +1 -1
- package/src/system/Table/TableCell.js +1 -1
- package/src/system/Tabs/TabItem.js +2 -1
- package/src/system/Wizard/Wizard.js +8 -6
- package/src/system/Wizard/Wizard.stories.jsx +19 -0
- package/src/system/Wizard/WizardStep.js +22 -11
- package/src/system/Wizard/WizardStepHorizontal.js +5 -4
- package/src/system/index.js +3 -0
- package/src/system/theme/index.js +21 -5
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports["default"] = exports.Default = void 0;
|
|
6
|
+
exports["default"] = exports.Default = exports.CustomHeadingVariant = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -81,4 +81,26 @@ var Default = function Default() {
|
|
|
81
81
|
});
|
|
82
82
|
};
|
|
83
83
|
|
|
84
|
-
exports.Default = Default;
|
|
84
|
+
exports.Default = Default;
|
|
85
|
+
|
|
86
|
+
var CustomHeadingVariant = function CustomHeadingVariant() {
|
|
87
|
+
var steps = [{
|
|
88
|
+
title: 'Choose Domain',
|
|
89
|
+
titleVariant: 'h1',
|
|
90
|
+
subTitle: (0, _jsxRuntime.jsx)("h2", {
|
|
91
|
+
children: "You can bring a domain name you already own, or buy a new one."
|
|
92
|
+
})
|
|
93
|
+
}, {
|
|
94
|
+
title: 'Configure DNS',
|
|
95
|
+
titleVariant: 'h1'
|
|
96
|
+
}];
|
|
97
|
+
return (0, _jsxRuntime.jsx)(_react["default"].Fragment, {
|
|
98
|
+
children: (0, _jsxRuntime.jsx)(_.Wizard, {
|
|
99
|
+
activeStep: 0,
|
|
100
|
+
steps: steps,
|
|
101
|
+
className: "vip-wizard-xyz"
|
|
102
|
+
})
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
exports.CustomHeadingVariant = CustomHeadingVariant;
|
|
@@ -29,8 +29,10 @@ var WizardStep = function WizardStep(_ref) {
|
|
|
29
29
|
complete = _ref$complete === void 0 ? false : _ref$complete,
|
|
30
30
|
children = _ref.children,
|
|
31
31
|
active = _ref.active,
|
|
32
|
-
order = _ref.order
|
|
33
|
-
|
|
32
|
+
order = _ref.order,
|
|
33
|
+
_ref$titleVariant = _ref.titleVariant,
|
|
34
|
+
titleVariant = _ref$titleVariant === void 0 ? 'h4' : _ref$titleVariant;
|
|
35
|
+
var borderLeftColor = 'borders.2';
|
|
34
36
|
|
|
35
37
|
if (complete) {
|
|
36
38
|
borderLeftColor = 'success';
|
|
@@ -55,26 +57,29 @@ var WizardStep = function WizardStep(_ref) {
|
|
|
55
57
|
borderRadius: 0,
|
|
56
58
|
borderBottom: active ? 'none' : '1px solid',
|
|
57
59
|
'&:first-of-type': {
|
|
58
|
-
borderTopWidth:
|
|
59
|
-
borderTopStyle:
|
|
60
|
+
borderTopWidth: '1px',
|
|
61
|
+
borderTopStyle: 'solid',
|
|
62
|
+
borderTopColor: 'borders.2'
|
|
60
63
|
},
|
|
61
|
-
borderColor: active ? 'primary' : '
|
|
64
|
+
borderColor: active ? 'primary' : 'borders.2',
|
|
62
65
|
borderLeftColor: borderLeftColor
|
|
63
66
|
},
|
|
64
67
|
"data-step": order,
|
|
65
68
|
"data-active": active || undefined,
|
|
66
69
|
children: [(0, _jsxRuntime.jsxs)(_.Heading, {
|
|
67
|
-
variant:
|
|
70
|
+
variant: titleVariant,
|
|
68
71
|
sx: {
|
|
69
72
|
mb: 0,
|
|
70
73
|
display: 'flex',
|
|
71
74
|
alignItems: 'center',
|
|
72
|
-
color: color
|
|
75
|
+
color: color,
|
|
76
|
+
fontSize: 2
|
|
73
77
|
},
|
|
74
78
|
children: [(0, _jsxRuntime.jsx)(_md.MdCheckCircle, {
|
|
75
79
|
sx: {
|
|
76
80
|
mr: 2
|
|
77
|
-
}
|
|
81
|
+
},
|
|
82
|
+
size: 18
|
|
78
83
|
}), title]
|
|
79
84
|
}), subTitle && active && (0, _jsxRuntime.jsx)(_.Text, {
|
|
80
85
|
sx: {
|
|
@@ -87,10 +92,11 @@ var WizardStep = function WizardStep(_ref) {
|
|
|
87
92
|
|
|
88
93
|
exports.WizardStep = WizardStep;
|
|
89
94
|
WizardStep.propTypes = {
|
|
90
|
-
title: _propTypes["default"].node,
|
|
91
|
-
subTitle: _propTypes["default"].node,
|
|
92
|
-
complete: _propTypes["default"].bool,
|
|
93
95
|
active: _propTypes["default"].bool,
|
|
94
96
|
children: _propTypes["default"].node,
|
|
95
|
-
|
|
97
|
+
complete: _propTypes["default"].bool,
|
|
98
|
+
order: _propTypes["default"].number.isRequired,
|
|
99
|
+
subTitle: _propTypes["default"].node,
|
|
100
|
+
title: _propTypes["default"].node,
|
|
101
|
+
titleVariant: _propTypes["default"].string
|
|
96
102
|
};
|
|
@@ -25,9 +25,11 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
|
25
25
|
var WizardStepHorizontal = function WizardStepHorizontal(_ref) {
|
|
26
26
|
var title = _ref.title,
|
|
27
27
|
active = _ref.active,
|
|
28
|
-
order = _ref.order
|
|
28
|
+
order = _ref.order,
|
|
29
|
+
_ref$titleVariant = _ref.titleVariant,
|
|
30
|
+
titleVariant = _ref$titleVariant === void 0 ? 'h4' : _ref$titleVariant;
|
|
29
31
|
return (0, _jsxRuntime.jsxs)(_.Heading, {
|
|
30
|
-
variant:
|
|
32
|
+
variant: titleVariant,
|
|
31
33
|
sx: {
|
|
32
34
|
mb: 0,
|
|
33
35
|
display: 'flex',
|
|
@@ -46,8 +48,9 @@ var WizardStepHorizontal = function WizardStepHorizontal(_ref) {
|
|
|
46
48
|
|
|
47
49
|
exports.WizardStepHorizontal = WizardStepHorizontal;
|
|
48
50
|
WizardStepHorizontal.propTypes = {
|
|
49
|
-
title: _propTypes["default"].node,
|
|
50
|
-
subTitle: _propTypes["default"].node,
|
|
51
51
|
active: _propTypes["default"].bool,
|
|
52
|
-
order: _propTypes["default"].number.isRequired
|
|
52
|
+
order: _propTypes["default"].number.isRequired,
|
|
53
|
+
subTitle: _propTypes["default"].node,
|
|
54
|
+
title: _propTypes["default"].node,
|
|
55
|
+
titleVariant: _propTypes["default"].string
|
|
53
56
|
};
|
package/build/system/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports.NewDialog = exports.Dropdown = void 0;
|
|
6
|
+
exports.NewDialog = exports.Form = exports.Dropdown = void 0;
|
|
7
7
|
|
|
8
8
|
var _Avatar = require("./Avatar");
|
|
9
9
|
|
|
@@ -51,6 +51,10 @@ var Dropdown = _interopRequireWildcard(require("./Dropdown"));
|
|
|
51
51
|
|
|
52
52
|
exports.Dropdown = Dropdown;
|
|
53
53
|
|
|
54
|
+
var Form = _interopRequireWildcard(require("./NewForm"));
|
|
55
|
+
|
|
56
|
+
exports.Form = Form;
|
|
57
|
+
|
|
54
58
|
var _ConfirmationDialog = require("./ConfirmationDialog");
|
|
55
59
|
|
|
56
60
|
exports.ConfirmationDialog = _ConfirmationDialog.ConfirmationDialog;
|
|
@@ -97,18 +97,31 @@ var _default = {
|
|
|
97
97
|
colors: (0, _extends2["default"])({
|
|
98
98
|
text: (0, _getColor.getColor)('text', 'secondary'),
|
|
99
99
|
heading: (0, _getColor.getColor)('text', 'primary'),
|
|
100
|
-
background: '
|
|
100
|
+
background: (0, _getColor.getColor)('background', 'primary'),
|
|
101
101
|
backgroundSecondary: _colors.light.grey['10'],
|
|
102
102
|
primary: _colors.light.brand['70'],
|
|
103
103
|
secondary: '#30c',
|
|
104
104
|
muted: _colors.light.grey['90'],
|
|
105
|
-
link:
|
|
105
|
+
link: (0, _getColor.getColor)('link', 'default'),
|
|
106
|
+
links: {
|
|
107
|
+
"default": (0, _getColor.getColor)('link', 'default'),
|
|
108
|
+
hover: (0, _getColor.getColor)('link', 'hover'),
|
|
109
|
+
active: (0, _getColor.getColor)('link', 'active'),
|
|
110
|
+
visited: (0, _getColor.getColor)('link', 'visited')
|
|
111
|
+
},
|
|
106
112
|
card: '#fff',
|
|
107
|
-
|
|
113
|
+
borders: {
|
|
114
|
+
1: (0, _getColor.getColor)('border', '1'),
|
|
115
|
+
2: (0, _getColor.getColor)('border', '2'),
|
|
116
|
+
3: (0, _getColor.getColor)('border', '3'),
|
|
117
|
+
4: (0, _getColor.getColor)('border', '4'),
|
|
118
|
+
accent: (0, _getColor.getColor)('border', 'accent')
|
|
119
|
+
},
|
|
120
|
+
border: (0, _getColor.getColor)('border', '1'),
|
|
108
121
|
hover: 'rgba(0,0,0,.02)',
|
|
109
122
|
lightenBackground: 'rgba(255,255,255,.5)',
|
|
110
123
|
darken: 'rgba(0,0,0,.05)',
|
|
111
|
-
placeholder:
|
|
124
|
+
placeholder: (0, _getColor.getColor)('text', 'placeholder'),
|
|
112
125
|
midnight: '#13191E',
|
|
113
126
|
navigationStart: _colors.light.grey['5'],
|
|
114
127
|
navigationEnd: _colors.light.grey['5'],
|
package/package.json
CHANGED
package/src/system/Form/Input.js
CHANGED
|
@@ -38,10 +38,8 @@ const Input = React.forwardRef(
|
|
|
38
38
|
color: 'text',
|
|
39
39
|
display: 'block',
|
|
40
40
|
width: '100%',
|
|
41
|
-
'&:focus':
|
|
42
|
-
|
|
43
|
-
outline: 'none',
|
|
44
|
-
},
|
|
41
|
+
'&:focus': theme => theme.outline,
|
|
42
|
+
'&:focus-visible': theme => theme.outline,
|
|
45
43
|
'&:disabled': {
|
|
46
44
|
bg: 'backgroundSecondary',
|
|
47
45
|
},
|
package/src/system/Link/Link.js
CHANGED
|
@@ -10,15 +10,17 @@ const Link = ( { active = false, sx, ...props } ) => (
|
|
|
10
10
|
<ThemeLink
|
|
11
11
|
{ ...props }
|
|
12
12
|
sx={ {
|
|
13
|
-
color: active ? '
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
borderBottomColor: 'border',
|
|
13
|
+
color: active ? 'links.active' : 'link',
|
|
14
|
+
textDdecorationThickness: '0.1em',
|
|
15
|
+
textUnderlineOffset: '0.1em',
|
|
17
16
|
'&:visited': {
|
|
18
|
-
color: '
|
|
17
|
+
color: 'links.visited',
|
|
18
|
+
},
|
|
19
|
+
'&:active': {
|
|
20
|
+
color: 'links.active',
|
|
19
21
|
},
|
|
20
22
|
'&:hover, &:focus': {
|
|
21
|
-
color: '
|
|
23
|
+
color: 'links.hover',
|
|
22
24
|
},
|
|
23
25
|
'&:focus': theme => theme.outline,
|
|
24
26
|
'&:focus-visible': theme => theme.outline,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
|
|
7
|
+
const Form = React.forwardRef( ( { children, ...props }, forwardRef ) => (
|
|
8
|
+
<form ref={ forwardRef } { ...props }>
|
|
9
|
+
{ children }
|
|
10
|
+
</form>
|
|
11
|
+
) );
|
|
12
|
+
|
|
13
|
+
Form.propTypes = {
|
|
14
|
+
children: PropTypes.any,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
Form.displayName = 'Form';
|
|
18
|
+
|
|
19
|
+
export { Form };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { Label } from '../Form/Label';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import { FormSelectArrow } from './FormSelectArrow';
|
|
14
|
+
import { FormSelectContent } from './FormSelectContent';
|
|
15
|
+
|
|
16
|
+
const MAX_SUGGESTED_OPTIONS = 15;
|
|
17
|
+
const isDev = process.env.NODE_ENV !== 'production';
|
|
18
|
+
|
|
19
|
+
const defaultStyles = {
|
|
20
|
+
width: '100%',
|
|
21
|
+
paddingLeft: 3,
|
|
22
|
+
paddingRight: 40, // 40px for the icon
|
|
23
|
+
py: 0,
|
|
24
|
+
borderColor: 'border',
|
|
25
|
+
borderRadius: 1,
|
|
26
|
+
appearance: 'none',
|
|
27
|
+
minHeight: '36px',
|
|
28
|
+
'&:focus': theme => theme.outline,
|
|
29
|
+
'&:focus-visible': theme => theme.outline,
|
|
30
|
+
'&:focus-within': theme => theme.outline,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const renderOption = ( label, value ) => {
|
|
34
|
+
return (
|
|
35
|
+
<option key={ value } value={ value }>
|
|
36
|
+
{ label }
|
|
37
|
+
</option>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const renderGroup = ( groupLabel, groupOptions ) => {
|
|
42
|
+
return (
|
|
43
|
+
<optgroup key={ groupLabel } label={ groupLabel }>
|
|
44
|
+
{ groupOptions.map( ( { label, value } ) => renderOption( label, value ) ) }
|
|
45
|
+
</optgroup>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const FormSelect = React.forwardRef(
|
|
50
|
+
( { isInline, placeholder, forLabel, options, label, ...props }, forwardRef ) => {
|
|
51
|
+
if ( isDev && options.length > MAX_SUGGESTED_OPTIONS ) {
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
console.info(
|
|
54
|
+
'For 16 or more items, consider using another component with a typeahead capability.'
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const SelectLabel = () => <Label htmlFor={ forLabel || props.id }>{ label }</Label>;
|
|
59
|
+
const inlineLabel = !! ( isInline && label );
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
{ label && ! isInline && <SelectLabel /> }
|
|
64
|
+
|
|
65
|
+
<FormSelectContent isInline={ inlineLabel } label={ inlineLabel ? <SelectLabel /> : null }>
|
|
66
|
+
<select ref={ forwardRef } sx={ defaultStyles } { ...props }>
|
|
67
|
+
{ placeholder && <option>{ placeholder }</option> }
|
|
68
|
+
{ options.map( ( { label: optionLabel, value, options: groupOptions } ) =>
|
|
69
|
+
value ? renderOption( optionLabel, value ) : renderGroup( optionLabel, groupOptions )
|
|
70
|
+
) }
|
|
71
|
+
</select>
|
|
72
|
+
|
|
73
|
+
<FormSelectArrow />
|
|
74
|
+
</FormSelectContent>
|
|
75
|
+
</>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
FormSelect.propTypes = {
|
|
81
|
+
id: PropTypes.string,
|
|
82
|
+
isInline: PropTypes.bool,
|
|
83
|
+
forLabel: PropTypes.string,
|
|
84
|
+
placeholder: PropTypes.string,
|
|
85
|
+
label: PropTypes.string,
|
|
86
|
+
options: PropTypes.array,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
FormSelect.displayName = 'FormSelect';
|
|
90
|
+
|
|
91
|
+
export { FormSelect };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Internal dependencies
|
|
5
|
+
*/
|
|
6
|
+
import * as Form from '.';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Form/Select',
|
|
10
|
+
argTypes: {
|
|
11
|
+
placeholder: {
|
|
12
|
+
type: { name: 'string', required: false },
|
|
13
|
+
control: { type: 'text' },
|
|
14
|
+
},
|
|
15
|
+
label: {
|
|
16
|
+
type: { name: 'string', required: false },
|
|
17
|
+
control: { type: 'text' },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const options = [
|
|
23
|
+
{ value: 'chocolate', label: 'Chocolate' },
|
|
24
|
+
{ value: 'strawberry', label: 'Strawberry Chocolate Vanilla Chocolate Vanilla' },
|
|
25
|
+
{ value: 'vanilla', label: 'Vanilla' },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// eslint-disable-next-line react/prop-types
|
|
29
|
+
const DefaultComponent = ( { label = 'Label', width = 250, ...rest } ) => (
|
|
30
|
+
<>
|
|
31
|
+
<p>
|
|
32
|
+
This is a simple wrapper at the top of a browser default select component. This component
|
|
33
|
+
should be used for situations where you have up to <strong>15 options</strong>. If you need to
|
|
34
|
+
use a auto-complete, searchable solution, please use another component with a typeahead
|
|
35
|
+
capability.
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+
<p>
|
|
39
|
+
This component was heavily inspired by the{ ' ' }
|
|
40
|
+
<a
|
|
41
|
+
href="https://designsystem.digital.gov/components/select/"
|
|
42
|
+
target="_blank"
|
|
43
|
+
rel="noreferrer"
|
|
44
|
+
>
|
|
45
|
+
{ ' ' }
|
|
46
|
+
U.S. Web Design System (USWDS) Select component
|
|
47
|
+
</a>
|
|
48
|
+
.
|
|
49
|
+
</p>
|
|
50
|
+
<Form.Root>
|
|
51
|
+
<div sx={ { width } }>
|
|
52
|
+
<Form.Select id="form-select" label={ label } { ...rest } />
|
|
53
|
+
</div>
|
|
54
|
+
</Form.Root>
|
|
55
|
+
</>
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
export const Default = DefaultComponent.bind( {} );
|
|
59
|
+
Default.args = {
|
|
60
|
+
placeholder: '- Select -',
|
|
61
|
+
options: options,
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const WithGroup = DefaultComponent.bind( {} );
|
|
65
|
+
|
|
66
|
+
WithGroup.args = {
|
|
67
|
+
label: 'Group Label',
|
|
68
|
+
options: [
|
|
69
|
+
{
|
|
70
|
+
label: 'Group name',
|
|
71
|
+
options: options,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
label: 'Another Group name',
|
|
75
|
+
options: options,
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const IsInline = DefaultComponent.bind( {} );
|
|
81
|
+
|
|
82
|
+
IsInline.args = {
|
|
83
|
+
label: 'Inline Select',
|
|
84
|
+
isInline: true,
|
|
85
|
+
width: '100%',
|
|
86
|
+
options: [
|
|
87
|
+
{
|
|
88
|
+
label: 'Group name',
|
|
89
|
+
options: options,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
label: 'Another Group name',
|
|
93
|
+
options: options,
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
import { axe } from 'jest-axe';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { FormSelect } from './FormSelect';
|
|
11
|
+
|
|
12
|
+
const options = [
|
|
13
|
+
{ value: 'chocolate', label: 'Chocolate' },
|
|
14
|
+
{ value: 'strawberry', label: 'Strawberry Chocolate Vanilla Chocolate Vanilla' },
|
|
15
|
+
{ value: 'vanilla', label: 'Vanilla' },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const defaultProps = {
|
|
19
|
+
label: 'This is a label',
|
|
20
|
+
forLabel: 'my_desert_list',
|
|
21
|
+
options,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
describe( '<FormSelect />', () => {
|
|
25
|
+
it( 'renders the FormSelect component', async () => {
|
|
26
|
+
const { container } = render( <FormSelect id="my_desert_list" { ...defaultProps } /> );
|
|
27
|
+
|
|
28
|
+
expect( screen.getByLabelText( defaultProps.label ) ).toBeInTheDocument();
|
|
29
|
+
expect( screen.getByRole( 'combobox' ) ).toBeInTheDocument();
|
|
30
|
+
|
|
31
|
+
// Check for accessibility issues
|
|
32
|
+
await expect( await axe( container ) ).toHaveNoViolations();
|
|
33
|
+
} );
|
|
34
|
+
} );
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { MdExpandMore } from 'react-icons/md';
|
|
8
|
+
|
|
9
|
+
export const FormSelectArrow = React.forwardRef( ( props, forwardRef ) => (
|
|
10
|
+
<MdExpandMore
|
|
11
|
+
ref={ forwardRef }
|
|
12
|
+
aria-hidden="true"
|
|
13
|
+
size={ 24 }
|
|
14
|
+
sx={ {
|
|
15
|
+
paddingLeft: 2,
|
|
16
|
+
borderLeftWidth: '1px',
|
|
17
|
+
borderLeftStyle: 'solid',
|
|
18
|
+
borderLeftColor: 'border',
|
|
19
|
+
position: 'relative',
|
|
20
|
+
right: 34,
|
|
21
|
+
pointerEvents: 'none',
|
|
22
|
+
} }
|
|
23
|
+
{ ...props }
|
|
24
|
+
/>
|
|
25
|
+
) );
|
|
26
|
+
|
|
27
|
+
FormSelectArrow.displayName = 'FormSelectArrow';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External dependencies
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import PropTypes from 'prop-types';
|
|
8
|
+
import { inlineStyles } from './FormSelectInline';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const defaultStyles = {
|
|
15
|
+
'&:hover select': { borderColor: 'border' },
|
|
16
|
+
display: 'inline-flex',
|
|
17
|
+
flexDirection: 'row',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const FormSelectContent = React.forwardRef( ( { isInline, label, children }, forwardRef ) => (
|
|
22
|
+
<div sx={ isInline ? inlineStyles : {} } className="vip-select-component" ref={ forwardRef }>
|
|
23
|
+
{ isInline && label }
|
|
24
|
+
|
|
25
|
+
<div sx={ defaultStyles }>{ children }</div>
|
|
26
|
+
</div>
|
|
27
|
+
) );
|
|
28
|
+
|
|
29
|
+
FormSelectContent.propTypes = {
|
|
30
|
+
isInline: PropTypes.bool,
|
|
31
|
+
label: PropTypes.any,
|
|
32
|
+
children: PropTypes.any,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
FormSelectContent.displayName = 'FormSelectContent';
|
|
36
|
+
|
|
37
|
+
export { FormSelectContent };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const inlineStyles = {
|
|
2
|
+
position: 'relative',
|
|
3
|
+
display: 'inline-flex',
|
|
4
|
+
alignItems: 'center',
|
|
5
|
+
borderColor: 'border',
|
|
6
|
+
borderRadius: 1,
|
|
7
|
+
borderWidth: 1,
|
|
8
|
+
borderStyle: 'solid',
|
|
9
|
+
paddingRight: 0,
|
|
10
|
+
paddingLeft: 3,
|
|
11
|
+
|
|
12
|
+
label: {
|
|
13
|
+
margin: 0,
|
|
14
|
+
paddingRight: 2,
|
|
15
|
+
borderRightWidth: '1px',
|
|
16
|
+
borderRightStyle: 'solid',
|
|
17
|
+
borderRightColor: 'border',
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
select: {
|
|
21
|
+
width: '100%',
|
|
22
|
+
border: 'none',
|
|
23
|
+
margin: 0,
|
|
24
|
+
paddingLeft: 2,
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
svg: {
|
|
28
|
+
right: 2,
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -15,7 +15,7 @@ import classNames from 'classnames';
|
|
|
15
15
|
|
|
16
16
|
const disabledStyles = {
|
|
17
17
|
border: '1px solid',
|
|
18
|
-
borderColor: '
|
|
18
|
+
borderColor: 'borders.2',
|
|
19
19
|
background: 'none',
|
|
20
20
|
boxShadow: 'none',
|
|
21
21
|
color: 'grey.70',
|
|
@@ -31,7 +31,7 @@ const regularGridStyle = small => ( {
|
|
|
31
31
|
py: 3,
|
|
32
32
|
px: [ 3, 3, small ? 3 : 5 ],
|
|
33
33
|
borderBottom: '1px solid',
|
|
34
|
-
borderColor: '
|
|
34
|
+
borderColor: 'borders.2',
|
|
35
35
|
} );
|
|
36
36
|
|
|
37
37
|
const OptionRow = ( {
|
|
@@ -16,7 +16,7 @@ const TableCell = ( { head, children, ...rest } ) => {
|
|
|
16
16
|
borderBottom: '1px solid',
|
|
17
17
|
borderTop: head ? '1px solid' : 'none',
|
|
18
18
|
// borderColor should come after borderTop so it can override it
|
|
19
|
-
borderColor: '
|
|
19
|
+
borderColor: 'borders.2',
|
|
20
20
|
fontWeight: 'body',
|
|
21
21
|
px: 3,
|
|
22
22
|
py: 2,
|