mirror of
https://github.com/shadcn-ui/ui.git
synced 2026-06-11 09:51:40 +00:00
* feat: init * fix * fix * fix * feat * feat * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: implement icons * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: update init command * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: dialog * feat * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: add registry:base item type * feat: rename frame to canva * fix * feat * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fi * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: add all colors * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * feat: add outfit font * fix * fix * fix * fix * fix * chore: changeset * fix * fix * fix * fix * fix * fix * fix * fix
84 lines
2.4 KiB
TypeScript
84 lines
2.4 KiB
TypeScript
"use client"
|
|
|
|
import * as React from "react"
|
|
import { type PopoverProps } from "@radix-ui/react-popover"
|
|
import { Check, ChevronsUpDown } from "lucide-react"
|
|
|
|
import { cn } from "@/lib/utils"
|
|
import { Button } from "@/registry/new-york-v4/ui/button"
|
|
import {
|
|
Command,
|
|
CommandEmpty,
|
|
CommandGroup,
|
|
CommandInput,
|
|
CommandItem,
|
|
CommandList,
|
|
CommandSeparator,
|
|
} from "@/registry/new-york-v4/ui/command"
|
|
import {
|
|
Popover,
|
|
PopoverContent,
|
|
PopoverTrigger,
|
|
} from "@/registry/new-york-v4/ui/popover"
|
|
|
|
import { type Preset } from "../data/presets"
|
|
|
|
interface PresetSelectorProps extends PopoverProps {
|
|
presets: Preset[]
|
|
}
|
|
|
|
export function PresetSelector({ presets, ...props }: PresetSelectorProps) {
|
|
const [open, setOpen] = React.useState(false)
|
|
const [selectedPreset, setSelectedPreset] = React.useState<Preset>()
|
|
|
|
return (
|
|
<Popover open={open} onOpenChange={setOpen} {...props}>
|
|
<PopoverTrigger asChild>
|
|
<Button
|
|
variant="outline"
|
|
role="combobox"
|
|
aria-label="Load a preset..."
|
|
aria-expanded={open}
|
|
className="flex-1 justify-between md:max-w-[200px] lg:max-w-[300px]"
|
|
>
|
|
{selectedPreset ? selectedPreset.name : "Load a preset..."}
|
|
<ChevronsUpDown className="opacity-50" />
|
|
</Button>
|
|
</PopoverTrigger>
|
|
<PopoverContent className="w-[300px] p-0">
|
|
<Command>
|
|
<CommandInput placeholder="Search presets..." />
|
|
<CommandList>
|
|
<CommandEmpty>No presets found.</CommandEmpty>
|
|
<CommandGroup heading="Examples">
|
|
{presets.map((preset) => (
|
|
<CommandItem
|
|
key={preset.id}
|
|
onSelect={() => {
|
|
setSelectedPreset(preset)
|
|
setOpen(false)
|
|
}}
|
|
>
|
|
{preset.name}
|
|
<Check
|
|
className={cn(
|
|
"ml-auto",
|
|
selectedPreset?.id === preset.id
|
|
? "opacity-100"
|
|
: "opacity-0"
|
|
)}
|
|
/>
|
|
</CommandItem>
|
|
))}
|
|
</CommandGroup>
|
|
<CommandSeparator />
|
|
<CommandGroup>
|
|
<CommandItem>More examples</CommandItem>
|
|
</CommandGroup>
|
|
</CommandList>
|
|
</Command>
|
|
</PopoverContent>
|
|
</Popover>
|
|
)
|
|
}
|