Skip to content

Commit

Permalink
feat: remove window frame, compact chrome layout (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya authored Jan 7, 2025
1 parent 73e7dc2 commit 927d200
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 9 deletions.
1 change: 0 additions & 1 deletion packages/raga-app/src/client/app.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
left: 0;
right: 0;
bottom: 0;
padding: 10px;
}

.fontWeightLight {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.appChrome {
--mantine-line-height-sm: 1;
}

.appChromeDraggable {
-webkit-app-region: drag;
user-select: none;
}

.appChromeGroup {
height: 100%;
-webkit-app-region: no-drag;
}
31 changes: 27 additions & 4 deletions packages/raga-app/src/client/components/chrome/appChrome.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
import { Divider, Group, Title } from "@mantine/core";
import classNames from "classnames";

import { appStore } from "../../store/appStore";
import UserSettingsDropdown from "../settings/userSettingsDropdown";
import styles from "./appChrome.module.scss";
import AudioAnalyzerStatus from "./audioAnalyzerStatus";
import AudioFilesServerControls from "./audioFilesServerControls";
import LibraryControls from "./libraryControls";

export default function AppChrome() {
const audioFilesServerStatus = appStore.use.audioFilesServerStatus();
const isLibraryLoaded = appStore.use.libraryLoadingState() === "loaded";
const isMacOS = window.api.platform === "darwin";
const isWindows = window.api.platform === "win32";
// use left padding on macOS to account for window traffic light buttons
const leftPadding = isMacOS ? 75 : undefined;
// use right padding on Windows to account for window buttons
const rightPadding = isWindows ? 100 : undefined;

return (
<Group mb={5} justify="space-between" wrap="nowrap">
<Group h={30} wrap="nowrap" preventGrowOverflow={true} gap="sm">
<Title order={4}>Raga</Title>
<Group
pl={leftPadding}
pr={rightPadding}
justify="space-between"
wrap="nowrap"
className={classNames(styles.appChromeDraggable, styles.appChrome)}
>
<Group
h={30}
p={5}
wrap="nowrap"
preventGrowOverflow={true}
gap="sm"
className={styles.appChromeGroup}
>
<Title order={4} className={styles.appChromeDraggable}>
Raga
</Title>
{isLibraryLoaded && (
<>
<Divider orientation="vertical" />
Expand All @@ -29,7 +52,7 @@ export default function AppChrome() {
<Divider orientation="vertical" />
<UserSettingsDropdown />
</Group>
<Group>
<Group className={styles.appChromeGroup} p={5}>
<LibraryControls />
</Group>
</Group>
Expand Down
8 changes: 6 additions & 2 deletions packages/raga-app/src/client/views/libraryView.module.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.container {
height: calc(100vh - 50px);
padding: 0;
height: calc(100vh - 40px);
}

.emptyState {
Expand Down Expand Up @@ -43,3 +42,8 @@
right: 0;
}
}

.library {
border-bottom-left-radius: 8px;
border-bottom-right-radius: 8px;
}
4 changes: 2 additions & 2 deletions packages/raga-app/src/client/views/libraryView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function LibraryView() {
);

return (
<Stack className={styles.container} gap={0}>
<Stack className={styles.container} gap={0} px={5}>
{libraryState === "none" ? (
<EmptyState
className={styles.emptyState}
Expand Down Expand Up @@ -69,7 +69,7 @@ function Library() {
const selectedTrack = getSelectedTrackDef();

return (
<Paper w="100%" h="100%" shadow="sm" withBorder={true} radius="sm">
<Paper w="100%" h="100%" shadow="sm" withBorder={true} radius="sm" className={styles.library}>
<Stack gap={0} w="100%" h="100%">
{selectedTrack === undefined || waveSurfer === undefined ? null : (
<>
Expand Down
4 changes: 4 additions & 0 deletions packages/raga-app/src/contextBridgeApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import type { ClientEventChannel, ServerEventChannel } from "./common/events";
* Promises for async operations.
*/
export interface ContextBridgeApi {
/** OS platform */
platform: NodeJS.Platform;

/** Node.js process version info */
versions: Record<string, string | undefined>;

/**
Expand Down
2 changes: 2 additions & 0 deletions packages/raga-app/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ const createWindow = async () => {
preload: join(__dirname, "preload.js"),
webSecurity: false,
},
titleBarStyle: "hiddenInset",
titleBarOverlay: true,
});

// and load the index.html of the app.
Expand Down
3 changes: 3 additions & 0 deletions packages/raga-app/src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

import { blueBright } from "ansis";
import { contextBridge, ipcRenderer, type IpcRendererEvent } from "electron";
import { platform } from "os";

import { ClientEventChannel, ServerEventChannel } from "./common/events";
import { createScopedLogger } from "./common/logUtils";
import { type ContextBridgeApi } from "./contextBridgeApi";

const log = createScopedLogger("contextBridge", blueBright);
const contextBridgeApi: ContextBridgeApi = {
platform: platform(),

versions: process.versions,

isReady: false,
Expand Down

0 comments on commit 927d200

Please sign in to comment.