From 9bb5ed1517bb018cafb1a1657b1751660a3a5d66 Mon Sep 17 00:00:00 2001 From: Ishaan Dey Date: Sat, 11 May 2024 18:13:01 -0700 Subject: [PATCH] fix loading state --- frontend/app/(app)/code/[id]/page.tsx | 1 + frontend/components/editor/loading.tsx | 62 +++++++++++---------- frontend/components/editor/navbar/index.tsx | 44 +++++++-------- 3 files changed, 55 insertions(+), 52 deletions(-) diff --git a/frontend/app/(app)/code/[id]/page.tsx b/frontend/app/(app)/code/[id]/page.tsx index fe6a253..6d123eb 100644 --- a/frontend/app/(app)/code/[id]/page.tsx +++ b/frontend/app/(app)/code/[id]/page.tsx @@ -9,6 +9,7 @@ import { Suspense } from "react"; const CodeEditor = dynamic(() => import("@/components/editor"), { ssr: false, + loading: () => , }); const getUserData = async (id: string) => { diff --git a/frontend/components/editor/loading.tsx b/frontend/components/editor/loading.tsx index 662e354..5ee9ca8 100644 --- a/frontend/components/editor/loading.tsx +++ b/frontend/components/editor/loading.tsx @@ -3,43 +3,45 @@ import Logo from "@/assets/logo.svg"; import { Skeleton } from "../ui/skeleton"; import { Loader, Loader2 } from "lucide-react"; -export default function Loading() { +export default function Loading({ withNav = false }: { withNav?: boolean }) { return ( - //
- //
- //
- // Logo - // - //
- //
- // - // - //
- //
-
-
-
-
Explorer
-
- - +
+ {withNav ? ( +
+
+ Logo + +
+
+ +
-
-
- + ) : null} +
+
+
+
Explorer
+
+ + +
+
+
+
+ +
-
-
-
- - Loading... +
+
+ + Loading... +
+ +
- -
- //
); } diff --git a/frontend/components/editor/navbar/index.tsx b/frontend/components/editor/navbar/index.tsx index b5cfede..413200b 100644 --- a/frontend/components/editor/navbar/index.tsx +++ b/frontend/components/editor/navbar/index.tsx @@ -1,33 +1,33 @@ -"use client" +"use client"; -import Image from "next/image" -import Logo from "@/assets/logo.svg" -import { Pencil, Users } from "lucide-react" -import Link from "next/link" -import { Sandbox, User } from "@/lib/types" -import UserButton from "@/components/ui/userButton" -import { Button } from "@/components/ui/button" -import { useState } from "react" -import EditSandboxModal from "./edit" -import ShareSandboxModal from "./share" -import { Avatars } from "../live/avatars" +import Image from "next/image"; +import Logo from "@/assets/logo.svg"; +import { Pencil, Users } from "lucide-react"; +import Link from "next/link"; +import { Sandbox, User } from "@/lib/types"; +import UserButton from "@/components/ui/userButton"; +import { Button } from "@/components/ui/button"; +import { useState } from "react"; +import EditSandboxModal from "./edit"; +import ShareSandboxModal from "./share"; +import { Avatars } from "../live/avatars"; export default function Navbar({ userData, sandboxData, shared, }: { - userData: User - sandboxData: Sandbox + userData: User; + sandboxData: Sandbox; shared: { - id: string - name: string - }[] + id: string; + name: string; + }[]; }) { - const [isEditOpen, setIsEditOpen] = useState(false) - const [isShareOpen, setIsShareOpen] = useState(false) + const [isEditOpen, setIsEditOpen] = useState(false); + const [isShareOpen, setIsShareOpen] = useState(false); - const isOwner = sandboxData.userId === userData.id + const isOwner = sandboxData.userId === userData.id; return ( <> @@ -42,7 +42,7 @@ export default function Navbar({ data={sandboxData} shared={shared} /> -
+
- ) + ); }