Skip to content

An open-source, self-hosted system for apps built with web technologies.

Refine client view foundations

zohayrslileh6c98eb06ed94
diff --git a/source/client/index.html b/source/client/index.html
index e184b80..ff6105f 100644
--- a/source/client/index.html
+++ b/source/client/index.html
@@ -8,7 +8,6 @@
</head>
<body>
- <div id="root"></div>
</body>
</html>
diff --git a/source/client/view2/appearance/appearance.tsx b/source/client/view2/appearance/appearance.tsx
index ae06e05..880cf2d 100644
--- a/source/client/view2/appearance/appearance.tsx
+++ b/source/client/view2/appearance/appearance.tsx
@@ -6,11 +6,7 @@ export default function ({ children }: PropsWithChildren) {
return <ThemeProvider attribute="class" defaultTheme="system">
- <main className="grid min-h-dvh place-items-center bg-background font-roboto text-foreground">
-
- {children}
-
- </main>
+ {children}
</ThemeProvider>
}
diff --git a/source/client/view2/structure/structure.tsx b/source/client/view2/structure/structure.tsx
index 700eb2b..c648099 100644
--- a/source/client/view2/structure/structure.tsx
+++ b/source/client/view2/structure/structure.tsx
@@ -1,20 +1,16 @@
import { Switch, SwitchGroup } from "@heroui/react"
-import { useLayoutEffect, useState } from "react"
+import useStorage from "@libs/storage-hook"
import { useTheme } from "next-themes"
-export default function ({ document }: StructureProps) {
+export default function () {
const { resolvedTheme, setTheme } = useTheme()
- const [reversed, setReversed] = useState(false)
+ const direction = useStorage("direction")
- useLayoutEffect(function () {
+ const reversed = direction.value === "rtl"
- document.documentElement.dir = reversed ? "rtl" : "ltr"
-
- }, [document, reversed])
-
- return <section className="grid justify-items-start gap-6">
+ return <main dir={reversed ? "rtl" : "ltr"} className="grid min-h-dvh place-content-center justify-items-start gap-6 bg-background font-roboto text-foreground">
<p className="text-xl font-medium">PhreshOS</p>
@@ -36,7 +32,7 @@ export default function ({ document }: StructureProps) {
</Switch>
- <Switch isSelected={reversed} onChange={setReversed}>
+ <Switch isSelected={reversed} onChange={reversed => direction.update(reversed ? "rtl" : "ltr")}>
<Switch.Content>
@@ -54,10 +50,5 @@ export default function ({ document }: StructureProps) {
</SwitchGroup>
- </section>
-}
-
-interface StructureProps {
-
- document: Document
+ </main>
}
diff --git a/source/client/view2/view.tsx b/source/client/view2/view.tsx
index 6d19adf..b74cfd6 100644
--- a/source/client/view2/view.tsx
+++ b/source/client/view2/view.tsx
@@ -15,13 +15,9 @@ export default function (config: Config) {
config.document.head.appendChild(icon)
- const container = config.document.getElementById("root")
+ client.createRoot(config.document.body).render(<Appearance>
- if (!container) throw new Error("The Client root container is missing")
-
- client.createRoot(container).render(<Appearance>
-
- <Structure document={config.document} />
+ <Structure />
</Appearance>)
}