newspack-components 4.9.2 → 4.10.0-alpha.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.
Files changed (103) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/DEVELOPMENT.md +13 -14
  3. package/dist/cjs/_mixins.scss +0 -2
  4. package/dist/cjs/card/core-card.js +6 -3
  5. package/dist/cjs/card/core-card.test.js +76 -5
  6. package/dist/cjs/card/style-core.scss +12 -3
  7. package/dist/cjs/card/style.scss +4 -7
  8. package/dist/cjs/card-feature/index.js +2 -1
  9. package/dist/cjs/card-feature/index.test.js +13 -0
  10. package/dist/cjs/card-feature/style.scss +5 -0
  11. package/dist/cjs/color-picker/index.js +26 -15
  12. package/dist/cjs/color-picker/index.test.js +47 -0
  13. package/dist/cjs/color-picker/style.scss +13 -10
  14. package/dist/cjs/debug-badge/style.scss +1 -1
  15. package/dist/cjs/divider/index.js +2 -2
  16. package/dist/cjs/divider/style.scss +7 -5
  17. package/dist/cjs/grid/style.scss +4 -16
  18. package/dist/cjs/image-upload/index.js +9 -3
  19. package/dist/cjs/image-upload/style.scss +3 -0
  20. package/dist/cjs/index.js +0 -7
  21. package/dist/cjs/info-button/style.scss +1 -1
  22. package/dist/cjs/modal/style.scss +7 -8
  23. package/dist/cjs/page/style.scss +2 -4
  24. package/dist/cjs/plugin-settings/style.scss +1 -1
  25. package/dist/cjs/section-header/index.js +5 -2
  26. package/dist/cjs/section-header/style.scss +3 -3
  27. package/dist/cjs/settings/style.scss +1 -1
  28. package/dist/cjs/style-card/index.js +5 -6
  29. package/dist/cjs/style-card/style.scss +6 -10
  30. package/dist/cjs/style.scss +3 -2
  31. package/dist/cjs/tabbed-navigation/style.scss +0 -1
  32. package/dist/cjs/with-wizard-screen/style.scss +3 -2
  33. package/dist/cjs/wizard/index.js +2 -0
  34. package/dist/esm/_mixins.scss +0 -2
  35. package/dist/esm/card/core-card.js +6 -3
  36. package/dist/esm/card/core-card.test.js +76 -1
  37. package/dist/esm/card/style-core.scss +12 -3
  38. package/dist/esm/card/style.scss +4 -7
  39. package/dist/esm/card-feature/index.js +2 -1
  40. package/dist/esm/card-feature/index.test.js +13 -0
  41. package/dist/esm/card-feature/style.scss +5 -0
  42. package/dist/esm/color-picker/index.js +25 -8
  43. package/dist/esm/color-picker/index.test.js +47 -0
  44. package/dist/esm/color-picker/style.scss +13 -10
  45. package/dist/esm/debug-badge/style.scss +1 -1
  46. package/dist/esm/divider/index.js +2 -2
  47. package/dist/esm/divider/style.scss +7 -5
  48. package/dist/esm/grid/style.scss +4 -16
  49. package/dist/esm/image-upload/index.js +9 -3
  50. package/dist/esm/image-upload/style.scss +3 -0
  51. package/dist/esm/index.js +0 -1
  52. package/dist/esm/info-button/style.scss +1 -1
  53. package/dist/esm/modal/style.scss +7 -8
  54. package/dist/esm/page/style.scss +2 -4
  55. package/dist/esm/plugin-settings/style.scss +1 -1
  56. package/dist/esm/section-header/index.js +5 -2
  57. package/dist/esm/section-header/style.scss +3 -3
  58. package/dist/esm/settings/style.scss +1 -1
  59. package/dist/esm/style-card/index.js +6 -7
  60. package/dist/esm/style-card/style.scss +6 -10
  61. package/dist/esm/style.scss +3 -2
  62. package/dist/esm/tabbed-navigation/style.scss +0 -1
  63. package/dist/esm/with-wizard-screen/style.scss +3 -2
  64. package/dist/esm/wizard/index.js +2 -0
  65. package/package.json +7 -7
  66. package/src/_mixins.scss +0 -2
  67. package/src/card/core-card.js +5 -1
  68. package/src/card/core-card.test.js +28 -1
  69. package/src/card/style-core.scss +12 -3
  70. package/src/card/style.scss +4 -7
  71. package/src/card-feature/index.test.js +7 -0
  72. package/src/card-feature/index.tsx +1 -0
  73. package/src/card-feature/style.scss +5 -0
  74. package/src/color-picker/index.js +20 -6
  75. package/src/color-picker/index.test.js +25 -0
  76. package/src/color-picker/style.scss +13 -10
  77. package/src/debug-badge/style.scss +1 -1
  78. package/src/divider/README.md +2 -2
  79. package/src/divider/index.js +1 -1
  80. package/src/divider/style.scss +7 -5
  81. package/src/grid/style.scss +4 -16
  82. package/src/image-upload/index.js +7 -3
  83. package/src/image-upload/style.scss +3 -0
  84. package/src/index.js +0 -1
  85. package/src/info-button/style.scss +1 -1
  86. package/src/modal/style.scss +7 -8
  87. package/src/page/style.scss +2 -4
  88. package/src/plugin-settings/style.scss +1 -1
  89. package/src/section-header/index.js +4 -1
  90. package/src/section-header/style.scss +3 -3
  91. package/src/settings/style.scss +1 -1
  92. package/src/style-card/index.js +5 -6
  93. package/src/style-card/style.scss +6 -10
  94. package/src/style.scss +3 -2
  95. package/src/tabbed-navigation/style.scss +0 -1
  96. package/src/with-wizard-screen/style.scss +3 -2
  97. package/src/wizard/index.js +2 -0
  98. package/dist/cjs/box-contrast/index.js +0 -53
  99. package/dist/cjs/utils/color.js +0 -35
  100. package/dist/esm/box-contrast/index.js +0 -48
  101. package/dist/esm/utils/color.js +0 -29
  102. package/src/box-contrast/index.tsx +0 -44
  103. package/src/utils/color.ts +0 -32
@@ -3,21 +3,23 @@
3
3
  */
4
4
 
5
5
  @use "~@wordpress/base-styles/colors" as wp-colors;
6
+ @use "~@wordpress/base-styles/mixins" as wp-mixins;
7
+ @use "~@wordpress/base-styles/variables" as wp-vars;
6
8
 
7
9
  .newspack-divider {
8
10
  background: transparent;
9
11
  border: 0;
10
12
  display: block;
11
13
  height: 1px;
12
- margin-bottom: min(32px, var(--divider-margin-bottom, 64px));
14
+ margin-bottom: min(#{wp-vars.$grid-unit-40}, var(--divider-margin-bottom, #{wp-vars.$grid-unit-60}));
13
15
  margin-left: 0;
14
16
  margin-right: 0;
15
- margin-top: min(32px, var(--divider-margin-top, 64px));
17
+ margin-top: min(#{wp-vars.$grid-unit-40}, var(--divider-margin-top, #{wp-vars.$grid-unit-60}));
16
18
  padding: 0;
17
19
 
18
- @media screen and (min-width: 783px) {
19
- margin-bottom: var(--divider-margin-bottom, 64px);
20
- margin-top: var(--divider-margin-top, 64px);
20
+ @include wp-mixins.break-medium {
21
+ margin-bottom: var(--divider-margin-bottom, #{wp-vars.$grid-unit-60});
22
+ margin-top: var(--divider-margin-top, #{wp-vars.$grid-unit-60});
21
23
  }
22
24
 
23
25
  // Alignment
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  @use "~@wordpress/base-styles/colors" as wp-colors;
6
+ @use "~@wordpress/base-styles/variables" as wp-vars;
6
7
 
7
8
  .newspack-grid {
8
9
  display: grid;
@@ -41,9 +42,9 @@
41
42
  grid-gap: 32px;
42
43
  }
43
44
 
44
- // Gutter 64
45
- &__gutter-64 {
46
- grid-gap: 64px;
45
+ // Gutter 48
46
+ &__gutter-48 {
47
+ grid-gap: wp-vars.$grid-unit-60;
47
48
  }
48
49
 
49
50
  // Row Gap 0
@@ -143,16 +144,6 @@
143
144
  &__columns-12 {
144
145
  grid-template-columns: repeat(12, 1fr);
145
146
  }
146
-
147
- // Gutter 48
148
- &__gutter-48 {
149
- grid-gap: 48px;
150
- }
151
-
152
- // Gutter 64
153
- &__gutter-64 {
154
- grid-gap: 64px;
155
- }
156
147
  }
157
148
 
158
149
  // Children
@@ -194,9 +185,6 @@
194
185
  &.newspack-grid__gutter-32 > * {
195
186
  padding: 32px;
196
187
  }
197
- &.newspack-grid__gutter-64 > * {
198
- padding: 64px;
199
- }
200
188
  }
201
189
 
202
190
  .components-base-control {
@@ -78,11 +78,14 @@ var ImageUpload = /*#__PURE__*/function (_Component) {
78
78
  disabled = _this$props.disabled,
79
79
  help = _this$props.help,
80
80
  image = _this$props.image,
81
+ imageStyle = _this$props.imageStyle,
81
82
  isCovering = _this$props.isCovering,
82
83
  label = _this$props.label,
83
84
  onChange = _this$props.onChange,
84
85
  _this$props$style = _this$props.style,
85
- style = _this$props$style === void 0 ? {} : _this$props$style;
86
+ style = _this$props$style === void 0 ? {} : _this$props$style,
87
+ _this$props$withMargi = _this$props.withMargin,
88
+ withMargin = _this$props$withMargi === void 0 ? true : _this$props$withMargi;
86
89
  var classes = (0, _classnames["default"])('newspack-image-upload__image', {
87
90
  'newspack-image-upload__image--has-image': image
88
91
  }, {
@@ -90,7 +93,9 @@ var ImageUpload = /*#__PURE__*/function (_Component) {
90
93
  });
91
94
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.BaseControl, {
92
95
  __nextHasNoMarginBottom: true,
93
- className: (0, _classnames["default"])('newspack-image-upload', className),
96
+ className: (0, _classnames["default"])('newspack-image-upload', {
97
+ 'newspack-image-upload--no-margin': !withMargin
98
+ }, className),
94
99
  help: help,
95
100
  children: [label && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BaseControl.VisualLabel, {
96
101
  children: label
@@ -101,7 +106,8 @@ var ImageUpload = /*#__PURE__*/function (_Component) {
101
106
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
102
107
  "data-testid": "image-upload",
103
108
  src: image.url,
104
- alt: (0, _i18n.__)('Image preview', 'newspack-plugin')
109
+ alt: (0, _i18n.__)('Image preview', 'newspack-plugin'),
110
+ style: imageStyle
105
111
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
106
112
  className: "newspack-image-upload__controls",
107
113
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
@@ -7,6 +7,9 @@
7
7
 
8
8
  .newspack-image-upload {
9
9
  margin: wp-vars.$grid-unit-40 0;
10
+ &--no-margin {
11
+ margin: 0;
12
+ }
10
13
  &__image {
11
14
  align-items: center;
12
15
  background-position: center;
package/dist/cjs/index.js CHANGED
@@ -28,12 +28,6 @@ Object.defineProperty(exports, "AutocompleteWithSuggestions", {
28
28
  return _autocompleteWithSuggestions["default"];
29
29
  }
30
30
  });
31
- Object.defineProperty(exports, "BoxContrast", {
32
- enumerable: true,
33
- get: function get() {
34
- return _boxContrast["default"];
35
- }
36
- });
37
31
  Object.defineProperty(exports, "Breadcrumbs", {
38
32
  enumerable: true,
39
33
  get: function get() {
@@ -407,7 +401,6 @@ var _autocompleteWithSuggestions = _interopRequireDefault(require("./autocomplet
407
401
  var _autocompleteWithLatestPosts = _interopRequireDefault(require("./autocomplete-with-latest-posts"));
408
402
  var _breadcrumbs = _interopRequireDefault(require("./breadcrumbs"));
409
403
  var _button = _interopRequireDefault(require("./button"));
410
- var _boxContrast = _interopRequireDefault(require("./box-contrast"));
411
404
  var _card = _interopRequireDefault(require("./card"));
412
405
  var _cardFeature = _interopRequireDefault(require("./card-feature"));
413
406
  var _cardForm = _interopRequireDefault(require("./card-form"));
@@ -39,7 +39,7 @@
39
39
  .newspack-info-button__popup {
40
40
  background-color: wp-colors.$gray-900;
41
41
  border-radius: var(--wpds-border-radius-md, #{wp-vars.$radius-medium});
42
- box-shadow: var(--wpds-elevation-sm, #{wp-vars.$elevation-small});
42
+ box-shadow: wp-vars.$elevation-small;
43
43
  color: wp-colors.$white;
44
44
  outline: 0;
45
45
  padding: var(--wpds-dimension-padding-xs, #{wp-vars.$grid-unit-05}) var(--wpds-dimension-padding-sm, #{wp-vars.$grid-unit-10});
@@ -83,15 +83,14 @@
83
83
  }
84
84
  }
85
85
 
86
- .components-modal__content {
87
- > * {
88
- &:first-child {
89
- margin-top: 0;
90
- }
86
+ .components-modal__children-container {
87
+ > :first-child,
88
+ > .screen-reader-text:first-child + * {
89
+ margin-top: 0;
90
+ }
91
91
 
92
- &:last-child {
93
- margin-bottom: 0;
94
- }
92
+ > :last-child {
93
+ margin-bottom: 0;
95
94
  }
96
95
  }
97
96
  }
@@ -9,10 +9,10 @@
9
9
  // postcss-import cannot resolve exports maps, and resolving the public
10
10
  // specifier through sass/webpack leaks a bogus `wp-theme/design-tokens.css`
11
11
  // script dependency into consumers' asset manifests, which silently blocks
12
- // their enqueues. If upstream moves `src/prebuilt/`, this fails loudly at
12
+ // their enqueues. If upstream moves `prebuilt/`, this fails loudly at
13
13
  // build time.
14
14
  /* stylelint-disable-next-line no-invalid-position-at-import-rule -- sass @use must precede the CSS @import; postcss-import inlines it at build time. */
15
- @import "@wordpress/theme/src/prebuilt/css/design-tokens.css";
15
+ @import "@wordpress/theme/prebuilt/css/design-tokens.css";
16
16
 
17
17
  // Newspack brand mapping: the wpds brand color tokens ship in WordPress
18
18
  // blue; remap them onto the Newspack primary scale so every design-system
@@ -51,7 +51,6 @@
51
51
  }
52
52
 
53
53
  .newspack-page__header {
54
- /* stylelint-disable-next-line plugin-wpds/no-unknown-ds-tokens -- the plugin's token list lags the prebuilt design-tokens.css names. */
55
54
  background: var(--wpds-color-background-surface-neutral-strong);
56
55
  border-block-end: var(--wpds-border-width-xs) solid var(--wpds-color-stroke-surface-neutral-weak);
57
56
  padding: var(--wpds-dimension-padding-lg) var(--wpds-dimension-padding-2xl);
@@ -62,7 +61,6 @@
62
61
  }
63
62
 
64
63
  .newspack-page__header-subtitle {
65
- /* stylelint-disable-next-line plugin-wpds/no-unknown-ds-tokens -- the plugin's token list lags the prebuilt design-tokens.css names. */
66
64
  color: var(--wpds-color-foreground-content-neutral-weak);
67
65
  padding-block-end: var(--wpds-dimension-padding-xs);
68
66
  }
@@ -1,6 +1,6 @@
1
1
  .newspack-card:not(.newspack-settings__no-border) {
2
2
  .newspack-action-card__region-children {
3
- > .newspack-grid {
3
+ > .newspack-grid:not(.newspack-grid--no-margin) {
4
4
  margin: 32px 0 0 !important;
5
5
  }
6
6
  }
@@ -42,6 +42,7 @@ var _jsxRuntime = require("react/jsx-runtime");
42
42
  * @property {boolean} [centered=false] - Indicates if the header is centered.
43
43
  * @property {?string} [className=null] - Additional CSS class name, applied to the outer container.
44
44
  * @property {string|Function|*} [description] - Description of the section.
45
+ * @property {boolean} [fullWidthText] - Lets the title and description span the full header width. With a back nav they are otherwise capped at half, which suits a page-wide header but not one already sitting in a column.
45
46
  * @property {number} [heading=2] - HTML heading level, e.g., 1 for h1, 2 for h2, etc.
46
47
  * @property {string|Function|*} [icon] - Icon to display in the header.
47
48
  * @property {boolean} [isWhite=false] - Indicates if the header should use a white theme.
@@ -70,6 +71,8 @@ var _jsxRuntime = require("react/jsx-runtime");
70
71
  className = _ref$className === void 0 ? null : _ref$className,
71
72
  _ref$description = _ref.description,
72
73
  description = _ref$description === void 0 ? '' : _ref$description,
74
+ _ref$fullWidthText = _ref.fullWidthText,
75
+ fullWidthText = _ref$fullWidthText === void 0 ? false : _ref$fullWidthText,
73
76
  _ref$heading = _ref.heading,
74
77
  heading = _ref$heading === void 0 ? 2 : _ref$heading,
75
78
  _ref$icon = _ref.icon,
@@ -91,7 +94,7 @@ var _jsxRuntime = require("react/jsx-runtime");
91
94
  _ref$children = _ref.children,
92
95
  children = _ref$children === void 0 ? null : _ref$children;
93
96
  // If id is in the URL as a scrollTo param, scroll to it on render.
94
- var ref = (0, _element.useRef)();
97
+ var ref = (0, _element.useRef)(undefined);
95
98
  (0, _element.useEffect)(function () {
96
99
  var params = new Proxy(new URLSearchParams(window.location.search), {
97
100
  get: function get(searchParams, prop) {
@@ -167,7 +170,7 @@ var _jsxRuntime = require("react/jsx-runtime");
167
170
  }
168
171
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
169
172
  id: id,
170
- className: (0, _classnames["default"])('newspack-section-header__container', backNav && 'newspack-section-header--has-back-nav', primaryAction && 'newspack-section-header--has-primary-action', className),
173
+ className: (0, _classnames["default"])('newspack-section-header__container', backNav && 'newspack-section-header--has-back-nav', fullWidthText && 'newspack-section-header--full-width-text', primaryAction && 'newspack-section-header--has-primary-action', className),
171
174
  ref: ref,
172
175
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_grid["default"], {
173
176
  columns: 1,
@@ -9,7 +9,7 @@
9
9
 
10
10
  .newspack-section-header {
11
11
  flex: 1;
12
- margin: 64px 0 32px;
12
+ margin: wp-vars.$grid-unit-60 0 wp-vars.$grid-unit-40;
13
13
 
14
14
  &__container {
15
15
  position: relative;
@@ -17,7 +17,7 @@
17
17
  text-wrap: balance;
18
18
  }
19
19
  &:not(:first-child) {
20
- margin-top: 48px;
20
+ margin-top: wp-vars.$grid-unit-60;
21
21
  }
22
22
  &:has(> .newspack-section-header--no-margin) {
23
23
  margin-top: 0;
@@ -34,7 +34,7 @@
34
34
  flex-direction: row;
35
35
  }
36
36
  }
37
- &.newspack-section-header--has-back-nav {
37
+ &.newspack-section-header--has-back-nav:not(.newspack-section-header--full-width-text) {
38
38
  @include wp-mixins.break-wide {
39
39
  .newspack-section-header__title-container,
40
40
  p {
@@ -145,7 +145,7 @@
145
145
  }
146
146
 
147
147
  & + & {
148
- margin-top: 64px;
148
+ margin-top: wp-vars.$grid-unit-60;
149
149
  }
150
150
  }
151
151
  }
@@ -62,13 +62,12 @@ var StyleCard = /*#__PURE__*/function (_Component) {
62
62
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
63
63
  src: image,
64
64
  alt: cardTitle + ' ' + (0, _i18n.__)('Thumbnail', 'newspack-plugin')
65
+ }), isActive && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.VisuallyHidden, {
66
+ children: (0, _i18n.__)('Selected', 'newspack-plugin')
65
67
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
66
68
  className: "newspack-style-card__actions",
67
- children: [isActive ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
68
- className: "newspack-style-card__actions__badge",
69
- children: (0, _i18n.__)('Selected', 'newspack-plugin')
70
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
71
- variant: "link",
69
+ children: [!isActive && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
70
+ variant: "tertiary",
72
71
  onClick: onClick,
73
72
  "aria-label": ariaLabel ? ariaLabel : (0, _i18n.__)('Select', 'newspack-plugin') + ' ' + cardTitle,
74
73
  tabIndex: "0",
@@ -76,7 +75,7 @@ var StyleCard = /*#__PURE__*/function (_Component) {
76
75
  }), url && /*#__PURE__*/(0, _jsxRuntime.jsx)(_.WebPreview, {
77
76
  url: url,
78
77
  label: (0, _i18n.__)('View Demo', 'newspack-plugin'),
79
- variant: "link"
78
+ variant: "tertiary"
80
79
  })]
81
80
  })]
82
81
  }), cardTitle && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
@@ -48,11 +48,13 @@
48
48
 
49
49
  .newspack-style-card__is-active & {
50
50
  border-color: var(--wp-admin-theme-color);
51
- box-shadow: inset 0 0 0 1px var(--wp-admin-theme-color);
52
51
 
53
- img {
54
- position: relative;
55
- z-index: -1;
52
+ &::after {
53
+ box-shadow: inset 0 0 0 1px var(--wp-admin-theme-color);
54
+ content: "";
55
+ inset: 0;
56
+ pointer-events: none;
57
+ position: absolute;
56
58
  }
57
59
  }
58
60
  }
@@ -74,18 +76,12 @@
74
76
  display: none;
75
77
  }
76
78
 
77
- &__badge,
78
79
  .components-button {
79
80
  margin: 4px;
80
81
  opacity: 0;
81
82
  transition: opacity 125ms ease-in-out;
82
83
  }
83
84
 
84
- &__badge {
85
- color: var(--wp-admin-theme-color);
86
- font-weight: bold;
87
- }
88
-
89
85
  .newspack-style-card__is-active & {
90
86
  box-shadow: inset 0 0 0 1px var(--wp-admin-theme-color);
91
87
  }
@@ -1,4 +1,5 @@
1
1
  @use "~@wordpress/base-styles/colors" as wp-colors;
2
+ @use "~@wordpress/base-styles/variables" as wp-vars;
2
3
  @use "../../colors/colors.module" as np-colors;
3
4
 
4
5
  :root {
@@ -21,14 +22,14 @@
21
22
  gap: 16px;
22
23
  justify-content: flex-start;
23
24
  align-items: center;
24
- margin: 64px 0 32px;
25
+ margin: wp-vars.$grid-unit-60 0 wp-vars.$grid-unit-40;
25
26
 
26
27
  &:empty {
27
28
  display: none;
28
29
  }
29
30
 
30
31
  + .newspack-card {
31
- margin-top: 64px;
32
+ margin-top: wp-vars.$grid-unit-60;
32
33
  }
33
34
  }
34
35
 
@@ -54,7 +54,6 @@
54
54
 
55
55
  &[data-disabled],
56
56
  &[aria-disabled="true"] {
57
- /* stylelint-disable-next-line plugin-wpds/no-unknown-ds-tokens -- the plugin's token list lags the prebuilt design-tokens.css names. */
58
57
  color: var( --wpds-color-foreground-interactive-neutral-disabled, #{wp-colors.$gray-600} );
59
58
  pointer-events: none;
60
59
  }
@@ -3,6 +3,7 @@
3
3
  */
4
4
 
5
5
  @use "~@wordpress/base-styles/colors" as wp-colors;
6
+ @use "~@wordpress/base-styles/variables" as wp-vars;
6
7
  @use "../../../colors/colors.module" as np-colors;
7
8
 
8
9
  .newspack-wizard {
@@ -94,10 +95,10 @@
94
95
  background: wp-colors.$gray-300;
95
96
  border: 0;
96
97
  height: 1px;
97
- margin: 32px 0;
98
+ margin: wp-vars.$grid-unit-40 0;
98
99
 
99
100
  @media screen and ( min-width: 744px ) {
100
- margin: 64px 0;
101
+ margin: wp-vars.$grid-unit-60 0;
101
102
  }
102
103
  }
103
104
  &:not(.newspack-wizard__content--full-width) {
@@ -404,6 +404,7 @@ var Wizard = function Wizard(_ref2, ref) {
404
404
  var headerActions = (actions === null || actions === void 0 ? void 0 : actions.length) > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
405
405
  children: [mainActions.map(function (action, index) {
406
406
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_.Button, {
407
+ "aria-label": action.ariaLabel,
407
408
  className: "newspack-wizard__actions__main",
408
409
  href: action.href,
409
410
  icon: resolveIcon(action.icon),
@@ -434,6 +435,7 @@ var Wizard = function Wizard(_ref2, ref) {
434
435
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuGroup, {
435
436
  children: group.map(function (action, index) {
436
437
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.MenuItem, {
438
+ "aria-label": action.ariaLabel,
437
439
  className: action.type === 'primary' || action.type === 'secondary' ? 'newspack-wizard__actions__more__main' : 'newspack-wizard__actions__more__more',
438
440
  icon: action.icon,
439
441
  href: action.href,
@@ -3,11 +3,9 @@
3
3
  @use "~@wordpress/base-styles/variables" as wp-vars;
4
4
 
5
5
  @mixin text-muted {
6
- /* stylelint-disable-next-line plugin-wpds/no-unknown-ds-tokens -- the plugin's token list lags the prebuilt design-tokens.css names. */
7
6
  color: var( --wpds-color-foreground-content-neutral-weak, #{wp-colors.$gray-700} );
8
7
  }
9
8
 
10
9
  @mixin wpds-focus-ring {
11
- /* stylelint-disable-next-line plugin-wpds/no-unknown-ds-tokens -- the plugin's token list lags the prebuilt design-tokens.css names. */
12
10
  outline: var( --wpds-border-width-focus, var( --wp-admin-border-width-focus, #{wp-vars.$border-width-focus-fallback} ) ) solid var( --wpds-color-stroke-focus, var( --wp-admin-theme-color, #{colors.$primary-600} ) );
13
11
  }
@@ -1,6 +1,6 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["actions", "actionType", "as", "buttonsCard", "className", "footer", "header", "headerAction", "headerStyle", "childrenStyle", "footerStyle", "disabled", "icon", "iconElement", "iconBackgroundColor", "isActive", "isDraggable", "isFirstTarget", "isLastTarget", "isNarrow", "isSelectable", "isSmall", "isVertical", "size", "dragIndex", "onDragCallback", "onToggle", "onHeaderClick", "noBorder", "noMargin", "children", "hasGreyHeader", "hasHeaderBorder"];
3
+ var _excluded = ["actions", "actionsLabel", "actionType", "as", "buttonsCard", "className", "footer", "header", "headerAction", "headerStyle", "childrenStyle", "footerStyle", "disabled", "icon", "iconElement", "iconBackgroundColor", "isActive", "isDraggable", "isFirstTarget", "isLastTarget", "isNarrow", "isSelectable", "isSmall", "isVertical", "size", "dragIndex", "onDragCallback", "onToggle", "onHeaderClick", "noBorder", "noMargin", "children", "hasGreyHeader", "hasHeaderBorder"];
4
4
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
5
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
6
  /**
@@ -27,6 +27,7 @@ import classNames from 'classnames';
27
27
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
28
28
  var CoreCard = function CoreCard(_ref) {
29
29
  var actions = _ref.actions,
30
+ actionsLabel = _ref.actionsLabel,
30
31
  actionType = _ref.actionType,
31
32
  as = _ref.as,
32
33
  buttonsCard = _ref.buttonsCard,
@@ -65,7 +66,7 @@ var CoreCard = function CoreCard(_ref) {
65
66
  hasHeaderBorder = _ref$hasHeaderBorder === void 0 ? true : _ref$hasHeaderBorder,
66
67
  otherProps = _objectWithoutProperties(_ref, _excluded);
67
68
  var bodySize = isSmall ? undefined : size;
68
- var classes = classNames('newspack-card--core', className, (buttonsCard || as === 'a') && 'newspack-card--core__buttons-card', (actions === null || actions === void 0 ? void 0 : actions.length) > 0 && 'newspack-card--core__header--has-actions', isDraggable && 'newspack-card--core__is-draggable', isNarrow && 'newspack-card--core__is-narrow', isSmall && 'newspack-card--core__is-small', isSelectable && 'newspack-card--core__is-selectable', bodySize === 'large' && 'newspack-card--core__is-large', isVertical && 'newspack-card--core__is-vertical', (icon || iconElement) && 'newspack-card--core__has-icon', iconBackgroundColor && 'newspack-card--core__has-icon-background-color', isActive && 'newspack-card--core__is-active', disabled && 'newspack-card--core__is-disabled', children && 'newspack-card--core__has-children', noMargin && 'newspack-card--core__no-margin', hasGreyHeader && 'newspack-card--core__has-grey-header');
69
+ var classes = classNames('newspack-card--core', className, (buttonsCard || as === 'a') && 'newspack-card--core__buttons-card', (actions === null || actions === void 0 ? void 0 : actions.length) > 0 && 'newspack-card--core__header--has-actions', isDraggable && 'newspack-card--core__is-draggable', isNarrow && 'newspack-card--core__is-narrow', isSmall && 'newspack-card--core__is-small', isSelectable && 'newspack-card--core__is-selectable', bodySize === 'large' && 'newspack-card--core__is-large', isVertical && 'newspack-card--core__is-vertical', (icon || iconElement) && 'newspack-card--core__has-icon', iconBackgroundColor && 'newspack-card--core__has-icon-background-color', isActive && 'newspack-card--core__is-active', disabled && 'newspack-card--core__is-disabled', children && 'newspack-card--core__has-children', noMargin && 'newspack-card--core__no-margin', (noBorder || otherProps.isBorderless) && 'newspack-card--core__no-border', hasGreyHeader && 'newspack-card--core__has-grey-header');
69
70
  var sizeProps = isSmall ? 'small' : size;
70
71
  if (buttonsCard || as === 'a') {
71
72
  if (!isSmall) {
@@ -154,7 +155,7 @@ var CoreCard = function CoreCard(_ref) {
154
155
  onChange: onToggle
155
156
  }), (actions === null || actions === void 0 ? void 0 : actions.length) > 0 && /*#__PURE__*/_jsx(DropdownMenu, {
156
157
  icon: moreVertical,
157
- label: __('More', 'newspack-plugin'),
158
+ label: actionsLabel || __('More actions', 'newspack-plugin'),
158
159
  children: function children() {
159
160
  return actions.map(function (action, index) {
160
161
  // Actions can be an array of sub-actions, which are rendered within a MenuGroup.
@@ -165,6 +166,7 @@ var CoreCard = function CoreCard(_ref) {
165
166
  icon: subAction.icon,
166
167
  onClick: subAction.action,
167
168
  href: subAction.href,
169
+ "aria-label": subAction.ariaLabel,
168
170
  disabled: subAction.disabled || false,
169
171
  isDestructive: subAction.destructive || false,
170
172
  children: subAction.label
@@ -176,6 +178,7 @@ var CoreCard = function CoreCard(_ref) {
176
178
  icon: action.icon,
177
179
  onClick: action.action,
178
180
  href: action.href,
181
+ "aria-label": action.ariaLabel,
179
182
  disabled: action.disabled || false,
180
183
  isDestructive: action.destructive || false,
181
184
  children: action.label
@@ -1,7 +1,10 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
3
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
1
4
  /**
2
5
  * External dependencies.
3
6
  */
4
- import { render } from '@testing-library/react';
7
+ import { fireEvent, render, screen } from '@testing-library/react';
5
8
 
6
9
  /**
7
10
  * Internal dependencies.
@@ -53,6 +56,59 @@ describe('CoreCard', function () {
53
56
  container = _render4.container;
54
57
  expect(getHeader(container).tagName).not.toBe('BUTTON');
55
58
  });
59
+ it('names the actions menu "More actions" by default', function () {
60
+ render(/*#__PURE__*/_jsx(CoreCard, {
61
+ header: "Settings",
62
+ actions: [{
63
+ label: 'Delete',
64
+ action: function action() {}
65
+ }]
66
+ }));
67
+ expect(screen.getByRole('button', {
68
+ name: 'More actions'
69
+ })).toBeInTheDocument();
70
+ });
71
+ it('names the actions menu with actionsLabel when supplied', function () {
72
+ render(/*#__PURE__*/_jsx(CoreCard, {
73
+ header: "Settings",
74
+ actions: [{
75
+ label: 'Delete',
76
+ action: function action() {}
77
+ }],
78
+ actionsLabel: "Settings actions"
79
+ }));
80
+ expect(screen.getByRole('button', {
81
+ name: 'Settings actions'
82
+ })).toBeInTheDocument();
83
+ });
84
+ it('gives a menu item its ariaLabel as the accessible name', /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
85
+ var _t;
86
+ return _regenerator().w(function (_context) {
87
+ while (1) switch (_context.n) {
88
+ case 0:
89
+ render(/*#__PURE__*/_jsx(CoreCard, {
90
+ header: "Settings",
91
+ actions: [{
92
+ label: 'Delete',
93
+ ariaLabel: 'Delete: Settings',
94
+ action: function action() {}
95
+ }]
96
+ }));
97
+ fireEvent.click(screen.getByRole('button', {
98
+ name: 'More actions'
99
+ }));
100
+ _t = expect;
101
+ _context.n = 1;
102
+ return screen.findByRole('menuitem', {
103
+ name: 'Delete: Settings'
104
+ });
105
+ case 1:
106
+ _t(_context.v).toBeInTheDocument();
107
+ case 2:
108
+ return _context.a(2);
109
+ }
110
+ }, _callee);
111
+ })));
56
112
  it('renders the header as a non-button when it is also draggable', function () {
57
113
  var _render5 = render(/*#__PURE__*/_jsx(CoreCard, {
58
114
  header: "Settings",
@@ -91,4 +147,23 @@ describe('CoreCard', function () {
91
147
  vertical = _render9.container;
92
148
  expect(vertical.querySelector('.newspack-card--core__is-vertical')).not.toBeNull();
93
149
  });
150
+ it('marks the card borderless only when noBorder or isBorderless is passed', function () {
151
+ var _render0 = render(/*#__PURE__*/_jsx(CoreCard, {
152
+ header: "Settings"
153
+ })),
154
+ plain = _render0.container;
155
+ expect(plain.querySelector('.newspack-card--core__no-border')).toBeNull();
156
+ var _render1 = render(/*#__PURE__*/_jsx(CoreCard, {
157
+ header: "Settings",
158
+ noBorder: true
159
+ })),
160
+ borderless = _render1.container;
161
+ expect(borderless.querySelector('.newspack-card--core__no-border')).not.toBeNull();
162
+ var _render10 = render(/*#__PURE__*/_jsx(CoreCard, {
163
+ header: "Settings",
164
+ isBorderless: true
165
+ })),
166
+ coreBorderless = _render10.container;
167
+ expect(coreBorderless.querySelector('.newspack-card--core__no-border')).not.toBeNull();
168
+ });
94
169
  });
@@ -5,6 +5,15 @@
5
5
  @use "~@wordpress/base-styles/colors" as wp-colors;
6
6
  @use "~@wordpress/base-styles/variables" as wp-vars;
7
7
 
8
+ .newspack-card--core.components-card:where(:not(.newspack-card--core__no-border)) {
9
+ box-shadow: 0 0 0 1px var( --wpds-color-stroke-surface-neutral, #{wp-colors.$gray-300} );
10
+ }
11
+
12
+ .newspack-card--core .newspack-card--core__header.components-card__header,
13
+ .newspack-card--core .components-card__footer {
14
+ border-color: var( --wpds-color-stroke-surface-neutral, #{wp-colors.$gray-300} );
15
+ }
16
+
8
17
  .newspack-card--core,
9
18
  .newspack-wizard .newspack-card--core {
10
19
  background: wp-colors.$white;
@@ -107,10 +116,10 @@
107
116
  }
108
117
  > .components-dropdown-menu {
109
118
  aspect-ratio: 1;
110
- border-left: 1px solid wp-colors.$gray-200;
119
+ border-left: 1px solid var( --wpds-color-stroke-surface-neutral, #{wp-colors.$gray-300} );
111
120
  display: grid;
112
121
  height: 100%;
113
- max-width: 50px;
122
+ max-width: 70px;
114
123
  padding: 4px;
115
124
  place-items: center;
116
125
  position: absolute;
@@ -127,7 +136,7 @@
127
136
  padding-left: 80px !important;
128
137
  .newspack-card--core__header__draggable-controls {
129
138
  align-items: center;
130
- border-right: 1px solid wp-colors.$gray-200;
139
+ border-right: 1px solid var( --wpds-color-stroke-surface-neutral, #{wp-colors.$gray-300} );
131
140
  display: flex;
132
141
  height: 100%;
133
142
  justify-content: space-between;