diff --git a/app/app/routes/home.tsx b/app/app/routes/home.tsx new file mode 100644 index 0000000..28cbad8 --- /dev/null +++ b/app/app/routes/home.tsx @@ -0,0 +1,90 @@ +import { useState } from "react"; +import type { Route } from "./+types/home"; +import { Button } from "~/components/ui/button"; +import { Input } from "~/components/ui/input"; +import { Card, CardContent } from "~/components/ui/card"; +import { Plus } from "lucide-react"; +import { SongCard } from "~/components/song-card"; +import { AddSongSheet } from "~/components/add-song-sheet"; +import { MOCK_SONGS } from "~/lib/mock"; +import type { SongSummary } from "~/lib/types"; + +export function meta({}: Route.MetaArgs) { + return [ + { title: "PocketChords" }, + { name: "description", content: "Your personal chord chart library" }, + ]; +} + +export function loader() { + return { songs: MOCK_SONGS }; +} + +export default function Home({ loaderData }: Route.ComponentProps) { + const { songs } = loaderData; + const [query, setQuery] = useState(""); + const [sheetOpen, setSheetOpen] = useState(false); + const [localSongs, setLocalSongs] = useState([]); + + const allSongs = [...songs, ...localSongs]; + const filtered = query.trim() + ? allSongs.filter( + (s) => + s.meta.title.toLowerCase().includes(query.toLowerCase()) || + s.meta.artist.toLowerCase().includes(query.toLowerCase()) + ) + : allSongs; + + return ( +
+ {/* Header */} +
+

PocketChords

+ +
+ + {/* Search */} +
+ setQuery(e.target.value)} + className="w-full" + /> +
+ + {/* Grid */} +
+ {filtered.length === 0 ? ( +

+ {query ? "No songs match your search." : "No songs yet. Tap Add to get started."} +

+ ) : ( +
+ {filtered.map((song) => ( + + ))} + {/* Add card */} + setSheetOpen(true)} + > + + + + +
+ )} +
+ + setLocalSongs((prev) => [...prev, summary])} + /> +
+ ); +}