From 7e1f4e1cd429f9b2a51837c2cfadd8bd36beb4d5 Mon Sep 17 00:00:00 2001 From: Geert Rademakes Date: Fri, 25 Apr 2025 09:21:38 +0200 Subject: [PATCH] UI fixes! --- .../src/components/PlaylistManager.tsx | 77 ++++++++++++++----- packages/frontend/src/components/SongList.tsx | 28 +++++-- 2 files changed, 78 insertions(+), 27 deletions(-) diff --git a/packages/frontend/src/components/PlaylistManager.tsx b/packages/frontend/src/components/PlaylistManager.tsx index 9670229..a15af79 100644 --- a/packages/frontend/src/components/PlaylistManager.tsx +++ b/packages/frontend/src/components/PlaylistManager.tsx @@ -10,7 +10,6 @@ import { ModalFooter, ModalHeader, ModalOverlay, - Text, useDisclosure, VStack, Menu, @@ -21,7 +20,7 @@ import { Collapse, MenuDivider, MenuGroup, - useToast + Icon } from "@chakra-ui/react"; import { ChevronDownIcon, DeleteIcon, ChevronRightIcon, AddIcon, ViewIcon } from "@chakra-ui/icons"; import React, { useState, useCallback } from "react"; @@ -39,13 +38,16 @@ interface PlaylistManagerProps { const getButtonStyles = (isSelected: boolean) => ({ width: "100%", - justifyContent: "flex-start", + display: "flex", + alignItems: "center", + justifyContent: "space-between", bg: isSelected ? "blue.800" : "transparent", color: isSelected ? "white" : "gray.100", fontWeight: isSelected ? "600" : "normal", borderRadius: "md", px: 4, py: 2, + cursor: "pointer", transition: "all 0.2s", _hover: { bg: isSelected ? "blue.600" : "whiteAlpha.200", @@ -76,7 +78,7 @@ const PlaylistItem: React.FC = ({ allFolders, }) => { const [isOpen, setIsOpen] = useState(true); - const indent = level * 20; // Increased indent per level + const indent = level * 10; if (node.type === 'folder') { return ( @@ -86,19 +88,36 @@ const PlaylistItem: React.FC = ({ flex={1} {...getButtonStyles(false)} onClick={() => setIsOpen(!isOpen)} - pl={indent} + ml={indent} + justifyContent="flex-start" leftIcon={ - + + + } > + + + {node.name} - + {node.children?.map((child, index) => ( = ({ } return ( - + } - variant="ghost" - size="sm" - color="gray.400" - _hover={{ color: "white", bg: "whiteAlpha.200" }} - /> + p={0} + > + + void; selectedSongId: string | null; currentPlaylist: string | null; + depth?: number; } export const SongList: React.FC = ({ @@ -37,7 +38,8 @@ export const SongList: React.FC = ({ playlists, onSongSelect, selectedSongId, - currentPlaylist + currentPlaylist, + depth = 0 }) => { const [selectedSongs, setSelectedSongs] = useState>(new Set()); const [searchQuery, setSearchQuery] = useState(""); @@ -147,8 +149,9 @@ export const SongList: React.FC = ({ {allPlaylists.map((playlist) => ( { - handleBulkAddToPlaylist(playlist.name); + onClick={(e) => { + e.stopPropagation(); + onAddToPlaylist([Array.from(selectedSongs)[0]], playlist.name); }} > Add to {playlist.name} @@ -159,9 +162,9 @@ export const SongList: React.FC = ({ { + onClick={(e) => { + e.stopPropagation(); onRemoveFromPlaylist(Array.from(selectedSongs)); - setSelectedSongs(new Set()); }} > Remove from {currentPlaylist} @@ -180,6 +183,7 @@ export const SongList: React.FC = ({ key={song.id} alignItems="center" p={2} + pl={depth > 0 ? 4 + (depth * 4) : 2} borderBottom="1px" borderColor="gray.700" bg={selectedSongId === song.id ? "gray.700" : "transparent"} @@ -194,12 +198,20 @@ export const SongList: React.FC = ({ }} mr={4} onClick={(e) => e.stopPropagation()} + size={depth > 0 ? "sm" : "md"} /> - + 0 ? "sm" : "md"} + > {song.title} - + 0 ? "xs" : "sm"} + color={selectedSongId === song.id ? "gray.300" : "gray.500"} + > {song.artist} @@ -210,6 +222,8 @@ export const SongList: React.FC = ({ icon={} variant="ghost" onClick={(e) => e.stopPropagation()} + size={depth > 0 ? "xs" : "sm"} + ml="auto" /> {allPlaylists.map((playlist) => (