@automattic/jetpack-components 2.0.0 → 2.1.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ### This is a list detailing changes for the Jetpack RNA Components package releases.
4
4
 
5
+ ## [2.1.0] - 2026-08-03
6
+ ### Changed
7
+ - Decorative card: Build on the shared Card component, inline the unlink glyph, and hide the card from assistive technology. [#50861]
8
+
9
+ ## [2.0.1] - 2026-07-27
10
+ ### Changed
11
+ - Update package dependencies. [#50751]
12
+
5
13
  ## [2.0.0] - 2026-07-22
6
14
  ### Removed
7
15
  - Number Slider: remove the NumberSlider component. It wrapped the unmaintained react-slider dependency (which blocked React 19) and had a single consumer; use the WordPress RangeControl component from @wordpress/components directly instead. [#50289]
@@ -1889,6 +1897,8 @@
1889
1897
  ### Changed
1890
1898
  - Update node version requirement to 14.16.1
1891
1899
 
1900
+ [2.1.0]: https://github.com/Automattic/jetpack-components/compare/2.0.1...2.1.0
1901
+ [2.0.1]: https://github.com/Automattic/jetpack-components/compare/2.0.0...2.0.1
1892
1902
  [2.0.0]: https://github.com/Automattic/jetpack-components/compare/1.12.17...2.0.0
1893
1903
  [1.12.17]: https://github.com/Automattic/jetpack-components/compare/1.12.16...1.12.17
1894
1904
  [1.12.16]: https://github.com/Automattic/jetpack-components/compare/1.12.15...1.12.16
@@ -1,11 +1,24 @@
1
- import type { DecorativeCardProps } from './types.ts';
2
- import type { FC } from 'react';
1
+ import type { ComponentProps } from 'react';
3
2
  import './style.scss';
3
+ export interface DecorativeCardProps extends Omit<ComponentProps<'div'>, 'children' | 'aria-hidden'> {
4
+ /**
5
+ * The format of the card (horizontal or vertical)
6
+ */
7
+ format?: 'horizontal' | 'vertical';
8
+ /**
9
+ * Show a glyph in a circle over the centre of the card.
10
+ */
11
+ icon?: 'unlink';
12
+ /**
13
+ * URL for an image to show in the card.
14
+ */
15
+ imageUrl?: string;
16
+ }
4
17
  /**
5
18
  * A decorative card used in the disconnection flow.
6
19
  *
7
20
  * @param {DecorativeCardProps} props - The properties.
8
- * @return {ReactNode} - The DecorativeCard component.
21
+ * @return {import('react').ReactNode} - The DecorativeCard component.
9
22
  */
10
- declare const DecorativeCard: FC<DecorativeCardProps>;
23
+ declare function DecorativeCard({ format, icon, imageUrl, className, ...rest }: DecorativeCardProps): import("react/jsx-runtime").JSX.Element;
11
24
  export default DecorativeCard;
@@ -1,13 +1,14 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Card, Stack } from '@wordpress/ui';
3
+ import clsx from 'clsx';
2
4
  import './style.scss';
3
5
  /**
4
6
  * A decorative card used in the disconnection flow.
5
7
  *
6
8
  * @param {DecorativeCardProps} props - The properties.
7
- * @return {ReactNode} - The DecorativeCard component.
9
+ * @return {import('react').ReactNode} - The DecorativeCard component.
8
10
  */
9
- const DecorativeCard = ({ format = 'horizontal', icon, imageUrl }) => {
10
- return (_jsxs("div", { className: 'jp-components__decorative-card ' +
11
- (format ? 'jp-components__decorative-card--' + format : ''), children: [_jsx("div", { className: "jp-components__decorative-card__image", style: { backgroundImage: imageUrl ? `url( ${imageUrl} )` : '' } }), _jsx("div", { className: "jp-components__decorative-card__content", children: _jsx("div", { className: "jp-components__decorative-card__lines" }) }), icon ? (_jsx("div", { className: "jp-components__decorative-card__icon-container", children: _jsx("span", { className: 'jp-components__decorative-card__icon jp-components__decorative-card__icon--' + icon }) })) : null] }));
12
- };
11
+ function DecorativeCard({ format = 'horizontal', icon, imageUrl, className, ...rest }) {
12
+ return (_jsxs(Card.Root, { "data-testid": "decorative-card", ...rest, "aria-hidden": "true", className: clsx('jp-components__decorative-card', `jp-components__decorative-card--${format}`, className), children: [_jsx("div", { className: "jp-components__decorative-card__image", "data-testid": "decorative-card_image", style: { backgroundImage: imageUrl ? `url(${imageUrl})` : undefined } }), icon === 'unlink' && (_jsx("div", { className: "jp-components__decorative-card__icon-container", children: _jsxs("svg", { className: "jp-components__decorative-card__icon", "data-testid": "decorative-card_icon", width: "34", height: "37", viewBox: "0 0 34 37", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M22.3335 10.001H25.0002C29.4184 10.001 33.0002 13.5827 33.0002 18.001V19.7788C33.0002 24.197 29.4184 27.7788 25.0002 27.7788H22.3335", stroke: "white", strokeWidth: "1.5", strokeLinecap: "square" }), _jsx("path", { d: "M11.6675 27.7783L9.00082 27.7783C4.58254 27.7783 1.00081 24.1966 1.00081 19.7783L1.00081 18.0005C1.00081 13.5823 4.58253 10.0005 9.00081 10.0005L11.6675 10.0005", stroke: "white", strokeWidth: "1.5", strokeLinecap: "square" }), _jsx("path", { d: "M10.9998 19.167L16.9998 19.167", stroke: "white", strokeWidth: "1.5" }), _jsx("path", { d: "M8.99951 35.998L24.9995 0.998048", stroke: "white" })] }) })), _jsx(Card.Content, { className: "jp-components__decorative-card__content", children: _jsxs(Stack, { className: "jp-components__decorative-card__lines", direction: "column", gap: "lg", children: [_jsx("div", { className: "jp-components__decorative-card__line" }), _jsx("div", { className: "jp-components__decorative-card__line" }), _jsx("div", { className: "jp-components__decorative-card__line jp-components__decorative-card__line--short" })] }) })] }));
13
+ }
13
14
  export default DecorativeCard;
@@ -1,9 +1,11 @@
1
1
  @use "@automattic/jetpack-base-styles/style";
2
2
 
3
+ // Size, layout and elevation on top of @wordpress/ui's Card, which supplies the
4
+ // surface itself (border radius, clipping, background).
3
5
  .jp-components__decorative-card {
4
- display: flex;
5
- border-radius: 8px;
6
- overflow: hidden;
6
+ --wp-ui-card-padding: 2rem;
7
+
8
+ border: 0;
7
9
  box-shadow: 0 0 15px var(--jp-gray);
8
10
  position: relative;
9
11
  width: 360px;
@@ -36,7 +38,6 @@
36
38
 
37
39
  &__content {
38
40
  background: #fff;
39
- padding: 2rem;
40
41
  }
41
42
 
42
43
  &__icon-container {
@@ -51,47 +52,30 @@
51
52
  }
52
53
 
53
54
  &__icon {
54
- width: 40px;
55
- height: 40px;
56
55
  position: absolute;
57
56
  top: 50%;
58
57
  left: 50%;
59
58
  transform: translate(-50%, -50%);
60
- background-position: center, center;
61
- background-repeat: no-repeat;
62
-
63
- &--unlink {
64
- background-image: url('data:image/svg+xml,<svg width="34" height="37" viewBox="0 0 34 37" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M22.3335 10.001H25.0002C29.4184 10.001 33.0002 13.5827 33.0002 18.001V19.7788C33.0002 24.197 29.4184 27.7788 25.0002 27.7788H22.3335" stroke="white" stroke-width="1.5" stroke-linecap="square"/> <path d="M11.6675 27.7783L9.00082 27.7783C4.58254 27.7783 1.00081 24.1966 1.00081 19.7783L1.00081 18.0005C1.00081 13.5823 4.58253 10.0005 9.00081 10.0005L11.6675 10.0005" stroke="white" stroke-width="1.5" stroke-linecap="square"/> <path d="M10.9998 19.167L16.9998 19.167" stroke="white" stroke-width="1.5"/> <path d="M8.99951 35.998L24.9995 0.998048" stroke="white"/> </svg>');
65
- }
66
59
  }
67
60
 
68
- &__lines {
69
- display: block;
61
+ // The column direction and the 16px gap between bars come from the `Stack`
62
+ // wrapping them.
63
+ &__line {
70
64
  width: 100%;
71
65
  height: 12px;
72
66
  border-radius: 6px;
73
67
  background: #e9eff5;
74
- position: relative;
75
-
76
- &::before,
77
- &::after {
78
- content: "";
79
- display: block;
80
- width: 100%;
81
- height: 12px;
82
- border-radius: 6px;
83
- background: #e9eff5;
84
- position: relative;
85
- top: calc(100% + 16px);
86
- }
87
68
 
88
- &::after {
89
- top: calc(100% + 32px);
69
+ &--short {
90
70
  width: 75%;
91
71
  }
92
72
  }
93
73
 
94
74
  // Variants
75
+ &--horizontal {
76
+ flex-direction: row;
77
+ }
78
+
95
79
  &--vertical {
96
80
  flex-direction: column;
97
81
 
@@ -103,14 +87,11 @@
103
87
 
104
88
  .jp-components__decorative-card__lines {
105
89
  max-width: 135px;
106
- margin-left: auto;
107
- margin-right: auto;
90
+ margin-inline: auto;
91
+ }
108
92
 
109
- &::before,
110
- &::after {
111
- margin-left: auto;
112
- margin-right: auto;
113
- }
93
+ .jp-components__decorative-card__line {
94
+ margin-inline: auto;
114
95
  }
115
96
  }
116
97
  }
@@ -1,40 +1,95 @@
1
- import type { DecorativeCardProps } from './types.ts';
2
- import type { FC, ReactNode } from 'react';
1
+ import { Card, Stack } from '@wordpress/ui';
2
+ import clsx from 'clsx';
3
+ import type { ComponentProps } from 'react';
3
4
  import './style.scss';
4
5
 
6
+ // `children` is omitted: the card renders a fixed set of decorative panes, so
7
+ // there is nowhere to put consumer children. `aria-hidden` is omitted because
8
+ // the component hardcodes it — see the render below.
9
+ export interface DecorativeCardProps
10
+ extends Omit< ComponentProps< 'div' >, 'children' | 'aria-hidden' > {
11
+ /**
12
+ * The format of the card (horizontal or vertical)
13
+ */
14
+ format?: 'horizontal' | 'vertical';
15
+
16
+ /**
17
+ * Show a glyph in a circle over the centre of the card.
18
+ */
19
+ icon?: 'unlink';
20
+
21
+ /**
22
+ * URL for an image to show in the card.
23
+ */
24
+ imageUrl?: string;
25
+ }
26
+
5
27
  /**
6
28
  * A decorative card used in the disconnection flow.
7
29
  *
8
30
  * @param {DecorativeCardProps} props - The properties.
9
- * @return {ReactNode} - The DecorativeCard component.
31
+ * @return {import('react').ReactNode} - The DecorativeCard component.
10
32
  */
11
-
12
- const DecorativeCard: FC< DecorativeCardProps > = ( { format = 'horizontal', icon, imageUrl } ) => {
33
+ function DecorativeCard( {
34
+ format = 'horizontal',
35
+ icon,
36
+ imageUrl,
37
+ className,
38
+ ...rest
39
+ }: DecorativeCardProps ) {
13
40
  return (
14
- <div
15
- className={
16
- 'jp-components__decorative-card ' +
17
- ( format ? 'jp-components__decorative-card--' + format : '' )
18
- }
41
+ <Card.Root
42
+ data-testid="decorative-card"
43
+ { ...rest }
44
+ aria-hidden="true"
45
+ className={ clsx(
46
+ 'jp-components__decorative-card',
47
+ `jp-components__decorative-card--${ format }`,
48
+ className
49
+ ) }
19
50
  >
20
51
  <div
21
52
  className="jp-components__decorative-card__image"
22
- style={ { backgroundImage: imageUrl ? `url( ${ imageUrl } )` : '' } }
23
- ></div>
24
- <div className="jp-components__decorative-card__content">
25
- <div className="jp-components__decorative-card__lines"></div>
26
- </div>
27
- { icon ? (
53
+ data-testid="decorative-card_image"
54
+ style={ { backgroundImage: imageUrl ? `url(${ imageUrl })` : undefined } }
55
+ />
56
+ { icon === 'unlink' && (
28
57
  <div className="jp-components__decorative-card__icon-container">
29
- <span
30
- className={
31
- 'jp-components__decorative-card__icon jp-components__decorative-card__icon--' + icon
32
- }
33
- ></span>
58
+ <svg
59
+ className="jp-components__decorative-card__icon"
60
+ data-testid="decorative-card_icon"
61
+ width="34"
62
+ height="37"
63
+ viewBox="0 0 34 37"
64
+ fill="none"
65
+ xmlns="http://www.w3.org/2000/svg"
66
+ >
67
+ <path
68
+ d="M22.3335 10.001H25.0002C29.4184 10.001 33.0002 13.5827 33.0002 18.001V19.7788C33.0002 24.197 29.4184 27.7788 25.0002 27.7788H22.3335"
69
+ stroke="white"
70
+ strokeWidth="1.5"
71
+ strokeLinecap="square"
72
+ />
73
+ <path
74
+ d="M11.6675 27.7783L9.00082 27.7783C4.58254 27.7783 1.00081 24.1966 1.00081 19.7783L1.00081 18.0005C1.00081 13.5823 4.58253 10.0005 9.00081 10.0005L11.6675 10.0005"
75
+ stroke="white"
76
+ strokeWidth="1.5"
77
+ strokeLinecap="square"
78
+ />
79
+ <path d="M10.9998 19.167L16.9998 19.167" stroke="white" strokeWidth="1.5" />
80
+ <path d="M8.99951 35.998L24.9995 0.998048" stroke="white" />
81
+ </svg>
34
82
  </div>
35
- ) : null }
36
- </div>
83
+ ) }
84
+ <Card.Content className="jp-components__decorative-card__content">
85
+ <Stack className="jp-components__decorative-card__lines" direction="column" gap="lg">
86
+ <div className="jp-components__decorative-card__line" />
87
+ <div className="jp-components__decorative-card__line" />
88
+ <div className="jp-components__decorative-card__line jp-components__decorative-card__line--short" />
89
+ </Stack>
90
+ </Card.Content>
91
+ </Card.Root>
37
92
  );
38
- };
93
+ }
39
94
 
40
95
  export default DecorativeCard;
@@ -1,9 +1,11 @@
1
1
  @use "@automattic/jetpack-base-styles/style";
2
2
 
3
+ // Size, layout and elevation on top of @wordpress/ui's Card, which supplies the
4
+ // surface itself (border radius, clipping, background).
3
5
  .jp-components__decorative-card {
4
- display: flex;
5
- border-radius: 8px;
6
- overflow: hidden;
6
+ --wp-ui-card-padding: 2rem;
7
+
8
+ border: 0;
7
9
  box-shadow: 0 0 15px var(--jp-gray);
8
10
  position: relative;
9
11
  width: 360px;
@@ -36,7 +38,6 @@
36
38
 
37
39
  &__content {
38
40
  background: #fff;
39
- padding: 2rem;
40
41
  }
41
42
 
42
43
  &__icon-container {
@@ -51,47 +52,30 @@
51
52
  }
52
53
 
53
54
  &__icon {
54
- width: 40px;
55
- height: 40px;
56
55
  position: absolute;
57
56
  top: 50%;
58
57
  left: 50%;
59
58
  transform: translate(-50%, -50%);
60
- background-position: center, center;
61
- background-repeat: no-repeat;
62
-
63
- &--unlink {
64
- background-image: url('data:image/svg+xml,<svg width="34" height="37" viewBox="0 0 34 37" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M22.3335 10.001H25.0002C29.4184 10.001 33.0002 13.5827 33.0002 18.001V19.7788C33.0002 24.197 29.4184 27.7788 25.0002 27.7788H22.3335" stroke="white" stroke-width="1.5" stroke-linecap="square"/> <path d="M11.6675 27.7783L9.00082 27.7783C4.58254 27.7783 1.00081 24.1966 1.00081 19.7783L1.00081 18.0005C1.00081 13.5823 4.58253 10.0005 9.00081 10.0005L11.6675 10.0005" stroke="white" stroke-width="1.5" stroke-linecap="square"/> <path d="M10.9998 19.167L16.9998 19.167" stroke="white" stroke-width="1.5"/> <path d="M8.99951 35.998L24.9995 0.998048" stroke="white"/> </svg>');
65
- }
66
59
  }
67
60
 
68
- &__lines {
69
- display: block;
61
+ // The column direction and the 16px gap between bars come from the `Stack`
62
+ // wrapping them.
63
+ &__line {
70
64
  width: 100%;
71
65
  height: 12px;
72
66
  border-radius: 6px;
73
67
  background: #e9eff5;
74
- position: relative;
75
-
76
- &::before,
77
- &::after {
78
- content: "";
79
- display: block;
80
- width: 100%;
81
- height: 12px;
82
- border-radius: 6px;
83
- background: #e9eff5;
84
- position: relative;
85
- top: calc(100% + 16px);
86
- }
87
68
 
88
- &::after {
89
- top: calc(100% + 32px);
69
+ &--short {
90
70
  width: 75%;
91
71
  }
92
72
  }
93
73
 
94
74
  // Variants
75
+ &--horizontal {
76
+ flex-direction: row;
77
+ }
78
+
95
79
  &--vertical {
96
80
  flex-direction: column;
97
81
 
@@ -103,14 +87,11 @@
103
87
 
104
88
  .jp-components__decorative-card__lines {
105
89
  max-width: 135px;
106
- margin-left: auto;
107
- margin-right: auto;
90
+ margin-inline: auto;
91
+ }
108
92
 
109
- &::before,
110
- &::after {
111
- margin-left: auto;
112
- margin-right: auto;
113
- }
93
+ .jp-components__decorative-card__line {
94
+ margin-inline: auto;
114
95
  }
115
96
  }
116
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/jetpack-components",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Jetpack Components Package",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/components/#readme",
6
6
  "bugs": {
@@ -120,7 +120,7 @@
120
120
  "ts-dedent": "2.2.0",
121
121
  "typescript": "6.0.3",
122
122
  "webpack": "5.107.2",
123
- "webpack-cli": "6.0.1"
123
+ "webpack-cli": "7.2.1"
124
124
  },
125
125
  "peerDependencies": {
126
126
  "react": "^18.0.0",
@@ -1,14 +0,0 @@
1
- export type DecorativeCardProps = {
2
- /**
3
- * The format of the card (horizontal or vertical)
4
- */
5
- format?: 'horizontal' | 'vertical';
6
- /**
7
- * An icon slug that can be used to show an icon (options are limited to what is in the stylesheet)
8
- */
9
- icon?: 'unlink';
10
- /**
11
- * URL for an image to show in the card.
12
- */
13
- imageUrl?: string;
14
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,16 +0,0 @@
1
- export type DecorativeCardProps = {
2
- /**
3
- * The format of the card (horizontal or vertical)
4
- */
5
- format?: 'horizontal' | 'vertical';
6
-
7
- /**
8
- * An icon slug that can be used to show an icon (options are limited to what is in the stylesheet)
9
- */
10
- icon?: 'unlink';
11
-
12
- /**
13
- * URL for an image to show in the card.
14
- */
15
- imageUrl?: string;
16
- };