more tab/block structure

This commit is contained in:
sawka 2024-05-13 15:10:31 -07:00
parent 247b73c1e4
commit 4529a7d07f
8 changed files with 87 additions and 27 deletions

View File

@ -10,6 +10,7 @@ import { Events } from "@wailsio/runtime";
import * as rx from "rxjs"; import * as rx from "rxjs";
import { clsx } from "clsx"; import { clsx } from "clsx";
import { Block } from "./block.tsx"; import { Block } from "./block.tsx";
import { TabContent } from "./tab.tsx";
import "/public/style.less"; import "/public/style.less";
@ -35,9 +36,9 @@ const App = () => {
); );
}; };
const Tabs = () => { const TabBar = () => {
return ( return (
<div className="tabs"> <div className="tab-bar">
<div className="tab">Tab 1</div> <div className="tab">Tab 1</div>
<div className="tab">Tab 2</div> <div className="tab">Tab 2</div>
<div className="tab">Tab 3</div> <div className="tab">Tab 3</div>
@ -45,18 +46,10 @@ const Tabs = () => {
); );
}; };
const TabContent = () => {
return (
<div className="tabcontent">
<Block />
</div>
);
};
const Workspace = () => { const Workspace = () => {
return ( return (
<div className="workspace"> <div className="workspace">
<Tabs /> <TabBar />
<TabContent /> <TabContent />
</div> </div>
); );

View File

@ -9,6 +9,7 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
min-height: 0;
} }
.block .block-header { .block .block-header {
@ -26,4 +27,6 @@
flex-grow: 1; flex-grow: 1;
width: 100%; width: 100%;
background-color: green; background-color: green;
overflow: hidden;
min-height: 0;
} }

View File

@ -38,7 +38,7 @@ function getThemeFromCSSVars(el: Element): ITheme {
return theme; return theme;
} }
const Block = () => { const Block = ({ blockId }: { blockId: string }) => {
const blockRef = React.useRef<HTMLDivElement>(null); const blockRef = React.useRef<HTMLDivElement>(null);
const connectElemRef = React.useRef<HTMLDivElement>(null); const connectElemRef = React.useRef<HTMLDivElement>(null);
const [dims, setDims] = React.useState({ width: 0, height: 0 }); const [dims, setDims] = React.useState({ width: 0, height: 0 });
@ -71,8 +71,8 @@ const Block = () => {
return ( return (
<div className="block" ref={blockRef}> <div className="block" ref={blockRef}>
<div key="header" className="block-header"> <div key="header" className="block-header">
<div> <div className="text-fixed">
Block {dims.width}x{dims.height} Block [{blockId.substring(0, 8)}] {dims.width}x{dims.height}
</div> </div>
</div> </div>
<div key="conntectElem" className="block-term-connectelem" ref={connectElemRef}></div> <div key="conntectElem" className="block-term-connectelem" ref={connectElemRef}></div>

View File

@ -21,6 +21,7 @@
"jotai": "^2.8.0", "jotai": "^2.8.0",
"react": "^18.3.1", "react": "^18.3.1",
"react-dom": "^18.3.1", "react-dom": "^18.3.1",
"rxjs": "^7.8.1" "rxjs": "^7.8.1",
"uuid": "^9.0.1"
} }
} }

View File

@ -1,4 +1,4 @@
// Copyright 2023, Command Line Inc. // Copyright 2024, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
@import "./reset.less"; @import "./reset.less";
@ -8,6 +8,7 @@
--border-color: #333333; --border-color: #333333;
--main-color: #f7f7f7; --main-color: #f7f7f7;
--base-font: normal 15px / normal "Lato", sans-serif; --base-font: normal 15px / normal "Lato", sans-serif;
--fixed-font: normal 12px / normal "Hack", monospace;
--app-accent-color: rgb(88, 193, 66); --app-accent-color: rgb(88, 193, 66);
--panel-bg-color: rgba(31, 33, 31, 1); --panel-bg-color: rgba(31, 33, 31, 1);
} }
@ -23,6 +24,14 @@ body {
overflow: hidden; overflow: hidden;
} }
.flex-spacer {
flex-grow: 1;
}
.text-fixed {
font: var(--fixed-font);
}
#main, #main,
.mainapp { .mainapp {
display: flex; display: flex;
@ -42,9 +51,10 @@ body {
flex-direction: column; flex-direction: column;
width: 100%; width: 100%;
flex-grow: 1; flex-grow: 1;
overflow: hidden;
} }
.tabs { .tab-bar {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
height: 35px; height: 35px;
@ -64,13 +74,3 @@ body {
} }
} }
} }
.tabcontent {
display: flex;
flex-direction: row;
flex-grow: 1;
min-height: 0;
width: 100%;
align-items: center;
justify-content: center;
}

31
frontend/tab.less Normal file
View File

@ -0,0 +1,31 @@
// Copyright 2024, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
.tabcontent {
display: flex;
flex-direction: row;
flex-grow: 1;
min-height: 0;
width: 100%;
align-items: center;
justify-content: center;
overflow: hidden;
.block-container {
display: flex;
flex-direction: row;
flex: 1 0 0;
height: 100%;
overflow: hidden;
border: 1px solid var(--border-color);
margin: 5px;
border-radius: 4px;
padding: 5px;
}
.block1 {
}
.block2 {
}
}

27
frontend/tab.tsx Normal file
View File

@ -0,0 +1,27 @@
// Copyright 2023, Command Line Inc.
// SPDX-License-Identifier: Apache-2.0
import * as React from "react";
import * as jotai from "jotai";
import { Block } from "./block.tsx";
import { v4 as uuidv4 } from "uuid";
import "./tab.less";
const TabContent = () => {
const blockId1 = React.useMemo(() => uuidv4(), []);
const blockId2 = React.useMemo(() => uuidv4(), []);
return (
<div className="tabcontent">
<div className="block-container block1">
<Block blockId={blockId1} />
</div>
<div className="block-container block2">
<Block blockId={blockId2} />
</div>
</div>
);
};
export { TabContent };

View File

@ -472,6 +472,11 @@ tslib@^2.1.0, tslib@^2.3.0:
resolved "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz" resolved "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q== integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==
uuid@^9.0.1:
version "9.0.1"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==
vite@^5.0.0: vite@^5.0.0:
version "5.2.11" version "5.2.11"
resolved "https://registry.npmjs.org/vite/-/vite-5.2.11.tgz" resolved "https://registry.npmjs.org/vite/-/vite-5.2.11.tgz"