feat: add context menu on left controls and sidebar image

This commit is contained in:
Maxime LAFARIE 2025-09-09 23:38:39 +02:00
parent c36735575f
commit 65ecdc7666
2 changed files with 38 additions and 3 deletions

View file

@ -46,6 +46,11 @@ export const LeftControls = () => {
);
const handleToggleFullScreenPlayer = (e?: KeyboardEvent | MouseEvent<HTMLDivElement>) => {
// don't toggle if right click
if (e && 'button' in e && e.button === 2) {
return;
}
e?.stopPropagation();
setFullScreenPlayerStore({ expanded: !isFullScreenPlayerExpanded });
};
@ -55,6 +60,15 @@ export const LeftControls = () => {
setSideBar({ image: true });
};
const handleToggleContextMenu = (e: MouseEvent<HTMLDivElement>) => {
e.preventDefault();
e.stopPropagation();
if (isSongDefined && !isFullScreenPlayerExpanded) {
handleGeneralContextMenu(e, [currentSong!]);
}
};
const stopPropagation = (e?: MouseEvent) => e?.stopPropagation();
useHotkeys([
@ -79,6 +93,7 @@ export const LeftControls = () => {
initial={{ opacity: 0, x: -50 }}
key="playerbar-image"
onClick={handleToggleFullScreenPlayer}
onContextMenu={handleToggleContextMenu}
role="button"
transition={{ duration: 0.2, ease: 'easeIn' }}
>
@ -127,6 +142,7 @@ export const LeftControls = () => {
component={Link}
fw={500}
isLink
onContextMenu={handleToggleContextMenu} // Ajout du clic droit
overflow="hidden"
to={AppRoute.NOW_PLAYING}
>