Skip to content

Commit

Permalink
create dashboard group (#1562)
Browse files Browse the repository at this point in the history
* refactor: move files into dashboard group

* chore: remove horizonal padding from routes

* feat: add error and not found page, provided by nextjs example
  • Loading branch information
dominik-stumpf authored Nov 25, 2024
1 parent fe568d4 commit 27136f8
Show file tree
Hide file tree
Showing 20 changed files with 81 additions and 17 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const metadata = {
};

const CreateGuild = () => (
<main className="container mx-auto grid max-w-lg gap-8 px-4 py-16">
<main className="container mx-auto grid max-w-lg gap-8 py-16">
<div
className="-z-10 absolute inset-0 opacity-40 dark:opacity-60"
style={{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default async function Explorer() {

return (
<>
<main className="container mx-auto grid max-w-screen-lg gap-4 px-4 py-8">
<main className="container grid gap-4 py-16">
<section className="pt-6 pb-8">
<h1
className="font-black font-display text-5xl tracking-tight"
Expand Down
21 changes: 8 additions & 13 deletions src/app/(dashboard)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import { DashboardContainer } from "@/components/DashboardContainer";
import { Header } from "@/components/Header";
import type { PropsWithChildren } from "react";

const Dashboard = ({ children }: PropsWithChildren) => {
return <>{children}</>;
//<Layout>
// <LayoutHero className="pb-28">
// <Header />
// <LayoutHeadline className="max-w-screen-md">
// <LayoutTitle className="text-foreground">Privacy Policy</LayoutTitle>
// </LayoutHeadline>
// </LayoutHero>
//
// <LayoutMain className="prose flex max-w-screen-md flex-col prose-headings:font-display prose-headings:text-foreground prose-li:text-foreground text-foreground marker:text-foreground">
// {children}
// </LayoutMain>
//</Layout>
return (
<>
<Header />
<DashboardContainer>{children}</DashboardContainer>
</>
);
};

export default Dashboard;
33 changes: 33 additions & 0 deletions src/app/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"use client";

import { useEffect } from "react";

const ErrorBoundary = ({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) => {
useEffect(() => {
// Log the error to an error reporting service
console.error(error);
}, [error]);

return (
<div>
<h1>Something went wrong!</h1>
<button
type="button"
onClick={
// Attempt to recover by trying to re-render the segment
() => reset()
}
>
Try again
</button>
</div>
);
};

export default ErrorBoundary;
2 changes: 0 additions & 2 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Metadata } from "next";
import "@/styles/globals.css";
import { Header } from "@/components/Header";
import { PreloadResources } from "@/components/PreloadResources";
import { Providers } from "@/components/Providers";
import { SignInDialog } from "@/components/SignInDialog";
Expand Down Expand Up @@ -28,7 +27,6 @@ const RootLayout = ({
<body className={cn(dystopian.variable)}>
<PreloadResources />
<Providers>
<Header />
{children}

{/* TODO: maybe load this dynamically? */}
Expand Down
11 changes: 11 additions & 0 deletions src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Link from "next/link";

export default function NotFound() {
return (
<div>
<h1>Not Found</h1>
<p>Could not find requested resource</p>
<Link href="/">Return Home</Link>
</div>
);
}
27 changes: 27 additions & 0 deletions src/components/DashboardContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { cn } from "@/lib/cssUtils";
import { Slot } from "@radix-ui/react-slot";
import type { HTMLAttributes } from "react";

interface DashboardContainerProps extends HTMLAttributes<HTMLDivElement> {
asChild?: boolean;
}

export const DashboardContainer = ({
children,
className,
asChild = false,
...props
}: DashboardContainerProps) => {
const Comp = asChild ? Slot : "div";
return (
<Comp
className={cn(
"mx-auto w-full max-w-screen-lg px-4 sm:px-8 md:px-10",
className,
)}
{...props}
>
{children}
</Comp>
);
};

0 comments on commit 27136f8

Please sign in to comment.