From 81dbfbd68b09f47f56c034ac9fcbb7a7d2a69142 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 30 Sep 2021 02:22:47 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=A5=20Replace=20`useContext`=20with=20?= =?UTF-8?q?`useLookAndFeel`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/theme/LookAndFeelBluelib.tsx | 5 ++--- frontend/src/components/theme/LookAndFeelHeading.tsx | 5 ++--- frontend/src/components/theme/LookAndFeelPageTitle.tsx | 6 ++---- frontend/src/components/theme/SophonFooter.tsx | 5 ++--- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/frontend/src/components/theme/LookAndFeelBluelib.tsx b/frontend/src/components/theme/LookAndFeelBluelib.tsx index 96cd5d9..acab30b 100644 --- a/frontend/src/components/theme/LookAndFeelBluelib.tsx +++ b/frontend/src/components/theme/LookAndFeelBluelib.tsx @@ -1,6 +1,5 @@ import * as React from "react" -import {useContext} from "react"; -import {LookAndFeelContext} from "./LookAndFeel"; +import {useLookAndFeel} from "./LookAndFeel"; import {Bluelib} from "@steffo/bluelib-react"; @@ -10,7 +9,7 @@ interface LookAndFeelBluelibProps { export function LookAndFeelBluelib({children}: LookAndFeelBluelibProps): JSX.Element { - const lookAndFeel = useContext(LookAndFeelContext) + const lookAndFeel = useLookAndFeel() return ( diff --git a/frontend/src/components/theme/LookAndFeelHeading.tsx b/frontend/src/components/theme/LookAndFeelHeading.tsx index 1e96899..e7de503 100644 --- a/frontend/src/components/theme/LookAndFeelHeading.tsx +++ b/frontend/src/components/theme/LookAndFeelHeading.tsx @@ -1,8 +1,7 @@ import * as React from "react" import {HeadingProps} from "@steffo/bluelib-react/dist/components/common/Heading"; import {Heading} from "@steffo/bluelib-react"; -import {useContext} from "react"; -import {LookAndFeelContext} from "./LookAndFeel"; +import {useLookAndFeel} from "./LookAndFeel"; interface LookAndFeelHeadingProps extends HeadingProps { @@ -11,7 +10,7 @@ interface LookAndFeelHeadingProps extends HeadingProps { export function LookAndFeelHeading({...props}: LookAndFeelHeadingProps): JSX.Element { - const lookAndFeel = useContext(LookAndFeelContext) + const lookAndFeel = useLookAndFeel() return ( diff --git a/frontend/src/components/theme/LookAndFeelPageTitle.tsx b/frontend/src/components/theme/LookAndFeelPageTitle.tsx index df39ea5..0ec2462 100644 --- a/frontend/src/components/theme/LookAndFeelPageTitle.tsx +++ b/frontend/src/components/theme/LookAndFeelPageTitle.tsx @@ -1,11 +1,9 @@ import * as React from "react" -import * as ReactDOM from "react-dom" -import {useContext} from "react"; -import {LookAndFeelContext} from "./LookAndFeel"; +import {useLookAndFeel} from "./LookAndFeel"; export function LookAndFeelPageTitle(): null { - const lookAndFeel = useContext(LookAndFeelContext) + const lookAndFeel = useLookAndFeel() React.useEffect( () => { diff --git a/frontend/src/components/theme/SophonFooter.tsx b/frontend/src/components/theme/SophonFooter.tsx index 8b4bd62..81c3c80 100644 --- a/frontend/src/components/theme/SophonFooter.tsx +++ b/frontend/src/components/theme/SophonFooter.tsx @@ -1,7 +1,6 @@ import * as React from "react" -import {useContext} from "react" import {Anchor, Footer} from "@steffo/bluelib-react"; -import {LookAndFeelContext} from "./LookAndFeel"; +import {useLookAndFeel} from "./LookAndFeel"; const FOOTER_COLORS = { @@ -17,7 +16,7 @@ const LICENSE_URL = "https://github.com/Steffo99/sophon/blob/main/LICENSE.txt" export function SophonFooter(): JSX.Element { - const lookAndFeel = useContext(LookAndFeelContext) + const lookAndFeel = useLookAndFeel() const frontendVersion = process.env.REACT_APP_VERSION const backendVersion = lookAndFeel.backendVersion