feat(problem): add tabs state management with zustand and loading skeleton
This commit is contained in:
parent
466caed5bd
commit
faad41039a
@ -1,3 +1,7 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
import { useTabsStore } from "@/store/useTabsStore";
|
||||||
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { CircleCheckBigIcon, FileTextIcon, FlaskConicalIcon } from "lucide-react";
|
import { CircleCheckBigIcon, FileTextIcon, FlaskConicalIcon } from "lucide-react";
|
||||||
@ -13,8 +17,22 @@ export default function ProblemLayout({
|
|||||||
solution,
|
solution,
|
||||||
submission,
|
submission,
|
||||||
}: ProblemLayoutProps) {
|
}: ProblemLayoutProps) {
|
||||||
|
const { hydrated, problemTab, setProblemTab } = useTabsStore();
|
||||||
|
|
||||||
|
if (!hydrated) return (
|
||||||
|
<div className="h-9 w-full flex items-center px-2 py-1 bg-muted gap-1">
|
||||||
|
<Skeleton className="h-full w-[136px] rounded-3xl" />
|
||||||
|
<Skeleton className="h-full w-[111px] rounded-3xl" />
|
||||||
|
<Skeleton className="h-full w-32 rounded-3xl" />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
|
||||||
|
const handleTabChange = (value: string) => {
|
||||||
|
setProblemTab(value);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs defaultValue="description" className="h-full flex flex-col">
|
<Tabs value={problemTab} onValueChange={handleTabChange} className="h-full flex flex-col">
|
||||||
<ScrollArea className="h-9 flex-none bg-muted px-1">
|
<ScrollArea className="h-9 flex-none bg-muted px-1">
|
||||||
<TabsList className="gap-1 bg-transparent">
|
<TabsList className="gap-1 bg-transparent">
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
|
Loading…
Reference in New Issue
Block a user