Make sidebar hidable with Ctrl+B
This commit is contained in:
parent
eb0a3f0231
commit
134d73da9b
|
|
@ -8,6 +8,7 @@ import { Editor } from "./editor";
|
|||
import { Terminal } from "./terminal";
|
||||
import { Displayable } from "./displayable";
|
||||
import { QuickOpen } from "./quickopen";
|
||||
import { toggleSidebar } from "./renderer";
|
||||
|
||||
const EditorWrapper = (
|
||||
editor: State<Displayable>,
|
||||
|
|
@ -141,6 +142,10 @@ function shortcutHandler(e: KeyboardEvent) {
|
|||
QuickOpen.open();
|
||||
}
|
||||
e.preventDefault();
|
||||
} else if (e.key === "b" && e.ctrlKey) {
|
||||
if (e.type === "keydown") {
|
||||
toggleSidebar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,22 @@ function newFile() {
|
|||
addEditor(file);
|
||||
}
|
||||
|
||||
export function toggleSidebar() {
|
||||
if (sidebar.val == "none") {
|
||||
sidebar.val = "tree";
|
||||
} else if (sidebar.val == "tree") {
|
||||
sidebar.val = "none";
|
||||
}
|
||||
}
|
||||
|
||||
export const sidebar = van.state<"tree" | "none">("tree");
|
||||
|
||||
const app = v.div(
|
||||
{ class: "h-screen max-h-screen w-screen max-w-screen flex" },
|
||||
v.aside(
|
||||
{
|
||||
class: "flex-none resize-x overflow-x-hidden overflow-y-scroll w-3xs min-w-32",
|
||||
hidden: () => sidebar.val != "tree",
|
||||
},
|
||||
u.InlineButton(addTab, "Add Tab", "+Tab"),
|
||||
u.InlineButton(newFile, "Add Editor", "+File"),
|
||||
|
|
|
|||
Loading…
Reference in New Issue