diff --git a/src/renderer/components/layout/main-layout.scss b/src/renderer/components/layout/main-layout.scss index 3a02d36717..2c14562cb5 100755 --- a/src/renderer/components/layout/main-layout.scss +++ b/src/renderer/components/layout/main-layout.scss @@ -1,6 +1,4 @@ .MainLayout { - --sidebar-max-size: 200px; - display: grid; grid-template-areas: "aside header" @@ -8,7 +6,7 @@ "aside main" "aside footer"; grid-template-rows: [header] var(--main-layout-header) [tabs] min-content [main] 1fr [footer] auto; - grid-template-columns: [sidebar] minmax(var(--main-layout-header), min-content) [main] 1fr; + grid-template-columns: [sidebar] auto [main] 1fr; height: 100%; @@ -33,19 +31,15 @@ background: $sidebarBackground; white-space: nowrap; transition: width 150ms cubic-bezier(0.4, 0, 0.2, 1); - - &.pinned { - width: var(--sidebar-max-size); - } + width: var(--sidebar-width); &:not(.pinned) { - position: absolute; width: var(--main-layout-header); height: 100%; overflow: hidden; &.accessible:hover { - width: var(--sidebar-max-size); + width: max-content; transition-delay: 750ms; box-shadow: 3px 3px 16px rgba(0, 0, 0, 0.35); z-index: $zIndex-sidebar-hover; diff --git a/src/renderer/components/layout/main-layout.tsx b/src/renderer/components/layout/main-layout.tsx index 97f5727a2d..10c4fc7ea9 100755 --- a/src/renderer/components/layout/main-layout.tsx +++ b/src/renderer/components/layout/main-layout.tsx @@ -3,11 +3,12 @@ import "./main-layout.scss"; import React from "react"; import { observable, reaction } from "mobx"; import { disposeOnUnmount, observer } from "mobx-react"; -import { createStorage, cssNames } from "../../utils"; +import { autobind, createStorage, cssNames } from "../../utils"; import { Sidebar } from "./sidebar"; import { ErrorBoundary } from "../error-boundary"; import { Dock } from "../dock"; import { getHostedCluster } from "../../../common/cluster-store"; +import { ResizeDirection, ResizeGrowthDirection, ResizeSide, ResizingAnchor } from "../resizing-anchor"; interface Props { className?: any; @@ -18,22 +19,42 @@ interface Props { @observer export class MainLayout extends React.Component { - public storage = createStorage("main_layout", { pinnedSidebar: true }); + public storage = createStorage("main_layout", { + pinnedSidebar: true, + sidebarWidth: 200, + }); @observable isPinned = this.storage.get().pinnedSidebar; @observable isAccessible = true; + @observable sidebarWidth = this.storage.get().sidebarWidth @disposeOnUnmount syncPinnedStateWithStorage = reaction( () => this.isPinned, (isPinned) => this.storage.merge({ pinnedSidebar: isPinned }) ); + @disposeOnUnmount syncWidthStateWithStorage = reaction( + () => this.sidebarWidth, + (sidebarWidth) => this.storage.merge({ sidebarWidth }) + ); + toggleSidebar = () => { this.isPinned = !this.isPinned; this.isAccessible = false; setTimeout(() => (this.isAccessible = true), 250); }; + getSidebarSize = () => { + return { + "--sidebar-width": `${this.sidebarWidth}px`, + } + } + + @autobind() + adjustWidth(newWidth: number): void { + this.sidebarWidth = newWidth + } + render() { const { className, headerClass, footer, footerClass, children } = this.props; const cluster = getHostedCluster(); @@ -41,20 +62,31 @@ export class MainLayout extends React.Component { return null; // fix: skip render when removing active (visible) cluster } return ( -
+
{cluster.preferences.clusterName || cluster.contextName}
{children}
-
{footer === undefined ? : footer}
+
); }