diff --git a/build.rs b/build.rs index 2bc0682..a49c85d 100644 --- a/build.rs +++ b/build.rs @@ -13,7 +13,7 @@ use swc_common::{ fn main() { // Find all Typescript files (that are not type declaration) - let ts_files: Vec<_> = glob::glob(&format!("{}/**/*.ts", "static/source")) + let ts_files: Vec<_> = glob::glob(&format!("{}/**/*.ts", "static/scripts")) .expect("Failed to read glob pattern") .filter_map(|entry| entry.ok()) .filter(|entry| !entry.to_string_lossy().ends_with(".d.ts")) diff --git a/static/scripts/ace.mjs b/static/scripts/ace.mjs index d8428e7..2a3fea0 100644 --- a/static/scripts/ace.mjs +++ b/static/scripts/ace.mjs @@ -1,5 +1,5 @@ import "../vendor/ace/ace.js"; -import { findNearestParent } from "./node-utils.mjs"; +import { findNearestParent } from "./node-utils.js"; export default class Editor { editor; diff --git a/static/scripts/components/editor/script.ts b/static/scripts/components/editor/script.ts index a34ee78..4938418 100644 --- a/static/scripts/components/editor/script.ts +++ b/static/scripts/components/editor/script.ts @@ -6,6 +6,7 @@ class Editor extends HTMLElement { private tabEl: HTMLDivElement; private files: Record; private root: ShadowRoot; + private addTabButton: HTMLDivElement; constructor() { super(); @@ -14,13 +15,15 @@ class Editor extends HTMLElement { } connectedCallback() { - this.tabEl = $el("div", { className: "tab-container" }); + this.addTabButton = $el("div", { className: "tab" }, "+"); + this.tabEl = $el("div", { className: "tab-container" }, this.addTabButton); this.root.append(this.tabEl); const style = $el("style"); style.textContent = ` .tab-container { display: flex; + margin-bottom: -2px; & .tab { border: 2px solid var(--table-border-color); @@ -73,6 +76,14 @@ class Editor extends HTMLElement { tab.click(); } + setCurrent(name: string) { + this.editor.setSession(this.files[name]); + this.tabEl.querySelectorAll(".tab").forEach(el => { + if (el.dataset.name === name) el.classList.add("active"); + else el.classList.remove("active"); + }); + } + /** * Create a new tab * @param name Tab name @@ -81,13 +92,10 @@ class Editor extends HTMLElement { #addTab(name: string) { const tab = $el("div", { className: "tab", - "@click": () => { - this.editor.setSession(this.files[name]); - this.tabEl.querySelectorAll(".tab").forEach(el => el.classList.remove("active")); - tab.classList.add("active"); - } + dataset: { name }, + "@click": () => this.setCurrent(name) }, name); - this.tabEl.append(tab); + this.tabEl.insertBefore(tab, this.addTabButton); return tab; } } diff --git a/templates/stack/get-one.html b/templates/stack/get-one.html index 0b6f603..474d2c9 100644 --- a/templates/stack/get-one.html +++ b/templates/stack/get-one.html @@ -3,7 +3,7 @@ {% block title %}Stack {{stack_name}}{% endblock %} {% block content %} - +

Stack details for {{stack_name}}

@@ -113,12 +113,11 @@