Adjust playerbar

This commit is contained in:
jeffvli
2022-10-30 20:20:04 -07:00
parent bc9e6a9a73
commit 689560a7a5
3 changed files with 102 additions and 42 deletions
@@ -25,6 +25,7 @@ interface CenterControlsProps {
const ControlsContainer = styled.div` const ControlsContainer = styled.div`
display: flex; display: flex;
align-items: center;
justify-content: center; justify-content: center;
height: 35px; height: 35px;
`; `;
@@ -1,12 +1,12 @@
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { Group } from '@mantine/core'; import { Box, Group } from '@mantine/core';
import { motion, AnimatePresence, LayoutGroup } from 'framer-motion'; import { motion, AnimatePresence, LayoutGroup } from 'framer-motion';
import { RiArrowUpSLine } from 'react-icons/ri'; import { RiArrowUpSLine } from 'react-icons/ri';
import { Link } from 'react-router-dom'; import { generatePath, Link } from 'react-router-dom';
import { Button, Text } from '@/renderer/components'; import { Button, Text } from '@/renderer/components';
import { AppRoute } from '@/renderer/router/routes'; import { AppRoute } from '@/renderer/router/routes';
import { useAppStore, usePlayerStore } from '@/renderer/store'; import { useAppStore, usePlayerStore } from '@/renderer/store';
import { fadeIn, Font } from '@/renderer/styles'; import { fadeIn } from '@/renderer/styles';
const LeftControlsContainer = styled.div` const LeftControlsContainer = styled.div`
display: flex; display: flex;
@@ -33,11 +33,12 @@ const MetadataStack = styled(motion.div)`
const Image = styled(motion(Link))<{ url: string }>` const Image = styled(motion(Link))<{ url: string }>`
${fadeIn}; ${fadeIn};
width: 60px; width: 70px;
height: 60px; height: 70px;
background-image: url(${(props) => props.url}); background-image: url(${(props) => props.url});
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: cover; background-size: cover;
filter: drop-shadow(0 0 5px rgb(0, 0, 0, 100%));
button { button {
display: none; display: none;
@@ -48,12 +49,26 @@ const Image = styled(motion(Link))<{ url: string }>`
} }
`; `;
const LineItem = styled(Box)<{ secondary?: boolean }>`
display: inline-block;
width: 95%;
max-width: 30vw;
overflow: hidden;
color: ${(props) => props.secondary && 'var(--main-fg-secondary)'};
white-space: nowrap;
text-overflow: ellipsis;
a {
color: ${(props) => props.secondary && 'var(--text-secondary)'};
}
`;
export const LeftControls = () => { export const LeftControls = () => {
const hideImage = useAppStore((state) => state.sidebar.image); const hideImage = useAppStore((state) => state.sidebar.image);
const setSidebar = useAppStore((state) => state.setSidebar); const setSidebar = useAppStore((state) => state.setSidebar);
const song = usePlayerStore((state) => state.current.song); const song = usePlayerStore((state) => state.current.song);
const title = song?.name; const title = song?.name;
const artists = song?.artists?.map((artist) => artist?.name).join(', '); const artists = song?.artists;
const album = song?.album; const album = song?.album;
return ( return (
@@ -88,38 +103,66 @@ export const LeftControls = () => {
)} )}
</AnimatePresence> </AnimatePresence>
<MetadataStack layout> <MetadataStack layout>
<Text <LineItem>
font={Font.POPPINS} <Text
link={!!title} component={Link}
overflow="hidden" overflow="hidden"
size="sm" size="sm"
to="/nowplaying" sx={{ '&:hover': { textDecoration: 'underline' } }}
weight={500} to={AppRoute.NOW_PLAYING}
> weight={500}
{title || '—'} >
</Text> {title || '—'}
<Text </Text>
secondary </LineItem>
font={Font.POPPINS} <LineItem secondary>
link={!!artists} {artists?.map((artist, index) => (
overflow="hidden" <>
size="sm" {index > 0 && (
to="/nowplaying" <Text secondary style={{ display: 'inline-block' }}>
weight={500} ,
> </Text>
{artists || ''} )}{' '}
</Text> <Text
<Text component={Link}
secondary overflow="hidden"
font={Font.POPPINS} size="sm"
link={!!album} sx={{
overflow="hidden" '&:hover': { textDecoration: 'underline' },
size="sm" width: 'inherit',
to="/nowplaying" }}
weight={500} to={
> artist.id
{album?.name || '—'} ? generatePath(AppRoute.LIBRARY_ARTISTS_DETAIL, {
</Text> artistId: artist.id,
})
: ''
}
weight={500}
>
{artist.name || '—'}
</Text>
</>
))}
</LineItem>
<LineItem secondary>
<Text
component={Link}
overflow="hidden"
size="sm"
sx={{ '&:hover': { textDecoration: 'underline' } }}
to={
album?.id
? generatePath(AppRoute.LIBRARY_ALBUMS_DETAIL, {
albumId: album?.id,
})
: ''
}
weight={500}
>
{album?.name || '—'}
</Text>
</LineItem>
</MetadataStack> </MetadataStack>
</LayoutGroup> </LayoutGroup>
</LeftControlsContainer> </LeftControlsContainer>
@@ -1,15 +1,22 @@
import styled from '@emotion/styled'; import styled from '@emotion/styled';
import { RiVolumeUpFill, RiVolumeMuteFill } from 'react-icons/ri'; import { Group } from '@mantine/core';
import { usePlayerStore } from '../../../store'; import {
RiVolumeUpFill,
RiVolumeMuteFill,
RiPlayListFill,
} from 'react-icons/ri';
import { usePlayerStore, useAppStore } from '@/renderer/store';
import { useRightControls } from '../hooks/use-right-controls'; import { useRightControls } from '../hooks/use-right-controls';
import { PlayerButton } from './player-button'; import { PlayerButton } from './player-button';
import { Slider } from './slider'; import { Slider } from './slider';
const RightControlsContainer = styled.div` const RightControlsContainer = styled.div`
display: flex; display: flex;
flex-direction: row;
justify-content: flex-end;
width: 100%; width: 100%;
height: 100%; height: 100%;
padding: 0.5rem; padding-right: 1rem;
`; `;
const VolumeSliderWrapper = styled.div` const VolumeSliderWrapper = styled.div`
@@ -25,18 +32,27 @@ const MetadataStack = styled.div`
gap: 0.3rem; gap: 0.3rem;
align-items: flex-end; align-items: flex-end;
justify-content: center; justify-content: center;
width: 100%;
overflow: visible; overflow: visible;
`; `;
export const RightControls = () => { export const RightControls = () => {
const volume = usePlayerStore((state) => state.settings.volume); const volume = usePlayerStore((state) => state.settings.volume);
const muted = usePlayerStore((state) => state.settings.muted); const muted = usePlayerStore((state) => state.settings.muted);
const setSidebar = useAppStore((state) => state.setSidebar);
const isQueueExpanded = useAppStore((state) => state.sidebar.rightExpanded);
const { handleVolumeSlider, handleVolumeSliderState, handleMute } = const { handleVolumeSlider, handleVolumeSliderState, handleMute } =
useRightControls(); useRightControls();
return ( return (
<RightControlsContainer> <RightControlsContainer>
<Group>
<PlayerButton
icon={<RiPlayListFill size={15} />}
tooltip={{ label: 'View queue' }}
variant="secondary"
onClick={() => setSidebar({ rightExpanded: !isQueueExpanded })}
/>
</Group>
<MetadataStack> <MetadataStack>
<VolumeSliderWrapper> <VolumeSliderWrapper>
<PlayerButton <PlayerButton