Skip to content

Commit

Permalink
Replace old buttons with Button element (#466)
Browse files Browse the repository at this point in the history
* init

* model

* pass model

* increase snap threshold

* move saving of state to model. backend implementation

* fix wrong clientdata prop

* right header space for right sidebar toggles

* button component refactor

* set default classname to primary

* remove debugging code

* hide trigger for now

* refactor Button. replace old buttons with Button element

* fix issue with closing alert modal

* make small button a little more round

* hide right sidebar toggle in prod
  • Loading branch information
adred authored Mar 18, 2024
1 parent 338b9c4 commit b656f4c
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 63 deletions.
78 changes: 38 additions & 40 deletions src/app/common/elements/button.less
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.wave-button {
background: none;
color: inherit;
border: none;
font: inherit;
cursor: pointer;
outline: inherit;
display: flex;
Expand All @@ -12,64 +10,64 @@
border-radius: 6px;
height: auto;
line-height: 1.5;
display: block;
white-space: nowrap;

color: var(--form-element-text-color);
background: var(--form-element-primary-color);
i {
fill: var(--form-element-text-color);
}

&.primary {
color: var(--form-element-text-color);
background: var(--form-element-primary-color);

i {
fill: var(--form-element-primary-color);
}

&.solid {
color: var(--form-element-text-color);
background: var(--form-element-primary-color);

i {
fill: var(--form-element-text-color);
}
fill: var(--form-element-text-color);
}
}

&.outlined {
background: none;
border: 1px solid var(--form-element-primary-color);
}
&.primary.outlined {
background: none;
border: 1px solid var(--form-element-primary-color);

&.ghost {
background: none;
i {
fill: var(--form-element-primary-color);
}
}

&:hover {
color: var(--form-element-text-color);
&.primary.ghost {
background: none;
i {
fill: var(--form-element-primary-color);
}
}

&.secondary {
color: var(--form-element-text-color);
background: none;
color: var(--form-element-text-color);
background: var(--form-element-secondary-color);
box-shadow: none;

&.solid {
color: var(--form-element-text-color);
background: var(--form-element-secondary-color);
box-shadow: none;
i {
fill: var(--form-element-text-color);
}
}

&.outlined {
background: none;
border: 1px solid var(--form-element-secondary-color);
}
&.secondary.outlined {
background: none;
border: 1px solid var(--form-element-text-color);
}

&.ghost {
background: none;
padding: 6px 10px;
&.secondary.ghost {
background: none;
}

i {
fill: var(--form-element-primary-color);
}
}
&.secondary.danger {
color: var(--app-error-color);
}

&.small {
padding: 4px 8px;
font-size: 12px;
border-radius: 3.6px;
}

&.term-inline {
Expand Down
2 changes: 1 addition & 1 deletion src/app/common/modals/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import "./alert.less";
class AlertModal extends React.Component<{}, {}> {
@boundMethod
closeModal(): void {
GlobalModel.cancelAlert();
GlobalModel.modalsModel.popModal(() => GlobalModel.cancelAlert());
}

@boundMethod
Expand Down
9 changes: 3 additions & 6 deletions src/app/common/modals/screensettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import cn from "classnames";
import { GlobalModel, GlobalCommandRunner, Screen } from "@/models";
import { Toggle, InlineSettingsTextEdit, SettingsError, Modal, Dropdown, Tooltip } from "@/elements";
import * as util from "@/util/util";
import { TabIcon } from "@/common/elements/tabicon";
import { TabIcon, Button } from "@/elements";
import { ReactComponent as GlobeIcon } from "@/assets/icons/globe.svg";
import { ReactComponent as StatusCircleIcon } from "@/assets/icons/statuscircle.svg";
import * as appconst from "@/app/appconst";
Expand Down Expand Up @@ -334,12 +334,9 @@ class ScreenSettingsModal extends React.Component<{}, {}> {
</Tooltip>
</div>
<div className="settings-input">
<div
onClick={this.handleDeleteScreen}
className="button is-prompt-danger is-outlined is-small"
>
<Button onClick={this.handleDeleteScreen} className="secondary small danger">
Delete Tab
</div>
</Button>
</div>
</div>
<SettingsError errorMessage={this.errorMessage} />
Expand Down
8 changes: 3 additions & 5 deletions src/app/common/modals/sessionsettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as mobxReact from "mobx-react";
import * as mobx from "mobx";
import { boundMethod } from "autobind-decorator";
import { GlobalModel, GlobalCommandRunner, Session } from "@/models";
import { Button } from "@/elements";
import { Toggle, InlineSettingsTextEdit, SettingsError, Modal, Tooltip } from "@/elements";
import * as util from "@/util/util";

Expand Down Expand Up @@ -133,12 +134,9 @@ class SessionSettingsModal extends React.Component<{}, {}> {
</Tooltip>
</div>
<div className="settings-input">
<div
onClick={this.handleDeleteSession}
className="button is-prompt-danger is-outlined is-small"
>
<Button onClick={this.handleDeleteSession} className="secondary small danger">
Delete Workspace
</div>
</Button>
</div>
</div>
<SettingsError errorMessage={this.errorMessage} />
Expand Down
4 changes: 2 additions & 2 deletions src/app/common/modals/viewremoteconndetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
</Button>
);
let archiveButton = (
<Button className="secondary" onClick={() => this.clickArchive()}>
<Button className="secondary danger" onClick={() => this.clickArchive()}>
Delete
</Button>
);
Expand All @@ -207,7 +207,7 @@ class ViewRemoteConnDetailModal extends React.Component<{}, {}> {
}
if (remote.sshconfigsrc == "sshconfig-import") {
archiveButton = (
<Button className="secondary" onClick={() => this.clickArchive()}>
<Button className="secondary danger" onClick={() => this.clickArchive()}>
Delete
<Tooltip
message={
Expand Down
2 changes: 1 addition & 1 deletion src/app/workspace/cmdinput/cmdinput.less
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
color: var(--app-warning-color);
align-items: center;

.button {
.wave-button {
margin-left: 10px;
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/workspace/cmdinput/cmdinput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import cn from "classnames";
import dayjs from "dayjs";
import localizedFormat from "dayjs/plugin/localizedFormat";
import { GlobalModel, GlobalCommandRunner, Screen } from "@/models";
import { renderCmdText } from "@/elements";
import { Button } from "@/elements";
import { TextAreaInput } from "./textareainput";
import { InfoMsg } from "./infomsg";
import { HistoryInfo } from "./historyinfo";
Expand Down Expand Up @@ -188,12 +188,12 @@ class CmdInput extends React.Component<{}, {}> {
<span className="remote-name">[{GlobalModel.resolveRemoteIdToFullRef(remote.remoteid)}]</span>
&nbsp;is {remote.status}
<If condition={remote.status != "connecting"}>
<div
className="button is-wave-green is-outlined is-small"
<Button
className="secondary small connect"
onClick={() => this.clickConnectRemote(remote.remoteid)}
>
connect now
</div>
</Button>
</If>
</div>
</If>
Expand Down
4 changes: 0 additions & 4 deletions src/models/rightsidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ class RightSidebarModel implements SidebarModel {
}

getCollapsed(): boolean {
// disable right sidebar in production
if (!this.globalModel.isDev) {
return true;
}
const clientData = this.globalModel.clientData.get();
const collapsed = clientData?.clientopts?.rightsidebar?.collapsed;
if (this.isDragging.get()) {
Expand Down

0 comments on commit b656f4c

Please sign in to comment.