@automattic/vip-design-system 2.13.11 → 2.14.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.
@@ -18,6 +18,7 @@ export interface ButtonProps extends ThemeButtonProps {
18
18
  full?: boolean;
19
19
  grow?: boolean;
20
20
  variant?: keyof typeof ButtonVariant;
21
+ danger?: boolean;
21
22
  }
22
23
  declare const Button: React.ForwardRefExoticComponent<Omit<ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
23
24
  export { Button };
@@ -1,4 +1,4 @@
1
- var _excluded = ["className", "disabled", "preferAriaDisabled", "onClick", "sx", "full", "grow"];
1
+ var _excluded = ["className", "disabled", "preferAriaDisabled", "onClick", "sx", "full", "grow", "variant", "danger"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
3
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
4
  import classNames from 'classnames';
@@ -24,12 +24,17 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
24
24
  sx = _ref.sx,
25
25
  full = _ref.full,
26
26
  grow = _ref.grow,
27
+ _ref$variant = _ref.variant,
28
+ variant = _ref$variant === void 0 ? 'primary' : _ref$variant,
29
+ _ref$danger = _ref.danger,
30
+ danger = _ref$danger === void 0 ? variant === 'danger' : _ref$danger,
27
31
  rest = _objectWithoutPropertiesLoose(_ref, _excluded);
28
32
  var disabledAttributes = disabled && preferAriaDisabled === true ? {
29
33
  'aria-disabled': true
30
34
  } : {
31
35
  disabled: disabled
32
36
  };
37
+ var disabledStyles = {};
33
38
  var handleOnClick = useCallback(function (event) {
34
39
  if (preferAriaDisabled && disabled) {
35
40
  return event.preventDefault();
@@ -38,19 +43,23 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
38
43
  return onClick(event);
39
44
  }
40
45
  }, [disabled, onClick]);
46
+ if (disabled && !danger && variant !== 'text' && variant !== 'ghost' && variant !== 'tertiary') {
47
+ disabledStyles = {
48
+ opacity: 0.7,
49
+ backgroundColor: 'input.border.disabled',
50
+ color: 'texts.secondary'
51
+ };
52
+ }
41
53
  return _jsx(ThemeButton, _extends({
42
54
  sx: _extends({
43
55
  '&:focus': 'none',
44
56
  '&:focus-visible': function focusVisible(theme) {
45
57
  return theme.outline;
46
58
  },
47
- '&[disabled], &[aria-disabled="true"]': {
48
- opacity: 0.7,
49
- backgroundColor: 'input.border.disabled',
50
- color: 'texts.secondary',
59
+ '&[disabled], &[aria-disabled="true"]': _extends({
51
60
  cursor: 'not-allowed',
52
61
  pointerEvents: 'none'
53
- },
62
+ }, disabledStyles),
54
63
  '&:hover, &:focus': {
55
64
  textDecoration: 'none'
56
65
  },
@@ -58,8 +67,10 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
58
67
  width: Boolean(full) === true ? '100%' : undefined
59
68
  }, sx)
60
69
  }, rest, disabledAttributes, {
70
+ variant: variant,
61
71
  onClick: handleOnClick,
62
72
  className: classNames('vip-button-component', className),
73
+ "data-danger": danger,
63
74
  ref: ref
64
75
  }));
65
76
  });
@@ -1,15 +1,12 @@
1
1
  /** @jsxImportSource theme-ui */
2
- /**
3
- * External dependencies
4
- */
5
- import React from 'react';
2
+ /// <reference types="react" />
6
3
  /**
7
4
  * Internal dependencies
8
5
  */
9
6
  import { ButtonVariant } from '..';
10
7
  declare const _default: {
11
8
  title: string;
12
- component: React.ForwardRefExoticComponent<Omit<import("./Button").ButtonProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
9
+ component: import("react").ForwardRefExoticComponent<Omit<import("./Button").ButtonProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
13
10
  argTypes: {
14
11
  children: {};
15
12
  disabled: {
@@ -17,6 +14,11 @@ declare const _default: {
17
14
  type: string;
18
15
  };
19
16
  };
17
+ danger: {
18
+ control: {
19
+ type: string;
20
+ };
21
+ };
20
22
  variant: {
21
23
  type: string;
22
24
  options: (string | ButtonVariant)[];
@@ -31,5 +33,5 @@ declare const _default: {
31
33
  };
32
34
  };
33
35
  export default _default;
34
- export declare const Default: (args: any) => React.JSX.Element;
35
- export declare const PreferAriaDisabled: (args: any) => React.JSX.Element;
36
+ export declare const Default: (args: any) => import("react").JSX.Element;
37
+ export declare const PreferAriaDisabled: (args: any) => import("react").JSX.Element;
@@ -4,14 +4,12 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
4
4
  /**
5
5
  * External dependencies
6
6
  */
7
- import React from 'react';
8
7
  import { BiCalendarHeart } from 'react-icons/bi';
9
8
 
10
9
  /**
11
10
  * Internal dependencies
12
11
  */
13
- import { Button, ButtonVariant } from '..';
14
- import { Flex } from '../Flex/Flex';
12
+ import { Button, ButtonVariant, Table, TableCell, TableRow } from '..';
15
13
  import ScreenReaderText from '../ScreenReaderText';
16
14
  import { jsx as _jsx } from "theme-ui/jsx-runtime";
17
15
  import { jsxs as _jsxs } from "theme-ui/jsx-runtime";
@@ -25,6 +23,11 @@ export default {
25
23
  type: 'boolean'
26
24
  }
27
25
  },
26
+ danger: {
27
+ control: {
28
+ type: 'boolean'
29
+ }
30
+ },
28
31
  variant: {
29
32
  type: 'select',
30
33
  options: Object.values(ButtonVariant)
@@ -40,78 +43,127 @@ export default {
40
43
  };
41
44
  var Template = function Template(args) {
42
45
  return _jsxs("div", {
43
- children: [_jsxs(Flex, {
44
- sx: {
45
- gap: 2,
46
- flexDirection: 'row'
47
- },
48
- children: [_jsx(Button, _extends({}, args, {
49
- children: "Primary"
50
- })), _jsx(Button, _extends({
51
- variant: "secondary",
52
- sx: {
53
- ml: 2
54
- }
55
- }, args, {
56
- children: "Secondary"
57
- })), _jsx(Button, _extends({
58
- variant: "tertiary",
59
- sx: {
60
- ml: 2
61
- }
62
- }, args, {
63
- children: "Tertiary"
64
- })), _jsx(Button, _extends({
65
- variant: "ghost",
66
- sx: {
67
- ml: 2
68
- }
69
- }, args, {
70
- children: "Ghost"
71
- })), _jsx(Button, _extends({
72
- variant: "display",
73
- sx: {
74
- ml: 2
75
- }
76
- }, args, {
77
- children: "Display"
78
- })), _jsx(Button, _extends({
79
- variant: "danger",
80
- sx: {
81
- ml: 2
82
- }
83
- }, args, {
84
- children: "Danger"
85
- })), _jsx(Button, _extends({
86
- variant: "primary",
87
- disabled: true,
88
- sx: {
89
- ml: 2
90
- }
91
- }, args, {
92
- children: "Disabled"
93
- })), _jsx(Button, _extends({
94
- variant: "text",
95
- sx: {
96
- ml: 2
97
- },
98
- as: "a",
99
- href: "https://google/com"
100
- }, args, {
101
- children: "Button link"
102
- })), _jsxs(Button, _extends({
103
- variant: "icon",
104
- sx: {
105
- ml: 2
106
- },
107
- type: "button"
108
- }, args, {
109
- children: [_jsx(BiCalendarHeart, {
110
- size: 24
111
- }), _jsx(ScreenReaderText, {
112
- children: "domain.com"
46
+ children: [_jsx("h3", {
47
+ children: "Default"
48
+ }), _jsxs(Table, {
49
+ children: [_jsxs(TableRow, {
50
+ children: [_jsx(TableCell, {
51
+ head: true,
52
+ children: "Variant"
53
+ }), _jsx(TableCell, {
54
+ head: true,
55
+ children: "Primary"
56
+ }), _jsx(TableCell, {
57
+ head: true,
58
+ children: "Secondary"
59
+ }), _jsx(TableCell, {
60
+ head: true,
61
+ children: "Tertiary"
62
+ }), _jsx(TableCell, {
63
+ head: true,
64
+ children: "Ghost"
65
+ }), _jsx(TableCell, {
66
+ head: true,
67
+ children: "Display"
68
+ }), _jsx(TableCell, {
69
+ head: true,
70
+ children: "Icon"
113
71
  })]
114
- }))]
72
+ }), _jsxs(TableRow, {
73
+ children: [_jsx(TableCell, {
74
+ children: "Default"
75
+ }), _jsx(TableCell, {
76
+ children: _jsx(Button, _extends({}, args, {
77
+ children: "Primary"
78
+ }))
79
+ }), _jsx(TableCell, {
80
+ children: _jsx(Button, _extends({
81
+ variant: "secondary"
82
+ }, args, {
83
+ children: "Secondary"
84
+ }))
85
+ }), _jsx(TableCell, {
86
+ children: _jsx(Button, _extends({
87
+ variant: "tertiary"
88
+ }, args, {
89
+ children: "Tertiary"
90
+ }))
91
+ }), _jsx(TableCell, {
92
+ children: _jsx(Button, _extends({
93
+ variant: "ghost"
94
+ }, args, {
95
+ children: "Ghost"
96
+ }))
97
+ }), _jsx(TableCell, {
98
+ children: _jsx(Button, _extends({
99
+ variant: "display"
100
+ }, args, {
101
+ children: "Display"
102
+ }))
103
+ }), _jsx(TableCell, {
104
+ children: _jsxs(Button, _extends({
105
+ variant: "icon",
106
+ type: "button"
107
+ }, args, {
108
+ children: [_jsx(BiCalendarHeart, {
109
+ size: 24
110
+ }), _jsx(ScreenReaderText, {
111
+ children: "domain.com"
112
+ })]
113
+ }))
114
+ })]
115
+ }), _jsxs(TableRow, {
116
+ children: [_jsx(TableCell, {
117
+ children: "Disabled"
118
+ }), _jsx(TableCell, {
119
+ children: _jsx(Button, _extends({
120
+ variant: "primary",
121
+ disabled: true
122
+ }, args, {
123
+ children: "Primary"
124
+ }))
125
+ }), _jsx(TableCell, {
126
+ children: _jsx(Button, _extends({
127
+ variant: "secondary",
128
+ disabled: true
129
+ }, args, {
130
+ children: "Secondary"
131
+ }))
132
+ }), _jsx(TableCell, {
133
+ children: _jsx(Button, _extends({
134
+ variant: "tertiary",
135
+ disabled: true
136
+ }, args, {
137
+ children: "Tertiary"
138
+ }))
139
+ }), _jsx(TableCell, {
140
+ children: _jsx(Button, _extends({
141
+ variant: "ghost",
142
+ disabled: true
143
+ }, args, {
144
+ children: "Ghost"
145
+ }))
146
+ }), _jsx(TableCell, {
147
+ children: _jsx(Button, _extends({
148
+ variant: "display",
149
+ disabled: true
150
+ }, args, {
151
+ children: "Display"
152
+ }))
153
+ }), _jsx(TableCell, {
154
+ children: _jsxs(Button, _extends({
155
+ variant: "icon",
156
+ type: "button",
157
+ disabled: true
158
+ }, args, {
159
+ children: [_jsx(BiCalendarHeart, {
160
+ size: 24
161
+ }), _jsx(ScreenReaderText, {
162
+ children: "domain.com"
163
+ })]
164
+ }))
165
+ })]
166
+ })]
115
167
  }), _jsx("div", {
116
168
  sx: {
117
169
  mt: 3
@@ -135,6 +187,75 @@ var Template = function Template(args) {
135
187
  grow: true,
136
188
  children: "Button with grow width"
137
189
  }))
190
+ }), _jsx("h3", {
191
+ children: "Danger"
192
+ }), _jsxs(Table, {
193
+ children: [_jsxs(TableRow, {
194
+ children: [_jsx(TableCell, {
195
+ head: true,
196
+ children: "Variant"
197
+ }), _jsx(TableCell, {
198
+ head: true,
199
+ children: "Primary"
200
+ }), _jsx(TableCell, {
201
+ head: true,
202
+ children: "Secondary"
203
+ }), _jsx(TableCell, {
204
+ head: true,
205
+ children: "Ghost"
206
+ })]
207
+ }), _jsxs(TableRow, {
208
+ children: [_jsx(TableCell, {
209
+ children: "Default"
210
+ }), _jsx(TableCell, {
211
+ children: _jsx(Button, _extends({
212
+ danger: true
213
+ }, args, {
214
+ children: "Primary"
215
+ }))
216
+ }), _jsx(TableCell, {
217
+ children: _jsx(Button, _extends({
218
+ danger: true,
219
+ variant: "secondary"
220
+ }, args, {
221
+ children: "Secondary"
222
+ }))
223
+ }), _jsx(TableCell, {
224
+ children: _jsx(Button, _extends({
225
+ danger: true,
226
+ variant: "ghost"
227
+ }, args, {
228
+ children: "Ghost"
229
+ }))
230
+ })]
231
+ }), _jsxs(TableRow, {
232
+ children: [_jsx(TableCell, {
233
+ children: "Disabled"
234
+ }), _jsx(TableCell, {
235
+ children: _jsx(Button, _extends({
236
+ variant: "primary",
237
+ danger: true,
238
+ disabled: true
239
+ }, args, {
240
+ children: "Primary"
241
+ }))
242
+ }), _jsx(TableCell, {
243
+ children: _jsx(Button, _extends({
244
+ variant: "secondary",
245
+ danger: true,
246
+ disabled: true
247
+ }, args, {
248
+ children: "Secondary"
249
+ }))
250
+ }), _jsx(TableCell, {
251
+ children: _jsx(Button, _extends({
252
+ variant: "ghost",
253
+ disabled: true
254
+ }, args, {
255
+ children: "Ghost"
256
+ }))
257
+ })]
258
+ })]
138
259
  })]
139
260
  });
140
261
  };
@@ -51,6 +51,7 @@ export var Wizard = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef) {
51
51
  onChange = _ref2.onChange,
52
52
  actionLabel = _ref2.actionLabel,
53
53
  actionIcon = _ref2.actionIcon,
54
+ actionDisabled = _ref2.actionDisabled,
54
55
  summaryTitle = _ref2.summaryTitle;
55
56
  return _jsx(WizardStep, {
56
57
  active: index === activeStep,
@@ -69,6 +70,7 @@ export var Wizard = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef) {
69
70
  showStepText: showStepText,
70
71
  summaryAs: summaryAs,
71
72
  summaryTitle: summaryTitle,
73
+ actionDisabled: actionDisabled,
72
74
  children: children
73
75
  }, index);
74
76
  })
@@ -36,7 +36,8 @@ export var Default = function Default() {
36
36
  })
37
37
  }, {
38
38
  title: 'Configure DNS',
39
- titleVariant: 'h2'
39
+ titleVariant: 'h2',
40
+ summaryTitle: 'Summary of Configure DNS'
40
41
  }, {
41
42
  title: 'Configure Certificate',
42
43
  titleVariant: 'h2'
@@ -51,6 +52,7 @@ export var Default = function Default() {
51
52
  activeStep: 0,
52
53
  steps: steps,
53
54
  completed: [1],
55
+ summaryAs: "dl",
54
56
  className: "vip-wizard-xyz"
55
57
  })
56
58
  })
@@ -95,6 +97,7 @@ export var WithTitleAutoFocus = function WithTitleAutoFocus() {
95
97
  return setActiveStep(1);
96
98
  },
97
99
  actionLabel: 'Edit',
100
+ actionDisabled: true,
98
101
  actionIcon: _jsx(BsPencil, {}),
99
102
  children: _jsxs(Box, {
100
103
  children: [_jsx(Label, {
@@ -24,7 +24,8 @@ export interface WizardStepProps {
24
24
  summaryAs?: 'table' | 'dl';
25
25
  shouldFocusTitle?: boolean;
26
26
  actionLabel?: string;
27
- showStepText?: boolean;
28
27
  actionIcon?: React.ReactNode;
28
+ actionDisabled?: boolean;
29
+ showStepText?: boolean;
29
30
  }
30
31
  export declare const WizardStep: React.ForwardRefExoticComponent<WizardStepProps & React.RefAttributes<HTMLDivElement>>;
@@ -34,9 +34,11 @@ export var WizardStep = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef
34
34
  onChange = _ref.onChange,
35
35
  _ref$actionLabel = _ref.actionLabel,
36
36
  actionLabel = _ref$actionLabel === void 0 ? 'Change' : _ref$actionLabel,
37
+ actionIcon = _ref.actionIcon,
38
+ _ref$actionDisabled = _ref.actionDisabled,
39
+ actionDisabled = _ref$actionDisabled === void 0 ? false : _ref$actionDisabled,
37
40
  _ref$showStepText = _ref.showStepText,
38
- showStepText = _ref$showStepText === void 0 ? true : _ref$showStepText,
39
- actionIcon = _ref.actionIcon;
41
+ showStepText = _ref$showStepText === void 0 ? true : _ref$showStepText;
40
42
  var titleRef = React.useRef(null);
41
43
  var status = 'inactive';
42
44
  var statusText = 'Step not completed';
@@ -54,7 +56,7 @@ export var WizardStep = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef
54
56
  if (statusText !== '') {
55
57
  statusText = "Status: " + statusText;
56
58
  }
57
- var stepText = "Step " + order + " of " + totalSteps;
59
+ var stepText = "STEP " + order + " OF " + totalSteps;
58
60
  var borderLeftColor = "wizard.step.border." + status;
59
61
  var statusIconColor = "wizard.step.icon." + status;
60
62
  var statusIconStyles = {
@@ -76,6 +78,7 @@ export var WizardStep = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef
76
78
  backgroundColor: active ? 'background' : 'transparent',
77
79
  borderRadius: 0,
78
80
  borderBottom: active ? 'none' : '1px solid',
81
+ borderRight: active ? 'none' : '1px solid',
79
82
  '&:first-of-type': {
80
83
  borderTopWidth: '1px',
81
84
  borderTopStyle: 'solid'
@@ -133,6 +136,7 @@ export var WizardStep = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef
133
136
  })]
134
137
  }), !active && (complete || skipped) && onChange && _jsxs(Button, {
135
138
  variant: "text",
139
+ disabled: actionDisabled,
136
140
  onClick: onChange,
137
141
  sx: {
138
142
  height: 'auto',
@@ -147,9 +151,9 @@ export var WizardStep = /*#__PURE__*/React.forwardRef(function (_ref, forwardRef
147
151
  children: actionIcon
148
152
  })]
149
153
  })]
150
- }), !active && (complete || skipped) && summary && summary.length > 0 && _jsx(DescriptionList, {
154
+ }), !active && (complete || skipped) && (summary || summaryTitle) && _jsx(DescriptionList, {
151
155
  as: summaryAs,
152
- list: summary,
156
+ list: summary || [],
153
157
  title: summaryTitle
154
158
  }), subTitle && active && _jsx(Text, {
155
159
  sx: {
@@ -147,6 +147,27 @@ declare namespace _default {
147
147
  fill: string;
148
148
  };
149
149
  };
150
+ '&[data-danger="true"]': {
151
+ color: string;
152
+ bg: string;
153
+ border: string;
154
+ borderColor: string;
155
+ };
156
+ '&:hover[data-danger="true"]': {
157
+ backgroundColor: string;
158
+ color: string;
159
+ border: string;
160
+ borderColor: string;
161
+ };
162
+ '&[disabled], &[aria-disabled="true"]': {
163
+ backgroundColor: string;
164
+ color: string;
165
+ opacity: number;
166
+ };
167
+ '&[disabled][data-danger="true"], &[aria-disabled="true"][data-danger="true"]': {
168
+ backgroundColor: string;
169
+ color: string;
170
+ };
150
171
  };
151
172
  export { primary_1 as primary };
152
173
  let secondary_1: {
@@ -157,6 +178,28 @@ declare namespace _default {
157
178
  backgroundColor: string;
158
179
  color: string;
159
180
  };
181
+ '&[data-danger="true"]': {
182
+ color: string;
183
+ bg: string;
184
+ border: string;
185
+ borderColor: string;
186
+ };
187
+ '&:hover[data-danger="true"]': {
188
+ backgroundColor: string;
189
+ color: string;
190
+ border: string;
191
+ borderColor: string;
192
+ };
193
+ '&[disabled], &[aria-disabled="true"]': {
194
+ backgroundColor: string;
195
+ color: string;
196
+ };
197
+ '&[disabled][data-danger="true"], &[aria-disabled="true"][data-danger="true"]': {
198
+ backgroundColor: string;
199
+ color: string;
200
+ border: string;
201
+ borderColor: string;
202
+ };
160
203
  };
161
204
  export { secondary_1 as secondary };
162
205
  export let tertiary: {
@@ -171,6 +214,10 @@ declare namespace _default {
171
214
  border: string;
172
215
  borderColor: string;
173
216
  };
217
+ '&[disabled], &[aria-disabled="true"]': {
218
+ backgroundColor: string;
219
+ color: string;
220
+ };
174
221
  };
175
222
  let display_3: {
176
223
  variant: string;
@@ -184,6 +231,10 @@ declare namespace _default {
184
231
  border: string;
185
232
  borderColor: string;
186
233
  };
234
+ '&[disabled], &[aria-disabled="true"]': {
235
+ backgroundColor: string;
236
+ color: string;
237
+ };
187
238
  };
188
239
  export { display_3 as display };
189
240
  export let ghost: {
@@ -198,6 +249,20 @@ declare namespace _default {
198
249
  border: string;
199
250
  borderColor: string;
200
251
  };
252
+ '&[disabled], &[aria-disabled="true"]': {
253
+ backgroundColor: string;
254
+ color: string;
255
+ };
256
+ '&[data-danger="true"]': {
257
+ color: string;
258
+ bg: string;
259
+ };
260
+ '&:hover[data-danger="true"]': {
261
+ backgroundColor: string;
262
+ color: string;
263
+ border: string;
264
+ borderColor: string;
265
+ };
201
266
  };
202
267
  export let danger: {
203
268
  variant: string;
@@ -362,6 +362,30 @@ export default {
362
362
  fill: 'inherit',
363
363
  },
364
364
  },
365
+ '&[data-danger="true"]': {
366
+ color: 'button.danger.primary.label.default',
367
+ bg: 'button.danger.primary.background.default',
368
+ border: '1px solid',
369
+ borderColor: 'transparent',
370
+ },
371
+
372
+ '&:hover[data-danger="true"]': {
373
+ backgroundColor: 'button.danger.primary.background.hover',
374
+ color: 'button.danger.primary.label.hover',
375
+ border: '1px solid',
376
+ borderColor: 'transparent',
377
+ },
378
+
379
+ '&[disabled], &[aria-disabled="true"]': {
380
+ backgroundColor: 'button.primary.background.disabled',
381
+ color: 'button.primary.label.disabled',
382
+ opacity: 0.7,
383
+ },
384
+
385
+ '&[disabled][data-danger="true"], &[aria-disabled="true"][data-danger="true"]': {
386
+ backgroundColor: 'button.secondary.background.disabled',
387
+ color: 'button.secondary.label.default',
388
+ },
365
389
  },
366
390
 
367
391
  secondary: {
@@ -373,6 +397,32 @@ export default {
373
397
  backgroundColor: 'button.secondary.background.hover',
374
398
  color: 'button.secondary.label.hover',
375
399
  },
400
+
401
+ '&[data-danger="true"]': {
402
+ color: 'button.danger.secondary.label.default',
403
+ bg: 'button.danger.secondary.background.default',
404
+ border: '1px solid',
405
+ borderColor: 'button.danger.secondary.border.default',
406
+ },
407
+
408
+ '&:hover[data-danger="true"]': {
409
+ backgroundColor: 'button.danger.secondary.background.hover',
410
+ color: 'button.danger.secondary.label.hover',
411
+ border: '1px solid',
412
+ borderColor: 'transparent',
413
+ },
414
+
415
+ '&[disabled], &[aria-disabled="true"]': {
416
+ backgroundColor: 'button.secondary.background.disabled',
417
+ color: 'button.secondary.label.disabled',
418
+ },
419
+
420
+ '&[disabled][data-danger="true"], &[aria-disabled="true"][data-danger="true"]': {
421
+ backgroundColor: 'button.danger.secondary.background.default',
422
+ color: 'button.secondary.label.disabled',
423
+ border: '1px solid',
424
+ borderColor: 'button.secondary.border.default',
425
+ },
376
426
  },
377
427
 
378
428
  tertiary: {
@@ -388,6 +438,11 @@ export default {
388
438
  border: '1px solid',
389
439
  borderColor: 'button.tertiary.border.hover',
390
440
  },
441
+
442
+ '&[disabled], &[aria-disabled="true"]': {
443
+ backgroundColor: 'button.tertiary.background.default',
444
+ color: 'texts.disabled',
445
+ },
391
446
  },
392
447
 
393
448
  display: {
@@ -403,6 +458,11 @@ export default {
403
458
  border: '1px solid',
404
459
  borderColor: 'transparent',
405
460
  },
461
+
462
+ '&[disabled], &[aria-disabled="true"]': {
463
+ backgroundColor: 'button.display.background.disabled',
464
+ color: 'button.display.label.disabled',
465
+ },
406
466
  },
407
467
 
408
468
  ghost: {
@@ -418,6 +478,23 @@ export default {
418
478
  border: '1px solid',
419
479
  borderColor: 'transparent',
420
480
  },
481
+
482
+ '&[disabled], &[aria-disabled="true"]': {
483
+ backgroundColor: 'button.ghost.background.default',
484
+ color: 'texts.disabled',
485
+ },
486
+
487
+ '&[data-danger="true"]': {
488
+ color: 'button.danger.ghost.label.default',
489
+ bg: 'button.danger.ghost.background.default',
490
+ },
491
+
492
+ '&:hover[data-danger="true"]': {
493
+ backgroundColor: 'button.danger.ghost.background.hover',
494
+ color: 'button.danger.ghost.label.hover',
495
+ border: '1px solid',
496
+ borderColor: 'transparent',
497
+ },
421
498
  },
422
499
 
423
500
  danger: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "2.13.11",
3
+ "version": "2.14.0",
4
4
  "main": "build/system/index.js",
5
5
  "scripts": {
6
6
  "build-storybook": "storybook build",
@@ -3,14 +3,12 @@
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
- import React from 'react';
7
6
  import { BiCalendarHeart } from 'react-icons/bi';
8
7
 
9
8
  /**
10
9
  * Internal dependencies
11
10
  */
12
- import { Button, ButtonVariant } from '..';
13
- import { Flex } from '../Flex/Flex';
11
+ import { Button, ButtonVariant, Table, TableCell, TableRow } from '..';
14
12
  import ScreenReaderText from '../ScreenReaderText';
15
13
 
16
14
  export default {
@@ -21,6 +19,9 @@ export default {
21
19
  disabled: {
22
20
  control: { type: 'boolean' },
23
21
  },
22
+ danger: {
23
+ control: { type: 'boolean' },
24
+ },
24
25
  variant: {
25
26
  type: 'select',
26
27
  options: Object.values( ButtonVariant ),
@@ -68,42 +69,84 @@ This documentation is heavily inspired by the [U.S Web Design System (USWDS)](ht
68
69
 
69
70
  const Template = args => (
70
71
  <div>
71
- <Flex sx={ { gap: 2, flexDirection: 'row' } }>
72
- <Button { ...args }>Primary</Button>
73
-
74
- <Button variant="secondary" sx={ { ml: 2 } } { ...args }>
75
- Secondary
76
- </Button>
77
-
78
- <Button variant="tertiary" sx={ { ml: 2 } } { ...args }>
79
- Tertiary
80
- </Button>
81
-
82
- <Button variant="ghost" sx={ { ml: 2 } } { ...args }>
83
- Ghost
84
- </Button>
85
-
86
- <Button variant="display" sx={ { ml: 2 } } { ...args }>
87
- Display
88
- </Button>
89
-
90
- <Button variant="danger" sx={ { ml: 2 } } { ...args }>
91
- Danger
92
- </Button>
93
-
94
- <Button variant="primary" disabled={ true } sx={ { ml: 2 } } { ...args }>
95
- Disabled
96
- </Button>
97
-
98
- <Button variant="text" sx={ { ml: 2 } } as="a" href="https://google/com" { ...args }>
99
- Button link
100
- </Button>
101
-
102
- <Button variant="icon" sx={ { ml: 2 } } type="button" { ...args }>
103
- <BiCalendarHeart size={ 24 } />
104
- <ScreenReaderText>domain.com</ScreenReaderText>
105
- </Button>
106
- </Flex>
72
+ <h3>Default</h3>
73
+ <Table>
74
+ <TableRow>
75
+ <TableCell head>Variant</TableCell>
76
+ <TableCell head>Primary</TableCell>
77
+ <TableCell head>Secondary</TableCell>
78
+ <TableCell head>Tertiary</TableCell>
79
+ <TableCell head>Ghost</TableCell>
80
+ <TableCell head>Display</TableCell>
81
+ <TableCell head>Icon</TableCell>
82
+ </TableRow>
83
+ <TableRow>
84
+ <TableCell>Default</TableCell>
85
+ <TableCell>
86
+ <Button { ...args }>Primary</Button>
87
+ </TableCell>
88
+ <TableCell>
89
+ <Button variant="secondary" { ...args }>
90
+ Secondary
91
+ </Button>
92
+ </TableCell>
93
+ <TableCell>
94
+ <Button variant="tertiary" { ...args }>
95
+ Tertiary
96
+ </Button>
97
+ </TableCell>
98
+ <TableCell>
99
+ <Button variant="ghost" { ...args }>
100
+ Ghost
101
+ </Button>
102
+ </TableCell>
103
+ <TableCell>
104
+ <Button variant="display" { ...args }>
105
+ Display
106
+ </Button>
107
+ </TableCell>
108
+ <TableCell>
109
+ <Button variant="icon" type="button" { ...args }>
110
+ <BiCalendarHeart size={ 24 } />
111
+ <ScreenReaderText>domain.com</ScreenReaderText>
112
+ </Button>
113
+ </TableCell>
114
+ </TableRow>
115
+ <TableRow>
116
+ <TableCell>Disabled</TableCell>
117
+ <TableCell>
118
+ <Button variant="primary" disabled { ...args }>
119
+ Primary
120
+ </Button>
121
+ </TableCell>
122
+ <TableCell>
123
+ <Button variant="secondary" disabled={ true } { ...args }>
124
+ Secondary
125
+ </Button>
126
+ </TableCell>
127
+ <TableCell>
128
+ <Button variant="tertiary" disabled { ...args }>
129
+ Tertiary
130
+ </Button>
131
+ </TableCell>
132
+ <TableCell>
133
+ <Button variant="ghost" disabled { ...args }>
134
+ Ghost
135
+ </Button>
136
+ </TableCell>
137
+ <TableCell>
138
+ <Button variant="display" disabled { ...args }>
139
+ Display
140
+ </Button>
141
+ </TableCell>
142
+ <TableCell>
143
+ <Button variant="icon" type="button" disabled { ...args }>
144
+ <BiCalendarHeart size={ 24 } />
145
+ <ScreenReaderText>domain.com</ScreenReaderText>
146
+ </Button>
147
+ </TableCell>
148
+ </TableRow>
149
+ </Table>
107
150
 
108
151
  <div sx={ { mt: 3 } }>
109
152
  <Button variant="secondary" href="https://google/com" { ...args } full>
@@ -116,6 +159,52 @@ const Template = args => (
116
159
  Button with grow width
117
160
  </Button>
118
161
  </div>
162
+
163
+ <h3>Danger</h3>
164
+ <Table>
165
+ <TableRow>
166
+ <TableCell head>Variant</TableCell>
167
+ <TableCell head>Primary</TableCell>
168
+ <TableCell head>Secondary</TableCell>
169
+ <TableCell head>Ghost</TableCell>
170
+ </TableRow>
171
+ <TableRow>
172
+ <TableCell>Default</TableCell>
173
+ <TableCell>
174
+ <Button danger { ...args }>
175
+ Primary
176
+ </Button>
177
+ </TableCell>
178
+ <TableCell>
179
+ <Button danger variant="secondary" { ...args }>
180
+ Secondary
181
+ </Button>
182
+ </TableCell>
183
+ <TableCell>
184
+ <Button danger variant="ghost" { ...args }>
185
+ Ghost
186
+ </Button>
187
+ </TableCell>
188
+ </TableRow>
189
+ <TableRow>
190
+ <TableCell>Disabled</TableCell>
191
+ <TableCell>
192
+ <Button variant="primary" danger disabled { ...args }>
193
+ Primary
194
+ </Button>
195
+ </TableCell>
196
+ <TableCell>
197
+ <Button variant="secondary" danger disabled { ...args }>
198
+ Secondary
199
+ </Button>
200
+ </TableCell>
201
+ <TableCell>
202
+ <Button variant="ghost" disabled { ...args }>
203
+ Ghost
204
+ </Button>
205
+ </TableCell>
206
+ </TableRow>
207
+ </Table>
119
208
  </div>
120
209
  );
121
210
 
@@ -9,7 +9,7 @@ interface ButtonTheme extends Theme {
9
9
  }
10
10
 
11
11
  export enum ButtonVariant {
12
- 'danger',
12
+ 'danger', // will be deprecated in the future
13
13
  'display',
14
14
  'ghost',
15
15
  'icon',
@@ -26,12 +26,28 @@ export interface ButtonProps extends ThemeButtonProps {
26
26
  full?: boolean;
27
27
  grow?: boolean;
28
28
  variant?: keyof typeof ButtonVariant; // converts the enum to a string union type
29
+ danger?: boolean;
29
30
  }
30
31
 
31
32
  const Button = forwardRef< HTMLButtonElement, ButtonProps >(
32
- ( { className, disabled, preferAriaDisabled, onClick, sx, full, grow, ...rest }, ref ) => {
33
+ (
34
+ {
35
+ className,
36
+ disabled,
37
+ preferAriaDisabled,
38
+ onClick,
39
+ sx,
40
+ full,
41
+ grow,
42
+ variant = 'primary',
43
+ danger = variant === 'danger', // fallback for danger variant used before the prop was added
44
+ ...rest
45
+ },
46
+ ref
47
+ ) => {
33
48
  const disabledAttributes =
34
49
  disabled && preferAriaDisabled === true ? { 'aria-disabled': true } : { disabled };
50
+ let disabledStyles = {};
35
51
 
36
52
  const handleOnClick = useCallback(
37
53
  ( event: ButtonClickType ) => {
@@ -46,17 +62,29 @@ const Button = forwardRef< HTMLButtonElement, ButtonProps >(
46
62
  [ disabled, onClick ]
47
63
  );
48
64
 
65
+ if (
66
+ disabled &&
67
+ ! danger &&
68
+ variant !== 'text' &&
69
+ variant !== 'ghost' &&
70
+ variant !== 'tertiary'
71
+ ) {
72
+ disabledStyles = {
73
+ opacity: 0.7,
74
+ backgroundColor: 'input.border.disabled',
75
+ color: 'texts.secondary',
76
+ };
77
+ }
78
+
49
79
  return (
50
80
  <ThemeButton
51
81
  sx={ {
52
82
  '&:focus': 'none',
53
83
  '&:focus-visible': ( theme: ButtonTheme ) => theme.outline,
54
84
  '&[disabled], &[aria-disabled="true"]': {
55
- opacity: 0.7,
56
- backgroundColor: 'input.border.disabled',
57
- color: 'texts.secondary',
58
85
  cursor: 'not-allowed',
59
86
  pointerEvents: 'none',
87
+ ...disabledStyles,
60
88
  },
61
89
  '&:hover, &:focus': {
62
90
  textDecoration: 'none',
@@ -67,8 +95,10 @@ const Button = forwardRef< HTMLButtonElement, ButtonProps >(
67
95
  } }
68
96
  { ...rest }
69
97
  { ...disabledAttributes }
98
+ variant={ variant }
70
99
  onClick={ handleOnClick }
71
100
  className={ classNames( 'vip-button-component', className ) }
101
+ data-danger={ danger }
72
102
  ref={ ref }
73
103
  />
74
104
  );
@@ -34,6 +34,7 @@ export const Default = () => {
34
34
  {
35
35
  title: 'Configure DNS',
36
36
  titleVariant: 'h2',
37
+ summaryTitle: 'Summary of Configure DNS',
37
38
  },
38
39
  {
39
40
  title: 'Configure Certificate',
@@ -47,7 +48,13 @@ export const Default = () => {
47
48
  return (
48
49
  <React.Fragment>
49
50
  <Box mt={ 4 }>
50
- <Wizard activeStep={ 0 } steps={ steps } completed={ [ 1 ] } className="vip-wizard-xyz" />
51
+ <Wizard
52
+ activeStep={ 0 }
53
+ steps={ steps }
54
+ completed={ [ 1 ] }
55
+ summaryAs="dl"
56
+ className="vip-wizard-xyz"
57
+ />
51
58
  </Box>
52
59
  </React.Fragment>
53
60
  );
@@ -82,6 +89,7 @@ export const WithTitleAutoFocus = () => {
82
89
  titleVariant: 'h2',
83
90
  onChange: () => setActiveStep( 1 ),
84
91
  actionLabel: 'Edit',
92
+ actionDisabled: true,
85
93
  actionIcon: <BsPencil />,
86
94
  children: (
87
95
  <Box>
@@ -58,6 +58,7 @@ export const Wizard = React.forwardRef< HTMLDivElement, WizardProps >(
58
58
  onChange,
59
59
  actionLabel,
60
60
  actionIcon,
61
+ actionDisabled,
61
62
  summaryTitle,
62
63
  },
63
64
  index
@@ -80,6 +81,7 @@ export const Wizard = React.forwardRef< HTMLDivElement, WizardProps >(
80
81
  showStepText={ showStepText }
81
82
  summaryAs={ summaryAs }
82
83
  summaryTitle={ summaryTitle }
84
+ actionDisabled={ actionDisabled }
83
85
  >
84
86
  { children }
85
87
  </WizardStep>
@@ -33,8 +33,9 @@ export interface WizardStepProps {
33
33
  summaryAs?: 'table' | 'dl';
34
34
  shouldFocusTitle?: boolean;
35
35
  actionLabel?: string;
36
- showStepText?: boolean;
37
36
  actionIcon?: React.ReactNode;
37
+ actionDisabled?: boolean;
38
+ showStepText?: boolean;
38
39
  }
39
40
 
40
41
  export const WizardStep = React.forwardRef< HTMLDivElement, WizardStepProps >(
@@ -55,8 +56,9 @@ export const WizardStep = React.forwardRef< HTMLDivElement, WizardStepProps >(
55
56
  summaryAs = 'table',
56
57
  onChange,
57
58
  actionLabel = 'Change',
58
- showStepText = true,
59
59
  actionIcon,
60
+ actionDisabled = false,
61
+ showStepText = true,
60
62
  },
61
63
  forwardRef
62
64
  ) => {
@@ -77,7 +79,7 @@ export const WizardStep = React.forwardRef< HTMLDivElement, WizardStepProps >(
77
79
  if ( statusText !== '' ) {
78
80
  statusText = `Status: ${ statusText }`;
79
81
  }
80
- const stepText = `Step ${ order } of ${ totalSteps }`;
82
+ const stepText = `STEP ${ order } OF ${ totalSteps }`;
81
83
 
82
84
  const borderLeftColor = `wizard.step.border.${ status }`;
83
85
  const statusIconColor = `wizard.step.icon.${ status }`;
@@ -102,6 +104,7 @@ export const WizardStep = React.forwardRef< HTMLDivElement, WizardStepProps >(
102
104
  backgroundColor: active ? 'background' : 'transparent',
103
105
  borderRadius: 0,
104
106
  borderBottom: active ? 'none' : '1px solid',
107
+ borderRight: active ? 'none' : '1px solid',
105
108
  '&:first-of-type': {
106
109
  borderTopWidth: '1px',
107
110
  borderTopStyle: 'solid',
@@ -156,6 +159,7 @@ export const WizardStep = React.forwardRef< HTMLDivElement, WizardStepProps >(
156
159
  { ! active && ( complete || skipped ) && onChange && (
157
160
  <Button
158
161
  variant="text"
162
+ disabled={ actionDisabled }
159
163
  onClick={ onChange }
160
164
  sx={ { height: 'auto', alignSelf: 'flex-end' } }
161
165
  >
@@ -165,8 +169,8 @@ export const WizardStep = React.forwardRef< HTMLDivElement, WizardStepProps >(
165
169
  </Button>
166
170
  ) }
167
171
  </Flex>
168
- { ! active && ( complete || skipped ) && summary && summary.length > 0 && (
169
- <DescriptionList as={ summaryAs } list={ summary } title={ summaryTitle } />
172
+ { ! active && ( complete || skipped ) && ( summary || summaryTitle ) && (
173
+ <DescriptionList as={ summaryAs } list={ summary || [] } title={ summaryTitle } />
170
174
  ) }
171
175
 
172
176
  { subTitle && active && <Text sx={ { mb: 3, mt: 2 } }>{ subTitle }</Text> }
@@ -362,6 +362,30 @@ export default {
362
362
  fill: 'inherit',
363
363
  },
364
364
  },
365
+ '&[data-danger="true"]': {
366
+ color: 'button.danger.primary.label.default',
367
+ bg: 'button.danger.primary.background.default',
368
+ border: '1px solid',
369
+ borderColor: 'transparent',
370
+ },
371
+
372
+ '&:hover[data-danger="true"]': {
373
+ backgroundColor: 'button.danger.primary.background.hover',
374
+ color: 'button.danger.primary.label.hover',
375
+ border: '1px solid',
376
+ borderColor: 'transparent',
377
+ },
378
+
379
+ '&[disabled], &[aria-disabled="true"]': {
380
+ backgroundColor: 'button.primary.background.disabled',
381
+ color: 'button.primary.label.disabled',
382
+ opacity: 0.7,
383
+ },
384
+
385
+ '&[disabled][data-danger="true"], &[aria-disabled="true"][data-danger="true"]': {
386
+ backgroundColor: 'button.secondary.background.disabled',
387
+ color: 'button.secondary.label.default',
388
+ },
365
389
  },
366
390
 
367
391
  secondary: {
@@ -373,6 +397,32 @@ export default {
373
397
  backgroundColor: 'button.secondary.background.hover',
374
398
  color: 'button.secondary.label.hover',
375
399
  },
400
+
401
+ '&[data-danger="true"]': {
402
+ color: 'button.danger.secondary.label.default',
403
+ bg: 'button.danger.secondary.background.default',
404
+ border: '1px solid',
405
+ borderColor: 'button.danger.secondary.border.default',
406
+ },
407
+
408
+ '&:hover[data-danger="true"]': {
409
+ backgroundColor: 'button.danger.secondary.background.hover',
410
+ color: 'button.danger.secondary.label.hover',
411
+ border: '1px solid',
412
+ borderColor: 'transparent',
413
+ },
414
+
415
+ '&[disabled], &[aria-disabled="true"]': {
416
+ backgroundColor: 'button.secondary.background.disabled',
417
+ color: 'button.secondary.label.disabled',
418
+ },
419
+
420
+ '&[disabled][data-danger="true"], &[aria-disabled="true"][data-danger="true"]': {
421
+ backgroundColor: 'button.danger.secondary.background.default',
422
+ color: 'button.secondary.label.disabled',
423
+ border: '1px solid',
424
+ borderColor: 'button.secondary.border.default',
425
+ },
376
426
  },
377
427
 
378
428
  tertiary: {
@@ -388,6 +438,11 @@ export default {
388
438
  border: '1px solid',
389
439
  borderColor: 'button.tertiary.border.hover',
390
440
  },
441
+
442
+ '&[disabled], &[aria-disabled="true"]': {
443
+ backgroundColor: 'button.tertiary.background.default',
444
+ color: 'texts.disabled',
445
+ },
391
446
  },
392
447
 
393
448
  display: {
@@ -403,6 +458,11 @@ export default {
403
458
  border: '1px solid',
404
459
  borderColor: 'transparent',
405
460
  },
461
+
462
+ '&[disabled], &[aria-disabled="true"]': {
463
+ backgroundColor: 'button.display.background.disabled',
464
+ color: 'button.display.label.disabled',
465
+ },
406
466
  },
407
467
 
408
468
  ghost: {
@@ -418,6 +478,23 @@ export default {
418
478
  border: '1px solid',
419
479
  borderColor: 'transparent',
420
480
  },
481
+
482
+ '&[disabled], &[aria-disabled="true"]': {
483
+ backgroundColor: 'button.ghost.background.default',
484
+ color: 'texts.disabled',
485
+ },
486
+
487
+ '&[data-danger="true"]': {
488
+ color: 'button.danger.ghost.label.default',
489
+ bg: 'button.danger.ghost.background.default',
490
+ },
491
+
492
+ '&:hover[data-danger="true"]': {
493
+ backgroundColor: 'button.danger.ghost.background.hover',
494
+ color: 'button.danger.ghost.label.hover',
495
+ border: '1px solid',
496
+ borderColor: 'transparent',
497
+ },
421
498
  },
422
499
 
423
500
  danger: {