This repository was archived by the owner on Feb 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
assets/js/base/context/providers/store-notices/components
packages/checkout/registry Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 33 */
44import { SnackbarList } from 'wordpress-components' ;
55import classnames from 'classnames' ;
6+ import { __experimentalApplyCheckoutFilter } from '@woocommerce/blocks-checkout' ;
67
78const SnackbarNoticesContainer = ( {
89 className,
@@ -18,14 +19,19 @@ const SnackbarNoticesContainer = ( {
1819 ( notice ) => notice . type === 'snackbar'
1920 ) ;
2021
22+ const filteredNotices = __experimentalApplyCheckoutFilter ( {
23+ filterName : 'snackbarNotices' ,
24+ defaultValue : snackbarNotices ,
25+ } ) ;
26+
2127 const wrapperClass = classnames (
2228 className ,
2329 'wc-block-components-notices__snackbar'
2430 ) ;
2531
2632 return (
2733 < SnackbarList
28- notices = { snackbarNotices }
34+ notices = { filteredNotices }
2935 className = { wrapperClass }
3036 onRemove = { removeNotice }
3137 />
Original file line number Diff line number Diff line change @@ -116,6 +116,32 @@ interface CartCoupon {
116116 }
117117}
118118```
119+ ### Snackbar notices
120+
121+ There is a snackbar at the bottom of the page used to display notices to the customer, it looks like this:
122+
123+ <img src =" https://user-images.githubusercontent.com/5656702/120882329-d573c100-c5ce-11eb-901b-d7f206f74a66.png " width =300 />
124+
125+ It may be desirable to hide this (by removing it from the array) or to change the text in the notice.
126+
127+ | Filter name | Description | Return type |
128+ | ---| ---| ---|
129+ | ` snackbarNotices ` | An array of notices waiting to be shown in the snackbar | ` SnackbarNotice[] `
130+
131+ These are the relevant members of a ` SnackbarNotice ` object.
132+
133+ ``` typescript
134+ SnackbarNotice {
135+ content : string ;
136+ explicitDismiss : boolean ;
137+ icon : string | null ;
138+ isDismissable : boolean ;
139+ onDismiss : Function ;
140+ spokenMessage : string ;
141+ status : string ;
142+ type : string
143+ }
144+ ```
119145
120146## Examples
121147
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ export const __experimentalApplyCheckoutFilter = < T >( {
7272 /** Values extend to REST API response. */
7373 extensions ?: Record < string , unknown > ;
7474 /** Object containing arguments for the filter function. */
75- arg : CheckoutFilterArguments ;
75+ arg ? : CheckoutFilterArguments ;
7676 /** Function that needs to return true when the filtered value is passed in order for the filter to be applied. */
7777 validation ?: ( value : T ) => true | Error ;
7878} ) : T => {
You can’t perform that action at this time.
0 commit comments