diff --git a/web/src/components/plants/PlantChip.tsx b/web/src/components/plants/PlantChip.tsx new file mode 100644 index 0000000..c7e46a4 --- /dev/null +++ b/web/src/components/plants/PlantChip.tsx @@ -0,0 +1,41 @@ +import { cn } from '@/lib/cn' +import { PlantIcon } from '@/components/plants/PlantIcon' +import type { Plant } from '@/lib/plants' + +/** + * A small tap-to-arm plant chip (icon + name), highlighted when it's the armed + * plant. Shared by the Seed Tray (which wraps it with a remove button) and the + * Recent-plants strip, so the two quick-pick surfaces stay visually identical. + * `rounded` is false when a caller (the tray) attaches a trailing control and + * needs a flat right edge. + */ +export function PlantChip({ + plant, + active, + onArm, + rounded = true, +}: { + plant: Plant + active: boolean + onArm: (plant: Plant) => void + rounded?: boolean +}) { + return ( + + ) +} diff --git a/web/src/editor/RecentPlants.tsx b/web/src/editor/RecentPlants.tsx index 6b4f41a..1f86fd2 100644 --- a/web/src/editor/RecentPlants.tsx +++ b/web/src/editor/RecentPlants.tsx @@ -1,5 +1,4 @@ -import { cn } from '@/lib/cn' -import { PlantIcon } from '@/components/plants/PlantIcon' +import { PlantChip } from '@/components/plants/PlantChip' import type { Plant } from '@/lib/plants' /** @@ -22,27 +21,9 @@ export function RecentPlants({ return (
Recent - {plants.map((p) => { - const active = p.id === armedPlantId - return ( - - ) - })} + {plants.map((p) => ( + + ))}
) } diff --git a/web/src/editor/SeedTray.tsx b/web/src/editor/SeedTray.tsx index cbfe6f1..06e6de6 100644 --- a/web/src/editor/SeedTray.tsx +++ b/web/src/editor/SeedTray.tsx @@ -1,5 +1,5 @@ import { cn } from '@/lib/cn' -import { PlantIcon } from '@/components/plants/PlantIcon' +import { PlantChip } from '@/components/plants/PlantChip' import type { Plant } from '@/lib/plants' /** @@ -26,28 +26,19 @@ export function SeedTray({ {trayPlants.map((p) => { const active = p.id === armedPlantId return ( - - + + {/* Flat right edge so the remove button below seams into one pill. */} + diff --git a/web/src/pages/GardenEditorPage.tsx b/web/src/pages/GardenEditorPage.tsx index 3d3157d..dac74ee 100644 --- a/web/src/pages/GardenEditorPage.tsx +++ b/web/src/pages/GardenEditorPage.tsx @@ -45,6 +45,10 @@ import { ApiError } from '@/lib/api' const routeApi = getRouteApi('/gardens/$gardenId') +// How many recently-planted chips the Plants-mode quick strip shows — a working +// set, not the whole history; the picker covers the long tail. +const RECENT_PLANTS_MAX = 8 + export function GardenEditorPage() { const { gardenId } = routeApi.useParams() const gid = Number(gardenId) @@ -118,7 +122,7 @@ export function GardenEditorPage() { const recentPlants = useMemo( () => recentlyPlantedIds(plantings) - .slice(0, 8) + .slice(0, RECENT_PLANTS_MAX) .map((id) => plantsById.get(id)) .filter((p): p is Plant => !!p), [plantings, plantsById],