fix: Fixed dumb nextjs hydration error + styling fixes

main
Elias Almqvist 8 months ago
parent 931894c454
commit 502149dc41
No known key found for this signature in database
GPG Key ID: E31A99CE3E75A158
  1. 1
      README.md
  2. 4
      src/app/not-found.tsx
  3. 14
      src/app/page.tsx
  4. 25
      src/components/age.tsx
  5. 6
      src/components/ilink.tsx

@ -1,2 +1,3 @@
# Wych # Wych
Source code + blog posts for my website, [wych.dev](https://wych.dev). Source code + blog posts for my website, [wych.dev](https://wych.dev).

@ -19,11 +19,11 @@ const NotFound = () => (
<p className="max-w-md text-foreground/60 space-y-2"> <p className="max-w-md text-foreground/60 space-y-2">
{quote.split("\n").map((line, i) => ( {quote.split("\n").map((line, i) => (
<span key={i} className="block"> <span key={i} className="block">
{'>'} {line} {">"} {line}
</span> </span>
))} ))}
</p> </p>
<div> <div className="space-x-8">
<ILink href="#">Stay</ILink> <ILink href="#">Stay</ILink>
<ILink href="/">Leave</ILink> <ILink href="/">Leave</ILink>
</div> </div>

@ -26,7 +26,7 @@ export default function Home() {
<CardHeader> <CardHeader>
<CardTitle>Elias Almqvist</CardTitle> <CardTitle>Elias Almqvist</CardTitle>
<CardDescription className="pl-0 space-y-4"> <CardDescription className="pl-0 space-y-4">
<p> <span className="inline-block">
I am a{" "} I am a{" "}
{ {
<AgeHCyclesDisplay <AgeHCyclesDisplay
@ -38,23 +38,23 @@ export default function Home() {
<span className="text-xs text-foreground/40">(± 2 MHz)</span>{" "} <span className="text-xs text-foreground/40">(± 2 MHz)</span>{" "}
old <span className="font-bold">human-</span> founder, engineer, old <span className="font-bold">human-</span> founder, engineer,
and hacker with a passion for CS, physics, and mathematics. and hacker with a passion for CS, physics, and mathematics.
</p> </span>
<p> <span className="inline-block">
Currently working on{" "} Currently working on{" "}
<ILink href="https://rembr.co" target="_blank" className="px-0"> <ILink href="https://rembr.co" target="_blank">
ingenuity ingenuity
</ILink> </ILink>
. Some of my projects are open-source (FOSS), and if you are . Some of my projects are open-source (FOSS), and if you are
interested, you can find them on my{" "} interested, you can find them on my{" "}
<ILink href="https://git.wych.dev/elal" target="_blank" className="px-0"> <ILink href="https://git.wych.dev/elal" target="_blank">
self-hosted git-server self-hosted git-server
</ILink>{" "} </ILink>{" "}
or{" "} or{" "}
<ILink href="https://github.com/almqv" target="_blank" className="px-0"> <ILink href="https://github.com/almqv" target="_blank">
GitHub GitHub
</ILink> </ILink>
. .
</p> </span>
</CardDescription> </CardDescription>
<CardContent className="flex flex-col items-center justify-center pb-0 pt-4"> <CardContent className="flex flex-col items-center justify-center pb-0 pt-4">
<ExternalNav className="w-full max-w-48 flex flex-row justify-between" /> <ExternalNav className="w-full max-w-48 flex flex-row justify-between" />

@ -5,12 +5,6 @@ import { useEffect, useState } from "react";
const hydrogenLineFrequency_Hz = 1420.405751768 * 10 ** 6; const hydrogenLineFrequency_Hz = 1420.405751768 * 10 ** 6;
function getAge() {
let birth = 1050019200;
let now = Math.floor(Date.now() / 1000);
return now - birth;
}
function secondsToHydrogenLineCycles(secs: number) { function secondsToHydrogenLineCycles(secs: number) {
return secs * hydrogenLineFrequency_Hz; return secs * hydrogenLineFrequency_Hz;
} }
@ -108,18 +102,27 @@ const AgeHCyclesDisplay: React.FC<AgeHCyclesDisplayProps> = ({
className, className,
precision = 2, precision = 2,
}) => { }) => {
const [cycles, setCycles] = useState<number>(0); const [age, setAge] = useState<number | null>(null);
function getAge() {
let birth = 1050019200;
let now = Math.floor(Date.now() / 1000);
return now - birth;
}
useEffect(() => { useEffect(() => {
const interval = setInterval(() => { const interval = setInterval(() => {
setCycles(secondsToHydrogenLineCycles(getAge())); setAge(getAge());
}, 400); }, 400);
return () => clearInterval(interval); return () => clearInterval(interval);
}); }, [getAge]);
return ( return (
<FormatBigNumber num={cycles} precision={precision} className={className} /> <FormatBigNumber
num={secondsToHydrogenLineCycles(age ?? 0)}
precision={precision}
className={className}
/>
); );
}; };

@ -1,5 +1,6 @@
import Link from "next/link"; import Link from "next/link";
import { Button } from "./ui/button"; import { Button } from "./ui/button";
import { cn } from "@/lib/utils";
type ILinkProps = { type ILinkProps = {
href: string; href: string;
@ -15,7 +16,10 @@ const ILink: React.FC<ILinkProps> = ({
}) => { }) => {
return ( return (
<Link href={href} {...props}> <Link href={href} {...props}>
<Button className={className} variant="link"> <Button
className={cn("p-0 m-0 inline-block h-fit w-fit", className)}
variant="link"
>
{children} {children}
</Button> </Button>
</Link> </Link>

Loading…
Cancel
Save