File tree 6 files changed +37
-12
lines changed
6 files changed +37
-12
lines changed Original file line number Diff line number Diff line change 1
1
"use client" ;
2
2
3
- import React , { Suspense , lazy } from "react" ;
3
+ import React from "react" ;
4
4
import { ArtworkGov } from "./ArtworkGov" ;
5
5
import { useIsGov } from "../../mui/useIsGov" ;
6
- const ArtworkWhiteLabel = lazy ( ( ) => import ( "./ArtworkWhiteLabel" ) ) ;
6
+ import { useArtworkWhiteLabel } from "./ArtworkWhiteLabel/useArtworkWhiteLabel" ;
7
+ import { assert } from "tsafe/assert" ;
7
8
8
9
export function Artwork ( props : { theme : "light" | "dark" | "system" ; className ?: string } ) {
9
10
const { theme, className } = props ;
10
11
11
12
const { isGov } = useIsGov ( ) ;
13
+ const { ArtworkWhiteLabel } = useArtworkWhiteLabel ( ) ;
12
14
13
15
if ( ! isGov ) {
14
- return (
15
- < Suspense >
16
- < ArtworkWhiteLabel theme = { theme } sizePx = { 80 } />
17
- </ Suspense >
18
- ) ;
16
+ assert ( ArtworkWhiteLabel !== undefined ) ;
17
+
18
+ return < ArtworkWhiteLabel theme = { theme } sizePx = { 80 } /> ;
19
19
}
20
20
21
21
return < ArtworkGov theme = { theme } className = { className } /> ;
Original file line number Diff line number Diff line change @@ -4,10 +4,7 @@ import React from "react";
4
4
import { useTheme } from "@mui/material/styles" ;
5
5
import { assert , type Equals } from "tsafe/assert" ;
6
6
7
- export default function ArtworkWhiteLabel ( props : {
8
- theme : "light" | "dark" | "system" ;
9
- sizePx : number ;
10
- } ) {
7
+ export function ArtworkWhiteLabel ( props : { theme : "light" | "dark" | "system" ; sizePx : number } ) {
11
8
const { theme : theme_mode , sizePx } = props ;
12
9
13
10
const theme = useTheme ( ) ;
Original file line number Diff line number Diff line change
1
+ import React , { type ReactNode } from "react" ;
2
+ import { context } from "./context" ;
3
+ import { ArtworkWhiteLabel } from "./ArtworkWhiteLabel" ;
4
+
5
+ export function DisplayArtworkWhiteLabelProvider ( props : { children : ReactNode } ) {
6
+ const { children } = props ;
7
+
8
+ return < context . Provider value = { ArtworkWhiteLabel } > { children } </ context . Provider > ;
9
+ }
Original file line number Diff line number Diff line change
1
+ import { JSX } from "../../../tools/JSX" ;
2
+ import { createContext } from "react" ;
3
+
4
+ export const context = createContext <
5
+ ( ( props : { theme : "light" | "dark" | "system" ; sizePx : number } ) => JSX . Element ) | undefined
6
+ > ( undefined ) ;
Original file line number Diff line number Diff line change
1
+ import { useContext } from "react" ;
2
+ import { context } from "./context" ;
3
+
4
+ export function useArtworkWhiteLabel ( ) {
5
+ const ArtworkWhiteLabel = useContext ( context ) ;
6
+
7
+ return { ArtworkWhiteLabel } ;
8
+ }
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import { deepAssign } from "../tools/deepAssign";
17
17
import { Global , css } from "@emotion/react" ;
18
18
import { getAssetUrl } from "../tools/getAssetUrl" ;
19
19
import { IsGovProvider } from "./useIsGov" ;
20
+ import { DisplayArtworkWhiteLabelProvider } from "../Display/Artwork/ArtworkWhiteLabel/DisplayArtworkWhiteLabelProvider" ;
20
21
import marianneFaviconSvgUrl from "../dsfr/favicon/favicon.svg" ;
21
22
import blankFaviconSvgUrl from "../assets/blank-favicon.svg" ;
22
23
@@ -597,7 +598,11 @@ export function createDsfrCustomBrandingProvider(params: {
597
598
/>
598
599
) }
599
600
< IsGovProvider isGov = { isGov } >
600
- < mui . ThemeProvider theme = { theme } > { children } </ mui . ThemeProvider >
601
+ < mui . ThemeProvider theme = { theme } >
602
+ < DisplayArtworkWhiteLabelProvider >
603
+ { children }
604
+ </ DisplayArtworkWhiteLabelProvider >
605
+ </ mui . ThemeProvider >
601
606
</ IsGovProvider >
602
607
</ >
603
608
) ;
You can’t perform that action at this time.
0 commit comments