@automattic/jetpack-components 0.53.0 → 0.53.2
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 +23 -0
- package/components/global-notices/use-global-notices.ts +37 -0
- package/components/theme-provider/index.tsx +1 -0
- 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.2] - 2024-05-13
|
|
6
|
+
### Added
|
|
7
|
+
- Added --jp-gray-5 as an alias of --jp-gray to the theme [#37327]
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- Fixed notices z-index for global notices when modal is open [#37196]
|
|
11
|
+
|
|
12
|
+
## [0.53.1] - 2024-05-09
|
|
13
|
+
### Added
|
|
14
|
+
- Added GlobalNotices component and useGlobalNotices hook [#37286]
|
|
15
|
+
|
|
5
16
|
## [0.53.0] - 2024-05-08
|
|
6
17
|
### Added
|
|
7
18
|
- Social: Added add connection modal [#37211]
|
|
@@ -1019,6 +1030,8 @@
|
|
|
1019
1030
|
### Changed
|
|
1020
1031
|
- Update node version requirement to 14.16.1
|
|
1021
1032
|
|
|
1033
|
+
[0.53.2]: https://github.com/Automattic/jetpack-components/compare/0.53.1...0.53.2
|
|
1034
|
+
[0.53.1]: https://github.com/Automattic/jetpack-components/compare/0.53.0...0.53.1
|
|
1022
1035
|
[0.53.0]: https://github.com/Automattic/jetpack-components/compare/0.52.1...0.53.0
|
|
1023
1036
|
[0.52.1]: https://github.com/Automattic/jetpack-components/compare/0.52.0...0.52.1
|
|
1024
1037
|
[0.52.0]: https://github.com/Automattic/jetpack-components/compare/0.51.0...0.52.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,23 @@
|
|
|
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
|
+
// Modals have 100000, so this needs to be above them
|
|
10
|
+
z-index: 100001;
|
|
11
|
+
|
|
12
|
+
@include break-small {
|
|
13
|
+
width: auto;
|
|
14
|
+
inset-inline: unset; // left and right
|
|
15
|
+
inset-block-start: 4rem;
|
|
16
|
+
inset-inline-end: 1rem;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@include break-medium {
|
|
20
|
+
inset-block-start: 3rem;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -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
|
+
}
|
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.53.
|
|
3
|
+
"version": "0.53.2",
|
|
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",
|