Skip to content

Commit ea635a5

Browse files
authored
Merge pull request #16 from AnasSarkiz/main
Enhance PreviewCanvas view mode selector with tab-style design
2 parents 893b1ee + b5dc6ca commit ea635a5

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

lib/components/preview-canvas.tsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Layers, Move, RotateCcwSquare, RotateCwSquare } from "lucide-react"
66
import { useWorkspace } from "./workspace-context"
77
import { useState, useRef } from "react"
88
import { useSvgGeneration, useSvgTransform } from "../hooks/preview-hooks"
9+
import { cn } from "@/utils"
910
export function PreviewCanvas() {
1011
const { circuitJson, lbrnOptions } = useWorkspace()
1112
const [viewMode, setViewMode] = useState<"lbrn" | "pcb" | "both">("lbrn")
@@ -55,28 +56,42 @@ export function PreviewCanvas() {
5556
<RotateCwSquare className="size-3.5" />
5657
</Button>
5758
</div>
58-
<div className="flex items-center gap-0 border border-border rounded-md p-1 bg-muted/20">
59+
<div className="inline-flex items-center rounded-lg bg-muted p-1">
5960
<Button
60-
variant={viewMode === "lbrn" ? "default" : "ghost"}
61+
variant="ghost"
6162
size="sm"
62-
className="rounded-r-none"
6363
onClick={() => setViewMode("lbrn")}
64+
className={cn(
65+
"rounded-md px-4 h-8 transition-all",
66+
viewMode === "lbrn" &&
67+
"bg-primary text-primary-foreground shadow-sm",
68+
)}
6469
>
6570
LBRN
6671
</Button>
72+
6773
<Button
68-
variant={viewMode === "pcb" ? "default" : "ghost"}
74+
variant="ghost"
6975
size="sm"
70-
className="rounded-none border-x"
7176
onClick={() => setViewMode("pcb")}
77+
className={cn(
78+
"rounded-md px-4 h-8 transition-all",
79+
viewMode === "pcb" &&
80+
"bg-primary text-primary-foreground shadow-sm",
81+
)}
7282
>
7383
PCB
7484
</Button>
85+
7586
<Button
76-
variant={viewMode === "both" ? "default" : "ghost"}
87+
variant="ghost"
7788
size="sm"
78-
className="rounded-l-none"
7989
onClick={() => setViewMode("both")}
90+
className={cn(
91+
"rounded-md px-4 h-8 transition-all",
92+
viewMode === "both" &&
93+
"bg-primary text-primary-foreground shadow-sm",
94+
)}
8095
>
8196
Both
8297
</Button>

0 commit comments

Comments
 (0)