mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
refactor: swap out manual tabs withthe shared tabs component in stickers
This commit is contained in:
@@ -8,6 +8,7 @@ import { DraggableItem } from "@/components/editor/panels/assets/draggable-item"
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Spinner } from "@/components/ui/spinner";
|
import { Spinner } from "@/components/ui/spinner";
|
||||||
|
import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import { useEditor } from "@/hooks/use-editor";
|
import { useEditor } from "@/hooks/use-editor";
|
||||||
import { resolveStickerIntrinsicSize } from "@/lib/stickers";
|
import { resolveStickerIntrinsicSize } from "@/lib/stickers";
|
||||||
import {
|
import {
|
||||||
@@ -70,41 +71,25 @@ export function StickersView() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="mt-2 flex min-h-0 flex-1 flex-col">
|
<Tabs
|
||||||
<div className="border-b border-border px-2">
|
value={selectedCategory}
|
||||||
<div
|
onValueChange={(value) => {
|
||||||
role="tablist"
|
setSelectedCategory({ category: value as StickerCategory });
|
||||||
aria-label="Sticker categories"
|
}}
|
||||||
className="text-muted-foreground inline-flex h-auto items-center gap-0 bg-transparent p-0"
|
variant="underline"
|
||||||
>
|
className="mt-2 flex min-h-0 flex-1 flex-col"
|
||||||
{Object.entries(STICKER_CATEGORIES).map(([key, label]) => {
|
|
||||||
const isActive = key === selectedCategory;
|
|
||||||
return (
|
|
||||||
<button
|
|
||||||
key={key}
|
|
||||||
type="button"
|
|
||||||
role="tab"
|
|
||||||
aria-selected={isActive}
|
|
||||||
onClick={() =>
|
|
||||||
setSelectedCategory({
|
|
||||||
category: key as StickerCategory,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
className={cn(
|
|
||||||
"text-muted-foreground rounded-none border-b-2 border-transparent px-3 py-2 text-sm font-medium whitespace-nowrap -mb-px",
|
|
||||||
isActive && "text-primary border-primary",
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
|
<TabsList aria-label="Sticker categories">
|
||||||
|
{Object.entries(STICKER_CATEGORIES).map(([key, label]) => (
|
||||||
|
<TabsTrigger key={key} value={key}>
|
||||||
{label}
|
{label}
|
||||||
</button>
|
</TabsTrigger>
|
||||||
);
|
))}
|
||||||
})}
|
</TabsList>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div className="min-h-0 flex-1 overflow-y-auto px-4 pt-4">
|
<div className="min-h-0 flex-1 overflow-y-auto px-4 pt-4">
|
||||||
<StickersContentView />
|
<StickersContentView />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user