improving

This commit is contained in:
zmeyer44 2023-10-23 15:02:49 -04:00
parent fb938204d4
commit dd9ffa1e07

View File

@ -42,7 +42,18 @@ export default function LocationSearchInput() {
return <p>hello{JSON.stringify(loadError)}</p>; return <p>hello{JSON.stringify(loadError)}</p>;
} }
if (!isLoaded) { if (!isLoaded) {
return <p>Loading...</p>; return (
<Button
variant={"ghost"}
disabled={true}
className={cn(
"justify-start p-0 text-left font-normal",
!value && "text-muted-foreground",
)}
>
Add a location...
</Button>
);
} }
return <CommandSearch />; return <CommandSearch />;
} }
@ -71,7 +82,10 @@ function CommandSearch() {
Add a location... Add a location...
</Button> </Button>
</PopoverTrigger> </PopoverTrigger>
<PopoverContent className="z-modal+ w-auto p-0" align="start"> <PopoverContent
className="z-modal+ w-auto max-w-[300px] p-0"
align="start"
>
<div className="rounded-lg border shadow-md"> <div className="rounded-lg border shadow-md">
<Input <Input
className="border-0 shadow-none focus-visible:ring-0" className="border-0 shadow-none focus-visible:ring-0"
@ -81,24 +95,30 @@ function CommandSearch() {
disabled={!ready} disabled={!ready}
/> />
<ul className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden")}> <ul className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden")}>
{data.map( {data.map((place) => {
({ const {
description, description,
place_id, place_id,
structured_formatting: { main_text, secondary_text }, structured_formatting: { main_text, secondary_text },
}) => ( } = place;
return (
<li <li
key={place_id} key={place_id}
onClick={() => console.log()}
className={cn( className={cn(
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 hover:bg-muted",
)} )}
> >
<HiOutlineBuildingStorefront className="mr-2 h-4 w-4" /> <HiOutlineBuildingStorefront className="mr-2 h-4 w-4" />
<span>{main_text}</span> <div className="line-clamp-1">
<span>{description}</span> <p>{main_text}</p>
<span className="text-[10px] text-muted-foreground">
{secondary_text}
</span>
</div>
</li> </li>
), );
)} })}
</ul> </ul>
</div> </div>
</PopoverContent> </PopoverContent>