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