Skip to content

Commit

Permalink
Feature: Browser UX (#32)
Browse files Browse the repository at this point in the history
* Add toggl'able and resizable Browser view
* make some minor fixes and adjustments to usability
* Fix drag region messing with Menus
* create a window height and width provider, then use it everywhere but LibraryList
  • Loading branch information
johnnyshankman authored Oct 30, 2024
1 parent 0db2b32 commit c625e0d
Show file tree
Hide file tree
Showing 12 changed files with 590 additions and 126 deletions.
16 changes: 16 additions & 0 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ export default class MenuBuilder {
this.mainWindow.webContents.toggleDevTools();
},
},
{ type: 'separator' },
{
label: 'Toggle Browser View',
accelerator: 'Command+B',
click: () => {
this.mainWindow.webContents.send('menu-toggle-browser');
},
},
],
};
const subMenuViewProd: MenuItemConstructorOptions = {
Expand All @@ -241,6 +249,14 @@ export default class MenuBuilder {
this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen());
},
},
{ type: 'separator' },
{
label: 'Toggle Browser View',
accelerator: 'Command+B',
click: () => {
this.mainWindow.webContents.send('menu-toggle-browser');
},
},
],
};
const subMenuWindow: DarwinMenuItemConstructorOptions = {
Expand Down
2 changes: 2 additions & 0 deletions src/main/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type Channels =
| 'hide-song'
| 'delete-song'
| 'delete-album'
| 'menu-toggle-browser'
// TODO: use this way more for replies
| 'update-store';

Expand All @@ -35,6 +36,7 @@ export interface SendMessageArgs extends ArgsBase {
rescan: boolean;
};
'add-to-library': undefined;
'menu-toggle-browser': undefined;
'get-album-art': string;
'set-last-played-song': string;
'modify-tag-of-file': {
Expand Down
34 changes: 29 additions & 5 deletions src/renderer/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ button:focus {
outline: none;
}

.nodrag {
-webkit-app-region: no-drag;
overflow: hidden;
}

.drag {
-webkit-app-region: drag;

Expand All @@ -52,6 +47,10 @@ button:focus {
}
}

.nodrag {
-webkit-app-region: no-drag !important;
}

.ReactVirtualized__List {
overflow-y: scroll !important;
}
Expand Down Expand Up @@ -145,3 +144,28 @@ button:focus {
::-webkit-scrollbar-thumb:hover {
border: 1px solid white;
}


.resize::after {
pointer-events: none;
content: " ";
font-size: 14px;
position: absolute;
height: 13px;
width: 13px;
text-align: center;
bottom: 0;
right: 0;
z-index: 2;
background-color: #0d0d0d;
}

.resize-handle-sw {
position: absolute;
bottom: 0;
left: 0;
width: 15px;
height: 15px;
cursor: sw-resize;
z-index: 3;
}
7 changes: 3 additions & 4 deletions src/renderer/components/AlbumArt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ import Draggable from 'react-draggable';
import { TinyText } from './SimpleStyledMaterialUIComponents';
import AlbumArtRightClickMenu from './AlbumArtRightClickMenu';
import usePlayerStore from '../store/player';
import { useWindowDimensions } from '../hooks/useWindowDimensions';

interface AlbumArtProps {
setShowAlbumArtMenu: (menu: any) => void;
showAlbumArtMenu: any;
width: number | null;
height: number | null;
}

export default function AlbumArt({
setShowAlbumArtMenu,
showAlbumArtMenu,
width,
height,
}: AlbumArtProps) {
const { width, height } = useWindowDimensions();

/**
* @dev global store hooks
*/
Expand Down
14 changes: 14 additions & 0 deletions src/renderer/components/AlbumArtRightClickMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export default function AlbumArtRightClickMenu(
onClose();
};

const toggleBrowserView = () => {
window.dispatchEvent(new Event('toggle-browser-view'));
onClose();
};

return (
<Menu
anchorEl={anchorEl}
Expand All @@ -37,6 +42,7 @@ export default function AlbumArtRightClickMenu(
}}
anchorPosition={{ top: mouseY, left: mouseX }}
anchorReference="anchorPosition"
className="nodrag"
id="basic-menu"
MenuListProps={{
'aria-labelledby': 'basic-button',
Expand All @@ -60,6 +66,14 @@ export default function AlbumArtRightClickMenu(
>
Download Artwork
</MenuItem>
<MenuItem
onClick={toggleBrowserView}
sx={{
fontSize: '11px',
}}
>
Toggle Browser View
</MenuItem>
</Menu>
);
}
Loading

0 comments on commit c625e0d

Please sign in to comment.