Add the logo back to the revamped sidebar, fix regressions from last PR (#353)

* Fix logo not being visible in auxiliary views when sidebar is collapsed

* Refactor auxiliary views into MainView component

* fix contents formatting

* Need a better-centered version of the logo for the sidebar

* Add logo back to the sidebar

* revert root.less change

* Fix regressions from last pr

* zero out subtractor if sidebar is collapsed

* remove unnecessary var
This commit is contained in:
Evan Simkowitz 2024-02-27 22:39:20 -08:00 committed by GitHub
parent 9e806d0621
commit 17990afd5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 54 additions and 119 deletions

View File

@ -180,6 +180,11 @@ class Bookmark extends React.Component<BookmarkProps, {}> {
@mobxReact.observer @mobxReact.observer
class BookmarksView extends React.Component<{}, {}> { class BookmarksView extends React.Component<{}, {}> {
@boundMethod
handleClose() {
GlobalModel.bookmarksModel.closeView();
}
render() { render() {
const isHidden = GlobalModel.activeMainView.get() != "bookmarks"; const isHidden = GlobalModel.activeMainView.get() != "bookmarks";
if (isHidden) { if (isHidden) {
@ -188,7 +193,7 @@ class BookmarksView extends React.Component<{}, {}> {
let bookmarks = GlobalModel.bookmarksModel.bookmarks; let bookmarks = GlobalModel.bookmarksModel.bookmarks;
let bookmark: BookmarkType = null; let bookmark: BookmarkType = null;
return ( return (
<MainView viewName="bookmarks" title="Bookmarks" onClose={GlobalModel.bookmarksModel.closeView}> <MainView viewName="bookmarks" title="Bookmarks" onClose={this.handleClose}>
<div className="bookmarks-list"> <div className="bookmarks-list">
<For index="idx" each="bookmark" of={bookmarks}> <For index="idx" each="bookmark" of={bookmarks}>
<Bookmark key={bookmark.bookmarkid} bookmark={bookmark} /> <Bookmark key={bookmark.bookmarkid} bookmark={bookmark} />

View File

@ -129,6 +129,11 @@ class ClientSettingsView extends React.Component<{ model: RemotesModel }, { hove
return clientData?.clientopts?.globalshortcut ?? ""; return clientData?.clientopts?.globalshortcut ?? "";
} }
@boundMethod
handleClose() {
GlobalModel.clientSettingsViewModel.closeView();
}
render() { render() {
const isHidden = GlobalModel.activeMainView.get() != "clientsettings"; const isHidden = GlobalModel.activeMainView.get() != "clientsettings";
if (isHidden) { if (isHidden) {
@ -145,11 +150,7 @@ class ClientSettingsView extends React.Component<{ model: RemotesModel }, { hove
const curFontFamily = GlobalModel.getTermFontFamily(); const curFontFamily = GlobalModel.getTermFontFamily();
return ( return (
<MainView <MainView viewName="clientsettings" title="Client Settings" onClose={this.handleClose}>
viewName="clientsettings"
title="Client Settings"
onClose={GlobalModel.clientSettingsViewModel.closeView}
>
<div className="content"> <div className="content">
<div className="settings-field"> <div className="settings-field">
<div className="settings-label">Term Font Size</div> <div className="settings-label">Term Font Size</div>

View File

@ -16,11 +16,13 @@ class MainView extends React.Component<{
children: React.ReactNode; children: React.ReactNode;
}> { }> {
render() { render() {
// TODO: This is a workaround for History view not honoring the sidebar width. This is rooted in the table width for the history view, which uses `calc(100%-20px)`. To properly fix this, History view needs a full overhaul. const sidebarModel = GlobalModel.mainSidebarModel;
const width = window.innerWidth - 6 - GlobalModel.mainSidebarModel.getWidth(); const maxWidthSubtractor = sidebarModel.getCollapsed() ? 0 : sidebarModel.getWidth();
return ( return (
<div className={cn("mainview", `${this.props.viewName}-view`)} style={{ maxWidth: width }}> <div
className={cn("mainview", `${this.props.viewName}-view`)}
style={{ maxWidth: `calc(100vw - ${maxWidthSubtractor}px)` }}
>
<div className="header-container bottom-border"> <div className="header-container bottom-border">
<header className="header"> <header className="header">
<div className="title text-primary">{this.props.title}</div> <div className="title text-primary">{this.props.title}</div>

View File

@ -98,6 +98,11 @@ class ConnectionsView extends React.Component<{ model: RemotesModel }, { hovered
} }
} }
@boundMethod
handleClose() {
GlobalModel.connectionViewModel.closeView();
}
componentDidMount() { componentDidMount() {
if (this.tableRef.current != null) { if (this.tableRef.current != null) {
this.tableRszObs = new ResizeObserver(this.handleTableResize.bind(this)); this.tableRszObs = new ResizeObserver(this.handleTableResize.bind(this));
@ -126,7 +131,7 @@ class ConnectionsView extends React.Component<{ model: RemotesModel }, { hovered
let item: RemoteType = null; let item: RemoteType = null;
return ( return (
<MainView viewName="connections" title="Connections" onClose={GlobalModel.connectionViewModel.closeView}> <MainView viewName="connections" title="Connections" onClose={this.handleClose}>
<table <table
className="connections-table" className="connections-table"
cellSpacing="0" cellSpacing="0"

View File

@ -386,6 +386,11 @@ class HistoryView extends React.Component<{}, {}> {
})(); })();
} }
@boundMethod
handleClose() {
GlobalModel.historyViewModel.closeView();
}
render() { render() {
let isHidden = GlobalModel.activeMainView.get() != "history"; let isHidden = GlobalModel.activeMainView.get() != "history";
if (isHidden) { if (isHidden) {
@ -408,7 +413,7 @@ class HistoryView extends React.Component<{}, {}> {
let remoteId: string = null; let remoteId: string = null;
return ( return (
<MainView viewName="history" title="History" onClose={GlobalModel.historyViewModel.closeView}> <MainView viewName="history" title="History" onClose={this.handleClose}>
<div key="search" className="history-search"> <div key="search" className="history-search">
<div className="main-search field"> <div className="main-search field">
<TextField <TextField

View File

@ -5,7 +5,6 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
position: relative; position: relative;
font-size: 12.5px;
line-height: 20px; line-height: 20px;
backdrop-filter: blur(4px); backdrop-filter: blur(4px);
z-index: 20; z-index: 20;
@ -19,123 +18,38 @@
.title-bar-drag { .title-bar-drag {
-webkit-app-region: drag; -webkit-app-region: drag;
height: calc(var(--screentabs-height) + 1px); height: calc(var(--screentabs-height) + 1px);
top: 0;
left: 0;
width: 100%;
border-bottom: 1px solid var(--app-border-color); border-bottom: 1px solid var(--app-border-color);
position: relative; position: relative;
display: flex;
.logo {
line-height: 15px;
margin: auto auto;
svg {
width: 88px;
}
}
.close-button { .close-button {
-webkit-app-region: no-drag; -webkit-app-region: no-drag;
position: absolute; position: absolute;
right: 0; right: 0;
top: 0;
height: 100%; height: 100%;
padding: 5px; padding: 10px;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center;
cursor: pointer; cursor: pointer;
} }
} }
&.collapsed { &.collapsed {
display: none; display: none;
width: 6em;
min-width: 6em;
.arrow-container,
.collapse-button {
transform: rotate(180deg);
margin-top: 20px;
}
.title-bar-drag {
.close-button {
display: none;
}
}
.contents {
.top,
.workspaces,
.middle,
.bottom,
.separator {
pointer-events: none;
opacity: 0;
visibility: hidden;
}
.logo {
display: flex;
flex-direction: column;
margin-left: 0;
justify-content: center;
align-items: center;
.logo-container {
width: 45px;
}
.collapse-button {
margin-right: 0;
}
}
}
overflow: hidden;
}
.arrow-container {
position: absolute;
top: 24px;
right: 15px;
width: 1.5em;
height: 1.5em;
border-radius: 50%;
transition: transform 0.3s ease-in-out;
z-index: 2;
svg {
width: 1.5em;
height: 1.5em;
}
} }
.contents { .contents {
margin-top: 16px; margin-top: 16px;
} }
.logo {
margin-left: 14px;
display: flex;
flex-direction: row;
.logo-container {
flex-shrink: 0;
img {
width: 40px;
}
}
.spacer {
flex-grow: 1;
}
img {
width: 100px;
}
.collapse-button {
transition: transform 0.3s ease-in-out;
margin-right: 14px;
svg {
margin-top: 3px;
width: 1.5em;
height: 1.5em;
}
}
}
.separator { .separator {
height: 1px; height: 1px;
margin: 16px 0; margin: 16px 0;
@ -188,10 +102,12 @@
.front-icon { .front-icon {
.positional-icon-visible; .positional-icon-visible;
font-size: 15px;
} }
.end-icons { .end-icons {
height: 20px; height: 20px;
line-height: normal;
} }
.item-contents { .item-contents {
@ -234,14 +150,6 @@
} }
} }
.front-icon {
font-size: 15px;
}
.end-icons {
line-height: normal;
}
.fa-discord { .fa-discord {
font-size: 13px; font-size: 13px;
} }

View File

@ -10,10 +10,11 @@ import dayjs from "dayjs";
import { If } from "tsx-control-statements/components"; import { If } from "tsx-control-statements/components";
import { compareLoose } from "semver"; import { compareLoose } from "semver";
import { ReactComponent as LeftChevronIcon } from "@/assets/icons/chevron_left.svg";
import { ReactComponent as AppsIcon } from "@/assets/icons/apps.svg"; import { ReactComponent as AppsIcon } from "@/assets/icons/apps.svg";
import { ReactComponent as WorkspacesIcon } from "@/assets/icons/workspaces.svg"; import { ReactComponent as WorkspacesIcon } from "@/assets/icons/workspaces.svg";
import { ReactComponent as SettingsIcon } from "@/assets/icons/settings.svg"; import { ReactComponent as SettingsIcon } from "@/assets/icons/settings.svg";
import { ReactComponent as WaveLogoWord } from "@/assets/wave-logo_horizontal-coloronblack.svg";
import { ReactComponent as WaveLogo } from "@/assets/waveterm-logo.svg";
import localizedFormat from "dayjs/plugin/localizedFormat"; import localizedFormat from "dayjs/plugin/localizedFormat";
import { GlobalModel, GlobalCommandRunner, Session } from "@/models"; import { GlobalModel, GlobalCommandRunner, Session } from "@/models";
@ -265,8 +266,8 @@ class MainSideBar extends React.Component<MainSideBarProps, {}> {
} }
render() { render() {
const mainSidebar = GlobalModel.mainSidebarModel; const sidebarWidth = GlobalModel.mainSidebarModel.getWidth();
const isCollapsed = mainSidebar.getCollapsed();
return ( return (
<ResizableSidebar <ResizableSidebar
className="main-sidebar" className="main-sidebar"
@ -277,6 +278,14 @@ class MainSideBar extends React.Component<MainSideBarProps, {}> {
{(toggleCollapse) => ( {(toggleCollapse) => (
<React.Fragment> <React.Fragment>
<div className="title-bar-drag"> <div className="title-bar-drag">
<div className="logo">
<If condition={sidebarWidth > 215}>
<WaveLogoWord />
</If>
<If condition={sidebarWidth <= 215}>
<WaveLogo />
</If>
</div>
<div className="close-button"> <div className="close-button">
<i className="fa-sharp fa-solid fa-xmark-large" onClick={toggleCollapse} /> <i className="fa-sharp fa-solid fa-xmark-large" onClick={toggleCollapse} />
</div> </div>