hezarfen_landing
Clone
https://git.tahinli.com/archive/hezarfen_landing.git
0 watching0 forksTypeScript581.6 KiB94b1804Burak Boduroğlu2 months ago15 commits
| 1 | import { MetaProvider } from "@solidjs/meta"; |
| 2 | import { Router, useIsRouting, useLocation } from "@solidjs/router"; |
| 3 | import { FileRoutes } from "@solidjs/start/router"; |
| 4 | import { createEffect, on, Suspense, type JSX } from "solid-js"; |
| 5 | import Header from "~/components/Header"; |
| 6 | import Footer from "~/components/Footer"; |
| 7 | import "@fontsource-variable/inter"; |
| 8 | import "@fontsource-variable/jetbrains-mono"; |
| 9 | import "./app.css"; |
| 10 | |
| 11 | /** |
| 12 | * The routed part of the page. A route's code arrives on demand, and until it |
| 13 | * does the router keeps the old page on screen — correct, but with nothing |
| 14 | * moving a click reads as a click that did nothing. So a bar runs along the |
| 15 | * top while the next page loads, and the new page fades in once it lands. |
| 16 | * Hash changes on the same page are scrolling, not navigation, and get |
| 17 | * neither. |
| 18 | */ |
| 19 | function Shell(props: { children: JSX.Element }) { |
| 20 | const location = useLocation(); |
| 21 | const routing = useIsRouting(); |
| 22 | let main!: HTMLElement; |
| 23 | |
| 24 | createEffect( |
| 25 | on( |
| 26 | () => location.pathname, |
| 27 | () => { |
| 28 | // Restart the animation: drop the class, force a style flush, re-add. |
| 29 | main.classList.remove("hz-page-in"); |
| 30 | void main.offsetWidth; |
| 31 | main.classList.add("hz-page-in"); |
| 32 | }, |
| 33 | { defer: true }, |
| 34 | ), |
| 35 | ); |
| 36 | |
| 37 | return ( |
| 38 | <> |
| 39 | <div class="hz-route-progress" classList={{ "is-active": routing() }} aria-hidden="true" /> |
| 40 | <main ref={main} id="main" class="flex-1"> |
| 41 | <Suspense>{props.children}</Suspense> |
| 42 | </main> |
| 43 | </> |
| 44 | ); |
| 45 | } |
| 46 | |
| 47 | export default function App() { |
| 48 | return ( |
| 49 | <Router |
| 50 | root={props => ( |
| 51 | <MetaProvider> |
| 52 | <div class="flex min-h-screen flex-col"> |
| 53 | <a |
| 54 | href="#main" |
| 55 | class="sr-only focus:not-sr-only focus:absolute focus:left-0 focus:top-0 focus:z-100 focus:rounded-br-md focus:bg-[var(--brand)] focus:px-4 focus:py-3 focus:text-white" |
| 56 | > |
| 57 | İçeriğe geç |
| 58 | </a> |
| 59 | <Header /> |
| 60 | <Shell>{props.children}</Shell> |
| 61 | <Footer /> |
| 62 | </div> |
| 63 | </MetaProvider> |
| 64 | )} |
| 65 | > |
| 66 | <FileRoutes /> |
| 67 | </Router> |
| 68 | ); |
| 69 | } |