Skip to content

Commit

Permalink
refactor: fix build bugs while moving to app router
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfortunato committed Jul 12, 2024
1 parent 983c0aa commit f3e3723
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 187 deletions.
11 changes: 1 addition & 10 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ import React, { useState } from "react";
import Grid from "@/components/Grid";
import Hero from "@/components/Hero";
import { AnimatePresence, motion } from "framer-motion";
import { type BuildInfo, type BuildCommitInfo } from "@/lib/buildInfo";

import { GetStaticProps } from "next";
import { Fingerprint } from "lucide-react";
import { Button, ButtonProps } from "@/components/ui/button";
import { NextPageWithLayout } from "./_app";
import RootPageLayout from "@/components/RootPageLayout";
import { Button } from "@/components/ui/button";

import {
Dialog,
Expand All @@ -25,7 +21,6 @@ import {
TooltipProvider,
TooltipTrigger,
} from "@/components/ui/tooltip";
import { getBuildInfo } from "@/lib/server-only/buildInfo";
import { FileIcon } from "@radix-ui/react-icons";
import GPGKey from "@/components/GPGKey";

Expand All @@ -38,10 +33,6 @@ const defaultGridConfig = {
isDot: true,
};

type Props = {
buildInfo: BuildInfo;
};

// Renders home page of a nextjs app (index.tsx)
export default function Page() {
const [triggerNameEnter, setTriggerNameEnter] = useState(false);
Expand Down
52 changes: 2 additions & 50 deletions app/projects/8-bit-adder/page.tsx
Original file line number Diff line number Diff line change
@@ -1,59 +1,11 @@
import Link from "next/link";
import Image from "next/image";
import { Layout, TileFactory } from "../page";
import WideShot1Bit from "@/public/projects/8-bit-adder/wide-shot-1-bit.jpg";
import Debug1Bit from "@/public/projects/8-bit-adder/debug-1-bit.jpg";
import Diagram1Bit from "@/public/projects/8-bit-adder/1-bit-adder-diagram.png";

function Tile() {
return TileFactory(
"8 Bit Adder",
<TileLeftSide />,
<TileRightSide />,
"8-bit-adder",
);
}

function TileLeftSide() {
return (
<div>
<div className="text-base">
<p>
This was my first electrical engineering project. Click{" "}
<Link
className="font-semibold"
href="/projects/8-bit-adder/1_bit_adder_image.pdf"
target="_blank"
>
here
</Link>{" "}
to download the full electrical diagram or see{" "}
<Link
className="font-semibold"
href="https://github.com/michaelfortunato/8-bit-adder"
target="_blank"
>
here
</Link>{" "}
for the project (still in progress).
</p>
</div>
</div>
);
}

function TileRightSide() {
return (
<div className="flex gap-4">
<Image src={WideShot1Bit} alt="ee-setup.jpg" width={200} />
<Image src={Diagram1Bit} alt="1-bit-adder-diagram.png" width={200} />
</div>
);
}

export default function Page() {
return (
<Layout url="/projects/8-bit-adder">
<div>
<div className="mt-4 flex flex-col items-center gap-2">
<div className="prose">
<h2>Overview</h2>
Expand Down Expand Up @@ -86,6 +38,6 @@ export default function Page() {
</div>
</div>
</div>
</Layout>
</div>
);
}
50 changes: 50 additions & 0 deletions app/projects/8-bit-adder/tile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import Link from "next/link";
import { TileFactory } from "../TileFactory";
import WideShot1Bit from "@/public/projects/8-bit-adder/wide-shot-1-bit.jpg";
import Diagram1Bit from "@/public/projects/8-bit-adder/1-bit-adder-diagram.png";
import Image from "next/image";

function TileLeftSide() {
return (
<div>
<div className="text-base">
<p>
This was my first electrical engineering project. Click{" "}
<Link
className="font-semibold"
href="/projects/8-bit-adder/1_bit_adder_image.pdf"
target="_blank"
>
here
</Link>{" "}
to download the full electrical diagram or see{" "}
<Link
className="font-semibold"
href="https://github.com/michaelfortunato/8-bit-adder"
target="_blank"
>
here
</Link>{" "}
for the project (still in progress).
</p>
</div>
</div>
);
}

function TileRightSide() {
return (
<div className="flex gap-4">
<Image src={WideShot1Bit} alt="ee-setup.jpg" width={200} />
<Image src={Diagram1Bit} alt="1-bit-adder-diagram.png" width={200} />
</div>
);
}
export function Tile() {
return TileFactory(
"8 Bit Adder",
<TileLeftSide />,
<TileRightSide />,
"8-bit-adder",
);
}
47 changes: 47 additions & 0 deletions app/projects/TileFactory.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
"use client";
import { IconButton } from "@mui/material";
import { ReactElement, ReactNode, useState } from "react";
import FlipIcon from "@mui/icons-material/Flip";

export function StyledTile({
props,
children,
}: {
props?: any;
children: ReactNode;
}) {
return (
<div className="min-h-96 rounded bg-neutral-50 p-3 shadow-md">
{children}
</div>
);
}

export function TileFactory(
title: string,
leftHandComponent: ReactElement,
rightHandComponent: ReactElement,
link: string,
) {
const [isOpen, setIsOpen] = useState(false);
return (
<StyledTile>
<div className="flex flex-col gap-5">
<div className="p2 flex">
<div className="flex-1">
<h2 className="p-4 text-5xl">{title}</h2>
</div>
<div className="flex flex-1 flex-row-reverse">
<IconButton aria-label="View full">
<FlipIcon />
</IconButton>
</div>
</div>
<div className="flex gap-1">
<div className="flex-1 p-4">{leftHandComponent}</div>
<div className="flex-1">{rightHandComponent}</div>
</div>
</div>
</StyledTile>
);
}
32 changes: 32 additions & 0 deletions app/projects/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"use client";
import { motion } from "framer-motion";
import Link from "next/link";
import { PropsWithChildren } from "react";

export default function Layout({ children }: PropsWithChildren) {
return (
<div className="h-screen bg-neutral-50 p-10">
<motion.div layoutId="page">
<div className="flex flex-row-reverse">
<Link href="/projects">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className="h-6 w-6 cursor-pointer"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
/>
</svg>
</Link>
</div>
<div>{children}</div>
</motion.div>
</div>
);
}
93 changes: 3 additions & 90 deletions app/projects/page.tsx
Original file line number Diff line number Diff line change
@@ -1,98 +1,11 @@
"use client";
import { ReactElement, PropsWithChildren, useState, ReactNode } from "react";
import { useState } from "react";
import { IconButton } from "@mui/material";
import FlipIcon from "@mui/icons-material/Flip";
import { AnimatePresence, motion } from "framer-motion";
import Link from "next/link";
import { useRouter } from "next/router";
import { ArrowDownward, ArrowUpward } from "@mui/icons-material";

import { Tile as WebsiteTile } from "./personal-website/page";
import { Tile as EightBitAdderTile } from "./8-bit-adder/page";

export function TileFactory(
title: string,
leftHandComponent: ReactElement,
rightHandComponent: ReactElement,
link: string,
) {
const [isOpen, setIsOpen] = useState(false);
const router = useRouter();
return (
<StyledTile>
<div className="flex flex-col gap-5">
<div className="p2 flex">
<div className="flex-1">
<h2 className="p-4 text-5xl">{title}</h2>
</div>
<div className="flex flex-1 flex-row-reverse">
<Link
href={link}
onClick={(e) => {
setIsOpen(!isOpen);
e.preventDefault();
setTimeout(() => {
router.push(`/projects/${link}`);
}, 350);
}}
>
<IconButton aria-label="View full">
<FlipIcon />
</IconButton>
</Link>
</div>
</div>
<div className="flex gap-1">
<div className="flex-1 p-4">{leftHandComponent}</div>
<div className="flex-1">{rightHandComponent}</div>
</div>
</div>
</StyledTile>
);
}

export function StyledTile({
props,
children,
}: {
props?: any;
children: ReactNode;
}) {
return (
<div className="min-h-96 rounded bg-neutral-50 p-3 shadow-md">
{children}
</div>
);
}

export function Layout(props: PropsWithChildren<{ url: string }>) {
const { url, children } = props;
return (
<div className="h-screen bg-neutral-50 p-10">
<motion.div layoutId="page">
<div className="flex flex-row-reverse">
<Link href="/projects">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
strokeWidth={1.5}
stroke="currentColor"
className="h-6 w-6 cursor-pointer"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
d="m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
/>
</svg>
</Link>
</div>
<div>{children}</div>
</motion.div>
</div>
);
}
import { Tile as WebsiteTile } from "./personal-website/tile";
import { Tile as EightBitAdderTile } from "./8-bit-adder/tile";

export default function Page() {
const [[selected, direction], setPage] = useState([0, 0]);
Expand Down
39 changes: 2 additions & 37 deletions app/projects/personal-website/page.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,9 @@
import { Layout, TileFactory } from "../page";
import Image from "next/image";
import clayiPhone from "@/public/projects/clay-iphone.svg";
import clayMBP from "@/public/projects/clay-mbp.svg";
import bundleSizes from "@/public/projects/personal-website/bundle-sizes.png";

export function Tile() {
return <WebsiteTile />;
}

function WebsiteTile() {
const leftHandSize = () => (
<div className="container flex flex-col gap-4">
<div className="text-base">
This website is a public vault of my life, and there is heavy emphasis
on intricate animations. It was built using NextJS, TailwindCSS, and
Framer Motion.
</div>
</div>
);
const rightHandside = () => (
<div className="flex">
<div className="flex-initial">
<Image src={clayiPhone} alt="clay-iphone.svgb" />
</div>
<div className="flex-initial">
<Image src={clayMBP} alt="clay-mbp.svgb" />
</div>
</div>
);
return TileFactory(
"Personal Website",
leftHandSize(),
rightHandside(),
"personal-website",
);
}

export default function Page() {
return (
<Layout url="/projects/personal-website">
<div>
<div className="flex justify-center">
<h1 className="text-6xl">Personal Website</h1>
</div>
Expand Down Expand Up @@ -66,6 +31,6 @@ export default function Page() {
</div>
</div>
</div>
</Layout>
</div>
);
}
Loading

0 comments on commit f3e3723

Please sign in to comment.