import { html, css, LitElement } from "lit";
import { customElement, query } from "lit/decorators.js";
import { CanvasNode, Canvas } from "./canvas";
import { BaseTreeNode, styles as treeStyles, template as treeTemplate } from "./ui/tree-view";
const PROPERTY_WIDTH = 200;
@customElement("node-editor")
export class NodeEditor extends LitElement {
editor = new Canvas(this, {
size: {
width: window.innerWidth - PROPERTY_WIDTH * 2,
height: window.innerHeight,
},
});
@query("#output")
outputContainer!: HTMLDivElement;
private _resizeObserver = new ResizeObserver((entries) => {
for (const entry of entries) {
const { width, height } = entry.contentRect;
this.editor.resize({ width, height });
}
});
static styles = [
treeStyles,
css`
:host {
display: block;
width: 100%;
height: 100%;
}
main {
height: 100%;
width: 100%;
display: flex;
flex-direction: row;
}
#output {
flex: 1;
overflow: hidden;
}
.sidebar {
width: ${PROPERTY_WIDTH}px;
overflow-y: auto;
background-color: #f5f5f5;
border-right: 1px solid #ddd;
}
#properties {
width: ${PROPERTY_WIDTH}px;
display: flex;
flex-direction: column;
overflow-y: auto;
background-color: #eee;
border-left: 1px solid #ddd;
}
.property {
display: flex;
flex-direction: column;
padding: 10px;
}
.title {
font-size: 1.5em;
font-weight: bold;
padding: 10px;
}
.destructive {
background-color: red;
color: white;
}
#links > span {
padding-left: 10px;
font-size: 0.9em;
font-weight: bold;
}
`,
];
render() {
return html`