diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 7aa3eba..49fe774 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,24 +1,21 @@ import * as React from 'react'; import {LayoutThreeCol} from "@steffo/bluelib-react"; import {Router} from "./routes/Router"; -import {InstanceContextProvider} from "./components/legacy/login/InstanceContext"; -import {LoginContextProvider} from "./components/legacy/login/LoginContext"; -import {InstanceBluelib} from "./components/legacy/login/InstanceBluelib"; +import {LookAndFeel} from "./components/theme/LookAndFeel"; -function App() { + +export default function App() { return ( - - - - - - - - - - - + + + + + + + + + + + ); } - -export default App; diff --git a/frontend/src/components/theme/LookAndFeel.tsx b/frontend/src/components/theme/LookAndFeel.tsx new file mode 100644 index 0000000..c671b22 --- /dev/null +++ b/frontend/src/components/theme/LookAndFeel.tsx @@ -0,0 +1,52 @@ +import * as React from "react" +import * as ReactDOM from "react-dom" +import {LookAndFeelBluelib} from "./LookAndFeelBluelib"; +import {LookAndFeelHeading} from "./LookAndFeelHeading"; +import {LookAndFeelPageTitle} from "./LookAndFeelPageTitle"; + + +export interface LookAndFeelState { + bluelibTheme: "sophon" | "royalblue" | "paper" | "hacker", + pageTitle: string, +} + + +export interface LookAndFeelContextData extends LookAndFeelState { + setLookAndFeel: React.Dispatch>, +} + + +export const LookAndFeelContext = React.createContext({ + bluelibTheme: "sophon", + pageTitle: "Sophon", + + setLookAndFeel: () => console.error("Can't setLookAndFeel outside a lookAndFeelContext.") +}) + + +export interface LookAndFeelProps { + children: React.ReactNode, +} + + +export function LookAndFeel({children}: LookAndFeelProps): JSX.Element { + const [lookAndFeel, setLookAndFeel] = + React.useState({ + bluelibTheme: "sophon", + pageTitle: "Sophon", + }) + + return ( + + {children} + + ) +} + + +LookAndFeel.Bluelib = LookAndFeelBluelib +LookAndFeel.Heading = LookAndFeelHeading +LookAndFeel.PageTitle = LookAndFeelPageTitle \ No newline at end of file diff --git a/frontend/src/components/theme/LookAndFeelBluelib.tsx b/frontend/src/components/theme/LookAndFeelBluelib.tsx new file mode 100644 index 0000000..96cd5d9 --- /dev/null +++ b/frontend/src/components/theme/LookAndFeelBluelib.tsx @@ -0,0 +1,20 @@ +import * as React from "react" +import {useContext} from "react"; +import {LookAndFeelContext} from "./LookAndFeel"; +import {Bluelib} from "@steffo/bluelib-react"; + + +interface LookAndFeelBluelibProps { + children: React.ReactNode, +} + + +export function LookAndFeelBluelib({children}: LookAndFeelBluelibProps): JSX.Element { + const lookAndFeel = useContext(LookAndFeelContext) + + return ( + + {children} + + ) +} diff --git a/frontend/src/components/theme/LookAndFeelHeading.tsx b/frontend/src/components/theme/LookAndFeelHeading.tsx new file mode 100644 index 0000000..1e96899 --- /dev/null +++ b/frontend/src/components/theme/LookAndFeelHeading.tsx @@ -0,0 +1,21 @@ +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"; + + +interface LookAndFeelHeadingProps extends HeadingProps { + +} + + +export function LookAndFeelHeading({...props}: LookAndFeelHeadingProps): JSX.Element { + const lookAndFeel = useContext(LookAndFeelContext) + + return ( + + {lookAndFeel.pageTitle} + + ) +} diff --git a/frontend/src/components/theme/LookAndFeelPageTitle.tsx b/frontend/src/components/theme/LookAndFeelPageTitle.tsx new file mode 100644 index 0000000..df39ea5 --- /dev/null +++ b/frontend/src/components/theme/LookAndFeelPageTitle.tsx @@ -0,0 +1,18 @@ +import * as React from "react" +import * as ReactDOM from "react-dom" +import {useContext} from "react"; +import {LookAndFeelContext} from "./LookAndFeel"; + + +export function LookAndFeelPageTitle(): null { + const lookAndFeel = useContext(LookAndFeelContext) + + React.useEffect( + () => { + document.title = lookAndFeel.pageTitle === "Sophon" ? "Sophon" : `${lookAndFeel.pageTitle} - Sophon` + }, + [lookAndFeel.pageTitle] + ) + + return null +}