newspack-components 4.9.2 → 4.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,10 +3,11 @@
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-card {
8
9
  border-radius: 2px;
9
- border: 1px solid wp-colors.$gray-300;
10
+ border: 1px solid var( --wpds-color-stroke-surface-neutral, #{wp-colors.$gray-300} );
10
11
  color: wp-colors.$gray-900;
11
12
  margin: 32px 0;
12
13
  padding: 16px 48px;
@@ -101,10 +102,6 @@
101
102
 
102
103
  // Margin
103
104
 
104
- &.mt64 {
105
- margin-top: 64px;
106
- }
107
-
108
105
  &.mt16 {
109
106
  margin-top: 16px;
110
107
  }
@@ -128,10 +125,10 @@
128
125
  background: wp-colors.$gray-300;
129
126
  border: 0;
130
127
  height: 1px;
131
- margin: 32px 0;
128
+ margin: wp-vars.$grid-unit-40 0;
132
129
 
133
130
  @media screen and ( min-width: 744px ) {
134
- margin: 64px 0;
131
+ margin: wp-vars.$grid-unit-60 0;
135
132
  }
136
133
  }
137
134
 
@@ -51,7 +51,8 @@ var _CardFeature = function CardFeature(_ref) {
51
51
  var describedById = requirements ? badgeId : undefined;
52
52
  var isMuted = !!requirements;
53
53
  var classes = classnames('newspack-card-feature', className, {
54
- 'newspack-card-feature--muted': isMuted
54
+ 'newspack-card-feature--muted': isMuted,
55
+ 'newspack-card-feature--not-enabled': !enabled
55
56
  });
56
57
  var badge;
57
58
  if (requirements) {
@@ -490,4 +490,17 @@ describe('CardFeature', function () {
490
490
  }));
491
491
  expect(container.querySelector('.newspack-card-feature--muted')).toBeInTheDocument();
492
492
  });
493
+ it('marks the card as not enabled only when enabled is false', function () {
494
+ var _render13 = render(/*#__PURE__*/_jsx(CardFeature, {
495
+ title: "Content gifting"
496
+ })),
497
+ container = _render13.container,
498
+ rerender = _render13.rerender;
499
+ expect(container.querySelector('.newspack-card-feature--not-enabled')).toBeInTheDocument();
500
+ rerender(/*#__PURE__*/_jsx(CardFeature, {
501
+ title: "Content gifting",
502
+ enabled: true
503
+ }));
504
+ expect(container.querySelector('.newspack-card-feature--not-enabled')).toBeNull();
505
+ });
493
506
  });
@@ -2,6 +2,7 @@
2
2
  * CardFeature
3
3
  */
4
4
 
5
+ @use "~@wordpress/base-styles/colors" as wp-colors;
5
6
  @use "~@wordpress/base-styles/mixins" as wp-mixins;
6
7
  @use "~@wordpress/base-styles/variables" as wp-vars;
7
8
  @use "../mixins" as np-mixins;
@@ -9,6 +10,10 @@
9
10
  .newspack-card-feature {
10
11
  height: 100%;
11
12
 
13
+ &.newspack-card-feature--not-enabled {
14
+ border-color: var( --wpds-color-stroke-surface-neutral-weak, #{wp-colors.$gray-100} );
15
+ }
16
+
12
17
  &__actions {
13
18
  margin-top: auto;
14
19
 
@@ -1,10 +1,13 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ 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; }
4
+ 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; }
2
5
  /**
3
6
  * WordPress dependencies.
4
7
  */
5
8
  import { BaseControl, ColorPicker as ColorPickerComponent } from '@wordpress/components';
6
9
  import { useInstanceId } from '@wordpress/compose';
7
- import { useState, useRef } from '@wordpress/element';
10
+ import { useState, useRef, useEffect } from '@wordpress/element';
8
11
 
9
12
  /**
10
13
  * External dependencies.
@@ -32,6 +35,7 @@ var InteractiveDiv = utils.InteractiveDiv;
32
35
  * @param {string} [props.color] - Default color.
33
36
  * @param {Function} props.onChange - Function to call when the color changes.
34
37
  * @param {string} [props.className] - Additional class name.
38
+ * @param {boolean} [props.disabled] - Whether the color is shown but cannot be changed.
35
39
  * @return {JSX.Element} ColorPicker component.
36
40
  */
37
41
  var _ColorPicker = function ColorPicker(_ref) {
@@ -40,21 +44,30 @@ var _ColorPicker = function ColorPicker(_ref) {
40
44
  _ref$color = _ref.color,
41
45
  color = _ref$color === void 0 ? '#ffffff' : _ref$color,
42
46
  onChange = _ref.onChange,
43
- className = _ref.className;
47
+ className = _ref.className,
48
+ _ref$disabled = _ref.disabled,
49
+ disabled = _ref$disabled === void 0 ? false : _ref$disabled;
44
50
  var _useState = useState(false),
45
51
  _useState2 = _slicedToArray(_useState, 2),
46
52
  isExpanded = _useState2[0],
47
53
  setIsExpanded = _useState2[1];
48
- var ref = useRef();
54
+ var ref = useRef(undefined);
49
55
  var id = useInstanceId(_ColorPicker, 'newspack-color-picker');
50
56
  var labelId = "".concat(id, "-label");
51
57
  var colordColor = colord(color);
52
58
  hooks.useOnClickOutside(ref, function () {
53
59
  return setIsExpanded(false);
54
60
  });
61
+ useEffect(function () {
62
+ if (disabled) {
63
+ setIsExpanded(false);
64
+ }
65
+ }, [disabled]);
55
66
  return /*#__PURE__*/_jsxs(BaseControl, {
56
67
  id: id,
57
- className: classnames('newspack-color-picker', className),
68
+ className: classnames('newspack-color-picker', {
69
+ 'is-disabled': disabled
70
+ }, className),
58
71
  help: help,
59
72
  __nextHasNoMarginBottom: true,
60
73
  children: [/*#__PURE__*/_jsx(BaseControl.VisualLabel, {
@@ -65,19 +78,23 @@ var _ColorPicker = function ColorPicker(_ref) {
65
78
  "aria-labelledby": labelId,
66
79
  "aria-describedby": help ? "".concat(id, "__help") : undefined,
67
80
  "aria-expanded": isExpanded,
81
+ "aria-disabled": disabled || undefined,
82
+ tabIndex: disabled ? -1 : 0,
68
83
  className: 'newspack-color-picker__expander',
69
84
  onClick: function onClick() {
70
- return setIsExpanded(!isExpanded);
85
+ return !disabled && setIsExpanded(!isExpanded);
71
86
  },
72
- style: {
87
+ style: _objectSpread(_objectSpread({}, disabled && {
88
+ cursor: 'default'
89
+ }), {}, {
73
90
  backgroundColor: color,
74
91
  color: colordColor.contrast() > colordColor.contrast('#000000') ? '#ffffff' : '#000000'
75
- },
92
+ }),
76
93
  children: color
77
94
  }), /*#__PURE__*/_jsx("div", {
78
95
  className: "newspack-color-picker__main",
79
96
  ref: ref,
80
- children: isExpanded && /*#__PURE__*/_jsx(ColorPickerComponent, {
97
+ children: isExpanded && !disabled && /*#__PURE__*/_jsx(ColorPickerComponent, {
81
98
  color: color,
82
99
  onChange: onChange,
83
100
  enableAlpha: false
@@ -75,4 +75,51 @@ describe('ColorPicker', function () {
75
75
  getByRole = _render7.getByRole;
76
76
  expect(getByRole('button')).not.toHaveAttribute('aria-describedby');
77
77
  });
78
+ describe('when disabled', function () {
79
+ it('should not open on click', function () {
80
+ var _render8 = render(/*#__PURE__*/_jsx(ColorPicker, {
81
+ label: "Background color",
82
+ disabled: true,
83
+ onChange: function onChange() {}
84
+ })),
85
+ getByRole = _render8.getByRole;
86
+ var expander = getByRole('button');
87
+ fireEvent.click(expander);
88
+ expect(expander).toHaveAttribute('aria-expanded', 'false');
89
+ expect(expander).toHaveAttribute('aria-disabled', 'true');
90
+ });
91
+ it('should not open on Enter', function () {
92
+ var _render9 = render(/*#__PURE__*/_jsx(ColorPicker, {
93
+ label: "Background color",
94
+ disabled: true,
95
+ onChange: function onChange() {}
96
+ })),
97
+ getByRole = _render9.getByRole;
98
+ var expander = getByRole('button');
99
+ fireEvent.keyDown(expander, {
100
+ key: 'Enter',
101
+ keyCode: 13
102
+ });
103
+ expect(expander).toHaveAttribute('aria-expanded', 'false');
104
+ });
105
+ it('should stay closed once re-enabled if it was open when disabled', function () {
106
+ var _render0 = render(/*#__PURE__*/_jsx(ColorPicker, {
107
+ label: "Background color",
108
+ onChange: function onChange() {}
109
+ })),
110
+ getByRole = _render0.getByRole,
111
+ rerender = _render0.rerender;
112
+ fireEvent.click(getByRole('button'));
113
+ rerender(/*#__PURE__*/_jsx(ColorPicker, {
114
+ label: "Background color",
115
+ disabled: true,
116
+ onChange: function onChange() {}
117
+ }));
118
+ rerender(/*#__PURE__*/_jsx(ColorPicker, {
119
+ label: "Background color",
120
+ onChange: function onChange() {}
121
+ }));
122
+ expect(getByRole('button')).toHaveAttribute('aria-expanded', 'false');
123
+ });
124
+ });
78
125
  });
@@ -8,25 +8,28 @@
8
8
  .newspack-color-picker {
9
9
  position: relative;
10
10
  &__expander {
11
- box-shadow: inset 0 0 0 1px rgba(wp-colors.$black, 0.54);
12
- border-radius: wp-vars.$radius-small;
13
- height: wp-vars.$grid-unit-80;
14
- padding: wp-vars.$grid-unit-10;
15
- text-align: right;
11
+ box-shadow: inset 0 0 0 var(--wpds-border-width-xs, #{wp-vars.$border-width}) rgba(wp-colors.$black, 0.54);
12
+ border-radius: var(--wpds-border-radius-sm, #{wp-vars.$radius-small});
13
+ height: var(--wpds-dimension-size-lg, #{wp-vars.$grid-unit-50});
14
+ line-height: calc(var(--wpds-dimension-size-lg, #{wp-vars.$grid-unit-50}) - var(--wpds-dimension-padding-md, #{wp-vars.$grid-unit-15}));
15
+ padding: calc(var(--wpds-dimension-padding-md, #{wp-vars.$grid-unit-15}) / 2) var(--wpds-dimension-padding-md, #{wp-vars.$grid-unit-15});
16
16
  text-transform: uppercase;
17
17
 
18
18
  &:focus-visible {
19
- box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
20
- border-color: wp-colors.$white;
19
+ box-shadow: 0 0 0 var(--wpds-border-width-focus, #{wp-vars.$border-width-focus-fallback}) var(--wpds-color-stroke-focus, var(--wp-admin-theme-color));
21
20
  }
22
21
  }
23
22
 
23
+ &.is-disabled &__expander {
24
+ opacity: 0.5;
25
+ }
26
+
24
27
  &__main {
25
- background: wp-colors.$white;
28
+ background: var(--wpds-color-background-surface-neutral-strong, #{wp-colors.$white});
26
29
  box-shadow: wp-vars.$elevation-small;
27
- margin: wp-vars.$grid-unit-10 0 0;
30
+ margin: var(--wpds-dimension-gap-sm, #{wp-vars.$grid-unit-10}) 0 0;
28
31
  position: absolute;
29
- z-index: 2;
32
+ z-index: 3;
30
33
 
31
34
  &:empty {
32
35
  display: none;
@@ -10,7 +10,7 @@
10
10
  background: np-colors.$primary-600;
11
11
  border-radius: wp-vars.$radius-round;
12
12
  bottom: 0;
13
- box-shadow: var(--wpds-elevation-sm, #{wp-vars.$elevation-small});
13
+ box-shadow: wp-vars.$elevation-small;
14
14
  display: grid;
15
15
  height: wp-vars.$button-size;
16
16
  margin: 0 wp-vars.$grid-unit-30 wp-vars.$grid-unit-30;
@@ -37,9 +37,9 @@ var Divider = function Divider(_ref) {
37
37
  _ref$className = _ref.className,
38
38
  className = _ref$className === void 0 ? undefined : _ref$className,
39
39
  _ref$marginBottom = _ref.marginBottom,
40
- marginBottom = _ref$marginBottom === void 0 ? 64 : _ref$marginBottom,
40
+ marginBottom = _ref$marginBottom === void 0 ? 48 : _ref$marginBottom,
41
41
  _ref$marginTop = _ref.marginTop,
42
- marginTop = _ref$marginTop === void 0 ? 64 : _ref$marginTop,
42
+ marginTop = _ref$marginTop === void 0 ? 48 : _ref$marginTop,
43
43
  _ref$variant = _ref.variant,
44
44
  variant = _ref$variant === void 0 ? 'default' : _ref$variant,
45
45
  otherProps = _objectWithoutProperties(_ref, _excluded);
@@ -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 = classnames('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__*/_jsxs(BaseControl, {
92
95
  __nextHasNoMarginBottom: true,
93
- className: classnames('newspack-image-upload', className),
96
+ className: classnames('newspack-image-upload', {
97
+ 'newspack-image-upload--no-margin': !withMargin
98
+ }, className),
94
99
  help: help,
95
100
  children: [label && /*#__PURE__*/_jsx(BaseControl.VisualLabel, {
96
101
  children: label
@@ -101,7 +106,8 @@ var ImageUpload = /*#__PURE__*/function (_Component) {
101
106
  children: [/*#__PURE__*/_jsx("img", {
102
107
  "data-testid": "image-upload",
103
108
  src: image.url,
104
- alt: __('Image preview', 'newspack-plugin')
109
+ alt: __('Image preview', 'newspack-plugin'),
110
+ style: imageStyle
105
111
  }), /*#__PURE__*/_jsxs("div", {
106
112
  className: "newspack-image-upload__controls",
107
113
  children: [/*#__PURE__*/_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/esm/index.js CHANGED
@@ -4,7 +4,6 @@ export { default as AutocompleteWithSuggestions } from './autocomplete-with-sugg
4
4
  export { default as AutocompleteWithLatestPosts } from './autocomplete-with-latest-posts';
5
5
  export { default as Breadcrumbs } from './breadcrumbs';
6
6
  export { default as Button } from './button';
7
- export { default as BoxContrast } from './box-contrast';
8
7
  export { default as Card } from './card';
9
8
  export { default as CardFeature } from './card-feature';
10
9
  export { default as CardForm } from './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
  }
@@ -32,6 +32,7 @@ import classnames from 'classnames';
32
32
  * @property {boolean} [centered=false] - Indicates if the header is centered.
33
33
  * @property {?string} [className=null] - Additional CSS class name, applied to the outer container.
34
34
  * @property {string|Function|*} [description] - Description of the section.
35
+ * @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.
35
36
  * @property {number} [heading=2] - HTML heading level, e.g., 1 for h1, 2 for h2, etc.
36
37
  * @property {string|Function|*} [icon] - Icon to display in the header.
37
38
  * @property {boolean} [isWhite=false] - Indicates if the header should use a white theme.
@@ -62,6 +63,8 @@ var SectionHeader = function SectionHeader(_ref) {
62
63
  className = _ref$className === void 0 ? null : _ref$className,
63
64
  _ref$description = _ref.description,
64
65
  description = _ref$description === void 0 ? '' : _ref$description,
66
+ _ref$fullWidthText = _ref.fullWidthText,
67
+ fullWidthText = _ref$fullWidthText === void 0 ? false : _ref$fullWidthText,
65
68
  _ref$heading = _ref.heading,
66
69
  heading = _ref$heading === void 0 ? 2 : _ref$heading,
67
70
  _ref$icon = _ref.icon,
@@ -83,7 +86,7 @@ var SectionHeader = function SectionHeader(_ref) {
83
86
  _ref$children = _ref.children,
84
87
  children = _ref$children === void 0 ? null : _ref$children;
85
88
  // If id is in the URL as a scrollTo param, scroll to it on render.
86
- var ref = useRef();
89
+ var ref = useRef(undefined);
87
90
  useEffect(function () {
88
91
  var params = new Proxy(new URLSearchParams(window.location.search), {
89
92
  get: function get(searchParams, prop) {
@@ -159,7 +162,7 @@ var SectionHeader = function SectionHeader(_ref) {
159
162
  }
160
163
  return /*#__PURE__*/_jsxs("div", {
161
164
  id: id,
162
- className: classnames('newspack-section-header__container', backNav && 'newspack-section-header--has-back-nav', primaryAction && 'newspack-section-header--has-primary-action', className),
165
+ className: classnames('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),
163
166
  ref: ref,
164
167
  children: [/*#__PURE__*/_jsxs(Grid, {
165
168
  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
  }
@@ -14,7 +14,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
14
14
  */
15
15
  import { Component } from '@wordpress/element';
16
16
  import { __ } from '@wordpress/i18n';
17
- import { Button } from '@wordpress/components';
17
+ import { Button, VisuallyHidden } from '@wordpress/components';
18
18
 
19
19
  /**
20
20
  * Internal dependencies
@@ -62,13 +62,12 @@ var StyleCard = /*#__PURE__*/function (_Component) {
62
62
  }) : /*#__PURE__*/_jsx("img", {
63
63
  src: image,
64
64
  alt: cardTitle + ' ' + __('Thumbnail', 'newspack-plugin')
65
+ }), isActive && /*#__PURE__*/_jsx(VisuallyHidden, {
66
+ children: __('Selected', 'newspack-plugin')
65
67
  }), /*#__PURE__*/_jsxs("div", {
66
68
  className: "newspack-style-card__actions",
67
- children: [isActive ? /*#__PURE__*/_jsx("span", {
68
- className: "newspack-style-card__actions__badge",
69
- children: __('Selected', 'newspack-plugin')
70
- }) : /*#__PURE__*/_jsx(Button, {
71
- variant: "link",
69
+ children: [!isActive && /*#__PURE__*/_jsx(Button, {
70
+ variant: "tertiary",
72
71
  onClick: onClick,
73
72
  "aria-label": ariaLabel ? ariaLabel : __('Select', 'newspack-plugin') + ' ' + cardTitle,
74
73
  tabIndex: "0",
@@ -76,7 +75,7 @@ var StyleCard = /*#__PURE__*/function (_Component) {
76
75
  }), url && /*#__PURE__*/_jsx(WebPreview, {
77
76
  url: url,
78
77
  label: __('View Demo', 'newspack-plugin'),
79
- variant: "link"
78
+ variant: "tertiary"
80
79
  })]
81
80
  })]
82
81
  }), cardTitle && /*#__PURE__*/_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