Skip to content

Commit

Permalink
route intercept fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cdleveille committed May 31, 2024
1 parent dac2ceb commit 954075b
Show file tree
Hide file tree
Showing 17 changed files with 104 additions and 83 deletions.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 0 additions & 3 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/** @type {import('next').NextConfig} */

const nextConfig = {
experimental: {
reactCompiler: true
},
images: {
remotePatterns: [
{
Expand Down
15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@
"@emotion/styled": "^11.11.5",
"@mui/icons-material": "^5.15.18",
"@mui/material": "^5.15.18",
"babel-plugin-react-compiler": "^0.0.0-experimental-592953e-20240517",
"next": "^14.3.0-canary.86",
"react": "^19.0.0-rc-6f23540c7d-20240528",
"react-dom": "^19.0.0-rc-6f23540c7d-20240528"
"next": "^14.2.3",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "npm:types-react@rc",
"@types/react-dom": "npm:types-react-dom@rc",
"@types/node": "20.3.1",
"@types/react": "^18.2.14",
"@types/react-dom": "^18.2.18",
"eslint": "^8",
"eslint-config-next": "14.2.3",
"prettier": "^3.2.5",
"typescript": "^5"
"typescript": "^5.1.3"
}
}
13 changes: 0 additions & 13 deletions src/app/@disc-detail/(.)[name_slug]/page.tsx

This file was deleted.

5 changes: 5 additions & 0 deletions src/app/@modal/(.)[name_slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { DiscDetail } from "@components";

export default function DiscDetailPage({ params: { name_slug } }: { params: { name_slug: string } }) {
return <DiscDetail name_slug={name_slug} />;
}
3 changes: 3 additions & 0 deletions src/app/@modal/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Default() {
return null;
}
12 changes: 2 additions & 10 deletions src/app/[name_slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
"use client";

import { useContext } from "react";

import { DiscContext, DiscDetail } from "@components";
import { DiscDetail } from "@components";

export default function DiscDetailPage({ params: { name_slug } }: { params: { name_slug: string } }) {
const { discs, setDiscDetail } = useContext(DiscContext);
const disc = discs.find(disc => disc.name_slug === name_slug);
if (!disc) return null;
setDiscDetail(disc);
return <DiscDetail />;
return <DiscDetail name_slug={name_slug} />;
}
3 changes: 3 additions & 0 deletions src/app/default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Default() {
return null;
}
13 changes: 8 additions & 5 deletions src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ body {
overflow-x: hidden;
}

a {
text-decoration: none;
}

main {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -86,13 +90,12 @@ h1 {
font-weight: 500;
}

.overlay {
position: fixed;
.modal {
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
width: 100vw;
height: 100vh;
z-index: 1000;
display: flex;
justify-content: center;
align-items: center;
Expand Down
33 changes: 31 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,49 @@ import { Inter } from "next/font/google";
import { DiscContextProvider } from "@components";
import { useApi } from "@hooks";

import type { Metadata } from "next";

const inter = Inter({ subsets: ["latin"] });

export default async function RootLayout({
children
children,
modal
}: Readonly<{
children: React.ReactNode;
modal: React.ReactNode;
}>) {
const { getDiscs } = useApi();
const discs = await getDiscs();
return (
<html lang="en">
<body className={inter.className}>
<DiscContextProvider discs={discs}>{children}</DiscContextProvider>
<DiscContextProvider discs={discs}>
{modal}
{children}
</DiscContextProvider>
</body>
</html>
);
}

export const metadata: Metadata = {
title: "DiscIt",
description: "A responsive disc golf disc search engine.",
authors: { name: "Chris Leveille", url: "https://www.cdleveille.net" },
publisher: "Chris Leveille",
openGraph: {
title: "DiscIt",
description: "A responsive disc golf disc search engine.",
type: "website",
emails: "cdleveille@gmail.com",
url: "https://discit.vercel.app",
images: {
url: "https://github.com/cdleveille/discit/assets/1410481/ce638b92-5142-4b1c-814a-5240e3cf8fde",
secureUrl: "https://github.com/cdleveille/discit/assets/1410481/ce638b92-5142-4b1c-814a-5240e3cf8fde",
type: "image/png",
alt: "DiscIt",
width: 256,
height: 256
}
}
};
24 changes: 0 additions & 24 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import type { Metadata } from "next";

import { Home } from "@components";

export default function HomePage() {
Expand All @@ -9,25 +7,3 @@ export default function HomePage() {
</main>
);
}

export const metadata: Metadata = {
title: "DiscIt",
description: "A responsive disc golf disc search engine.",
authors: { name: "Chris Leveille", url: "https://www.cdleveille.net" },
publisher: "Chris Leveille",
openGraph: {
title: "DiscIt",
description: "A responsive disc golf disc search engine.",
type: "website",
emails: "cdleveille@gmail.com",
url: "https://discit.vercel.app",
images: {
url: "https://github.com/cdleveille/discit/assets/1410481/ce638b92-5142-4b1c-814a-5240e3cf8fde",
secureUrl: "https://github.com/cdleveille/discit/assets/1410481/ce638b92-5142-4b1c-814a-5240e3cf8fde",
type: "image/png",
alt: "DiscIt",
width: 256,
height: 256
}
}
};
15 changes: 7 additions & 8 deletions src/components/Disc.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
"use client";

import { useContext, useState } from "react";
import Link from "next/link";
import { useState } from "react";

import { DiscContext } from "@components";
import { Stack } from "@mui/material";
import { hexToRgba } from "@util";

import type { DiscProps } from "@types";

export const Disc = ({ disc }: DiscProps) => {
const [isHovered, setIsHovered] = useState(false);

const { setDiscDetail } = useContext(DiscContext);

const {
name,
name_slug,
brand,
category,
stability,
Expand All @@ -30,10 +28,11 @@ export const Disc = ({ disc }: DiscProps) => {

return (
<div className="disc-container">
<div
<Link
href={`/${name_slug}`}
passHref
className="disc"
style={{ color, backgroundColor, border: `5px solid ${borderColor}` }}
onClick={() => setDiscDetail(disc)}
onMouseEnter={() => setIsHovered(true)}
onMouseLeave={() => setIsHovered(false)}
>
Expand All @@ -50,7 +49,7 @@ export const Disc = ({ disc }: DiscProps) => {
</Stack>
)}
</Stack>
</div>
</Link>
</div>
);
};
17 changes: 9 additions & 8 deletions src/components/DiscDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import Image from "next/image";
import { useContext } from "react";

import { DiscContext } from "@components";
import { DiscContext, Modal } from "@components";
import { hexToRgba } from "@util";

export const DiscDetail = () => {
const { discDetail, setDiscDetail } = useContext(DiscContext);

if (!discDetail) return null;
import type { DiscDetailProps } from "@types";
export const DiscDetail = ({ name_slug }: DiscDetailProps) => {
const { discs } = useContext(DiscContext);
const disc = discs.find(disc => disc.name_slug === name_slug);
if (!disc) return null;

const {
name,
Expand All @@ -23,12 +24,12 @@ export const DiscDetail = () => {
pic,
color,
background_color: backgroundColor
} = discDetail;
} = disc;

const borderColor = hexToRgba(color, 0.25);

return (
<div className="overlay" onClick={() => setDiscDetail(null)}>
<Modal>
<div
className="disc-detail"
onClick={e => e.stopPropagation()}
Expand All @@ -48,6 +49,6 @@ export const DiscDetail = () => {
<Image src={pic} alt={name} width={400} height={340} className="disc-detail-img" />
</div>
</div>
</div>
</Modal>
);
};
3 changes: 1 addition & 2 deletions src/components/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import { ClerkProvider } from "@clerk/nextjs";
import { DiscCount, DiscDetail, DiscGrid, Filters, Header, ScrollToTop } from "@components";
import { DiscCount, DiscGrid, Filters, Header, ScrollToTop } from "@components";
import { config } from "@services";

export const Home = () => {
Expand All @@ -11,7 +11,6 @@ export const Home = () => {
<Filters />
<DiscCount />
<DiscGrid />
<DiscDetail />
<ScrollToTop />
</ClerkProvider>
);
Expand Down
19 changes: 19 additions & 0 deletions src/components/Modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"use client";

import { useRouter } from "next/navigation";

import { Modal as MuiModal } from "@mui/material";

import type { ModalProps } from "@types";

export function Modal({ children }: ModalProps) {
const router = useRouter();
const onClose = () => router.back();
return (
<MuiModal open={true}>
<div className="modal" onClick={onClose}>
{children}
</div>
</MuiModal>
);
}
1 change: 1 addition & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export * from "./DiscGrid";
export * from "./Filters";
export * from "./Header";
export * from "./Home";
export * from "./Modal";
export * from "./ScrollToTop";
8 changes: 8 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,11 @@ export type HomeProps = {
export type DiscProps = {
disc: Disc;
};

export type DiscDetailProps = {
name_slug: string;
};

export type ModalProps = {
children: React.ReactNode;
};

0 comments on commit 954075b

Please sign in to comment.