diff --git a/pages/collection-preferences/simple.page.tsx b/pages/collection-preferences/simple.page.tsx index 8a5d4bbd7b..158bf1b1b1 100644 --- a/pages/collection-preferences/simple.page.tsx +++ b/pages/collection-preferences/simple.page.tsx @@ -2,6 +2,8 @@ // SPDX-License-Identifier: Apache-2.0 import * as React from 'react'; +import Alert from '~components/alert'; +import Box from '~components/box'; import CollectionPreferences from '~components/collection-preferences'; import ScreenshotArea from '../utils/screenshot-area'; @@ -29,6 +31,15 @@ export default function CollectionPreferencesPermutations() { visibleContentPreference={visibleContentPreference} stickyColumnsPreference={stickyColumnsPreference} customPreference={customPreference} + contentBefore={ + + + Go to your browser settings to enable local storage. This will persist your settings across sessions + unless your local storage is cleared. If local storage is not enabled preferences are saved in session + storage as a fallback. + + + } /> { wrapper.findModal()!.findConfirmButton()!.click(); expectVisibleModal(wrapper, false); }); + test('is additional content displayed when provided', () => { + const wrapper = renderCollectionPreferences({ + contentBefore: 'Test content before', + }); + wrapper.findTriggerButton().click(); + expect(wrapper.findModal()!.findContentBefore()?.getElement().textContent).toBe('Test content before'); + }); }); describe('Collection preferences - Events', () => { diff --git a/src/collection-preferences/index.tsx b/src/collection-preferences/index.tsx index 93b4a5662b..1688ef7e2b 100644 --- a/src/collection-preferences/index.tsx +++ b/src/collection-preferences/index.tsx @@ -60,6 +60,7 @@ export default function CollectionPreferences({ customPreference, getModalRoot, removeModalRoot, + contentBefore, ...rest }: CollectionPreferencesProps) { const parentMetadata = useContext(CollectionPreferencesMetadata); @@ -181,6 +182,10 @@ export default function CollectionPreferences({ size={hasContentOnTheLeft && hasContentOnTheRight ? 'large' : 'medium'} onDismiss={onCancelListener} > + {/* Content before */} +
{contentBefore}
+ + {/* Preferences content */} extends * The values for all configured preferences are present even if the user didn't change their values. */ onConfirm?: NonCancelableEventHandler>; + /** + * Content displayed before the preferences. Use it to display additional information relating to the preferences. + */ + contentBefore?: React.ReactNode; } export namespace CollectionPreferencesProps { diff --git a/src/collection-preferences/styles.scss b/src/collection-preferences/styles.scss index f330f773b4..211eb389de 100644 --- a/src/collection-preferences/styles.scss +++ b/src/collection-preferences/styles.scss @@ -13,7 +13,8 @@ .trigger-button, .cancel-button, .confirm-button, -.custom { +.custom, +.content-before { /* used in test-utils */ } diff --git a/src/test-utils/dom/collection-preferences/index.ts b/src/test-utils/dom/collection-preferences/index.ts index 21eaf4a987..3a69780118 100644 --- a/src/test-utils/dom/collection-preferences/index.ts +++ b/src/test-utils/dom/collection-preferences/index.ts @@ -55,6 +55,10 @@ class PreferencesModalWrapper extends ModalWrapper { findCustomPreference(): ElementWrapper | null { return this.findByClassName(styles.custom); } + + findContentBefore(): ElementWrapper | null { + return this.findByClassName(styles['content-before']); + } } export default class CollectionPreferencesWrapper extends ComponentWrapper {