From 66d750fb84944ca88e8f8cff183bd101b4818acb Mon Sep 17 00:00:00 2001 From: Corwin Date: Wed, 22 May 2024 02:21:37 +0100 Subject: [PATCH] make the webpage --- .../src/app/examples/[example]/emulator.tsx | 22 ++++++++++ .../agb/src/app/examples/[example]/page.tsx | 26 ++++++++++++ website/agb/src/app/examples/page.tsx | 42 +++++++++++++++++++ website/agb/src/app/examples/styles.tsx | 34 +++++++++++++++ 4 files changed, 124 insertions(+) create mode 100644 website/agb/src/app/examples/[example]/emulator.tsx create mode 100644 website/agb/src/app/examples/[example]/page.tsx create mode 100644 website/agb/src/app/examples/page.tsx create mode 100644 website/agb/src/app/examples/styles.tsx diff --git a/website/agb/src/app/examples/[example]/emulator.tsx b/website/agb/src/app/examples/[example]/emulator.tsx new file mode 100644 index 00000000..13dc489f --- /dev/null +++ b/website/agb/src/app/examples/[example]/emulator.tsx @@ -0,0 +1,22 @@ +"use client"; + +import MgbaWrapper from "@/components/mgba/mgbaWrapper"; +import { Examples } from "@/roms/examples/examples"; +import { slugify } from "@/sluggify"; +import { useMemo } from "react"; + +function gameUrl(exampleName: string) { + const example = Examples.find((x) => slugify(x.example_name) === exampleName); + console.log(exampleName); + if (!example) { + throw new Error(`cannot find example ${exampleName}`); + } + + return example.url; +} + +export function Emulator({ exampleName }: { exampleName: string }) { + const example = useMemo(() => gameUrl(exampleName), [exampleName]); + + return ; +} diff --git a/website/agb/src/app/examples/[example]/page.tsx b/website/agb/src/app/examples/[example]/page.tsx new file mode 100644 index 00000000..f9572cff --- /dev/null +++ b/website/agb/src/app/examples/[example]/page.tsx @@ -0,0 +1,26 @@ +import { Examples } from "@/roms/examples/examples"; +import { slugify } from "@/sluggify"; +import { Emulator } from "./emulator"; +import { ContentBlock } from "@/components/contentBlock"; + +export async function generateStaticParams() { + return Examples.map((example) => ({ + example: slugify(example.example_name), + })); +} + +export default function Page({ params }: { params: { example: string } }) { + return ( + <> + +

Example: {params.example}

+
+ + + + + <> + + + ); +} diff --git a/website/agb/src/app/examples/page.tsx b/website/agb/src/app/examples/page.tsx new file mode 100644 index 00000000..1a256403 --- /dev/null +++ b/website/agb/src/app/examples/page.tsx @@ -0,0 +1,42 @@ +import { Metadata } from "next"; +import { ContentBlock } from "@/components/contentBlock"; +import { slugify } from "@/sluggify"; +import { GameDisplay, GameGrid, GameImage } from "./styles"; +import { Examples } from "@/roms/examples/examples"; + +export const metadata: Metadata = { + title: "Examples - agb", +}; + +export default function ShowcasePage() { + return ( + <> + +

Examples

+
+ + + {Examples.map((example, idx) => ( + + ))} + + + + ); +} + +function Game({ example }: { example: (typeof Examples)[number] }) { + const screenshot = example.screenshot; + return ( + + +

{example.example_name}

+
+ ); +} diff --git a/website/agb/src/app/examples/styles.tsx b/website/agb/src/app/examples/styles.tsx new file mode 100644 index 00000000..6eac2dae --- /dev/null +++ b/website/agb/src/app/examples/styles.tsx @@ -0,0 +1,34 @@ +"use client"; + +import Link from "next/link"; +import styled from "styled-components"; +import Image from "next/image"; + +export const GameGrid = styled.div` + display: grid; + grid-template-columns: repeat(auto-fit, min(100vw, 600px)); + justify-content: center; + gap: 48px; +`; + +export const GameImage = styled(Image)` + width: 100%; + width: max( + round(down, 100%, calc(240 * var(--device-pixel))), + min(calc(240 * var(--device-pixel)), 100vw) + ); + height: auto; + image-rendering: pixelated; +`; + +export const GameDisplay = styled(Link)` + width: 100%; + text-align: center; + color: black; + text-decoration: none; + + h2 { + margin: 0; + margin-top: 8px; + } +`;