Files
Showy/docs-vault/Components.md
T
Mohammed AbadandCopilot 3448142242 feat(frontend): add Spotlight-style command palette with recent tracking
- Add CommandPalette component with keyboard navigation (arrows, Enter, Shift+Enter, Esc)
- Add useCommandPaletteStore Zustand store with localStorage-persisted recently viewed
- Show two distinct sections: Library results and TMDB Results (no duplicates)
- Exclude library entries from TMDB Results section by TMDB ID index
- Add "View all" links: Library section → /library, TMDB section → /search
- Persist non-library TMDB entries in localStorage for recently viewed support
- Register global Ctrl+P / Cmd+P / slash shortcuts in AppLayout
- Track entry visits in EntryDetailsPage for recently viewed
- Track TMDB preview visits in TmdbPreviewPage for recently viewed
- Updated related docs files

Co-authored-by: Copilot <copilot@github.com>
2026-05-04 08:33:27 +01:00

155 lines
6.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: Components
tags:
- frontend
- components
- react
---
# Components
All in `react_frontend/src/components/`. Organized by domain.
---
## Layout
| Component | File | Description |
|---|---|---|
| `AppLayout` | `layout/AppLayout.tsx` | Root layout with Sidebar + main area; registers global `Ctrl+P` / `/` shortcut for the command palette |
| `Sidebar` | `layout/Sidebar.tsx` | Left navigation sidebar |
| `TitleBar` | `layout/TitleBar.tsx` | Custom frameless title bar (Electron only) |
| `CommandPalette` | `CommandPalette.tsx` | Spotlight-style command palette — see [[Search#Command Palette]] |
## Entry Components
| Component | File | Description |
|---|---|---|
| `EntryCard` | `entries/EntryCard.tsx` | Entry poster card (grid item) |
| `EntryLibraryGrid` | `entries/EntryLibraryGrid.tsx` | Grid layout for entry cards |
| `TrendingSlider` | `entries/TrendingSlider.tsx` | Horizontal slider for trending entries |
| `TrendingGrid` | `entries/TrendingGrid.tsx` | Grid for trending/popular TMDB entries |
| `SeasonsContainer` | `entries/SeasonsContainer.tsx` | Seasons list for TV entry details |
| `EpisodeWatchHistory` | `entries/EpisodeWatchHistory.tsx` | Watch history list for an episode |
| `CastList` | `entries/CastList.tsx` | Horizontal cast/crew list |
## Collection Components
| Component | File | Description |
|---|---|---|
| `CollectionsGrid` | `collections/CollectionsGrid.tsx` | Grid of collection cards |
## Dashboard Charts
See [[Statistics]] for data details.
| Component | File | Description |
|---|---|---|
| `WatchActivityChart` | `dashboard/WatchActivityChart.tsx` | Monthly watch activity (area chart) |
| `WatchTimeChart` | `dashboard/WatchTimeChart.tsx` | Monthly watch time (area chart) |
| `CouchDayChart` | `dashboard/CouchDayChart.tsx` | Day-of-week distribution (bar chart) |
| `LibraryGrowthChart` | `dashboard/LibraryGrowthChart.tsx` | Library growth over time (area chart) |
| `MediaTypeChart` | `dashboard/MediaTypeChart.tsx` | Movies vs TV breakdown |
| `TopGenresChart` | `dashboard/TopGenresChart.tsx` | Top genres by count |
| `RatingsChart` | `dashboard/RatingsChart.tsx` | Ratings distribution |
## Dialogs
| Component | File | Description |
|---|---|---|
| `EntrySeenDialog` | `dialogs/EntrySeenDialog.tsx` | Mark movie/episode as watched. Uses react-hook-form + zod. See [[Watch Tracking]] |
| `EpisodeSeenEditDialog` | `dialogs/EpisodeSeenEditDialog.tsx` | Create/edit episode watch record |
| `EntryMediaDialog` | `dialogs/EntryMediaDialog.tsx` | Media gallery for entry |
| `EntrySettingsDialog` | `dialogs/EntrySettingsDialog.tsx` | Entry settings (calendar, sync, hidden) |
| `MovieWatchHistoryDialog` | `dialogs/MovieWatchHistoryDialog.tsx` | Full movie watch history |
| `RatingDialog` | `dialogs/RatingDialog.tsx` | Rate entry (supports half-stars) |
| `ConfirmDialog` | `dialogs/ConfirmDialog.tsx` | Generic confirmation dialog |
| `AddEntryToCollectionDialog` | `dialogs/AddEntryToCollectionDialog.tsx` | Add entry to collection picker |
| `CollectionEditDialog` | `dialogs/CollectionEditDialog.tsx` | Create/edit collection |
| `MarkSeasonWatchedDialog` | `dialogs/MarkSeasonWatchedDialog.tsx` | Mark season as watched — single date or scatter mode |
## Skeletons
> [!info] File: `components/skeletons/PageSkeletons.tsx`
14 named skeleton exports used as `<Suspense>` fallbacks for lazy-loaded pages:
`HomeSkeleton`, `LibrarySkeleton`, `WatchlistSkeleton`, `DashboardSkeleton`, `CollectionsSkeleton`, `CollectionDetailsSkeleton`, `MediaSkeleton`, `CalendarSkeleton`, `EntryDetailsSkeleton`, `SeasonSkeleton`, `EpisodeSkeleton`, `PeopleSkeleton`, `PersonDetailsSkeleton`, `SettingsSkeleton`
## Command Palette
> [!info] File: `components/CommandPalette.tsx`
Spotlight / Raycast-style command palette rendered at root level inside `AppLayout`.
### Trigger
| Shortcut | Condition |
|---|---|
| `Ctrl+P` / `Cmd+P` | Always |
| `/` | When focus is not on an input or textarea |
### Sections (when searching)
| Section | Source | Behaviour |
|---|---|---|
| Quick Actions / Commands | Static list | Navigation commands (Library, Watchlist, Stats, Calendar, People, Settings, Favorites) |
| Library | [[Stores\|useLibraryStore]] | Client-side fuzzy search — results appear instantly |
| TMDB Results | `tmdbApi.search()` (debounced 250 ms) | Entries already in library are **fully excluded** |
**View all links:**
- Library → `/library?search=<query>`
- TMDB Results → `/search?q=<query>`
### Recently Viewed (empty query)
Shown when the search input is empty. Populated by:
- `EntryDetailsPage` on mount → saves library entry with `id: "lib-{id}"`
- `TmdbPreviewPage` on mount → saves TMDB-only entry with `id: "tmdb-{tmdbId}"`
Persisted to `localStorage` via [[Stores\|useCommandPaletteStore]].
### Keyboard Navigation
| Key | Action |
|---|---|
| `↑` / `↓` | Move selection |
| `Enter` | Open selected item |
| `Shift+Enter` | Quick-add to library (TMDB items only) |
| `Esc` | Close palette |
### Selection Behaviour
- **Command** → navigate to route
- **Library item** → navigate to `/entry/:id`
- **TMDB item (Enter)** → navigate to `/entry/tmdb/:type/:tmdbId` (preview)
- **TMDB item (Shift+Enter)** → `useCreateEntry` mutation, then navigate to new entry
---
## UI Primitives (shadcn/ui)
Base components from shadcn/ui in `components/ui/`:
`badge`, `avatar`, `button`, `calendar`, `card`, `checkbox`, `dialog`, `dropdown-menu`, `input`, `label`, `popover`, `progress`, `scroll-area`, `select`, `separator`, `sheet`, `skeleton`, `sonner`, `star-rating`, `switch`, `tabs`, `textarea`, `tooltip`
### StarRating
> [!important] Centralized Rating Component
> All user rating inputs across the application MUST use `StarRating` from `components/ui/star-rating.tsx`.
| Prop | Type | Default | Description |
|---|---|---|---|
| `value` | `number` | — | Current rating value (0–10, supports halves like 7.5) |
| `onChange` | `(rating: number) => void` | — | Callback when user clicks a star. Clicking same value resets to 0 |
| `max` | `number` | `10` | Number of stars |
| `size` | `'sm' \| 'md' \| 'lg'` | `'lg'` | Star icon size (`h-4`, `h-6`, `h-8`) |
| `readOnly` | `boolean` | `false` | Disables interaction |
Used in:
- [[Components#Dialogs|RatingDialog]] — Entry rating dialog (size `lg`)
- [[Components#Dialogs|EntrySettingsDialog]] — Inline entry rating (size `sm`)
- [[Components#Dialogs|CollectionEditDialog]] — Collection rating (size `md`)
Theme: **base-nova** style.