Skip to content

Commit

Permalink
Directly accesss isDark outside of react
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej authored and JeromeBu committed Dec 11, 2024
1 parent 4ddca61 commit ac5320b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 40 deletions.
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@codegouvfr/react-dsfr": "^1.11.3",
"@codegouvfr/react-dsfr": "^1.16.0",
"@emotion/react": "^11.11.0",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.15.14",
Expand Down
9 changes: 3 additions & 6 deletions web/src/ui/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ import { pages } from "ui/pages";
import { useConst } from "powerhooks/useConst";
import { objectKeys } from "tsafe/objectKeys";
import { assert } from "tsafe/assert";
import { useIsDark } from "@codegouvfr/react-dsfr/useIsDark";
import { getIsDark } from "@codegouvfr/react-dsfr/useIsDark";
import { keyframes } from "tss-react";
import { LoadingFallback, loadingFallbackClassName } from "ui/shared/LoadingFallback";
import { useDomRect } from "powerhooks/useDomRect";
import { apiUrl, appUrl, appPath } from "urls";

let isDark: boolean | undefined = undefined;

const { CoreProvider } = createCoreProvider({
apiUrl,
Expand All @@ -38,15 +37,14 @@ const { CoreProvider } = createCoreProvider({
// TODO: Remove, Not needed in generic keycloak theme
.map(url => addSillApiUrlToQueryParams({ url, "value": apiUrl }))
// TODO: Remove, the query param is dark=true or dark=false in generic keycloak theme
.map(url => addIsDarkToQueryParams({ url, "value": isDark }))
.map(url => addIsDarkToQueryParams({ url, "value": getIsDark() }))
// TODO: Remove, Not implemented in generic keycloak theme
.map(url => addTermsOfServiceUrlToQueryParams({ url, "value": termsOfServiceUrl }))
// TODO: Remove, Not needed in generic keycloak theme, inferred from redirect_uri (redirect to codegouv.fr and not codegouv.fr/sill though)
.map(url => addAppLocationOriginToQueryParams({ url, "value": window.location.origin }))
.map(url => {
assert(isDark !== undefined);
const parsedUrl = new URL(url);
parsedUrl.searchParams.set("dark", `${isDark}`);
parsedUrl.searchParams.set("dark", `${getIsDark()}`);
return parsedUrl.toString();
})
[0],
Expand Down Expand Up @@ -86,7 +84,6 @@ export default function App() {
}

function ContextualizedApp() {
isDark = useIsDark().isDark;

const route = useRoute();

Expand Down
46 changes: 13 additions & 33 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1232,12 +1232,12 @@
exec-sh "^0.3.2"
minimist "^1.2.0"

"@codegouvfr/react-dsfr@^1.11.3":
version "1.14.5"
resolved "https://registry.yarnpkg.com/@codegouvfr/react-dsfr/-/react-dsfr-1.14.5.tgz#ec0d5baedd3cd528950f73f58fc5d02090d50017"
integrity sha512-e9FDhTIsW6+Y90cJlyIYLPgIhZGY5U7Rw0/knGk4CYysLIa7F88GZz+exyY9EDCyjOQ8xFg0VxaXS2MJxxIG6w==
"@codegouvfr/react-dsfr@^1.16.0":
version "1.16.0"
resolved "https://registry.yarnpkg.com/@codegouvfr/react-dsfr/-/react-dsfr-1.16.0.tgz#d99a28be0349aec37c1a5a3ec7392832b2431abf"
integrity sha512-nq1PCojQQboESP/VPprmLPHMuYkYlk3G49ISCDWRN0zJD3MfYK5yyDakwAknLgdN83uJFPZsv4Ll4OiZGzo8wA==
dependencies:
tsafe "^1.7.2"
tsafe "^1.8.5"
yargs-parser "^21.1.1"

"@colors/colors@1.5.0":
Expand Down Expand Up @@ -17065,16 +17065,7 @@ string-natural-compare@^3.0.1:
resolved "https://registry.yarnpkg.com/string-natural-compare/-/string-natural-compare-3.0.1.tgz#7a42d58474454963759e8e8b7ae63d71c1e7fdf4"
integrity sha512-n3sPwynL1nwKi3WJ6AIsClwBMa0zTi54fn2oLU6ndfTSIO05xaznjSf15PcBZU6FNWbmN5Q6cxT4V5hGvB4taw==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -17206,7 +17197,7 @@ stringify-object@^3.3.0:
is-obj "^1.0.1"
is-regexp "^1.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand All @@ -17220,13 +17211,6 @@ strip-ansi@^3.0.1:
dependencies:
ansi-regex "^2.0.0"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
Expand Down Expand Up @@ -17858,6 +17842,11 @@ tsafe@^1.6.0, tsafe@^1.6.5, tsafe@^1.6.6, tsafe@^1.7.2, tsafe@^1.8.4:
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.8.4.tgz#ef2ecb21829eb5003d931de6a80b34303ed907ee"
integrity sha512-k1myNdDFEbqfq2hS7ln4qlgpvRlJq3wkOawQWieqVHu/K7dX+qQHTDkdzfvBBPNFrkIM7S/846JD6B3fm6MWHQ==

tsafe@^1.8.5:
version "1.8.5"
resolved "https://registry.yarnpkg.com/tsafe/-/tsafe-1.8.5.tgz#cdf9fa3111974ac480d7ee519f8241815e5d22ea"
integrity sha512-LFWTWQrW6rwSY+IBNFl2ridGfUzVsPwrZ26T4KUJww/py8rzaQ/SY+MIz6YROozpUCaRcuISqagmlwub9YT9kw==

tsconfig-paths@^3.15.0:
version "3.15.0"
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz#5299ec605e55b1abb23ec939ef15edaf483070d4"
Expand Down Expand Up @@ -19355,16 +19344,7 @@ worker-rpc@^0.1.0:
dependencies:
microevent.ts "~0.1.1"

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down

0 comments on commit ac5320b

Please sign in to comment.