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;
}
const ControlsContainer = styled.div`
display: flex;
align-items: center;
justify-content: center;
height: 35px;
`;
const ButtonsContainer = styled.div`
display: flex;
gap: 0.5rem;
@ -58,14 +51,20 @@ const ButtonsContainer = styled.div`
const SliderContainer = styled.div`
display: flex;
width: 95%;
height: 20px;
`;
const SliderValueWrapper = styled.div<{ position: 'left' | 'right' }>`
display: flex;
flex: 1;
align-self: center;
align-self: flex-end;
justify-content: center;
max-width: 50px;
text-align: center;
@media (max-width: 768px) {
display: none;
}
`;
const SliderWrapper = styled.div`
@ -75,6 +74,23 @@ const SliderWrapper = styled.div`
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) => {
const queryClient = useQueryClient();
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 { 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`
position: relative;
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 = () => {
const { setSideBar } = useAppStoreActions();
const { expanded: isFullScreenPlayerExpanded } = useFullScreenPlayerStore();
const setFullScreenPlayerStore = useSetFullScreenPlayerStore();
// const hideImage = useAppStore((state) => state.sidebar.image);
const { image, collapsed } = useSidebarStore();
const hideImage = image && !collapsed;
const currentSong = useCurrentSong();

View file

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

View file

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

View file

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