From d6a375fff3b902729d0a81d63eaded06a32c0cce Mon Sep 17 00:00:00 2001 From: James Magahern Date: Sun, 23 Feb 2025 12:51:21 -0800 Subject: [PATCH] frontend: add scaffolding for favorites tab --- frontend/src/components/App.tsx | 47 +++++++++++++++------ frontend/src/components/SongRow.tsx | 4 +- frontend/src/components/TabView.tsx | 64 +++++++++++++++++++++++++++++ frontend/src/index.css | 4 ++ 4 files changed, 105 insertions(+), 14 deletions(-) create mode 100644 frontend/src/components/TabView.tsx diff --git a/frontend/src/components/App.tsx b/frontend/src/components/App.tsx index 8b3777b..ee5ebc9 100644 --- a/frontend/src/components/App.tsx +++ b/frontend/src/components/App.tsx @@ -2,8 +2,21 @@ import React, { useState, useEffect, useCallback } from 'react'; import SongTable from './SongTable'; import NowPlaying from './NowPlaying'; import AddSongPanel from './AddSongPanel'; +import { TabView, Tab } from './TabView'; import { API, getDisplayTitle, PlaylistItem } from '../api/player'; import { useEventWebSocket } from '../hooks/useEventWebsocket'; +import { FaMusic, FaHeart } from 'react-icons/fa'; + +enum Tabs { + Playlist = "playlist", + Favorites = "favorites", +} + +const EmptyContent: React.FC<{ label: string}> = ({label}) => ( +
+
{label}
+
+); const App: React.FC = () => { const [isPlaying, setIsPlaying] = useState(false); @@ -12,6 +25,7 @@ const App: React.FC = () => { const [volume, setVolume] = useState(100); const [volumeSettingIsLocked, setVolumeSettingIsLocked] = useState(false); const [songs, setSongs] = useState([]); + const [selectedTab, setSelectedTab] = useState(Tabs.Playlist); const fetchPlaylist = useCallback(async () => { const playlist = await API.getPlaylist(); @@ -122,6 +136,19 @@ const App: React.FC = () => { fetchNowPlaying(); }, [fetchPlaylist, fetchNowPlaying]); + const playlistContent = ( + songs.length > 0 ? ( + + ) : ( + + ) + ); + return (
@@ -139,18 +166,14 @@ const App: React.FC = () => { onVolumeDidChange={() => setVolumeSettingIsLocked(false)} /> - {songs.length > 0 ? ( - - ) : ( -
-
Playlist is empty
-
- )} + + }> + {playlistContent} + + }> + + +
diff --git a/frontend/src/components/SongRow.tsx b/frontend/src/components/SongRow.tsx index b0bfe2d..3d4c711 100644 --- a/frontend/src/components/SongRow.tsx +++ b/frontend/src/components/SongRow.tsx @@ -40,7 +40,7 @@ const SongRow: React.FC = ({ song, playState, onDelete, onPlay }) return (
@@ -78,7 +78,7 @@ const SongRow: React.FC = ({ song, playState, onDelete, onPlay })