Improve responsive styles for playerbar

This commit is contained in:
jeffvli 2023-06-04 16:02:40 -07:00 committed by Jeff
parent cf43bf360e
commit f380eccc68
5 changed files with 62 additions and 31 deletions

View file

@ -43,13 +43,6 @@ interface CenterControlsProps {
playersRef: any; playersRef: any;
} }
const ControlsContainer = styled.div`
display: flex;
align-items: center;
justify-content: center;
height: 35px;
`;
const ButtonsContainer = styled.div` const ButtonsContainer = styled.div`
display: flex; display: flex;
gap: 0.5rem; gap: 0.5rem;
@ -58,14 +51,20 @@ const ButtonsContainer = styled.div`
const SliderContainer = styled.div` const SliderContainer = styled.div`
display: flex; display: flex;
width: 95%;
height: 20px; height: 20px;
`; `;
const SliderValueWrapper = styled.div<{ position: 'left' | 'right' }>` const SliderValueWrapper = styled.div<{ position: 'left' | 'right' }>`
display: flex;
flex: 1; flex: 1;
align-self: center; align-self: flex-end;
justify-content: center;
max-width: 50px; max-width: 50px;
text-align: center;
@media (max-width: 768px) {
display: none;
}
`; `;
const SliderWrapper = styled.div` const SliderWrapper = styled.div`
@ -75,6 +74,23 @@ const SliderWrapper = styled.div`
height: 100%; height: 100%;
`; `;
const ControlsContainer = styled.div`
display: flex;
align-items: center;
justify-content: center;
height: 35px;
@media (max-width: 768px) {
${ButtonsContainer} {
gap: 0;
}
${SliderValueWrapper} {
display: none;
}
}
`;
export const CenterControls = ({ playersRef }: CenterControlsProps) => { export const CenterControls = ({ playersRef }: CenterControlsProps) => {
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const [isSeeking, setIsSeeking] = useState(false); const [isSeeking, setIsSeeking] = useState(false);

View file

@ -20,13 +20,6 @@ import { LibraryItem } from '/@/renderer/api/types';
import { SONG_CONTEXT_MENU_ITEMS } from '/@/renderer/features/context-menu/context-menu-items'; import { SONG_CONTEXT_MENU_ITEMS } from '/@/renderer/features/context-menu/context-menu-items';
import { useHandleGeneralContextMenu } from '/@/renderer/features/context-menu/hooks/use-handle-context-menu'; import { useHandleGeneralContextMenu } from '/@/renderer/features/context-menu/hooks/use-handle-context-menu';
const LeftControlsContainer = styled.div`
display: flex;
width: 100%;
height: 100%;
padding-left: 1rem;
`;
const ImageWrapper = styled.div` const ImageWrapper = styled.div`
position: relative; position: relative;
display: flex; display: flex;
@ -85,11 +78,23 @@ const LineItem = styled.div<{ $secondary?: boolean }>`
} }
`; `;
const LeftControlsContainer = styled.div`
display: flex;
width: 100%;
height: 100%;
padding-left: 1rem;
@media (max-width: 640px) {
${ImageWrapper} {
display: none;
}
}
`;
export const LeftControls = () => { export const LeftControls = () => {
const { setSideBar } = useAppStoreActions(); const { setSideBar } = useAppStoreActions();
const { expanded: isFullScreenPlayerExpanded } = useFullScreenPlayerStore(); const { expanded: isFullScreenPlayerExpanded } = useFullScreenPlayerStore();
const setFullScreenPlayerStore = useSetFullScreenPlayerStore(); const setFullScreenPlayerStore = useSetFullScreenPlayerStore();
// const hideImage = useAppStore((state) => state.sidebar.image);
const { image, collapsed } = useSidebarStore(); const { image, collapsed } = useSidebarStore();
const hideImage = image && !collapsed; const hideImage = image && !collapsed;
const currentSong = useCurrentSong(); const currentSong = useCurrentSong();

View file

@ -25,20 +25,25 @@ const PlayerbarContainer = styled.div`
`; `;
const PlayerbarControlsGrid = styled.div` const PlayerbarControlsGrid = styled.div`
display: flex; display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
gap: 1rem; gap: 1rem;
height: 100%; height: 100%;
@media (max-width: 768px) {
grid-template-columns: minmax(0, 0.5fr) minmax(0, 1fr) minmax(0, 0.5fr);
}
`; `;
const RightGridItem = styled.div` const RightGridItem = styled.div`
align-self: center; align-self: center;
width: calc(100% / 3); width: 100%;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
`; `;
const LeftGridItem = styled.div` const LeftGridItem = styled.div`
width: calc(100% / 3); width: 100%;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
`; `;
@ -47,8 +52,9 @@ const CenterGridItem = styled.div`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 0.5rem; gap: 0.5rem;
align-items: center;
justify-content: center; justify-content: center;
width: calc(100% / 3); width: 100%;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
`; `;

View file

@ -1,6 +1,6 @@
import { MouseEvent } from 'react'; import { MouseEvent } from 'react';
import { Flex, Group } from '@mantine/core'; import { Flex, Group } from '@mantine/core';
import { useHotkeys } from '@mantine/hooks'; import { useHotkeys, useMediaQuery } from '@mantine/hooks';
import { HiOutlineQueueList } from 'react-icons/hi2'; import { HiOutlineQueueList } from 'react-icons/hi2';
import { import {
RiVolumeUpFill, RiVolumeUpFill,
@ -26,6 +26,7 @@ import { Rating } from '/@/renderer/components';
import { PlayerbarSlider } from '/@/renderer/features/player/components/playerbar-slider'; import { PlayerbarSlider } from '/@/renderer/features/player/components/playerbar-slider';
export const RightControls = () => { export const RightControls = () => {
const isMinWidth = useMediaQuery('(max-width: 480px)');
const volume = useVolume(); const volume = useVolume();
const muted = useMuted(); const muted = useMuted();
const server = useCurrentServer(); const server = useCurrentServer();
@ -181,7 +182,9 @@ export const RightControls = () => {
tooltip={{ label: muted ? 'Muted' : volume, openDelay: 500 }} tooltip={{ label: muted ? 'Muted' : volume, openDelay: 500 }}
variant="secondary" variant="secondary"
onClick={handleMute} onClick={handleMute}
onWheel={handleVolumeWheel}
/> />
{!isMinWidth ? (
<PlayerbarSlider <PlayerbarSlider
max={100} max={100}
min={0} min={0}
@ -191,6 +194,7 @@ export const RightControls = () => {
onChange={handleVolumeSlider} onChange={handleVolumeSlider}
onWheel={handleVolumeWheel} onWheel={handleVolumeWheel}
/> />
) : null}
</Group> </Group>
</Group> </Group>
<Group h="calc(100% / 3)" /> <Group h="calc(100% / 3)" />

View file

@ -79,7 +79,7 @@ export const useRightControls = () => {
}, [setVolume, volume, volumeWheelStep]); }, [setVolume, volume, volumeWheelStep]);
const handleVolumeWheel = useCallback( const handleVolumeWheel = useCallback(
(e: WheelEvent<HTMLDivElement>) => { (e: WheelEvent<HTMLDivElement | HTMLButtonElement>) => {
let volumeToSet; let volumeToSet;
if (e.deltaY > 0) { if (e.deltaY > 0) {
volumeToSet = calculateVolumeDown(volume, volumeWheelStep); volumeToSet = calculateVolumeDown(volume, volumeWheelStep);