refactor: Setting redesign (#11124)

Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
Udit TakkarandPeer Richelsen authored and Alex van Andel committed 2023-09-29 15:10:13 +01:00
1 parent 85a1713897
commit 685be1663e
33 files changed
+1184 -782

No files matched your search

+4 -2
View File
@@ -9,6 +9,7 @@ type MetaType = {
description: string;
backButton?: boolean;
CTA?: ReactNode;
borderInShellHeader?: boolean;
};
const initialMeta: MetaType = {
@@ -16,6 +17,7 @@ const initialMeta: MetaType = {
description: "",
backButton: false,
CTA: null,
borderInShellHeader: true,
};
const MetaContext = createContext({
@@ -44,13 +46,13 @@ export function MetaProvider({ children }: { children: ReactNode }) {
* elsewhere (ie. on a Heading, Title, Subtitle, etc.)
* @example <Meta title="Password" description="Manage settings for your account passwords" />
*/
export default function Meta({ title, description, backButton, CTA }: MetaType) {
export default function Meta({ title, description, backButton, CTA, borderInShellHeader }: MetaType) {
const { setMeta, meta } = useMeta();
/* @TODO: maybe find a way to have this data on first render to prevent flicker */
useEffect(() => {
if (meta.title !== title || meta.description !== description || meta.CTA !== CTA) {
setMeta({ title, description, backButton, CTA });
setMeta({ title, description, backButton, CTA, borderInShellHeader });
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [title, description, backButton, CTA]);