basic styling and a fancy header
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import clsx from "clsx"
|
||||
import { useEffect, useState } from "react"
|
||||
import type { LinksFunction, MetaFunction } from "remix"
|
||||
import {
|
||||
Links,
|
||||
@@ -18,7 +20,7 @@ export const links: LinksFunction = () => [
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<html lang="en">
|
||||
<html lang="en" className="bg-slate-900 text-slate-100">
|
||||
<head>
|
||||
<meta charSet="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
@@ -26,7 +28,10 @@ export default function App() {
|
||||
<Links />
|
||||
</head>
|
||||
<body>
|
||||
<Outlet />
|
||||
<Header />
|
||||
<div className="m-auto max-w-screen-xl mt-8">
|
||||
<Outlet />
|
||||
</div>
|
||||
<ScrollRestoration />
|
||||
<Scripts />
|
||||
{process.env.NODE_ENV === "development" && <LiveReload />}
|
||||
@@ -34,3 +39,36 @@ export default function App() {
|
||||
</html>
|
||||
)
|
||||
}
|
||||
|
||||
function Header() {
|
||||
const isScrolled = useScrolled()
|
||||
return (
|
||||
<header
|
||||
className={clsx(
|
||||
isScrolled ? "bg-slate-700/30" : "bg-slate-800",
|
||||
"shadow-md sticky top-0 px-4 py-3 backdrop-blur-sm transition",
|
||||
)}
|
||||
>
|
||||
<div className="m-auto max-w-screen-xl">
|
||||
<h1 className="text-3xl font-light">reacord</h1>
|
||||
</div>
|
||||
</header>
|
||||
)
|
||||
}
|
||||
|
||||
function useScrolled() {
|
||||
const [isScrolled, setScrolled] = useState(
|
||||
typeof window !== "undefined" && window.scrollY > 0,
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
const handleScroll = () => {
|
||||
setScrolled(window.scrollY > 0)
|
||||
}
|
||||
|
||||
window.addEventListener("scroll", handleScroll)
|
||||
return () => window.removeEventListener("scroll", handleScroll)
|
||||
}, [])
|
||||
|
||||
return isScrolled
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
"@remix-run/react": "^1.1.1",
|
||||
"@remix-run/serve": "^1.1.1",
|
||||
"autoprefixer": "^10.4.1",
|
||||
"clsx": "^1.1.1",
|
||||
"postcss": "^8.4.5",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
|
||||
Reference in New Issue
Block a user