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.
- package/CHANGELOG.md +28 -0
- package/DEVELOPMENT.md +13 -14
- package/dist/cjs/_mixins.scss +0 -2
- package/dist/cjs/card/core-card.js +6 -3
- package/dist/cjs/card/core-card.test.js +76 -5
- package/dist/cjs/card/style-core.scss +12 -3
- package/dist/cjs/card/style.scss +4 -7
- package/dist/cjs/card-feature/index.js +2 -1
- package/dist/cjs/card-feature/index.test.js +13 -0
- package/dist/cjs/card-feature/style.scss +5 -0
- package/dist/cjs/color-picker/index.js +26 -15
- package/dist/cjs/color-picker/index.test.js +47 -0
- package/dist/cjs/color-picker/style.scss +13 -10
- package/dist/cjs/debug-badge/style.scss +1 -1
- package/dist/cjs/divider/index.js +2 -2
- package/dist/cjs/divider/style.scss +7 -5
- package/dist/cjs/grid/style.scss +4 -16
- package/dist/cjs/image-upload/index.js +9 -3
- package/dist/cjs/image-upload/style.scss +3 -0
- package/dist/cjs/index.js +0 -7
- package/dist/cjs/info-button/style.scss +1 -1
- package/dist/cjs/modal/style.scss +7 -8
- package/dist/cjs/page/style.scss +2 -4
- package/dist/cjs/plugin-settings/style.scss +1 -1
- package/dist/cjs/section-header/index.js +5 -2
- package/dist/cjs/section-header/style.scss +3 -3
- package/dist/cjs/settings/style.scss +1 -1
- package/dist/cjs/style-card/index.js +5 -6
- package/dist/cjs/style-card/style.scss +6 -10
- package/dist/cjs/style.scss +3 -2
- package/dist/cjs/tabbed-navigation/style.scss +0 -1
- package/dist/cjs/with-wizard-screen/style.scss +3 -2
- package/dist/cjs/wizard/index.js +2 -0
- package/dist/esm/_mixins.scss +0 -2
- package/dist/esm/card/core-card.js +6 -3
- package/dist/esm/card/core-card.test.js +76 -1
- package/dist/esm/card/style-core.scss +12 -3
- package/dist/esm/card/style.scss +4 -7
- package/dist/esm/card-feature/index.js +2 -1
- package/dist/esm/card-feature/index.test.js +13 -0
- package/dist/esm/card-feature/style.scss +5 -0
- package/dist/esm/color-picker/index.js +25 -8
- package/dist/esm/color-picker/index.test.js +47 -0
- package/dist/esm/color-picker/style.scss +13 -10
- package/dist/esm/debug-badge/style.scss +1 -1
- package/dist/esm/divider/index.js +2 -2
- package/dist/esm/divider/style.scss +7 -5
- package/dist/esm/grid/style.scss +4 -16
- package/dist/esm/image-upload/index.js +9 -3
- package/dist/esm/image-upload/style.scss +3 -0
- package/dist/esm/index.js +0 -1
- package/dist/esm/info-button/style.scss +1 -1
- package/dist/esm/modal/style.scss +7 -8
- package/dist/esm/page/style.scss +2 -4
- package/dist/esm/plugin-settings/style.scss +1 -1
- package/dist/esm/section-header/index.js +5 -2
- package/dist/esm/section-header/style.scss +3 -3
- package/dist/esm/settings/style.scss +1 -1
- package/dist/esm/style-card/index.js +6 -7
- package/dist/esm/style-card/style.scss +6 -10
- package/dist/esm/style.scss +3 -2
- package/dist/esm/tabbed-navigation/style.scss +0 -1
- package/dist/esm/with-wizard-screen/style.scss +3 -2
- package/dist/esm/wizard/index.js +2 -0
- package/package.json +7 -7
- package/src/_mixins.scss +0 -2
- package/src/card/core-card.js +5 -1
- package/src/card/core-card.test.js +28 -1
- package/src/card/style-core.scss +12 -3
- package/src/card/style.scss +4 -7
- package/src/card-feature/index.test.js +7 -0
- package/src/card-feature/index.tsx +1 -0
- package/src/card-feature/style.scss +5 -0
- package/src/color-picker/index.js +20 -6
- package/src/color-picker/index.test.js +25 -0
- package/src/color-picker/style.scss +13 -10
- package/src/debug-badge/style.scss +1 -1
- package/src/divider/README.md +2 -2
- package/src/divider/index.js +1 -1
- package/src/divider/style.scss +7 -5
- package/src/grid/style.scss +4 -16
- package/src/image-upload/index.js +7 -3
- package/src/image-upload/style.scss +3 -0
- package/src/index.js +0 -1
- package/src/info-button/style.scss +1 -1
- package/src/modal/style.scss +7 -8
- package/src/page/style.scss +2 -4
- package/src/plugin-settings/style.scss +1 -1
- package/src/section-header/index.js +4 -1
- package/src/section-header/style.scss +3 -3
- package/src/settings/style.scss +1 -1
- package/src/style-card/index.js +5 -6
- package/src/style-card/style.scss +6 -10
- package/src/style.scss +3 -2
- package/src/tabbed-navigation/style.scss +0 -1
- package/src/with-wizard-screen/style.scss +3 -2
- package/src/wizard/index.js +2 -0
- package/dist/cjs/box-contrast/index.js +0 -53
- package/dist/cjs/utils/color.js +0 -35
- package/dist/esm/box-contrast/index.js +0 -48
- package/dist/esm/utils/color.js +0 -29
- package/src/box-contrast/index.tsx +0 -44
- package/src/utils/color.ts +0 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
# newspack-components [4.10.0-alpha.1](https://github.com/Automattic/newspack-workspace/compare/newspack-components@4.9.2...newspack-components@4.10.0-alpha.1) (2026-10-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **components:** reduce admin vertical spacing from 64px to 48px ([#1148](https://github.com/Automattic/newspack-workspace/issues/1148)) ([cc58352](https://github.com/Automattic/newspack-workspace/commit/cc5835298f73cbdea5f94891530b8a4298118679))
|
|
7
|
+
* **components:** reduce the Divider's default margin to 48px ([#1147](https://github.com/Automattic/newspack-workspace/issues/1147)) ([6dda86f](https://github.com/Automattic/newspack-workspace/commit/6dda86fe3866761c00491bdda50e4b4475eaebd2))
|
|
8
|
+
* **content-gate:** tidy the gate card and name its actions menu ([#1161](https://github.com/Automattic/newspack-workspace/issues/1161)) ([d76a562](https://github.com/Automattic/newspack-workspace/commit/d76a562c8bf8063e0fd609c75d3b9f68625c9c76))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **audience:** refresh the Integrations brand marks ([#1155](https://github.com/Automattic/newspack-workspace/issues/1155)) ([d46ef08](https://github.com/Automattic/newspack-workspace/commit/d46ef0853a766967a2a121b34719f2e5822006f9))
|
|
14
|
+
* **audience:** refresh the Integrations screen icons, order and copy ([#1151](https://github.com/Automattic/newspack-workspace/issues/1151)) ([99912ba](https://github.com/Automattic/newspack-workspace/commit/99912ba739a4f05c86964b88abea263f456a411f))
|
|
15
|
+
* **components:** update @wordpress/ui and match its card borders ([#1195](https://github.com/Automattic/newspack-workspace/issues/1195)) ([9b62fe7](https://github.com/Automattic/newspack-workspace/commit/9b62fe7b69d824616ca931069c3a32738517d365))
|
|
16
|
+
* **dashboard:** remove the brand header ([#1142](https://github.com/Automattic/newspack-workspace/issues/1142)) ([c9f3d16](https://github.com/Automattic/newspack-workspace/commit/c9f3d16b6ee723b5fecf7863370ab6a711511485))
|
|
17
|
+
* **reader-activation:** split Gravity Forms into its own integration ([#1170](https://github.com/Automattic/newspack-workspace/issues/1170)) ([c74c13d](https://github.com/Automattic/newspack-workspace/commit/c74c13d2fc36813ff31ec8d842063e139b1bce19))
|
|
18
|
+
* **settings:** add an empty state to the Print tab ([#1123](https://github.com/Automattic/newspack-workspace/issues/1123)) ([04bbd0b](https://github.com/Automattic/newspack-workspace/commit/04bbd0b99f2e62174273642b64d01116988139a5))
|
|
19
|
+
* **settings:** rework the Experimental Tools configure screens ([#1140](https://github.com/Automattic/newspack-workspace/issues/1140)) ([8aad58b](https://github.com/Automattic/newspack-workspace/commit/8aad58bf4f56a99cbeee92c96b9b41f0a5529058))
|
|
20
|
+
* **settings:** rework the Theme and Brand tab layout ([#1136](https://github.com/Automattic/newspack-workspace/issues/1136)) ([0f54f67](https://github.com/Automattic/newspack-workspace/commit/0f54f671b97aa758b0cfe1d0a6d1a3918c90a4c2))
|
|
21
|
+
* **sync:** read the push log in a sync activity tab ([#1114](https://github.com/Automattic/newspack-workspace/issues/1114)) ([9390fdc](https://github.com/Automattic/newspack-workspace/commit/9390fdc884a9f31d31d1dbd1fbc1f61944dbc3cd))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Dependencies
|
|
25
|
+
|
|
26
|
+
* **newspack-icons:** upgraded to 1.2.0-alpha.1
|
|
27
|
+
* **newspack-scripts:** upgraded to 5.12.0-alpha.1
|
|
28
|
+
|
|
1
29
|
## newspack-components [4.9.2](https://github.com/Automattic/newspack-workspace/compare/newspack-components@4.9.1...newspack-components@4.9.2) (2026-09-28)
|
|
2
30
|
|
|
3
31
|
|
package/DEVELOPMENT.md
CHANGED
|
@@ -68,18 +68,17 @@ Follow this step-by-step process when selecting a component:
|
|
|
68
68
|
|
|
69
69
|
## Design & layout at a glance
|
|
70
70
|
|
|
71
|
-
When building a screen, use the **spacing scale** (8px unit: 16, 24, 32, 48, 64) and prefer **VStack** for vertical stacks and **HStack** for related items in a row; use **Grid** for real multi-column layouts. Structure content as **SectionHeader → Card → ActionCard → controls**, with **Divider** between sections and primary actions in **`.newspack-buttons-card`**. Use the same **breakpoints** (e.g. 744px,
|
|
71
|
+
When building a screen, use the **spacing scale** (8px unit: 16, 24, 32, 48, 64) and prefer **VStack** for vertical stacks and **HStack** for related items in a row; use **Grid** for real multi-column layouts. Structure content as **SectionHeader → Card → ActionCard → controls**, with **Divider** between sections and primary actions in **`.newspack-buttons-card`**. Use the same **breakpoints** (e.g. 744px, 1054px) as existing components. Full detail: [Spacing scale](#spacing-scale-design-system), [Layout (HStack / VStack / Grid)](#layout-when-to-use-hstack-vstack-grid), [Responsive breakpoints](#responsive-breakpoints), [Visual hierarchy patterns](#visual-hierarchy-patterns), [Component states](#component-states). For code examples by context and wizard patterns, see [Usage](#usage).
|
|
72
72
|
|
|
73
73
|
## Available Components
|
|
74
74
|
|
|
75
75
|
### Layout Components
|
|
76
76
|
|
|
77
|
-
- **`BoxContrast`** – High-contrast content box for emphasis.
|
|
78
77
|
- **`Card`** – Container for a logical block of content; use for grouping related settings. Default vertical margin is 32px so cards stack with consistent rhythm. Use `noBorder` when cards sit inside another card (e.g. ActionCard children).
|
|
79
|
-
- **`Divider`** – Use between logical sections (e.g. between ActionCards) to separate content without another card. Margins are 32px (
|
|
78
|
+
- **`Divider`** – Use between logical sections (e.g. between ActionCards) to separate content without another card. Margins are 32px (48px at larger breakpoints) so spacing stays consistent with the rest of the layout.
|
|
80
79
|
- **`EmptyState`** – Use when a list has nothing in it yet, or an onboarding view stands in for a feature that is not set up. Compound: `EmptyState.Root` wraps `EmptyState.Header` and `EmptyState.Actions`. Render it only when the *unfiltered* collection is empty, so a search matching nothing keeps the DataViews "no results" treatment. See [src/empty-state/README.md](src/empty-state/README.md).
|
|
81
|
-
- **`Grid`** – Use for laying out several items in columns (e.g. multiple controls or cards). Default gap is 32px; use `columns` and `gutter` modifiers (8, 16, 24, 32) when you need tighter or looser spacing. For a single row or a simple vertical stack, prefer **VStack** (or HStack) in new code; Grid is still used that way in many places and is fine to leave as-is until we refactor.
|
|
82
|
-
- **`SectionHeader`** – Use to start a new section; pair with a short description so the section’s goal is clear. Top margin (
|
|
80
|
+
- **`Grid`** – Use for laying out several items in columns (e.g. multiple controls or cards). Default gap is 32px; use `columns` and `gutter` modifiers (8, 16, 24, 32, 48) when you need tighter or looser spacing. For a single row or a simple vertical stack, prefer **VStack** (or HStack) in new code; Grid is still used that way in many places and is fine to leave as-is until we refactor.
|
|
81
|
+
- **`SectionHeader`** – Use to start a new section; pair with a short description so the section’s goal is clear. Top margin (48px) and bottom (32px) create clear separation from previous content and the section body.
|
|
83
82
|
- **`StatCard`** – Use for a single headline figure with a label above it and a description below. Compound: `StatCard.Root` wraps `Label`, `Body` (holding `Value` and an optional `Secondary`) and `Footer`, with `Delta` riding in the `Value`'s `suffix` for a change beside the figure. Format the figure yourself and pass a string; a `null`, `undefined` or blank `value` gets the shared null glyph rather than a misleading zero. The figure is sized by a container query, so give the cards a definite width (a Grid track, a `flex: 1` item) and equal widths across a row to keep one type scale. See [src/stat-card/README.md](src/stat-card/README.md).
|
|
84
83
|
|
|
85
84
|
### Form Components
|
|
@@ -387,7 +386,6 @@ function Dashboard() {
|
|
|
387
386
|
sections={ sections }
|
|
388
387
|
renderAboveSections={ () => (
|
|
389
388
|
<>
|
|
390
|
-
<BrandHeader />
|
|
391
389
|
<SiteStatuses />
|
|
392
390
|
</>
|
|
393
391
|
) }
|
|
@@ -624,8 +622,8 @@ Spacing is based on an **8px unit**. Use these values so new styles match existi
|
|
|
624
622
|
| **16px** | Gaps between related controls, buttons card gap, margins inside ActionCard region-children for Card/Grid/TextControl | Related items, form rows |
|
|
625
623
|
| **24px** | Default ActionCard region padding, toggle/region gaps, expandable content padding and sibling spacing | Default internal padding and gaps within a card |
|
|
626
624
|
| **32px** | Card vertical margin, Grid default gap and margin, SectionHeader first-child top, Newspack Notice margin, Divider margin | Section rhythm, between blocks |
|
|
627
|
-
| **48px** | SectionHeader
|
|
628
|
-
| **64px** |
|
|
625
|
+
| **48px** | SectionHeader top margin, buttons card top margin, Divider margins (large breakpoint), Card horizontal padding (small screens) | Major section separation |
|
|
626
|
+
| **64px** | Card horizontal padding (large screens) | Large-screen card padding |
|
|
629
627
|
|
|
630
628
|
**In code:** Card uses `margin: 32px 0` and `padding: 16px 48px` (32px 64px at 744px+). ActionCard uses 24px for region padding and 24px between regions; region-children use `padding: 0 24px 24px` (0 32px 32px for is-medium). Grid uses `grid-gap: 32px` and `margin: 32px 0` by default, with optional gutter classes (`__gutter-8`, `__gutter-16`, etc.). When adding new components or overrides, prefer these values (or 8px multiples) instead of ad-hoc spacing.
|
|
631
629
|
|
|
@@ -645,10 +643,11 @@ Components use consistent breakpoints so layouts behave predictably across viewp
|
|
|
645
643
|
|------------|-------------|
|
|
646
644
|
| **600px** | Narrow viewport overrides (e.g. wizard layout) |
|
|
647
645
|
| **744px** | Card padding, ActionCard region layout (title + toggle side-by-side), Grid columns (2–3), modal, withWizardScreen layout |
|
|
648
|
-
| **
|
|
646
|
+
| **782px** | Divider full margin (`wp-mixins.break-medium`) |
|
|
647
|
+
| **783px** | Wizard content width |
|
|
649
648
|
| **960px** | Modal width, wizard layout |
|
|
650
649
|
| **961px** | Wizard layout |
|
|
651
|
-
| **
|
|
650
|
+
| **1054px** | Grid 3–4 columns |
|
|
652
651
|
| **1224px** | Large wizard layout |
|
|
653
652
|
|
|
654
653
|
Prefer these values over new breakpoints so behaviour stays consistent with Card, Grid, and wizard shells.
|
|
@@ -661,14 +660,14 @@ Common composition patterns keep screens predictable. Use these as a reference w
|
|
|
661
660
|
```
|
|
662
661
|
Wizard
|
|
663
662
|
GlobalNotices
|
|
664
|
-
SectionHeader ←
|
|
663
|
+
SectionHeader ← 48px top margin
|
|
665
664
|
Card ← 32px margin
|
|
666
665
|
ActionCard ← 24px padding, optional toggle
|
|
667
666
|
Grid or VStack ← 32px gap
|
|
668
667
|
TextControl / SelectControl / etc.
|
|
669
|
-
Divider ← 32px /
|
|
668
|
+
Divider ← 32px / 48px margin
|
|
670
669
|
ActionCard
|
|
671
|
-
.newspack-buttons-card ←
|
|
670
|
+
.newspack-buttons-card ← 48px top / 32px bottom margin, 16px gap
|
|
672
671
|
Button (primary)
|
|
673
672
|
```
|
|
674
673
|
|
|
@@ -804,7 +803,7 @@ import './style.scss';
|
|
|
804
803
|
*/
|
|
805
804
|
import classNames from 'classnames';
|
|
806
805
|
|
|
807
|
-
const Divider = ( { alignment = 'none', className = undefined, marginBottom =
|
|
806
|
+
const Divider = ( { alignment = 'none', className = undefined, marginBottom = 48, marginTop = 48, variant = 'default', ...otherProps } ) => {
|
|
808
807
|
const classes = classNames(
|
|
809
808
|
'newspack-divider',
|
|
810
809
|
className,
|
package/dist/cjs/_mixins.scss
CHANGED
|
@@ -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
|
}
|
|
@@ -13,7 +13,7 @@ var _icons = require("@wordpress/icons");
|
|
|
13
13
|
require("./style-core.scss");
|
|
14
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
|
-
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"];
|
|
16
|
+
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"];
|
|
17
17
|
/**
|
|
18
18
|
* Card using WP Core's Card component.
|
|
19
19
|
* https://wordpress.github.io/gutenberg/?path=/docs/components-card--docs
|
|
@@ -31,6 +31,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
31
31
|
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) { (0, _defineProperty2["default"])(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; }
|
|
32
32
|
var CoreCard = function CoreCard(_ref) {
|
|
33
33
|
var actions = _ref.actions,
|
|
34
|
+
actionsLabel = _ref.actionsLabel,
|
|
34
35
|
actionType = _ref.actionType,
|
|
35
36
|
as = _ref.as,
|
|
36
37
|
buttonsCard = _ref.buttonsCard,
|
|
@@ -69,7 +70,7 @@ var CoreCard = function CoreCard(_ref) {
|
|
|
69
70
|
hasHeaderBorder = _ref$hasHeaderBorder === void 0 ? true : _ref$hasHeaderBorder,
|
|
70
71
|
otherProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
71
72
|
var bodySize = isSmall ? undefined : size;
|
|
72
|
-
var classes = (0, _classnames["default"])('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');
|
|
73
|
+
var classes = (0, _classnames["default"])('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');
|
|
73
74
|
var sizeProps = isSmall ? 'small' : size;
|
|
74
75
|
if (buttonsCard || as === 'a') {
|
|
75
76
|
if (!isSmall) {
|
|
@@ -158,7 +159,7 @@ var CoreCard = function CoreCard(_ref) {
|
|
|
158
159
|
onChange: onToggle
|
|
159
160
|
}), (actions === null || actions === void 0 ? void 0 : actions.length) > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.DropdownMenu, {
|
|
160
161
|
icon: _icons.moreVertical,
|
|
161
|
-
label: (0, _i18n.__)('More', 'newspack-plugin'),
|
|
162
|
+
label: actionsLabel || (0, _i18n.__)('More actions', 'newspack-plugin'),
|
|
162
163
|
children: function children() {
|
|
163
164
|
return actions.map(function (action, index) {
|
|
164
165
|
// Actions can be an array of sub-actions, which are rendered within a MenuGroup.
|
|
@@ -169,6 +170,7 @@ var CoreCard = function CoreCard(_ref) {
|
|
|
169
170
|
icon: subAction.icon,
|
|
170
171
|
onClick: subAction.action,
|
|
171
172
|
href: subAction.href,
|
|
173
|
+
"aria-label": subAction.ariaLabel,
|
|
172
174
|
disabled: subAction.disabled || false,
|
|
173
175
|
isDestructive: subAction.destructive || false,
|
|
174
176
|
children: subAction.label
|
|
@@ -180,6 +182,7 @@ var CoreCard = function CoreCard(_ref) {
|
|
|
180
182
|
icon: action.icon,
|
|
181
183
|
onClick: action.action,
|
|
182
184
|
href: action.href,
|
|
185
|
+
"aria-label": action.ariaLabel,
|
|
183
186
|
disabled: action.disabled || false,
|
|
184
187
|
isDestructive: action.destructive || false,
|
|
185
188
|
children: action.label
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
4
5
|
var _react = require("@testing-library/react");
|
|
5
6
|
var _coreCard = _interopRequireDefault(require("./core-card"));
|
|
6
7
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
|
-
|
|
8
|
+
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 }; })(); }
|
|
9
|
+
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); } /**
|
|
8
10
|
* External dependencies.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
11
|
+
*/ /**
|
|
12
12
|
* Internal dependencies.
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
14
|
var getHeader = function getHeader(container) {
|
|
16
15
|
return container.querySelector('.newspack-card--core__header');
|
|
17
16
|
};
|
|
@@ -57,6 +56,59 @@ describe('CoreCard', function () {
|
|
|
57
56
|
container = _render4.container;
|
|
58
57
|
expect(getHeader(container).tagName).not.toBe('BUTTON');
|
|
59
58
|
});
|
|
59
|
+
it('names the actions menu "More actions" by default', function () {
|
|
60
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_coreCard["default"], {
|
|
61
|
+
header: "Settings",
|
|
62
|
+
actions: [{
|
|
63
|
+
label: 'Delete',
|
|
64
|
+
action: function action() {}
|
|
65
|
+
}]
|
|
66
|
+
}));
|
|
67
|
+
expect(_react.screen.getByRole('button', {
|
|
68
|
+
name: 'More actions'
|
|
69
|
+
})).toBeInTheDocument();
|
|
70
|
+
});
|
|
71
|
+
it('names the actions menu with actionsLabel when supplied', function () {
|
|
72
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_coreCard["default"], {
|
|
73
|
+
header: "Settings",
|
|
74
|
+
actions: [{
|
|
75
|
+
label: 'Delete',
|
|
76
|
+
action: function action() {}
|
|
77
|
+
}],
|
|
78
|
+
actionsLabel: "Settings actions"
|
|
79
|
+
}));
|
|
80
|
+
expect(_react.screen.getByRole('button', {
|
|
81
|
+
name: 'Settings actions'
|
|
82
|
+
})).toBeInTheDocument();
|
|
83
|
+
});
|
|
84
|
+
it('gives a menu item its ariaLabel as the accessible name', /*#__PURE__*/(0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
85
|
+
var _t;
|
|
86
|
+
return _regenerator().w(function (_context) {
|
|
87
|
+
while (1) switch (_context.n) {
|
|
88
|
+
case 0:
|
|
89
|
+
(0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_coreCard["default"], {
|
|
90
|
+
header: "Settings",
|
|
91
|
+
actions: [{
|
|
92
|
+
label: 'Delete',
|
|
93
|
+
ariaLabel: 'Delete: Settings',
|
|
94
|
+
action: function action() {}
|
|
95
|
+
}]
|
|
96
|
+
}));
|
|
97
|
+
_react.fireEvent.click(_react.screen.getByRole('button', {
|
|
98
|
+
name: 'More actions'
|
|
99
|
+
}));
|
|
100
|
+
_t = expect;
|
|
101
|
+
_context.n = 1;
|
|
102
|
+
return _react.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
|
+
})));
|
|
60
112
|
it('renders the header as a non-button when it is also draggable', function () {
|
|
61
113
|
var _render5 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_coreCard["default"], {
|
|
62
114
|
header: "Settings",
|
|
@@ -95,4 +147,23 @@ describe('CoreCard', function () {
|
|
|
95
147
|
vertical = _render9.container;
|
|
96
148
|
expect(vertical.querySelector('.newspack-card--core__is-vertical')).not.toBeNull();
|
|
97
149
|
});
|
|
150
|
+
it('marks the card borderless only when noBorder or isBorderless is passed', function () {
|
|
151
|
+
var _render0 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_coreCard["default"], {
|
|
152
|
+
header: "Settings"
|
|
153
|
+
})),
|
|
154
|
+
plain = _render0.container;
|
|
155
|
+
expect(plain.querySelector('.newspack-card--core__no-border')).toBeNull();
|
|
156
|
+
var _render1 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_coreCard["default"], {
|
|
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 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_coreCard["default"], {
|
|
163
|
+
header: "Settings",
|
|
164
|
+
isBorderless: true
|
|
165
|
+
})),
|
|
166
|
+
coreBorderless = _render10.container;
|
|
167
|
+
expect(coreBorderless.querySelector('.newspack-card--core__no-border')).not.toBeNull();
|
|
168
|
+
});
|
|
98
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-
|
|
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:
|
|
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-
|
|
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;
|
package/dist/cjs/card/style.scss
CHANGED
|
@@ -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:
|
|
128
|
+
margin: wp-vars.$grid-unit-40 0;
|
|
132
129
|
|
|
133
130
|
@media screen and ( min-width: 744px ) {
|
|
134
|
-
margin:
|
|
131
|
+
margin: wp-vars.$grid-unit-60 0;
|
|
135
132
|
}
|
|
136
133
|
}
|
|
137
134
|
|
|
@@ -59,7 +59,8 @@ var _CardFeature = function CardFeature(_ref) {
|
|
|
59
59
|
var describedById = requirements ? badgeId : undefined;
|
|
60
60
|
var isMuted = !!requirements;
|
|
61
61
|
var classes = (0, _classnames["default"])('newspack-card-feature', className, {
|
|
62
|
-
'newspack-card-feature--muted': isMuted
|
|
62
|
+
'newspack-card-feature--muted': isMuted,
|
|
63
|
+
'newspack-card-feature--not-enabled': !enabled
|
|
63
64
|
});
|
|
64
65
|
var badge;
|
|
65
66
|
if (requirements) {
|
|
@@ -486,4 +486,17 @@ describe('CardFeature', function () {
|
|
|
486
486
|
}));
|
|
487
487
|
expect(container.querySelector('.newspack-card-feature--muted')).toBeInTheDocument();
|
|
488
488
|
});
|
|
489
|
+
it('marks the card as not enabled only when enabled is false', function () {
|
|
490
|
+
var _render13 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_index["default"], {
|
|
491
|
+
title: "Content gifting"
|
|
492
|
+
})),
|
|
493
|
+
container = _render13.container,
|
|
494
|
+
rerender = _render13.rerender;
|
|
495
|
+
expect(container.querySelector('.newspack-card-feature--not-enabled')).toBeInTheDocument();
|
|
496
|
+
rerender(/*#__PURE__*/(0, _jsxRuntime.jsx)(_index["default"], {
|
|
497
|
+
title: "Content gifting",
|
|
498
|
+
enabled: true
|
|
499
|
+
}));
|
|
500
|
+
expect(container.querySelector('.newspack-card-feature--not-enabled')).toBeNull();
|
|
501
|
+
});
|
|
489
502
|
});
|
|
@@ -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
|
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
10
|
var _components = require("@wordpress/components");
|
|
10
11
|
var _compose = require("@wordpress/compose");
|
|
@@ -16,18 +17,14 @@ var _hooks = _interopRequireDefault(require("../hooks"));
|
|
|
16
17
|
var _utils = _interopRequireDefault(require("../utils"));
|
|
17
18
|
require("./style.scss");
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
|
|
20
|
+
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; }
|
|
21
|
+
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) { (0, _defineProperty2["default"])(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; } /**
|
|
20
22
|
* WordPress dependencies.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/**
|
|
23
|
+
*/ /**
|
|
24
24
|
* External dependencies.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
25
|
+
*/ /**
|
|
28
26
|
* Internal dependencies.
|
|
29
27
|
*/
|
|
30
|
-
|
|
31
28
|
(0, _colord.extend)([_a11y["default"]]);
|
|
32
29
|
var InteractiveDiv = _utils["default"].InteractiveDiv;
|
|
33
30
|
|
|
@@ -40,6 +37,7 @@ var InteractiveDiv = _utils["default"].InteractiveDiv;
|
|
|
40
37
|
* @param {string} [props.color] - Default color.
|
|
41
38
|
* @param {Function} props.onChange - Function to call when the color changes.
|
|
42
39
|
* @param {string} [props.className] - Additional class name.
|
|
40
|
+
* @param {boolean} [props.disabled] - Whether the color is shown but cannot be changed.
|
|
43
41
|
* @return {JSX.Element} ColorPicker component.
|
|
44
42
|
*/
|
|
45
43
|
var _ColorPicker = function ColorPicker(_ref) {
|
|
@@ -48,21 +46,30 @@ var _ColorPicker = function ColorPicker(_ref) {
|
|
|
48
46
|
_ref$color = _ref.color,
|
|
49
47
|
color = _ref$color === void 0 ? '#ffffff' : _ref$color,
|
|
50
48
|
onChange = _ref.onChange,
|
|
51
|
-
className = _ref.className
|
|
49
|
+
className = _ref.className,
|
|
50
|
+
_ref$disabled = _ref.disabled,
|
|
51
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
|
52
52
|
var _useState = (0, _element.useState)(false),
|
|
53
53
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
54
54
|
isExpanded = _useState2[0],
|
|
55
55
|
setIsExpanded = _useState2[1];
|
|
56
|
-
var ref = (0, _element.useRef)();
|
|
56
|
+
var ref = (0, _element.useRef)(undefined);
|
|
57
57
|
var id = (0, _compose.useInstanceId)(_ColorPicker, 'newspack-color-picker');
|
|
58
58
|
var labelId = "".concat(id, "-label");
|
|
59
59
|
var colordColor = (0, _colord.colord)(color);
|
|
60
60
|
_hooks["default"].useOnClickOutside(ref, function () {
|
|
61
61
|
return setIsExpanded(false);
|
|
62
62
|
});
|
|
63
|
+
(0, _element.useEffect)(function () {
|
|
64
|
+
if (disabled) {
|
|
65
|
+
setIsExpanded(false);
|
|
66
|
+
}
|
|
67
|
+
}, [disabled]);
|
|
63
68
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.BaseControl, {
|
|
64
69
|
id: id,
|
|
65
|
-
className: (0, _classnames["default"])('newspack-color-picker',
|
|
70
|
+
className: (0, _classnames["default"])('newspack-color-picker', {
|
|
71
|
+
'is-disabled': disabled
|
|
72
|
+
}, className),
|
|
66
73
|
help: help,
|
|
67
74
|
__nextHasNoMarginBottom: true,
|
|
68
75
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.BaseControl.VisualLabel, {
|
|
@@ -73,19 +80,23 @@ var _ColorPicker = function ColorPicker(_ref) {
|
|
|
73
80
|
"aria-labelledby": labelId,
|
|
74
81
|
"aria-describedby": help ? "".concat(id, "__help") : undefined,
|
|
75
82
|
"aria-expanded": isExpanded,
|
|
83
|
+
"aria-disabled": disabled || undefined,
|
|
84
|
+
tabIndex: disabled ? -1 : 0,
|
|
76
85
|
className: 'newspack-color-picker__expander',
|
|
77
86
|
onClick: function onClick() {
|
|
78
|
-
return setIsExpanded(!isExpanded);
|
|
87
|
+
return !disabled && setIsExpanded(!isExpanded);
|
|
79
88
|
},
|
|
80
|
-
style: {
|
|
89
|
+
style: _objectSpread(_objectSpread({}, disabled && {
|
|
90
|
+
cursor: 'default'
|
|
91
|
+
}), {}, {
|
|
81
92
|
backgroundColor: color,
|
|
82
93
|
color: colordColor.contrast() > colordColor.contrast('#000000') ? '#ffffff' : '#000000'
|
|
83
|
-
},
|
|
94
|
+
}),
|
|
84
95
|
children: color
|
|
85
96
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
86
97
|
className: "newspack-color-picker__main",
|
|
87
98
|
ref: ref,
|
|
88
|
-
children: isExpanded && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ColorPicker, {
|
|
99
|
+
children: isExpanded && !disabled && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ColorPicker, {
|
|
89
100
|
color: color,
|
|
90
101
|
onChange: onChange,
|
|
91
102
|
enableAlpha: false
|
|
@@ -79,4 +79,51 @@ describe('ColorPicker', function () {
|
|
|
79
79
|
getByRole = _render7.getByRole;
|
|
80
80
|
expect(getByRole('button')).not.toHaveAttribute('aria-describedby');
|
|
81
81
|
});
|
|
82
|
+
describe('when disabled', function () {
|
|
83
|
+
it('should not open on click', function () {
|
|
84
|
+
var _render8 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
85
|
+
label: "Background color",
|
|
86
|
+
disabled: true,
|
|
87
|
+
onChange: function onChange() {}
|
|
88
|
+
})),
|
|
89
|
+
getByRole = _render8.getByRole;
|
|
90
|
+
var expander = getByRole('button');
|
|
91
|
+
_react.fireEvent.click(expander);
|
|
92
|
+
expect(expander).toHaveAttribute('aria-expanded', 'false');
|
|
93
|
+
expect(expander).toHaveAttribute('aria-disabled', 'true');
|
|
94
|
+
});
|
|
95
|
+
it('should not open on Enter', function () {
|
|
96
|
+
var _render9 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
97
|
+
label: "Background color",
|
|
98
|
+
disabled: true,
|
|
99
|
+
onChange: function onChange() {}
|
|
100
|
+
})),
|
|
101
|
+
getByRole = _render9.getByRole;
|
|
102
|
+
var expander = getByRole('button');
|
|
103
|
+
_react.fireEvent.keyDown(expander, {
|
|
104
|
+
key: 'Enter',
|
|
105
|
+
keyCode: 13
|
|
106
|
+
});
|
|
107
|
+
expect(expander).toHaveAttribute('aria-expanded', 'false');
|
|
108
|
+
});
|
|
109
|
+
it('should stay closed once re-enabled if it was open when disabled', function () {
|
|
110
|
+
var _render0 = (0, _react.render)(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
111
|
+
label: "Background color",
|
|
112
|
+
onChange: function onChange() {}
|
|
113
|
+
})),
|
|
114
|
+
getByRole = _render0.getByRole,
|
|
115
|
+
rerender = _render0.rerender;
|
|
116
|
+
_react.fireEvent.click(getByRole('button'));
|
|
117
|
+
rerender(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
118
|
+
label: "Background color",
|
|
119
|
+
disabled: true,
|
|
120
|
+
onChange: function onChange() {}
|
|
121
|
+
}));
|
|
122
|
+
rerender(/*#__PURE__*/(0, _jsxRuntime.jsx)(_["default"], {
|
|
123
|
+
label: "Background color",
|
|
124
|
+
onChange: function onChange() {}
|
|
125
|
+
}));
|
|
126
|
+
expect(getByRole('button')).toHaveAttribute('aria-expanded', 'false');
|
|
127
|
+
});
|
|
128
|
+
});
|
|
82
129
|
});
|
|
@@ -8,25 +8,28 @@
|
|
|
8
8
|
.newspack-color-picker {
|
|
9
9
|
position: relative;
|
|
10
10
|
&__expander {
|
|
11
|
-
box-shadow: inset 0 0 0
|
|
12
|
-
border-radius: wp-vars.$radius-small;
|
|
13
|
-
height: wp-vars.$grid-unit-
|
|
14
|
-
|
|
15
|
-
|
|
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-
|
|
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:
|
|
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:
|
|
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;
|
|
@@ -41,9 +41,9 @@ var Divider = function Divider(_ref) {
|
|
|
41
41
|
_ref$className = _ref.className,
|
|
42
42
|
className = _ref$className === void 0 ? undefined : _ref$className,
|
|
43
43
|
_ref$marginBottom = _ref.marginBottom,
|
|
44
|
-
marginBottom = _ref$marginBottom === void 0 ?
|
|
44
|
+
marginBottom = _ref$marginBottom === void 0 ? 48 : _ref$marginBottom,
|
|
45
45
|
_ref$marginTop = _ref.marginTop,
|
|
46
|
-
marginTop = _ref$marginTop === void 0 ?
|
|
46
|
+
marginTop = _ref$marginTop === void 0 ? 48 : _ref$marginTop,
|
|
47
47
|
_ref$variant = _ref.variant,
|
|
48
48
|
variant = _ref$variant === void 0 ? 'default' : _ref$variant,
|
|
49
49
|
otherProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|