From 97c2f65eb80ab79ee73b4993c60a7f3b0b646eff Mon Sep 17 00:00:00 2001 From: Elias Almqvist Date: Fri, 29 Mar 2024 19:11:40 +0100 Subject: [PATCH] Cringe --- src/app/page.tsx | 32 +++++++++++-- src/components/age.tsx | 47 +++++++++++++++++++ src/components/layout/header.tsx | 3 +- src/components/ui/card.tsx | 79 ++++++++++++++++++++++++++++++++ 4 files changed, 156 insertions(+), 5 deletions(-) create mode 100644 src/components/age.tsx create mode 100644 src/components/ui/card.tsx diff --git a/src/app/page.tsx b/src/app/page.tsx index ec94b73..8035a74 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,5 +1,14 @@ import ThingCurve from "@/components/3d/curves/thing"; import RenderedSection from "@/components/3d/renderedsection"; +import AgeDisplay from "@/components/age"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; + export default function Home() { return ( @@ -7,10 +16,27 @@ export default function Home() { -

Hello, I am a

+ + + Elias Almqvist + +

+ I am a {}-year-old human-{" "} + founder, engineer, and hacker with a passion for CS, physics, + and mathematics. +

+

+ Currently working on ingenuity. Most of my projects are + open-source, and if you are interested, you can find all of my + projects on my git-server or GitHub. +

+
+ {/* */} +
+
); diff --git a/src/components/age.tsx b/src/components/age.tsx new file mode 100644 index 0000000..f2ada83 --- /dev/null +++ b/src/components/age.tsx @@ -0,0 +1,47 @@ +"use client"; + +import { useCallback, useEffect, useRef, useState } from "react"; + +type AgeDisplayProps = { + className?: string; + precision?: number; +}; + +function getAge() { + let birth = 1050019200; + let now = Math.floor(Date.now() / 1000); + return now - birth; +} + +function secondsToYears(secs: number, precision: number) { + let years = secs / 31556952; + return years.toFixed(precision); +} + +const AgeDisplay: React.FC = ({ + className, + precision = 2, +}) => { + const ref = useRef(null); + + const anim = useCallback(() => { + if (!ref.current) { + return; + } + ref.current.textContent = secondsToYears(getAge(), precision); + }, []) + + useEffect(() => { + const animFrame = requestAnimationFrame(() => { + anim(); + }); + + return () => { + cancelAnimationFrame(animFrame); + }; + }, [getAge, ref.current]); + + return ??; +}; + +export default AgeDisplay; diff --git a/src/components/layout/header.tsx b/src/components/layout/header.tsx index 56bc561..5045d06 100644 --- a/src/components/layout/header.tsx +++ b/src/components/layout/header.tsx @@ -24,9 +24,8 @@ const Header = () => (
    {NavLinks.map((link, index) => ( -
  • +
  • +>(({ className, ...props }, ref) => ( +
    +)) +Card.displayName = "Card" + +const CardHeader = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
    +)) +CardHeader.displayName = "CardHeader" + +const CardTitle = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

    +)) +CardTitle.displayName = "CardTitle" + +const CardDescription = React.forwardRef< + HTMLParagraphElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

    +)) +CardDescription.displayName = "CardDescription" + +const CardContent = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +

    +)) +CardContent.displayName = "CardContent" + +const CardFooter = React.forwardRef< + HTMLDivElement, + React.HTMLAttributes +>(({ className, ...props }, ref) => ( +
    +)) +CardFooter.displayName = "CardFooter" + +export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }