mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
make buttons nodrag, make iconbutton a proper button
This commit is contained in:
parent
10a556aab3
commit
6bd3dfd1fd
@ -2,6 +2,11 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
padding: 0;
|
||||||
|
font: inherit;
|
||||||
|
outline: inherit;
|
||||||
|
|
||||||
&.bulb {
|
&.bulb {
|
||||||
color: var(--bulb-color);
|
color: var(--bulb-color);
|
||||||
|
@ -4,16 +4,18 @@
|
|||||||
import { useLongClick } from "@/app/hook/useLongClick";
|
import { useLongClick } from "@/app/hook/useLongClick";
|
||||||
import { makeIconClass } from "@/util/util";
|
import { makeIconClass } from "@/util/util";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import { memo, useRef } from "react";
|
import { forwardRef, memo, useRef } from "react";
|
||||||
import "./iconbutton.scss";
|
import "./iconbutton.scss";
|
||||||
|
|
||||||
export const IconButton = memo(({ decl, className }: { decl: IconButtonDecl; className?: string }) => {
|
type IconButtonProps = { decl: IconButtonDecl; className?: string };
|
||||||
const buttonRef = useRef<HTMLDivElement>(null);
|
export const IconButton = memo(
|
||||||
|
forwardRef<HTMLButtonElement, IconButtonProps>(({ decl, className }, ref) => {
|
||||||
|
ref = ref ?? useRef<HTMLButtonElement>(null);
|
||||||
const spin = decl.iconSpin ?? false;
|
const spin = decl.iconSpin ?? false;
|
||||||
useLongClick(buttonRef, decl.click, decl.longClick, decl.disabled);
|
useLongClick(ref, decl.click, decl.longClick, decl.disabled);
|
||||||
return (
|
return (
|
||||||
<div
|
<button
|
||||||
ref={buttonRef}
|
ref={ref}
|
||||||
className={clsx("iconbutton", className, decl.className, {
|
className={clsx("iconbutton", className, decl.className, {
|
||||||
disabled: decl.disabled,
|
disabled: decl.disabled,
|
||||||
"no-action": decl.noAction,
|
"no-action": decl.noAction,
|
||||||
@ -22,6 +24,7 @@ export const IconButton = memo(({ decl, className }: { decl: IconButtonDecl; cla
|
|||||||
style={{ color: decl.iconColor ?? "inherit" }}
|
style={{ color: decl.iconColor ?? "inherit" }}
|
||||||
>
|
>
|
||||||
{typeof decl.icon === "string" ? <i className={makeIconClass(decl.icon, true, { spin })} /> : decl.icon}
|
{typeof decl.icon === "string" ? <i className={makeIconClass(decl.icon, true, { spin })} /> : decl.icon}
|
||||||
</div>
|
</button>
|
||||||
);
|
);
|
||||||
});
|
})
|
||||||
|
);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.tab-bar-wrapper {
|
.tab-bar-wrapper {
|
||||||
|
margin-top: 6px;
|
||||||
position: relative;
|
position: relative;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -30,13 +31,16 @@
|
|||||||
width: 100vw;
|
width: 100vw;
|
||||||
-webkit-app-region: drag;
|
-webkit-app-region: drag;
|
||||||
|
|
||||||
|
button {
|
||||||
|
-webkit-app-region: no-drag;
|
||||||
|
}
|
||||||
|
|
||||||
.tabs-wrapper {
|
.tabs-wrapper {
|
||||||
transition: var(--tabs-wrapper-transition);
|
transition: var(--tabs-wrapper-transition);
|
||||||
height: 26px;
|
height: 26px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-bar {
|
.tab-bar {
|
||||||
margin-top: 6px;
|
|
||||||
position: relative; // Needed for absolute positioning of child tabs
|
position: relative; // Needed for absolute positioning of child tabs
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@ -58,7 +62,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 6px 6px 0 0;
|
padding: 0 6px 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.app-menu-button {
|
.app-menu-button {
|
||||||
|
@ -11,6 +11,7 @@ import { useAtomValue } from "jotai";
|
|||||||
import { OverlayScrollbars } from "overlayscrollbars";
|
import { OverlayScrollbars } from "overlayscrollbars";
|
||||||
import { createRef, memo, useCallback, useEffect, useRef, useState } from "react";
|
import { createRef, memo, useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { debounce } from "throttle-debounce";
|
import { debounce } from "throttle-debounce";
|
||||||
|
import { IconButton } from "../element/iconbutton";
|
||||||
import { WorkspaceService } from "../store/services";
|
import { WorkspaceService } from "../store/services";
|
||||||
import { Tab } from "./tab";
|
import { Tab } from "./tab";
|
||||||
import "./tabbar.scss";
|
import "./tabbar.scss";
|
||||||
@ -147,7 +148,7 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
|
|||||||
const tabBarRef = useRef<HTMLDivElement>(null);
|
const tabBarRef = useRef<HTMLDivElement>(null);
|
||||||
const tabsWrapperRef = useRef<HTMLDivElement>(null);
|
const tabsWrapperRef = useRef<HTMLDivElement>(null);
|
||||||
const tabRefs = useRef<React.RefObject<HTMLDivElement>[]>([]);
|
const tabRefs = useRef<React.RefObject<HTMLDivElement>[]>([]);
|
||||||
const addBtnRef = useRef<HTMLDivElement>(null);
|
const addBtnRef = useRef<HTMLButtonElement>(null);
|
||||||
const draggingRemovedRef = useRef(false);
|
const draggingRemovedRef = useRef(false);
|
||||||
const draggingTabDataRef = useRef({
|
const draggingTabDataRef = useRef({
|
||||||
tabId: "",
|
tabId: "",
|
||||||
@ -645,6 +646,13 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
|
|||||||
<i className="fa fa-ellipsis" />
|
<i className="fa fa-ellipsis" />
|
||||||
</div>
|
</div>
|
||||||
) : undefined;
|
) : undefined;
|
||||||
|
|
||||||
|
const addtabButtonDecl: IconButtonDecl = {
|
||||||
|
elemtype: "iconbutton",
|
||||||
|
icon: "plus",
|
||||||
|
click: handleAddTab,
|
||||||
|
title: "Add Tab",
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<div ref={tabbarWrapperRef} className="tab-bar-wrapper">
|
<div ref={tabbarWrapperRef} className="tab-bar-wrapper">
|
||||||
<WindowDrag ref={draggerLeftRef} className="left" />
|
<WindowDrag ref={draggerLeftRef} className="left" />
|
||||||
@ -677,9 +685,7 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ref={addBtnRef} className="add-tab-btn" onClick={handleAddTab}>
|
<IconButton decl={addtabButtonDecl} ref={addBtnRef} />
|
||||||
<i className="fa fa-solid fa-plus fa-fw" />
|
|
||||||
</div>
|
|
||||||
<UpdateStatusBanner ref={updateStatusBannerRef} />
|
<UpdateStatusBanner ref={updateStatusBannerRef} />
|
||||||
<ConfigErrorIcon buttonRef={configErrorButtonRef} />
|
<ConfigErrorIcon buttonRef={configErrorButtonRef} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
border-radius: 6px;
|
border-radius: 6px;
|
||||||
margin-top: 6px;
|
|
||||||
margin-right: 13px;
|
margin-right: 13px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background-color: rgb(from var(--main-text-color) r g b / 0.1) !important;
|
background-color: rgb(from var(--main-text-color) r g b / 0.1) !important;
|
||||||
|
Loading…
Reference in New Issue
Block a user