🎨 Style: tag-list-2

This commit is contained in:
cheliangzhao 2023-09-15 11:21:39 +08:00
parent 0e3042b458
commit d928368ceb
3 changed files with 24 additions and 19 deletions

View File

@ -53,7 +53,7 @@ export function TagAdd({
return ( return (
<Card <Card
className={cn("w-full h-fit border-none shadow-none", className)} className={cn("w-[272px] h-fit border-none shadow-none", className)}
ref={ref} ref={ref}
> >
<CardContent className="p-4 space-y-4"> <CardContent className="p-4 space-y-4">

View File

@ -65,7 +65,7 @@ const TagList2Options = ({ tag }: ITagList2OptionsProps) => {
<span></span> <span></span>
</DropdownMenuItem> </DropdownMenuItem>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent className="h-fit w-fit"> <PopoverContent className="h-fit w-fit p-0">
<TagAdd color={tag.color} value={tag.name} /> <TagAdd color={tag.color} value={tag.name} />
</PopoverContent> </PopoverContent>
</Popover> </Popover>
@ -167,7 +167,7 @@ export default function TagList2({ list, className }: ITagListProps) {
<span></span> <span></span>
</div> </div>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent className="w-[200px] p-0"> <PopoverContent className="w-fit h-fit p-0">
<TagAdd /> <TagAdd />
</PopoverContent> </PopoverContent>
</Popover> </Popover>

View File

@ -7,6 +7,7 @@ import {
CommandList, CommandList,
CommandSeparator, CommandSeparator,
} from "@/components/ui/command"; } from "@/components/ui/command";
import { ScrollArea } from "@/components/ui/scroll-area";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { Check, Plus } from "lucide-react"; import { Check, Plus } from "lucide-react";
import React, { useState } from "react"; import React, { useState } from "react";
@ -21,6 +22,7 @@ export default function TagList({ list, className }: ITagListProps) {
<Command className={cn("rounded-lg border shadow-md h-fit p-2", className)}> <Command className={cn("rounded-lg border shadow-md h-fit p-2", className)}>
<CommandList> <CommandList>
<CommandGroup> <CommandGroup>
<ScrollArea className="max-h-32">
{list.map((tag) => ( {list.map((tag) => (
<CommandItem <CommandItem
value={tag.id + ""} value={tag.id + ""}
@ -29,7 +31,9 @@ export default function TagList({ list, className }: ITagListProps) {
onSelect={(v) => setSelectedValue(v + "")} onSelect={(v) => setSelectedValue(v + "")}
> >
<div className="flex justify-start items-center"> <div className="flex justify-start items-center">
<div className={cn("mr-2 h-2 w-2 rounded-[2px]", tag.color)} /> <div
className={cn("mr-2 h-2 w-2 rounded-[2px]", tag.color)}
/>
<span>{tag.name}</span> <span>{tag.name}</span>
</div> </div>
{selectedValue === tag.id + "" && ( {selectedValue === tag.id + "" && (
@ -37,6 +41,7 @@ export default function TagList({ list, className }: ITagListProps) {
)} )}
</CommandItem> </CommandItem>
))} ))}
</ScrollArea>
</CommandGroup> </CommandGroup>
<CommandSeparator /> <CommandSeparator />
<CommandGroup> <CommandGroup>