diff --git a/src/renderer/components/layout/top-bar/top-bar.module.scss b/src/renderer/components/layout/top-bar/top-bar.module.scss index 189e93dc22..fd4610eb2e 100644 --- a/src/renderer/components/layout/top-bar/top-bar.module.scss +++ b/src/renderer/components/layout/top-bar/top-bar.module.scss @@ -13,10 +13,33 @@ justify-content: space-between; /* Use topbar as draggable region */ - -webkit-user-select: none; + user-select: none; -webkit-app-region: drag; } +.topBar .items { + align-items: center; + display: flex; + height: 100%; + -webkit-app-region: no-drag; + + &:first-of-type { + padding-left: 1.5rem; + + & > * { + margin-right: 1rem; + } + } + + &:last-of-type { + padding-right: 1.5rem; + + & > * { + margin-left: 1rem; + } + } +} + :global(.is-mac) .topBar { padding-left: var(--hotbar-width); } @@ -39,23 +62,8 @@ } } -.tools { - @apply flex items-center; - -webkit-app-region: no-drag; -} - -.controls { - align-self: flex-end; - padding-right: 1.5rem; - align-items: center; - display: flex; - height: 100%; - -webkit-app-region: no-drag; -} - .windowButtons { display: flex; - margin-left: 1.5rem; margin-right: -1.5rem; > div { @@ -94,7 +102,8 @@ } } -.minimize, .maximize { +.minimize, +.maximize { &:hover { background-color: var(--borderFaintColor); } diff --git a/src/renderer/components/layout/top-bar/top-bar.tsx b/src/renderer/components/layout/top-bar/top-bar.tsx index 3030cbad57..976c79a4d5 100644 --- a/src/renderer/components/layout/top-bar/top-bar.tsx +++ b/src/renderer/components/layout/top-bar/top-bar.tsx @@ -22,7 +22,7 @@ import { WindowAction } from "../../../../common/ipc/window"; import isLinuxInjectable from "../../../../common/vars/is-linux.injectable"; import isWindowsInjectable from "../../../../common/vars/is-windows.injectable"; -export interface TopBarProps extends React.HTMLAttributes {} +export interface TopBarProps {} interface Dependencies { items: IComputedValue; @@ -41,7 +41,7 @@ ipcRendererOn("history:can-go-forward", (event, state: boolean) => { nextEnabled.set(state); }); -const NonInjectedTopBar = observer(({ items, children, isWindows, isLinux, ...rest }: TopBarProps & Dependencies) => { +const NonInjectedTopBar = observer(({ items, isWindows, isLinux }: TopBarProps & Dependencies) => { const elem = useRef(); const openAppContextMenu = () => { @@ -61,12 +61,9 @@ const NonInjectedTopBar = observer(({ items, children, isWindows, isLinux, ...re }; const windowSizeToggle = (evt: React.MouseEvent) => { - if (elem.current != evt.target) { - // Skip clicking on child elements - return; + if (elem.current === evt.target) { + toggleMaximize(); } - - toggleMaximize(); }; const minimizeWindow = () => { @@ -84,8 +81,8 @@ const NonInjectedTopBar = observer(({ items, children, isWindows, isLinux, ...re useEffect(() => watchHistoryState(), []); return ( -
-
+
+
{(isWindows || isLinux) && (
@@ -100,28 +97,24 @@ const NonInjectedTopBar = observer(({ items, children, isWindows, isLinux, ...re
-
+
{renderRegisteredItems(items.get())} - {children} {(isWindows || isLinux) && (
@@ -147,23 +140,15 @@ const NonInjectedTopBar = observer(({ items, children, isWindows, isLinux, ...re }); const renderRegisteredItems = (items: TopBarRegistration[]) => ( -
- {items.map((registration, index) => { - if (!registration?.components?.Item) { - return null; - } + items.map((registration, index) => { + if (!registration?.components?.Item) { + return null; + } - return ( -
- -
- ); - })} -
+ return ; + }) ); - - export const TopBar = withInjectables(NonInjectedTopBar, { getProps: (di, props) => ({ items: di.inject(topBarItemsInjectable),