import { MouseEvent } from 'react'; import { Stack, Accordion, Center, Group, Divider, Box } from '@mantine/core'; import { closeAllModals, openModal } from '@mantine/modals'; import { AnimatePresence, motion } from 'framer-motion'; import { Button, MotionStack, Spinner } from '/@/renderer/components'; import { RiAddFill, RiAlbumFill, RiAlbumLine, RiArrowDownSLine, RiDatabaseFill, RiDatabaseLine, RiDiscLine, RiFlag2Line, RiFolder3Line, RiHome5Fill, RiHome5Line, RiListUnordered, RiMusic2Fill, RiMusic2Line, RiUserVoiceFill, RiUserVoiceLine, } from 'react-icons/ri'; import { Link, useLocation } from 'react-router-dom'; import styled from 'styled-components'; import { SidebarItem } from '/@/renderer/features/sidebar/components/sidebar-item'; import { AppRoute } from '/@/renderer/router/routes'; import { useSidebarStore, useAppStoreActions, useCurrentSong, useCurrentServer, useSetFullScreenPlayerStore, useFullScreenPlayerStore, } from '/@/renderer/store'; import { fadeIn } from '/@/renderer/styles'; import { CreatePlaylistForm, usePlaylistList } from '/@/renderer/features/playlists'; import { PlaylistListSort, ServerType, SortOrder } from '/@/renderer/api/types'; import { SidebarPlaylistList } from '/@/renderer/features/sidebar/components/sidebar-playlist-list'; import { useContainerQuery } from '/@/renderer/hooks'; import { ActionBar } from '/@/renderer/features/sidebar/components/action-bar'; import { Platform } from '/@/renderer/types'; import { useWindowSettings } from '../../../store/settings.store'; const SidebarContainer = styled.div<{ windowBarStyle: Platform }>` height: 100%; max-height: ${(props) => props.windowBarStyle === Platform.WEB ? 'calc(100vh - 149px)' : 'calc(100vh - 179px)'}; // Playerbar (90px), titlebar (65px), windowbar (30px) user-select: none; `; const ImageContainer = styled(motion.div)<{ height: string }>` position: relative; height: ${(props) => props.height}; ${fadeIn}; animation: fadein 0.2s ease-in-out; button { display: none; } &:hover button { display: block; } `; const SidebarImage = styled.img` width: 100%; height: 100%; object-fit: cover; background: var(--placeholder-bg); `; export const Sidebar = () => { const location = useLocation(); const sidebar = useSidebarStore(); const { setSideBar } = useAppStoreActions(); const { windowBarStyle } = useWindowSettings(); const imageUrl = useCurrentSong()?.imageUrl; const server = useCurrentServer(); const upsizedImageUrl = imageUrl ?.replace(/size=\d+/, 'size=300') .replace(/width=\d+/, 'width=300') .replace(/height=\d+/, 'height=300'); const showImage = sidebar.image; const handleCreatePlaylistModal = (e: MouseEvent) => { e.stopPropagation(); openModal({ children: closeAllModals()} />, size: server?.type === ServerType?.NAVIDROME ? 'lg' : 'sm', title: 'Create Playlist', }); }; const playlistsQuery = usePlaylistList({ sortBy: PlaylistListSort.NAME, sortOrder: SortOrder.ASC, startIndex: 0, }); const setFullScreenPlayerStore = useSetFullScreenPlayerStore(); const { expanded: isFullScreenPlayerExpanded } = useFullScreenPlayerStore(); const expandFullScreenPlayer = () => { setFullScreenPlayerStore({ expanded: !isFullScreenPlayerExpanded }); }; const cq = useContainerQuery({ sm: 300 }); return ( {location.pathname === AppRoute.HOME ? ( ) : ( )} Home setSideBar({ expanded: e })} > {location.pathname.includes('/library/') ? ( ) : ( )} Library {location.pathname === AppRoute.LIBRARY_ALBUMS ? ( ) : ( )} Albums {location.pathname === AppRoute.LIBRARY_SONGS ? ( ) : ( )} Tracks {location.pathname === AppRoute.LIBRARY_ALBUM_ARTISTS ? ( ) : ( )} Album Artists Genres Folders Playlists {playlistsQuery.isLoading && } {showImage && ( {upsizedImageUrl ? ( ) : (
)}
)}
); };