@automattic/jetpack-components 0.52.1 → 0.53.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 +13 -0
- package/components/global-notices/global-notices.tsx +31 -0
- package/components/global-notices/index.ts +3 -0
- package/components/global-notices/styles.module.scss +21 -0
- package/components/global-notices/use-global-notices.ts +37 -0
- package/components/icons/index.tsx +3 -1
- package/components/pricing-card/index.tsx +22 -15
- package/index.ts +1 -0
- package/package.json +2 -1
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
|
+
## [0.53.1] - 2024-05-09
|
|
6
|
+
### Added
|
|
7
|
+
- Added GlobalNotices component and useGlobalNotices hook [#37286]
|
|
8
|
+
|
|
9
|
+
## [0.53.0] - 2024-05-08
|
|
10
|
+
### Added
|
|
11
|
+
- Social: Added add connection modal [#37211]
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
- Jetpack Backup: Add a LoadingPlaceholder while waiting for Jetpack Backup price [#37238]
|
|
15
|
+
|
|
5
16
|
## [0.52.1] - 2024-05-06
|
|
6
17
|
### Changed
|
|
7
18
|
- Updated package dependencies. [#37147] [#37148] [#37160]
|
|
@@ -1012,6 +1023,8 @@
|
|
|
1012
1023
|
### Changed
|
|
1013
1024
|
- Update node version requirement to 14.16.1
|
|
1014
1025
|
|
|
1026
|
+
[0.53.1]: https://github.com/Automattic/jetpack-components/compare/0.53.0...0.53.1
|
|
1027
|
+
[0.53.0]: https://github.com/Automattic/jetpack-components/compare/0.52.1...0.53.0
|
|
1015
1028
|
[0.52.1]: https://github.com/Automattic/jetpack-components/compare/0.52.0...0.52.1
|
|
1016
1029
|
[0.52.0]: https://github.com/Automattic/jetpack-components/compare/0.51.0...0.52.0
|
|
1017
1030
|
[0.51.0]: https://github.com/Automattic/jetpack-components/compare/0.50.5...0.51.0
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { SnackbarList } from '@wordpress/components';
|
|
2
|
+
import styles from './styles.module.scss';
|
|
3
|
+
import { useGlobalNotices } from './use-global-notices';
|
|
4
|
+
|
|
5
|
+
export type GlobalNoticesProps = {
|
|
6
|
+
maxVisibleNotices?: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Renders the global notices.
|
|
11
|
+
*
|
|
12
|
+
* @param {GlobalNoticesProps} props - Component props.
|
|
13
|
+
*
|
|
14
|
+
* @returns {import('react').ReactNode} The rendered notices list.
|
|
15
|
+
*/
|
|
16
|
+
export function GlobalNotices( { maxVisibleNotices = 3 }: GlobalNoticesProps ) {
|
|
17
|
+
const { getNotices, removeNotice } = useGlobalNotices();
|
|
18
|
+
|
|
19
|
+
const snackbarNotices = getNotices()
|
|
20
|
+
.filter( ( { type } ) => type === 'snackbar' )
|
|
21
|
+
// Slices from the tail end of the list.
|
|
22
|
+
.slice( -maxVisibleNotices );
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<SnackbarList
|
|
26
|
+
notices={ snackbarNotices }
|
|
27
|
+
className={ styles[ 'global-notices' ] }
|
|
28
|
+
onRemove={ removeNotice }
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@import '@automattic/jetpack-base-styles/gutenberg-base-styles';
|
|
2
|
+
|
|
3
|
+
.global-notices {
|
|
4
|
+
&:global(.components-snackbar-list) {
|
|
5
|
+
position: fixed;
|
|
6
|
+
inset-block-start: auto; // top
|
|
7
|
+
inset-block-end: 0; // bottom
|
|
8
|
+
inset-inline: 0; // left and right
|
|
9
|
+
|
|
10
|
+
@include break-small {
|
|
11
|
+
width: auto;
|
|
12
|
+
inset-inline: unset; // left and right
|
|
13
|
+
inset-block-start: 4rem;
|
|
14
|
+
inset-inline-end: 1rem;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@include break-medium {
|
|
18
|
+
inset-block-start: 3rem;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
2
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
3
|
+
|
|
4
|
+
type NoticesStore = ReturnType< ( typeof noticesStore )[ 'instantiate' ] >;
|
|
5
|
+
|
|
6
|
+
export type TGlobalNotices = ReturnType< NoticesStore[ 'getActions' ] > &
|
|
7
|
+
ReturnType< NoticesStore[ 'getSelectors' ] >;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The global notices hook.
|
|
11
|
+
*
|
|
12
|
+
* @returns {TGlobalNotices} The global notices selectors and actions.
|
|
13
|
+
*/
|
|
14
|
+
export function useGlobalNotices(): TGlobalNotices {
|
|
15
|
+
const actionCreators = useDispatch( noticesStore );
|
|
16
|
+
const notices = useSelect( select => select( noticesStore ).getNotices(), [] );
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
...actionCreators,
|
|
20
|
+
createNotice( status, content, options ) {
|
|
21
|
+
return actionCreators.createNotice( status, content, { type: 'snackbar', ...options } );
|
|
22
|
+
},
|
|
23
|
+
createErrorNotice( content, options ) {
|
|
24
|
+
return actionCreators.createErrorNotice( content, { type: 'snackbar', ...options } );
|
|
25
|
+
},
|
|
26
|
+
createInfoNotice( content, options ) {
|
|
27
|
+
return actionCreators.createInfoNotice( content, { type: 'snackbar', ...options } );
|
|
28
|
+
},
|
|
29
|
+
createSuccessNotice( content, options ) {
|
|
30
|
+
return actionCreators.createSuccessNotice( content, { type: 'snackbar', ...options } );
|
|
31
|
+
},
|
|
32
|
+
createWarningNotice( content, options ) {
|
|
33
|
+
return actionCreators.createWarningNotice( content, { type: 'snackbar', ...options } );
|
|
34
|
+
},
|
|
35
|
+
getNotices: () => notices,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -278,11 +278,13 @@ export function getIconBySlug< Slug extends IconSlug >( slug: Slug ): IconsMap[
|
|
|
278
278
|
export const SocialServiceIcon: React.FC< {
|
|
279
279
|
serviceName: React.ComponentProps< typeof SocialLogo >[ 'icon' ];
|
|
280
280
|
className?: string;
|
|
281
|
-
|
|
281
|
+
iconSize?: number;
|
|
282
|
+
} > = ( { serviceName, className, iconSize } ) => {
|
|
282
283
|
return (
|
|
283
284
|
<SocialLogo
|
|
284
285
|
className={ classNames( styles.socialIcon, styles[ serviceName ], className ) }
|
|
285
286
|
icon={ serviceName }
|
|
287
|
+
size={ iconSize || 24 }
|
|
286
288
|
/>
|
|
287
289
|
);
|
|
288
290
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getCurrencyObject } from '@automattic/format-currency';
|
|
2
|
+
import { LoadingPlaceholder } from '@automattic/jetpack-components';
|
|
2
3
|
import { Button } from '@wordpress/components';
|
|
3
4
|
import { sprintf, __ } from '@wordpress/i18n';
|
|
4
5
|
import TermsOfService from '../terms-of-service';
|
|
@@ -54,7 +55,7 @@ const PricingCard: React.FC< PricingCardProps > = ( {
|
|
|
54
55
|
) }
|
|
55
56
|
<h1 className="jp-components__pricing-card__title">{ props.title }</h1>
|
|
56
57
|
<div className="jp-components__pricing-card__pricing">
|
|
57
|
-
{ props.priceBefore !== props.priceAfter && (
|
|
58
|
+
{ props.priceBefore !== props.priceAfter && props.priceAfter > 0 ? (
|
|
58
59
|
<div className="jp-components__pricing-card__price-before">
|
|
59
60
|
<span className="jp-components__pricing-card__currency">
|
|
60
61
|
{ currencyObjectBefore.symbol }
|
|
@@ -70,21 +71,27 @@ const PricingCard: React.FC< PricingCardProps > = ( {
|
|
|
70
71
|
) }
|
|
71
72
|
<div className="jp-components__pricing-card__price-strikethrough"></div>
|
|
72
73
|
</div>
|
|
74
|
+
) : (
|
|
75
|
+
<LoadingPlaceholder width="100%" height={ 48 } />
|
|
76
|
+
) }
|
|
77
|
+
{ props.priceAfter > 0 && (
|
|
78
|
+
<>
|
|
79
|
+
<div className="jp-components__pricing-card__price-after">
|
|
80
|
+
<span className="jp-components__pricing-card__currency">
|
|
81
|
+
{ currencyObjectAfter.symbol }
|
|
82
|
+
</span>
|
|
83
|
+
<span className="jp-components__pricing-card__price">
|
|
84
|
+
{ currencyObjectAfter.integer }
|
|
85
|
+
</span>
|
|
86
|
+
{ showPriceDecimals( currencyObjectAfter ) && (
|
|
87
|
+
<span className="jp-components__pricing-card__price-decimal">
|
|
88
|
+
{ currencyObjectAfter.fraction }
|
|
89
|
+
</span>
|
|
90
|
+
) }
|
|
91
|
+
</div>
|
|
92
|
+
<span className="jp-components__pricing-card__price-details">{ priceDetails }</span>
|
|
93
|
+
</>
|
|
73
94
|
) }
|
|
74
|
-
<div className="jp-components__pricing-card__price-after">
|
|
75
|
-
<span className="jp-components__pricing-card__currency">
|
|
76
|
-
{ currencyObjectAfter.symbol }
|
|
77
|
-
</span>
|
|
78
|
-
<span className="jp-components__pricing-card__price">
|
|
79
|
-
{ currencyObjectAfter.integer }
|
|
80
|
-
</span>
|
|
81
|
-
{ showPriceDecimals( currencyObjectAfter ) && (
|
|
82
|
-
<span className="jp-components__pricing-card__price-decimal">
|
|
83
|
-
{ currencyObjectAfter.fraction }
|
|
84
|
-
</span>
|
|
85
|
-
) }
|
|
86
|
-
</div>
|
|
87
|
-
<span className="jp-components__pricing-card__price-details">{ priceDetails }</span>
|
|
88
95
|
</div>
|
|
89
96
|
|
|
90
97
|
{ props.children && (
|
package/index.ts
CHANGED
|
@@ -75,3 +75,4 @@ export { default as ProgressBar } from './components/progress-bar';
|
|
|
75
75
|
export { default as UpsellBanner } from './components/upsell-banner';
|
|
76
76
|
export { getUserLocale, cleanLocale } from './lib/locale';
|
|
77
77
|
export { default as RadioControl } from './components/radio-control';
|
|
78
|
+
export * from './components/global-notices';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/jetpack-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.1",
|
|
4
4
|
"description": "Jetpack Components Package",
|
|
5
5
|
"author": "Automattic",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"@wordpress/element": "5.33.0",
|
|
26
26
|
"@wordpress/i18n": "4.56.0",
|
|
27
27
|
"@wordpress/icons": "9.47.0",
|
|
28
|
+
"@wordpress/notices": "4.24.0",
|
|
28
29
|
"classnames": "2.3.2",
|
|
29
30
|
"prop-types": "^15.7.2",
|
|
30
31
|
"qrcode.react": "3.1.0",
|