@automattic/jetpack-components 2.1.1 → 2.3.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 +13 -0
- package/build/components/action-button/index.d.ts +1 -1
- package/build/components/action-popover/index.d.ts +1 -1
- package/build/components/boost-score-graph/uplot-line-chart.d.ts +1 -1
- package/build/components/decorative-card/index.d.ts +1 -1
- package/build/components/details-viewer/index.d.ts +1 -1
- package/build/components/diff-viewer/index.d.ts +1 -1
- package/build/components/dot-pager/index.d.ts +1 -1
- package/build/components/global-notices/global-notices.d.ts +1 -1
- package/build/components/gravatar/index.js +47 -1
- package/build/components/loading-placeholder/index.d.ts +1 -1
- package/build/components/marked-lines/index.d.ts +1 -1
- package/build/components/navigator-modal/footer.d.ts +1 -1
- package/build/components/navigator-modal/header.d.ts +1 -1
- package/build/components/navigator-modal/index.d.ts +1 -1
- package/build/components/navigator-modal/screen.d.ts +1 -1
- package/build/components/stat-card/index.d.ts +1 -1
- package/build/components/swipeable/index.d.ts +1 -1
- package/build/components/upsell-banner/index.d.ts +1 -0
- package/build/components/upsell-banner/index.js +8 -2
- package/build/components/upsell-banner/style.scss +8 -0
- package/build/components/upsell-banner/types.d.ts +4 -0
- package/components/gravatar/index.tsx +50 -1
- package/components/upsell-banner/index.tsx +19 -0
- package/components/upsell-banner/style.scss +8 -0
- package/components/upsell-banner/types.ts +4 -0
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
### This is a list detailing changes for the Jetpack RNA Components package releases.
|
|
4
4
|
|
|
5
|
+
## [2.3.0] - 2026-09-01
|
|
6
|
+
### Added
|
|
7
|
+
- Upsell Banner: Add an optional dismiss button. [#51441]
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- Update package dependencies. [#51303] [#51802]
|
|
11
|
+
|
|
12
|
+
## [2.2.0] - 2026-08-19
|
|
13
|
+
### Added
|
|
14
|
+
- Gravatar: pick a stable Color Studio background color per email for initials identity avatars via bg_color [#50578]
|
|
15
|
+
|
|
5
16
|
## [2.1.1] - 2026-08-06
|
|
6
17
|
### Changed
|
|
7
18
|
- Update package dependencies. [#50509]
|
|
@@ -1901,6 +1912,8 @@
|
|
|
1901
1912
|
### Changed
|
|
1902
1913
|
- Update node version requirement to 14.16.1
|
|
1903
1914
|
|
|
1915
|
+
[2.3.0]: https://github.com/Automattic/jetpack-components/compare/2.2.0...2.3.0
|
|
1916
|
+
[2.2.0]: https://github.com/Automattic/jetpack-components/compare/2.1.1...2.2.0
|
|
1904
1917
|
[2.1.1]: https://github.com/Automattic/jetpack-components/compare/2.1.0...2.1.1
|
|
1905
1918
|
[2.1.0]: https://github.com/Automattic/jetpack-components/compare/2.0.1...2.1.0
|
|
1906
1919
|
[2.0.1]: https://github.com/Automattic/jetpack-components/compare/2.0.0...2.0.1
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Types
|
|
3
3
|
*/
|
|
4
4
|
import { ActionPopoverProps } from './types.ts';
|
|
5
|
-
declare const ActionPopover: ({ hideCloseButton, title, children, step, totalSteps, buttonContent, buttonDisabled, buttonHref, buttonExternalLink, offset, onClose, onClick, ...otherPopoverProps }: ActionPopoverProps) => import("react
|
|
5
|
+
declare const ActionPopover: ({ hideCloseButton, title, children, step, totalSteps, buttonContent, buttonDisabled, buttonHref, buttonExternalLink, offset, onClose, onClick, ...otherPopoverProps }: ActionPopoverProps) => import("react").JSX.Element;
|
|
6
6
|
export default ActionPopover;
|
|
@@ -23,5 +23,5 @@ interface UplotChartProps {
|
|
|
23
23
|
* @param {Annotation[]} props.annotations - The annotations to display in the chart.
|
|
24
24
|
* @return {ReactElement} The JSX element representing the UplotLineChart component.
|
|
25
25
|
*/
|
|
26
|
-
export default function UplotLineChart({ range, periods, annotations }: UplotChartProps): import("react
|
|
26
|
+
export default function UplotLineChart({ range, periods, annotations }: UplotChartProps): import("react").JSX.Element;
|
|
27
27
|
export {};
|
|
@@ -20,5 +20,5 @@ export interface DecorativeCardProps extends Omit<ComponentProps<'div'>, 'childr
|
|
|
20
20
|
* @param {DecorativeCardProps} props - The properties.
|
|
21
21
|
* @return {import('react').ReactNode} - The DecorativeCard component.
|
|
22
22
|
*/
|
|
23
|
-
declare function DecorativeCard({ format, icon, imageUrl, className, ...rest }: DecorativeCardProps): import("react
|
|
23
|
+
declare function DecorativeCard({ format, icon, imageUrl, className, ...rest }: DecorativeCardProps): import("react").JSX.Element;
|
|
24
24
|
export default DecorativeCard;
|
|
@@ -10,5 +10,5 @@ type DotPagerProps = {
|
|
|
10
10
|
tracksPrefix?: string;
|
|
11
11
|
tracksFn?: (eventName: string, data?: Record<string, unknown>) => void;
|
|
12
12
|
};
|
|
13
|
-
declare const DotPager: ({ hasDynamicHeight, children, className, onPageSelected, isClickEnabled, rotateTime, tracksPrefix, tracksFn, ...props }: DotPagerProps) => import("react
|
|
13
|
+
declare const DotPager: ({ hasDynamicHeight, children, className, onPageSelected, isClickEnabled, rotateTime, tracksPrefix, tracksFn, ...props }: DotPagerProps) => import("react").JSX.Element;
|
|
14
14
|
export default DotPager;
|
|
@@ -8,4 +8,4 @@ export type GlobalNoticesProps = {
|
|
|
8
8
|
*
|
|
9
9
|
* @return {import('react').ReactNode} The rendered notices list.
|
|
10
10
|
*/
|
|
11
|
-
export declare function GlobalNotices({ maxVisibleNotices }: GlobalNoticesProps): import("react
|
|
11
|
+
export declare function GlobalNotices({ maxVisibleNotices }: GlobalNoticesProps): import("react").JSX.Element;
|
|
@@ -9,6 +9,51 @@ import { __ } from '@wordpress/i18n';
|
|
|
9
9
|
import clsx from 'clsx';
|
|
10
10
|
import { sha256 } from 'js-sha256';
|
|
11
11
|
import './style.scss';
|
|
12
|
+
/**
|
|
13
|
+
* Background colors for the "initials" identity avatars, drawn from the
|
|
14
|
+
* Color Studio palette's 50 shades (https://color-studio.blog/).
|
|
15
|
+
*
|
|
16
|
+
* Only the 50-level shades are safe here: the white initials clear WCAG AA
|
|
17
|
+
* against them, and the warmer ones (orange, yellow, green, celadon) sit right
|
|
18
|
+
* on the 4.5:1 line. Swapping in a lighter tint would quietly drop below AA.
|
|
19
|
+
*
|
|
20
|
+
* Keep in sync with `Feedback_Author::IDENTITY_BG_COLORS` in
|
|
21
|
+
* projects/packages/forms/src/contact-form/class-feedback-author.php, which
|
|
22
|
+
* colors the same authors in the response notification emails. The hexes are
|
|
23
|
+
* spelled out rather than imported from `@automattic/color-studio` on purpose:
|
|
24
|
+
* PHP can't read node_modules at runtime, so importing here would let the two
|
|
25
|
+
* halves drift apart invisibly instead of visibly.
|
|
26
|
+
*
|
|
27
|
+
* Hex values without the leading `#`, as Gravatar's `bg_color` param expects.
|
|
28
|
+
*/
|
|
29
|
+
const IDENTITY_BG_COLORS = [
|
|
30
|
+
'3858e9', // Blue 50
|
|
31
|
+
'984a9c', // Purple 50
|
|
32
|
+
'c9356e', // Pink 50
|
|
33
|
+
'd63638', // Red 50
|
|
34
|
+
'b26200', // Orange 50
|
|
35
|
+
'9d6e00', // Yellow 50
|
|
36
|
+
'008a20', // Green 50
|
|
37
|
+
'008763', // Celadon 50
|
|
38
|
+
];
|
|
39
|
+
/**
|
|
40
|
+
* Picks a stable background color for an email's identity avatar, so the same
|
|
41
|
+
* address always renders on the same Color Studio color.
|
|
42
|
+
*
|
|
43
|
+
* Uses the first 8 hex chars of the normalized email's SHA-256, matching
|
|
44
|
+
* `Feedback_Author::get_identity_background_color()` in the Forms package.
|
|
45
|
+
*
|
|
46
|
+
* Any stable string works: the Forms dashboard falls back to the visitor's IP
|
|
47
|
+
* address for responses submitted without an email.
|
|
48
|
+
*
|
|
49
|
+
* @param email - Email address the avatar is rendered for.
|
|
50
|
+
* @return A hex color from IDENTITY_BG_COLORS.
|
|
51
|
+
*/
|
|
52
|
+
function getIdentityBackgroundColor(email) {
|
|
53
|
+
const hash = sha256(email.trim().toLowerCase());
|
|
54
|
+
const index = parseInt(hash.slice(0, 8), 16) % IDENTITY_BG_COLORS.length;
|
|
55
|
+
return IDENTITY_BG_COLORS[index];
|
|
56
|
+
}
|
|
12
57
|
/**
|
|
13
58
|
* Renders a Gravatar profile image with an optional Gravatar profile hovercard.
|
|
14
59
|
*
|
|
@@ -64,5 +109,6 @@ export default function Gravatar({ defaultImage = 'initials', displayName, email
|
|
|
64
109
|
}
|
|
65
110
|
const hashedEmail = sha256(email);
|
|
66
111
|
const hovercardName = displayName ? `&name=${encodeURIComponent(displayName)}` : '';
|
|
67
|
-
|
|
112
|
+
const bgColorParam = defaultImage === 'initials' ? `&bg_color=${getIdentityBackgroundColor(email)}` : '';
|
|
113
|
+
return (_jsx("img", { ref: profileImageRef, className: clsx('jetpack-components-gravatar', className), alt: displayName || '', src: `https://secure.gravatar.com/avatar/${hashedEmail}?d=${defaultImage}${hovercardName}${bgColorParam}`, width: size, height: size, loading: "lazy" }));
|
|
68
114
|
}
|
|
@@ -12,4 +12,4 @@ export type FooterProps = React.HTMLAttributes<HTMLDivElement> & {
|
|
|
12
12
|
*
|
|
13
13
|
* @return The rendered footer.
|
|
14
14
|
*/
|
|
15
|
-
export declare function Footer({ children, actions, isScreenLocked, className, ...props }: FooterProps): import("react
|
|
15
|
+
export declare function Footer({ children, actions, isScreenLocked, className, ...props }: FooterProps): import("react").JSX.Element;
|
|
@@ -26,4 +26,4 @@ export type HeaderProps = {
|
|
|
26
26
|
*
|
|
27
27
|
* @return component
|
|
28
28
|
*/
|
|
29
|
-
export declare function Header({ icon, title, isScreenLocked, onGoBack: onGoBackProp, onClose: onCloseProp, }: HeaderProps): import("react
|
|
29
|
+
export declare function Header({ icon, title, isScreenLocked, onGoBack: onGoBackProp, onClose: onCloseProp, }: HeaderProps): import("react").JSX.Element;
|
|
@@ -11,7 +11,7 @@ type NavigatorModalProps = Omit<ModalProps, 'onRequestClose'> & TNavigatorModalC
|
|
|
11
11
|
*
|
|
12
12
|
* @return Component
|
|
13
13
|
*/
|
|
14
|
-
declare function NavigatorModalMain({ children, className, initialPath, onClose, isDismissible, ...props }: NavigatorModalProps): import("react
|
|
14
|
+
declare function NavigatorModalMain({ children, className, initialPath, onClose, isDismissible, ...props }: NavigatorModalProps): import("react").JSX.Element;
|
|
15
15
|
export declare const NavigatorModal: typeof NavigatorModalMain & {
|
|
16
16
|
Screen: typeof Screen & {
|
|
17
17
|
displayName: string;
|
|
@@ -42,4 +42,4 @@ export type ScreenProps = Omit<React.ComponentProps<typeof Navigator.Screen>, 'c
|
|
|
42
42
|
*
|
|
43
43
|
* @return The rendered screen.
|
|
44
44
|
*/
|
|
45
|
-
export declare function Screen({ path, className, title, sidebar, headerIcon, isScreenLocked, onGoBack, onClose, footerContent, footerActions, children, content, ...props }: ScreenProps): import("react
|
|
45
|
+
export declare function Screen({ path, className, title, sidebar, headerIcon, isScreenLocked, onGoBack, onClose, footerContent, footerActions, children, content, ...props }: ScreenProps): import("react").JSX.Element;
|
|
@@ -5,5 +5,5 @@ import { StatCardProps } from './types.ts';
|
|
|
5
5
|
* @param {StatCardProps} props - Component props.
|
|
6
6
|
* @return {ReactNode} - StatCard react component.
|
|
7
7
|
*/
|
|
8
|
-
declare const StatCard: ({ className, hideValue, icon, label, value, variant, }: StatCardProps) => import("react
|
|
8
|
+
declare const StatCard: ({ className, hideValue, icon, label, value, variant, }: StatCardProps) => import("react").JSX.Element;
|
|
9
9
|
export default StatCard;
|
|
@@ -6,6 +6,7 @@ import './style.scss';
|
|
|
6
6
|
*
|
|
7
7
|
* - The primary CTA is the second button, at the right position.
|
|
8
8
|
* - The secondary CTA is the first button, at the left position.
|
|
9
|
+
* - Passing `onDismiss` renders a close button in the top corner of the banner.
|
|
9
10
|
*
|
|
10
11
|
* @param {UpsellBannerProps} props - Component props.
|
|
11
12
|
* @return {ReactNode} - UpsellBanner component.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Card, CardBody } from '@wordpress/components';
|
|
3
3
|
import { createInterpolateElement } from '@wordpress/element';
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { close } from '@wordpress/icons';
|
|
4
6
|
import Button from '../button/index.js';
|
|
5
7
|
import './style.scss';
|
|
6
8
|
/**
|
|
@@ -8,13 +10,17 @@ import './style.scss';
|
|
|
8
10
|
*
|
|
9
11
|
* - The primary CTA is the second button, at the right position.
|
|
10
12
|
* - The secondary CTA is the first button, at the left position.
|
|
13
|
+
* - Passing `onDismiss` renders a close button in the top corner of the banner.
|
|
11
14
|
*
|
|
12
15
|
* @param {UpsellBannerProps} props - Component props.
|
|
13
16
|
* @return {ReactNode} - UpsellBanner component.
|
|
14
17
|
*/
|
|
15
18
|
const UpsellBanner = props => {
|
|
16
|
-
const { icon, title, description, primaryCtaLabel, primaryCtaURL, primaryCtaIsExternalLink, primaryCtaOnClick, secondaryCtaLabel, secondaryCtaURL, secondaryCtaIsExternalLink, secondaryCtaOnClick, } = props;
|
|
17
|
-
return (_jsx(Card, { isRounded: true, size: "large", children: _jsxs(CardBody, { className: "upsell-banner", size: "large", children: [
|
|
19
|
+
const { icon, title, description, primaryCtaLabel, primaryCtaURL, primaryCtaIsExternalLink, primaryCtaOnClick, secondaryCtaLabel, secondaryCtaURL, secondaryCtaIsExternalLink, secondaryCtaOnClick, onDismiss, dismissLabel, } = props;
|
|
20
|
+
return (_jsx(Card, { isRounded: true, size: "large", children: _jsxs(CardBody, { className: "upsell-banner", size: "large", children: [onDismiss && (_jsx(Button, { className: "upsell-banner--dismiss", variant: "tertiary", size: "small", icon: close, iconSize: 16,
|
|
21
|
+
// Button wraps its children in a span, so the tooltip an icon-only
|
|
22
|
+
// WPButton would show on its own has to be asked for explicitly.
|
|
23
|
+
showTooltip: true, label: dismissLabel || __('Dismiss', 'jetpack-components'), onClick: onDismiss })), icon && (_jsx("div", { className: "upsell-banner--icon", children: _jsx("img", { src: icon, alt: "" }) })), _jsxs("div", { className: "upsell-banner--content", children: [_jsxs("div", { className: "upsell-banner--content-info", children: [_jsx("h3", { children: title }), _jsx("p", { children: createInterpolateElement(description, {
|
|
18
24
|
br: _jsx("br", {}),
|
|
19
25
|
}) })] }), _jsxs("div", { className: "upsell-banner--content-cta", children: [secondaryCtaLabel && secondaryCtaURL && (_jsx(Button, { className: "upsell-banner--content-cta-button secondary", href: secondaryCtaURL, onClick: secondaryCtaOnClick ?? undefined, isExternalLink: secondaryCtaIsExternalLink, children: secondaryCtaLabel })), primaryCtaLabel && primaryCtaURL && (_jsx(Button, { className: "upsell-banner--content-cta-button primary", href: primaryCtaURL, onClick: primaryCtaOnClick ?? undefined, isExternalLink: primaryCtaIsExternalLink, children: primaryCtaLabel }))] })] })] }) }));
|
|
20
26
|
};
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
.upsell-banner {
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
|
+
position: relative;
|
|
8
9
|
|
|
9
10
|
background: rgb(249, 249, 246);
|
|
10
11
|
background: linear-gradient(133deg, rgb(206, 217, 242) 0%, rgb(249, 249, 246) 10%, rgb(249, 249, 246) 80%, rgb(245, 230, 179) 100%);
|
|
@@ -18,6 +19,13 @@
|
|
|
18
19
|
padding: 36px;
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
.upsell-banner--dismiss.components-button {
|
|
23
|
+
position: absolute;
|
|
24
|
+
inset-block-start: 8px;
|
|
25
|
+
inset-inline-end: 8px;
|
|
26
|
+
color: var(--jp-gray-60);
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
.upsell-banner--icon {
|
|
22
30
|
display: flex;
|
|
23
31
|
align-items: flex-start;
|
|
@@ -10,4 +10,8 @@ export type UpsellBannerProps = {
|
|
|
10
10
|
secondaryCtaURL?: string;
|
|
11
11
|
secondaryCtaIsExternalLink?: boolean;
|
|
12
12
|
secondaryCtaOnClick?: () => void;
|
|
13
|
+
/** Renders a dismiss button in the top corner of the banner when provided. */
|
|
14
|
+
onDismiss?: () => void;
|
|
15
|
+
/** Accessible label for the dismiss button. Defaults to "Dismiss". */
|
|
16
|
+
dismissLabel?: string;
|
|
13
17
|
};
|
|
@@ -23,6 +23,53 @@ type DefaultImage =
|
|
|
23
23
|
| 'robohash'
|
|
24
24
|
| 'wavatar';
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Background colors for the "initials" identity avatars, drawn from the
|
|
28
|
+
* Color Studio palette's 50 shades (https://color-studio.blog/).
|
|
29
|
+
*
|
|
30
|
+
* Only the 50-level shades are safe here: the white initials clear WCAG AA
|
|
31
|
+
* against them, and the warmer ones (orange, yellow, green, celadon) sit right
|
|
32
|
+
* on the 4.5:1 line. Swapping in a lighter tint would quietly drop below AA.
|
|
33
|
+
*
|
|
34
|
+
* Keep in sync with `Feedback_Author::IDENTITY_BG_COLORS` in
|
|
35
|
+
* projects/packages/forms/src/contact-form/class-feedback-author.php, which
|
|
36
|
+
* colors the same authors in the response notification emails. The hexes are
|
|
37
|
+
* spelled out rather than imported from `@automattic/color-studio` on purpose:
|
|
38
|
+
* PHP can't read node_modules at runtime, so importing here would let the two
|
|
39
|
+
* halves drift apart invisibly instead of visibly.
|
|
40
|
+
*
|
|
41
|
+
* Hex values without the leading `#`, as Gravatar's `bg_color` param expects.
|
|
42
|
+
*/
|
|
43
|
+
const IDENTITY_BG_COLORS = [
|
|
44
|
+
'3858e9', // Blue 50
|
|
45
|
+
'984a9c', // Purple 50
|
|
46
|
+
'c9356e', // Pink 50
|
|
47
|
+
'd63638', // Red 50
|
|
48
|
+
'b26200', // Orange 50
|
|
49
|
+
'9d6e00', // Yellow 50
|
|
50
|
+
'008a20', // Green 50
|
|
51
|
+
'008763', // Celadon 50
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Picks a stable background color for an email's identity avatar, so the same
|
|
56
|
+
* address always renders on the same Color Studio color.
|
|
57
|
+
*
|
|
58
|
+
* Uses the first 8 hex chars of the normalized email's SHA-256, matching
|
|
59
|
+
* `Feedback_Author::get_identity_background_color()` in the Forms package.
|
|
60
|
+
*
|
|
61
|
+
* Any stable string works: the Forms dashboard falls back to the visitor's IP
|
|
62
|
+
* address for responses submitted without an email.
|
|
63
|
+
*
|
|
64
|
+
* @param email - Email address the avatar is rendered for.
|
|
65
|
+
* @return A hex color from IDENTITY_BG_COLORS.
|
|
66
|
+
*/
|
|
67
|
+
function getIdentityBackgroundColor( email: string ): string {
|
|
68
|
+
const hash = sha256( email.trim().toLowerCase() );
|
|
69
|
+
const index = parseInt( hash.slice( 0, 8 ), 16 ) % IDENTITY_BG_COLORS.length;
|
|
70
|
+
return IDENTITY_BG_COLORS[ index ];
|
|
71
|
+
}
|
|
72
|
+
|
|
26
73
|
export type GravatarProps = {
|
|
27
74
|
/**
|
|
28
75
|
* Style of the placeholder image when the email has no Gravatar profile.
|
|
@@ -123,13 +170,15 @@ export default function Gravatar( {
|
|
|
123
170
|
|
|
124
171
|
const hashedEmail = sha256( email );
|
|
125
172
|
const hovercardName = displayName ? `&name=${ encodeURIComponent( displayName ) }` : '';
|
|
173
|
+
const bgColorParam =
|
|
174
|
+
defaultImage === 'initials' ? `&bg_color=${ getIdentityBackgroundColor( email ) }` : '';
|
|
126
175
|
|
|
127
176
|
return (
|
|
128
177
|
<img
|
|
129
178
|
ref={ profileImageRef }
|
|
130
179
|
className={ clsx( 'jetpack-components-gravatar', className ) }
|
|
131
180
|
alt={ displayName || '' }
|
|
132
|
-
src={ `https://secure.gravatar.com/avatar/${ hashedEmail }?d=${ defaultImage }${ hovercardName }` }
|
|
181
|
+
src={ `https://secure.gravatar.com/avatar/${ hashedEmail }?d=${ defaultImage }${ hovercardName }${ bgColorParam }` }
|
|
133
182
|
width={ size }
|
|
134
183
|
height={ size }
|
|
135
184
|
loading="lazy"
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Card, CardBody } from '@wordpress/components';
|
|
2
2
|
import { createInterpolateElement } from '@wordpress/element';
|
|
3
|
+
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { close } from '@wordpress/icons';
|
|
3
5
|
import Button from '../button/index.tsx';
|
|
4
6
|
import { UpsellBannerProps } from './types.ts';
|
|
5
7
|
import type { FC, ReactNode } from 'react';
|
|
@@ -11,6 +13,7 @@ import './style.scss';
|
|
|
11
13
|
*
|
|
12
14
|
* - The primary CTA is the second button, at the right position.
|
|
13
15
|
* - The secondary CTA is the first button, at the left position.
|
|
16
|
+
* - Passing `onDismiss` renders a close button in the top corner of the banner.
|
|
14
17
|
*
|
|
15
18
|
* @param {UpsellBannerProps} props - Component props.
|
|
16
19
|
* @return {ReactNode} - UpsellBanner component.
|
|
@@ -28,11 +31,27 @@ const UpsellBanner: FC< UpsellBannerProps > = props => {
|
|
|
28
31
|
secondaryCtaURL,
|
|
29
32
|
secondaryCtaIsExternalLink,
|
|
30
33
|
secondaryCtaOnClick,
|
|
34
|
+
onDismiss,
|
|
35
|
+
dismissLabel,
|
|
31
36
|
} = props;
|
|
32
37
|
|
|
33
38
|
return (
|
|
34
39
|
<Card isRounded={ true } size="large">
|
|
35
40
|
<CardBody className="upsell-banner" size="large">
|
|
41
|
+
{ onDismiss && (
|
|
42
|
+
<Button
|
|
43
|
+
className="upsell-banner--dismiss"
|
|
44
|
+
variant="tertiary"
|
|
45
|
+
size="small"
|
|
46
|
+
icon={ close }
|
|
47
|
+
iconSize={ 16 }
|
|
48
|
+
// Button wraps its children in a span, so the tooltip an icon-only
|
|
49
|
+
// WPButton would show on its own has to be asked for explicitly.
|
|
50
|
+
showTooltip={ true }
|
|
51
|
+
label={ dismissLabel || __( 'Dismiss', 'jetpack-components' ) }
|
|
52
|
+
onClick={ onDismiss }
|
|
53
|
+
/>
|
|
54
|
+
) }
|
|
36
55
|
{ icon && (
|
|
37
56
|
<div className="upsell-banner--icon">
|
|
38
57
|
<img src={ icon } alt="" />
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
.upsell-banner {
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: column;
|
|
8
|
+
position: relative;
|
|
8
9
|
|
|
9
10
|
background: rgb(249, 249, 246);
|
|
10
11
|
background: linear-gradient(133deg, rgb(206, 217, 242) 0%, rgb(249, 249, 246) 10%, rgb(249, 249, 246) 80%, rgb(245, 230, 179) 100%);
|
|
@@ -18,6 +19,13 @@
|
|
|
18
19
|
padding: 36px;
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
.upsell-banner--dismiss.components-button {
|
|
23
|
+
position: absolute;
|
|
24
|
+
inset-block-start: 8px;
|
|
25
|
+
inset-inline-end: 8px;
|
|
26
|
+
color: var(--jp-gray-60);
|
|
27
|
+
}
|
|
28
|
+
|
|
21
29
|
.upsell-banner--icon {
|
|
22
30
|
display: flex;
|
|
23
31
|
align-items: flex-start;
|
|
@@ -10,4 +10,8 @@ export type UpsellBannerProps = {
|
|
|
10
10
|
secondaryCtaURL?: string;
|
|
11
11
|
secondaryCtaIsExternalLink?: boolean;
|
|
12
12
|
secondaryCtaOnClick?: () => void;
|
|
13
|
+
/** Renders a dismiss button in the top corner of the banner when provided. */
|
|
14
|
+
onDismiss?: () => void;
|
|
15
|
+
/** Accessible label for the dismiss button. Defaults to "Dismiss". */
|
|
16
|
+
dismissLabel?: string;
|
|
13
17
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/jetpack-components",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.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": {
|
|
@@ -74,28 +74,28 @@
|
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@automattic/format-currency": "1.0.1",
|
|
76
76
|
"@automattic/jetpack-api": "^1.0.32",
|
|
77
|
-
"@automattic/jetpack-boost-score-api": "^1.0.
|
|
77
|
+
"@automattic/jetpack-boost-score-api": "^1.0.56",
|
|
78
78
|
"@automattic/jetpack-script-data": "^0.6.6",
|
|
79
|
-
"@automattic/number-formatters": "^1.2.
|
|
79
|
+
"@automattic/number-formatters": "^1.2.8",
|
|
80
80
|
"@babel/runtime": "^7",
|
|
81
81
|
"@gravatar-com/hovercards": "0.16.0",
|
|
82
|
-
"@wordpress/admin-ui": "2.
|
|
82
|
+
"@wordpress/admin-ui": "2.8.0",
|
|
83
83
|
"@wordpress/browserslist-config": "6.51.0",
|
|
84
84
|
"@wordpress/components": "37.0.0",
|
|
85
|
-
"@wordpress/compose": "8.
|
|
85
|
+
"@wordpress/compose": "8.6.0",
|
|
86
86
|
"@wordpress/data": "10.51.0",
|
|
87
87
|
"@wordpress/date": "5.51.0",
|
|
88
88
|
"@wordpress/element": "8.3.0",
|
|
89
89
|
"@wordpress/i18n": "6.24.0",
|
|
90
|
-
"@wordpress/icons": "15.
|
|
90
|
+
"@wordpress/icons": "15.4.0",
|
|
91
91
|
"@wordpress/notices": "5.51.0",
|
|
92
|
-
"@wordpress/theme": "1.
|
|
93
|
-
"@wordpress/ui": "0.
|
|
92
|
+
"@wordpress/theme": "1.2.0",
|
|
93
|
+
"@wordpress/ui": "0.20.0",
|
|
94
94
|
"clsx": "2.1.1",
|
|
95
95
|
"js-sha256": "0.11.1",
|
|
96
96
|
"prop-types": "^15.7.2",
|
|
97
97
|
"qrcode.react": "4.2.0",
|
|
98
|
-
"social-logos": "^3.3.
|
|
98
|
+
"social-logos": "^3.3.19",
|
|
99
99
|
"uplot": "1.6.31",
|
|
100
100
|
"uplot-react": "1.1.4"
|
|
101
101
|
},
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"@testing-library/react": "16.3.2",
|
|
110
110
|
"@testing-library/user-event": "14.6.1",
|
|
111
111
|
"@types/jest": "30.0.0",
|
|
112
|
-
"@types/react": "18.3.
|
|
112
|
+
"@types/react": "18.3.31",
|
|
113
113
|
"@types/react-dom": "18.3.7",
|
|
114
114
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
115
115
|
"jest": "30.4.2",
|