delete block and close tab working

This commit is contained in:
sawka
2024-05-27 16:33:31 -07:00
parent e6d7a4e674
commit 3f45945cb4
8 changed files with 165 additions and 24 deletions
+15
View File
@@ -55,9 +55,24 @@
height: 100%;
border-right: 1px solid var(--border-color);
cursor: pointer;
position: relative;
&.active {
background-color: var(--highlight-bg-color);
}
&.active:hover .tab-close {
display: block;
}
.tab-close {
position: absolute;
display: none;
padding: 5px;
right: 2px;
top: 5px;
cursor: pointer;
}
}
.tab-add {
+18 -7
View File
@@ -14,17 +14,22 @@ import "./workspace.less";
function Tab({ tabId }: { tabId: string }) {
const windowData = jotai.useAtomValue(atoms.waveWindow);
const [tabData, tabLoading] = WOS.useWaveObjectValue<Tab>(WOS.makeORef("tab", tabId));
function setActiveTab(tabId: string) {
if (tabId == null) {
return;
}
function setActiveTab() {
WOS.SetActiveTab(tabId);
}
function handleCloseTab() {
WOS.CloseTab(tabId);
}
return (
<div
className={clsx("tab", { active: tabData != null && windowData.activetabid === tabData.oid })}
onClick={() => setActiveTab(tabData?.oid)}
onClick={() => setActiveTab()}
>
<div className="tab-close" onClick={() => handleCloseTab()}>
<div>
<i className="fa fa-solid fa-xmark" />
</div>
</div>
{tabData?.name ?? "..."}
</div>
);
@@ -115,8 +120,14 @@ function WorkspaceElem() {
<div className="workspace">
<TabBar workspace={ws} />
<div className="workspace-tabcontent">
<TabContent key={windowData.workspaceid} tabId={activeTabId} />
<Widgets />
{activeTabId == "" ? (
<CenteredDiv>No Active Tab</CenteredDiv>
) : (
<>
<TabContent key={windowData.workspaceid} tabId={activeTabId} />
<Widgets />
</>
)}
</div>
</div>
);