Skip to content

Open-source status page, incident response and uptime monitoring

feat: loading and more (#41)

Maximilian Kaskea285baceeed8
diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/endpoint/loading.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/endpoint/loading.tsx
new file mode 100644
index 000000000..3c4e9f583
--- /dev/null
+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/endpoint/loading.tsx
@@ -0,0 +1,13 @@
+import { Container } from "@/components/dashboard/container";
+import { Header } from "@/components/dashboard/header";
+
+export default function Loading() {
+ return (
+ <div className="grid gap-6 md:grid-cols-2 md:gap-8">
+ <Header.Skeleton />
+ <Container.Skeleton />
+ <Container.Skeleton />
+ <Container.Skeleton />
+ </div>
+ );
+}
diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/endpoint/page.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/endpoint/page.tsx
index e01a3bb9a..324b9cb14 100644
--- a/apps/web/src/app/app/(dashboard)/[workspaceId]/endpoint/page.tsx
+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/endpoint/page.tsx
@@ -1,11 +1,16 @@
import * as React from "react";
-import { Header } from "@/components/header";
+import { Container } from "@/components/dashboard/container";
+import { Header } from "@/components/dashboard/header";
+import { wait } from "@/lib/utils";
-export default function EndpointPage() {
+export default async function EndpointPage() {
+ await wait(1000);
return (
- <div>
+ <div className="grid gap-6 md:grid-cols-2 md:gap-8">
<Header title="Endpoint" description="Overview of all your sites." />
+ <Container title="Hello"></Container>
+ <Container title="World"></Container>
</div>
);
}
diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/incident/loading.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/incident/loading.tsx
new file mode 100644
index 000000000..3c4e9f583
--- /dev/null
+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/incident/loading.tsx
@@ -0,0 +1,13 @@
+import { Container } from "@/components/dashboard/container";
+import { Header } from "@/components/dashboard/header";
+
+export default function Loading() {
+ return (
+ <div className="grid gap-6 md:grid-cols-2 md:gap-8">
+ <Header.Skeleton />
+ <Container.Skeleton />
+ <Container.Skeleton />
+ <Container.Skeleton />
+ </div>
+ );
+}
diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/incident/page.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/incident/page.tsx
index e367a10eb..0f3c84b52 100644
--- a/apps/web/src/app/app/(dashboard)/[workspaceId]/incident/page.tsx
+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/incident/page.tsx
@@ -1,11 +1,16 @@
import * as React from "react";
-import { Header } from "@/components/header";
+import { Container } from "@/components/dashboard/container";
+import { Header } from "@/components/dashboard/header";
+import { wait } from "@/lib/utils";
-export default function IncidentPage() {
+export default async function IncidentPage() {
+ await wait(1000);
return (
- <div>
+ <div className="grid gap-6 md:grid-cols-2 md:gap-8">
<Header title="Monitor" description="Overview of all the responses." />
+ <Container title="Hello"></Container>
+ <Container title="World"></Container>
</div>
);
}
diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/loading.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/loading.tsx
new file mode 100644
index 000000000..3c4e9f583
--- /dev/null
+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/loading.tsx
@@ -0,0 +1,13 @@
+import { Container } from "@/components/dashboard/container";
+import { Header } from "@/components/dashboard/header";
+
+export default function Loading() {
+ return (
+ <div className="grid gap-6 md:grid-cols-2 md:gap-8">
+ <Header.Skeleton />
+ <Container.Skeleton />
+ <Container.Skeleton />
+ <Container.Skeleton />
+ </div>
+ );
+}
diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/monitor/loading.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitor/loading.tsx
new file mode 100644
index 000000000..3c4e9f583
--- /dev/null
+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitor/loading.tsx
@@ -0,0 +1,13 @@
+import { Container } from "@/components/dashboard/container";
+import { Header } from "@/components/dashboard/header";
+
+export default function Loading() {
+ return (
+ <div className="grid gap-6 md:grid-cols-2 md:gap-8">
+ <Header.Skeleton />
+ <Container.Skeleton />
+ <Container.Skeleton />
+ <Container.Skeleton />
+ </div>
+ );
+}
diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/monitor/page.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitor/page.tsx
index 9e108426d..183b6f334 100644
--- a/apps/web/src/app/app/(dashboard)/[workspaceId]/monitor/page.tsx
+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/monitor/page.tsx
@@ -1,11 +1,16 @@
import * as React from "react";
-import { Header } from "@/components/header";
+import { Container } from "@/components/dashboard/container";
+import { Header } from "@/components/dashboard/header";
+import { wait } from "@/lib/utils";
-export default function MonitorPage() {
+export default async function MonitorPage() {
+ await wait(1000);
return (
- <div>
+ <div className="grid gap-6 md:grid-cols-2 md:gap-8">
<Header title="Monitor" description="Overview of all the responses." />
+ <Container title="Hello"></Container>
+ <Container title="World"></Container>
</div>
);
}
diff --git a/apps/web/src/app/app/(dashboard)/[workspaceId]/page.tsx b/apps/web/src/app/app/(dashboard)/[workspaceId]/page.tsx
index a69f85c95..d2ba99d10 100644
--- a/apps/web/src/app/app/(dashboard)/[workspaceId]/page.tsx
+++ b/apps/web/src/app/app/(dashboard)/[workspaceId]/page.tsx
@@ -1,14 +1,16 @@
import * as React from "react";
-import { auth, currentUser } from "@clerk/nextjs";
-import { Header } from "@/components/header";
+import { Container } from "@/components/dashboard/container";
+import { Header } from "@/components/dashboard/header";
+import { wait } from "@/lib/utils";
-export default async function AppPage() {
- const user = await currentUser();
- console.log({ user });
+export default async function DashboardPage() {
+ await wait(1000);
return (
- <div>
- <Header title="App" description="Overview of all your websites" />
+ <div className="grid gap-6 md:grid-cols-2 md:gap-8">
+ <Header title="Dashboard" description="Overview of all your websites" />
+ <Container title="Hello"></Container>
+ <Container title="World"></Container>
</div>
);
}
diff --git a/apps/web/src/app/app/(dashboard)/layout.tsx b/apps/web/src/app/app/(dashboard)/layout.tsx
index 5b451e702..d846263e8 100644
--- a/apps/web/src/app/app/(dashboard)/layout.tsx
+++ b/apps/web/src/app/app/(dashboard)/layout.tsx
@@ -1,5 +1,6 @@
import * as React from "react";
+import { Shell } from "@/components/dashboard/shell";
import { AppHeader } from "@/components/layout/app-header";
import { AppMenu } from "@/components/layout/app-menu";
import { AppSidebar } from "@/components/layout/app-sidebar";
@@ -10,18 +11,18 @@ export default function AppLayout({ children }: { children: React.ReactNode }) {
<div className="container mx-auto flex min-h-screen w-full flex-col items-center justify-center space-y-6 p-4 md:p-8">
<AppHeader />
<div className="flex w-full flex-1 gap-6 md:gap-8">
- <aside className="border-border hidden rounded-lg border p-3 backdrop-blur-[2px] md:block md:p-6">
+ <Shell className="hidden max-w-min md:block">
<nav>
<AppSidebar />
</nav>
- </aside>
+ </Shell>
<main className="z-10 flex w-full flex-1 flex-col items-start justify-center">
- <div className="border-border relative w-full flex-1 rounded-lg border p-3 backdrop-blur-[2px] md:p-6">
+ <Shell className="relative flex-1">
<nav className="absolute right-4 top-4 block md:hidden">
<AppMenu />
</nav>
{children}
- </div>
+ </Shell>
</main>
</div>
<Footer />
diff --git a/apps/web/src/app/app/(dashboard)/page.tsx b/apps/web/src/app/app/(dashboard)/page.tsx
deleted file mode 100644
index a69f85c95..000000000
--- a/apps/web/src/app/app/(dashboard)/page.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import * as React from "react";
-import { auth, currentUser } from "@clerk/nextjs";
-
-import { Header } from "@/components/header";
-
-export default async function AppPage() {
- const user = await currentUser();
- console.log({ user });
- return (
- <div>
- <Header title="App" description="Overview of all your websites" />
- </div>
- );
-}
diff --git a/apps/web/src/components/dashboard/container.tsx b/apps/web/src/components/dashboard/container.tsx
new file mode 100644
index 000000000..816401e66
--- /dev/null
+++ b/apps/web/src/components/dashboard/container.tsx
@@ -0,0 +1,38 @@
+import {
+ Card,
+ CardContent,
+ CardDescription,
+ CardFooter,
+ CardHeader,
+ CardTitle,
+} from "@/components/ui/card";
+import { cn } from "@/lib/utils";
+import { Skeleton } from "../ui/skeleton";
+
+interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
+ title: string;
+ description?: string;
+}
+
+function Container({ title, description, className, children }: CardProps) {
+ return (
+ <Card className={cn("border-border/50 w-full shadow-none", className)}>
+ <CardHeader>
+ <CardTitle className="text-lg font-medium tracking-normal">
+ {title}
+ </CardTitle>
+ {description ? <CardDescription>{description}</CardDescription> : null}
+ </CardHeader>
+ {/* potentially `asChild` */}
+ <CardContent>{children}</CardContent>
+ </Card>
+ );
+}
+
+function ContainerSkeleton() {
+ return <Skeleton className="h-24 w-full" />;
+}
+
+Container.Skeleton = ContainerSkeleton;
+
+export { Container };
diff --git a/apps/web/src/components/dashboard/header.tsx b/apps/web/src/components/dashboard/header.tsx
new file mode 100644
index 000000000..2cd44f697
--- /dev/null
+++ b/apps/web/src/components/dashboard/header.tsx
@@ -0,0 +1,31 @@
+import { cn } from "@/lib/utils";
+import { Skeleton } from "../ui/skeleton";
+
+interface HeaderProps extends React.HTMLAttributes<HTMLDivElement> {
+ title: string;
+ description?: string | null;
+}
+
+function Header({ title, description, className }: HeaderProps) {
+ return (
+ <div className={cn("col-span-full grid gap-1", className)}>
+ <h1 className="font-cal text-3xl">{title}</h1>
+ {description ? (
+ <p className="text-muted-foreground">{description}</p>
+ ) : null}
+ </div>
+ );
+}
+
+function HeaderSkeleton() {
+ return (
+ <div className="col-span-full grid gap-3">
+ <Skeleton className="h-8 w-[200px]" />
+ <Skeleton className="h-4 w-[300px]" />
+ </div>
+ );
+}
+
+Header.Skeleton = HeaderSkeleton;
+
+export { Header };
diff --git a/apps/web/src/components/dashboard/shell.tsx b/apps/web/src/components/dashboard/shell.tsx
new file mode 100644
index 000000000..f9bae6320
--- /dev/null
+++ b/apps/web/src/components/dashboard/shell.tsx
@@ -0,0 +1,18 @@
+import { cn } from "@/lib/utils";
+
+type ShellProps = React.HTMLAttributes<HTMLDivElement>;
+
+function Shell({ children, className }: ShellProps) {
+ return (
+ <div
+ className={cn(
+ "border-border w-full rounded-lg border p-3 backdrop-blur-[2px] md:p-6",
+ className,
+ )}
+ >
+ {children}
+ </div>
+ );
+}
+
+export { Shell };
diff --git a/apps/web/src/components/header.tsx b/apps/web/src/components/header.tsx
deleted file mode 100644
index 8b4e12ac6..000000000
--- a/apps/web/src/components/header.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import { cn } from "@/lib/utils";
-
-interface HeaderProps extends React.HTMLAttributes<HTMLDivElement> {
- title: string;
- description?: string | null;
-}
-
-export function Header({ title, description, className }: HeaderProps) {
- return (
- <div className={cn("grid gap-1", className)}>
- <h1 className="font-cal text-3xl">{title}</h1>
- {description ? (
- <p className="text-muted-foreground">{description}</p>
- ) : null}
- </div>
- );
-}
diff --git a/apps/web/src/components/layout/app-menu.tsx b/apps/web/src/components/layout/app-menu.tsx
index 9523bfc01..b25ad804e 100644
--- a/apps/web/src/components/layout/app-menu.tsx
+++ b/apps/web/src/components/layout/app-menu.tsx
@@ -1,3 +1,7 @@
+"use client";
+
+import * as React from "react";
+import { usePathname, useSearchParams } from "next/navigation";
import { Menu } from "lucide-react";
import { Button } from "../ui/button";
@@ -9,11 +13,20 @@ import {
SheetTitle,
SheetTrigger,
} from "../ui/sheet";
+// your navigation
import { AppSidebar } from "./app-sidebar";
export function AppMenu() {
+ const [open, setOpen] = React.useState(false);
+ const pathname = usePathname();
+ const searchParams = useSearchParams();
+
+ React.useEffect(() => {
+ setOpen(false);
+ }, [pathname, searchParams]); // remove searchParams if not needed
+
return (
- <Sheet>
+ <Sheet open={open} onOpenChange={(value) => setOpen(value)}>
<SheetTrigger asChild>
<Button size="icon" variant="outline">
<Menu className="h-6 w-6" />
@@ -21,9 +34,9 @@ export function AppMenu() {
</SheetTrigger>
<SheetContent>
<SheetHeader>
- <SheetTitle>Navigation</SheetTitle>
+ <SheetTitle className="text-left">Navigation</SheetTitle>
<SheetDescription>
- <AppSidebar />
+ <AppSidebar /> {/* is here */}
</SheetDescription>
</SheetHeader>
</SheetContent>
diff --git a/apps/web/src/components/layout/app-sidebar.tsx b/apps/web/src/components/layout/app-sidebar.tsx
index 7cc4147bb..332dab944 100644
--- a/apps/web/src/components/layout/app-sidebar.tsx
+++ b/apps/web/src/components/layout/app-sidebar.tsx
@@ -7,6 +7,13 @@ import { pagesConfig } from "@/config/pages";
import { cn } from "@/lib/utils";
import { Icons } from "../icons";
+type PageConfig = {
+ title: string;
+ href: string;
+ icon: string;
+ disabled: boolean;
+};
+
export function AppSidebar() {
const pathname = usePathname();
const params = useParams();
@@ -14,13 +21,14 @@ export function AppSidebar() {
<ul className="grid gap-1">
{pagesConfig.map(({ title, href, icon, disabled }) => {
const Icon = Icons[icon];
+ const link = `/app/${params.workspaceId}${href}`; // TODO: add
return (
<li key={title} className="w-full">
<Link
- href={`/app/${params.workspaceId}/${href}`}
+ href={link}
className={cn(
- "hover:bg-muted/50 hover:text-foreground text-muted-foreground group -mx-2 flex w-full min-w-[200px] items-center rounded-md border border-transparent px-3 py-1",
- pathname === href &&
+ "hover:bg-muted/50 hover:text-foreground text-muted-foreground group flex w-full min-w-[200px] items-center rounded-md border border-transparent px-3 py-1",
+ pathname === link &&
"bg-muted/50 border-border text-foreground",
disabled && "pointer-events-none opacity-60",
)}
diff --git a/apps/web/src/components/ui/card.tsx b/apps/web/src/components/ui/card.tsx
new file mode 100644
index 000000000..f5df31597
--- /dev/null
+++ b/apps/web/src/components/ui/card.tsx
@@ -0,0 +1,83 @@
+import * as React from "react";
+
+import { cn } from "@/lib/utils";
+
+const Card = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn(
+ "bg-card text-card-foreground rounded-xl border shadow",
+ className,
+ )}
+ {...props}
+ />
+));
+Card.displayName = "Card";
+
+const CardHeader = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn("flex flex-col space-y-1.5 p-6", className)}
+ {...props}
+ />
+));
+CardHeader.displayName = "CardHeader";
+
+const CardTitle = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes<HTMLHeadingElement>
+>(({ className, ...props }, ref) => (
+ <h3
+ ref={ref}
+ className={cn("font-semibold leading-none tracking-tight", className)}
+ {...props}
+ />
+));
+CardTitle.displayName = "CardTitle";
+
+const CardDescription = React.forwardRef<
+ HTMLParagraphElement,
+ React.HTMLAttributes<HTMLParagraphElement>
+>(({ className, ...props }, ref) => (
+ <p
+ ref={ref}
+ className={cn("text-muted-foreground text-sm", className)}
+ {...props}
+ />
+));
+CardDescription.displayName = "CardDescription";
+
+const CardContent = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
+));
+CardContent.displayName = "CardContent";
+
+const CardFooter = React.forwardRef<
+ HTMLDivElement,
+ React.HTMLAttributes<HTMLDivElement>
+>(({ className, ...props }, ref) => (
+ <div
+ ref={ref}
+ className={cn(" flex items-center p-6 pt-0", className)}
+ {...props}
+ />
+));
+CardFooter.displayName = "CardFooter";
+
+export {
+ Card,
+ CardHeader,
+ CardFooter,
+ CardTitle,
+ CardDescription,
+ CardContent,
+};
diff --git a/apps/web/src/components/ui/skeleton.tsx b/apps/web/src/components/ui/skeleton.tsx
new file mode 100644
index 000000000..5788d6758
--- /dev/null
+++ b/apps/web/src/components/ui/skeleton.tsx
@@ -0,0 +1,15 @@
+import { cn } from "@/lib/utils";
+
+function Skeleton({
+ className,
+ ...props
+}: React.HTMLAttributes<HTMLDivElement>) {
+ return (
+ <div
+ className={cn("bg-primary/10 animate-pulse rounded-md", className)}
+ {...props}
+ />
+ );
+}
+
+export { Skeleton };
diff --git a/apps/web/src/config/pages.ts b/apps/web/src/config/pages.ts
index b0ed76be3..0d7f38884 100644
--- a/apps/web/src/config/pages.ts
+++ b/apps/web/src/config/pages.ts
@@ -12,7 +12,7 @@ export const pagesConfig = [
{
title: "Dashboard",
description: "Get an overview of what's hot.",
- href: "/",
+ href: "",
icon: "layout-dashboard",
},
{
diff --git a/apps/web/src/lib/utils.ts b/apps/web/src/lib/utils.ts
index 73be6201d..526181d8a 100644
--- a/apps/web/src/lib/utils.ts
+++ b/apps/web/src/lib/utils.ts
@@ -5,3 +5,7 @@ import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
+
+export function wait(ms: number) {
+ return new Promise((resolve) => setTimeout(resolve, ms));
+}