diff --git a/src/routes/_api/favorite/favorite.scss b/src/routes/_api/favorite/favorite.scss index e69de29..67d62ab 100644 --- a/src/routes/_api/favorite/favorite.scss +++ b/src/routes/_api/favorite/favorite.scss @@ -0,0 +1,140 @@ +@use "@/styles/variables.scss" as *; + +.favorite-page { + display: flex; + flex-direction: column; + height: 100%; + width: 100%; + overflow-y: auto; + padding-bottom: 2em; + + .favorite-header { + padding: 2em 2em 0 2em; + display: flex; + flex-direction: column; + gap: 0.5em; + position: relative; + z-index: 2; + + .header-content { + display: flex; + align-items: flex-end; + justify-content: space-between; + + h1 { + font-size: 2.2rem; + font-weight: 600; + margin: 0; + color: rgba(255, 255, 255, 0.95); + letter-spacing: -0.02em; + } + } + + .MuiTabs-root { + min-height: 40px; + margin-left: -12px; + margin-top: 1em; + + .MuiTabs-indicator { + display: none; // Hide default indicator + } + + .MuiTabs-scroller { + overflow: visible !important; // Allow shadows/glows to show + } + + .MuiTab-root { + text-transform: none; + font-size: 0.9rem; + font-weight: 500; + color: rgba(255, 255, 255, 0.6); + padding: 8px 20px; + min-height: 36px; + min-width: fit-content; + border-radius: 100px; + margin-right: 8px; + transition: all $transition-time-fast ease; + background-color: transparent; + border: 1px solid rgba(255, 255, 255, 0.1); + + &:first-of-type { + margin-left: 12px; + } + + &:hover { + color: rgba(255, 255, 255, 0.9); + background-color: rgba(255, 255, 255, 0.05); + border-color: rgba(255, 255, 255, 0.2); + } + + &.Mui-selected { + color: #fff; + font-weight: 600; + background-color: $clr-accent-default; + border-color: $clr-accent-default; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); + } + } + } + } + + .favorite-content { + padding: 0.5em 0; + flex: 1; + + // For Overview (Scrollers) + .overview-section { + padding: 0 2em; // Align with header + display: flex; + flex-direction: column; + gap: 1.5em; + + // Override card scroller buttons to fit the new padding + .card-scroller-button { + width: 2em !important; + + &.left { + left: -2em !important; + border-radius: 4px !important; + } + + &.right { + right: -2em !important; + border-radius: 4px !important; + } + + .material-symbols-rounded { + font-size: 2em; + } + } + } + + + // For Grid Views + .grid-section { + padding: 1em 2em; + display: grid; + grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); + gap: 1em; + + // Adjust for different card types if needed + &.grid-landscape { + grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); + } + } + + .empty-state { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + height: 300px; + color: rgba(255, 255, 255, 0.4); + + h3 { + margin-top: 1em; + font-weight: 400; + } + } + } +} diff --git a/src/routes/_api/favorite/index.tsx b/src/routes/_api/favorite/index.tsx index 573bd8e..2560cc5 100644 --- a/src/routes/_api/favorite/index.tsx +++ b/src/routes/_api/favorite/index.tsx @@ -1,16 +1,19 @@ -import React, { useEffect } from "react"; - -import { useBackdropStore } from "@/utils/store/backdrop"; - import { useQuery } from "@tanstack/react-query"; +import React, { type SyntheticEvent, useEffect, useState } from "react"; +import { useBackdropStore } from "@/utils/store/backdrop"; import "./favorite.scss"; -import { Card } from "@/components/card/card"; -import CardScroller from "@/components/cardScroller/cardScroller"; -import { useCentralStore } from "@/utils/store/central"; -import { BaseItemKind } from "@jellyfin/sdk/lib/generated-client"; +import { + type BaseItemDto, + BaseItemKind, +} from "@jellyfin/sdk/lib/generated-client"; import { getItemsApi } from "@jellyfin/sdk/lib/utils/api/items-api"; +import { Fade, Tab, Tabs, Typography } from "@mui/material"; import { createFileRoute } from "@tanstack/react-router"; +import { useShallow } from "zustand/react/shallow"; +import { Card } from "@/components/card/card"; +import CardScroller from "@/components/cardScroller/cardScroller"; +import { useCentralStore } from "@/utils/store/central"; export const Route = createFileRoute("/_api/favorite/")({ component: FavoritePage, @@ -18,7 +21,10 @@ export const Route = createFileRoute("/_api/favorite/")({ function FavoritePage() { const api = Route.useRouteContext().api; - const [setBackdrop] = useBackdropStore((state) => [state.setBackdrop]); + const [setBackdrop] = useBackdropStore( + useShallow((state) => [state.setBackdrop]), + ); + const [tabValue, setTabValue] = useState("overview"); const user = useCentralStore((s) => s.currentUser); @@ -30,6 +36,7 @@ function FavoritePage() { userId: user?.Id, isFavorite: true, includeItemTypes: [BaseItemKind.Movie], + enableImages: true, recursive: true, }); return result.data; @@ -121,141 +128,216 @@ function FavoritePage() { }); useEffect(() => { - setBackdrop("", ""); - }); + // Set a backdrop from one of the favorites if available? + // For now, clear it or maybe pick random from movies + if (movies.data?.Items && movies.data.Items.length > 0) { + const randomMovie = + movies.data.Items[Math.floor(Math.random() * movies.data.Items.length)]; + if (randomMovie.BackdropImageTags?.[0]) { + setBackdrop( + randomMovie.ImageBlurHashes?.Backdrop?.[ + randomMovie.BackdropImageTags[0] + ] || "", + ); + } + } else { + setBackdrop(""); + } + }, [movies.data, setBackdrop]); + + const handleTabChange = (_event: SyntheticEvent, newValue: string) => { + setTabValue(newValue); + }; + + const sections = [ + { + id: "movies", + title: "Movies", + query: movies, + renderCard: (item: BaseItemDto) => ( + + ), + }, + { + id: "series", + title: "TV Shows", + query: series, + renderCard: (item: BaseItemDto) => ( + + ), + }, + { + id: "albums", + title: "Albums", + query: musicAlbum, + renderCard: (item: BaseItemDto) => ( + + ), + }, + { + id: "artists", + title: "Artists", + query: musicArtists, + renderCard: (item: BaseItemDto) => ( + + ), + }, + { + id: "audio", + title: "Songs", + query: audio, + renderCard: (item: BaseItemDto) => ( + + ), + }, + { + id: "books", + title: "Books", + query: book, + renderCard: (item: BaseItemDto) => ( + + ), + }, + { + id: "person", + title: "People", + query: person, + renderCard: (item: BaseItemDto) => ( + + ), + }, + ]; + + const availableSections = sections.filter( + (s) => s.query.isSuccess && (s.query.data?.Items?.length ?? 0) > 0, + ); return ( -
- {movies.isSuccess && (movies.data?.Items?.length ?? 0) > 0 && ( - - {movies.data?.Items?.map((item) => ( - +
+
+
+ + Your Favorites + +
+ + + {availableSections.map((section) => ( + ))} - - )} - {series.isSuccess && (series.data?.Items?.length ?? 0) > 0 && ( - - {series.data?.Items?.map((item) => ( - - ))} - - )} - {audio.isSuccess && (audio.data?.Items?.length ?? 0) > 0 && ( - - {audio.data?.Items?.map((item) => ( - - ))} - - )} - {musicAlbum.isSuccess && (musicAlbum.data?.Items?.length ?? 0) > 0 && ( - - {musicAlbum.data?.Items?.map((item) => ( - - ))} - - )} - {book.isSuccess && (book.data?.Items?.length ?? 0) > 0 && ( - - {book.data?.Items?.map((item) => ( - - ))} - - )} - {musicArtists.isSuccess && - (musicArtists.data?.Items?.length ?? 0) > 0 && ( - - {musicArtists.data?.Items?.map((item) => ( - - ))} - + +
+ +
+ {tabValue === "overview" && ( + +
+ {availableSections.map((section) => ( + + {section.query.data?.Items?.map(section.renderCard)} + + ))} + {availableSections.length === 0 && ( +
+ No favorites yet + + Mark items as favorite to see them here. + +
+ )} +
+
)} - {person.isSuccess && (person.data?.Items?.length ?? 0) > 0 && ( - - {person.data?.Items?.map((item) => ( - - ))} - - )} + + {availableSections.map( + (section) => + tabValue === section.id && ( + +
+ {section.query.data?.Items?.map(section.renderCard)} +
+
+ ), + )} +
); }