Header/Headerless routes

This commit is contained in:
cohenerickson 2023-12-15 09:35:42 -06:00
parent 396e1f7233
commit 6c5a0f33ae
5 changed files with 71 additions and 55 deletions

View file

@ -0,0 +1,12 @@
import { Header } from "./Header";
export function HeaderRoute(props: { children: any }) {
return (
<div class="flex h-screen flex-col">
<Header />
<div class="flex-1 bg-primary">
<main class="h-full">{props.children}</main>
</div>
</div>
);
}

View file

@ -13,18 +13,11 @@ import "./i18n";
export function App() { export function App() {
return ( return (
<LocationProvider> <LocationProvider>
<div class="flex h-screen flex-col">
<Header />
<div class="flex-1 bg-primary">
<main class="h-full">
<Router> <Router>
<Route path="/" component={Home} /> <Route path="/" component={Home} />
<Route path="/discord" component={DiscordPage} /> <Route path="/discord" component={DiscordPage} />
<Route default component={NotFound} /> <Route default component={NotFound} />
</Router> </Router>
</main>
</div>
</div>
</LocationProvider> </LocationProvider>
); );
} }

View file

@ -1,11 +1,13 @@
import { useState } from "preact/hooks"; import { useState } from "preact/hooks";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { HeaderRoute } from "../components/HeaderRoute";
export function Home() { export function Home() {
const [isFocused, setIsFocused] = useState(false); const [isFocused, setIsFocused] = useState(false);
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<HeaderRoute>
<div class="flex h-full items-center justify-center"> <div class="flex h-full items-center justify-center">
<input <input
onFocus={(e) => { onFocus={(e) => {
@ -19,5 +21,6 @@ export function Home() {
placeholder={isFocused ? "" : t("home.placeholder")} placeholder={isFocused ? "" : t("home.placeholder")}
></input> ></input>
</div> </div>
</HeaderRoute>
); );
} }

View file

@ -1,9 +1,12 @@
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Link } from "preact-router"; import { Link } from "preact-router";
import { HeaderRoute } from "../components/HeaderRoute";
export function NotFound() { export function NotFound() {
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<HeaderRoute>
<section class="h-full"> <section class="h-full">
<div class="flex h-full flex-col items-center justify-center"> <div class="flex h-full flex-col items-center justify-center">
<img src="/404.png" class="h-72"></img> <img src="/404.png" class="h-72"></img>
@ -18,5 +21,6 @@ export function NotFound() {
</Link> </Link>
</div> </div>
</section> </section>
</HeaderRoute>
); );
} }

View file

@ -1,8 +1,11 @@
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { HeaderRoute } from "../components/HeaderRoute";
export function DiscordPage() { export function DiscordPage() {
const { t } = useTranslation(); const { t } = useTranslation();
return ( return (
<HeaderRoute>
<section class="h-full"> <section class="h-full">
<div class="flex h-full flex-col items-center justify-center"> <div class="flex h-full flex-col items-center justify-center">
<div class="flex flex-col items-center p-6"> <div class="flex flex-col items-center p-6">
@ -21,5 +24,6 @@ export function DiscordPage() {
</a> </a>
</div> </div>
</section> </section>
</HeaderRoute>
); );
} }