Files
Showy/docs-vault/Components.md
X4Lo eb3a12f6cb Add Discovery Videos feature
Let users upload videos, tag them with one or more entries, and watch
them from a new Discovery Videos page.

Backend:
- Add Video and VideoEntry models and relations
- Add video controller and /video routes
- Add video thumbnail generation service (ffmpeg-static)
- Add video upload storage location and config

Frontend:
- Add DiscoveryVideosPage with sidebar link and route
- Add AddVideoDialog, VideoDropzone, EntryMultiSelect, VideoCard
  and VideoPlayerDialog components
- Add discoveryVideos API client and useDiscoveryVideos hook
- Add format helpers, video types and normalizers
- Add skeleton for the page

Docs:
- Document the feature in docs-vault
2026-11-03 15:57:53 +00:00

169 lines
7.3 KiB
Markdown
Raw Permalink 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 |
## Discovery Video Components
> [!info] Folder: `components/discovery-videos/`
See [[Discovery Videos]].
| Component | File | Description |
|---|---|---|
| `VideoCard` | `discovery-videos/VideoCard.tsx` | Card with lazy thumbnail (`loading="lazy"`, on-demand generation) + play overlay, linked-entry chips, edit/delete actions |
| `VideoPlayerDialog` | `discovery-videos/VideoPlayerDialog.tsx` | Playback dialog — autoplay, ↑/↓ (and ←/→) prev/next navigation, linked-entry chips, inline edit |
| `AddVideoDialog` | `discovery-videos/AddVideoDialog.tsx` | Upload (create) and edit modes — dropzone + description + entry multi-select |
| `VideoDropzone` | `discovery-videos/VideoDropzone.tsx` | Native HTML5 drag & drop zone (no dependency) |
| `EntryMultiSelect` | `discovery-videos/EntryMultiSelect.tsx` | Search-first library entry picker (debounced 250 ms) reading from [[Stores\|library store]] |
## Skeletons
> [!info] File: `components/skeletons/PageSkeletons.tsx`
15 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`, `DiscoveryVideosSkeleton`
## 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.