返回 presentation-ai
WidthSection.tsx
1 "use client";
2
3 import { MdOutlineWidthFull } from "react-icons/md";
4
5 import { Label } from "@/components/ui/label";
6 import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group";
7 import { cn } from "@/lib/utils";
8 import { useCommonValues } from "../hooks/useCommonValues";
9 import { useUpdateAllSlides } from "../hooks/useUpdateAllSlides";
10
11 export function WidthSection() {
12 const { currentWidth } = useCommonValues();
13 const updateAllSlides = useUpdateAllSlides();
14
15 return (
16 <div className="space-y-2">
17 <Label
18 htmlFor="card-width"
19 className="flex items-center gap-2 text-sm font-semibold text-foreground"
20 >
21 <MdOutlineWidthFull className="size-4 text-muted-foreground" />
22 Card Width
23 </Label>
24 <ToggleGroup
25 id="card-width"
26 type="single"
27 variant="outline"
28 value={currentWidth}
29 onValueChange={(val) =>
30 val && updateAllSlides({ width: val as "S" | "M" | "L" })
31 }
32 className="w-full gap-2 rounded-full"
33 >
34 <ToggleGroupItem
35 value="S"
36 variant="outline"
37 size="sm"
38 className={cn(
39 "flex-1 border-border transition-all",
40 currentWidth === "S" &&
41 "border-primary bg-primary text-primary-foreground",
42 )}
43 >
44 S
45 </ToggleGroupItem>
46 <ToggleGroupItem
47 value="M"
48 variant="outline"
49 size="sm"
50 className={cn(
51 "flex-1 border-border transition-all",
52 currentWidth === "M" &&
53 "border-primary bg-primary text-primary-foreground",
54 )}
55 >
56 M
57 </ToggleGroupItem>
58 <ToggleGroupItem
59 value="L"
60 variant="outline"
61 size="sm"
62 className={cn(
63 "flex-1 border-border transition-all",
64 currentWidth === "L" &&
65 "border-primary bg-primary text-primary-foreground",
66 )}
67 >
68 L
69 </ToggleGroupItem>
70 </ToggleGroup>
71 </div>
72 );
73 }
74
74 lines Plain Text