From 249089dc7a23b137511afdac95598940b930135a Mon Sep 17 00:00:00 2001 From: Garrett Michael Flynn Date: Sat, 30 Dec 2023 21:18:02 -0600 Subject: [PATCH] Add group labels to sidebar (#547) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Cody Baker <51133164+CodyCBakerPhD@users.noreply.github.com> --- src/main/main.ts | 11 ++++--- src/renderer/assets/css/nav.css | 26 ++++++++++++++-- src/renderer/src/pages.js | 10 +++++++ src/renderer/src/stories/sidebar.js | 46 +++++++++++++++++++++++++---- 4 files changed, 82 insertions(+), 11 deletions(-) diff --git a/src/main/main.ts b/src/main/main.ts index c49609885..f75cbfc29 100755 --- a/src/main/main.ts +++ b/src/main/main.ts @@ -231,11 +231,14 @@ function initialize() { if (globals.mainWindow) return // Do not re-initialize if the main window is already declared + const minHeight = 800; + const minWidth = 1280; + const windowOptions = { - minWidth: 1121, - minHeight: 735, - width: 1121, - height: 735, + minWidth, + minHeight, + width: minWidth, + height: minHeight, center: true, show: false, icon, diff --git a/src/renderer/assets/css/nav.css b/src/renderer/assets/css/nav.css index dcedbecb5..494db926e 100755 --- a/src/renderer/assets/css/nav.css +++ b/src/renderer/assets/css/nav.css @@ -107,19 +107,41 @@ a[data-toggle="collapse"] { padding-bottom: 0px; } +#main-nav .sidebar-header img { + cursor: pointer; +} + #main-nav .sidebar-body { display: flex; flex-direction: column; justify-content: space-between; + overflow-y: hidden; + margin-top: 15px; flex-grow: 1; + border-top: 1px solid #8f8f8f; +} + +#main-nav .sidebar-body > *:last-child { + background: var(--color-sidebar); + padding: 3px; + padding-top: 8px; + border-top: 1px solid #8f8f8f; } -#main-nav ul.components { +#main-nav .sidebar-body > *:last-child h4 { + margin-top: 0px !important; +} + +#main-nav .sidebar-body li { list-style: none; +} + +#main-nav ul { padding-right: 10px; padding-left: 3px; margin-right: 0; - margin-top: 10px; + margin-bottom: 0; + overflow-y: auto; } #main-nav ul p { diff --git a/src/renderer/src/pages.js b/src/renderer/src/pages.js index d60abe07b..d2c8f2f74 100644 --- a/src/renderer/src/pages.js +++ b/src/renderer/src/pages.js @@ -37,6 +37,8 @@ dashboard.logo = logo; dashboard.name = "NWB GUIDE"; dashboard.renderNameInSidebar = false; +const resourcesGroup = "Resources"; + const overviewIcon = ` ${ logoNoName - ? html` ` + ? html` + this.select("/")} + /> + ` : "" } ${hasName ? html`

${this.name}

` : ""} @@ -162,26 +170,54 @@ export class Sidebar extends LitElement { ul.classList.add("components"); const groups = {}; + Object.entries(this.pages).forEach(([id, page]) => { const info = page.info ?? {}; const label = info.label ?? id; const icon = info.icon ?? ""; + + if (info.hidden) return; + const a = document.createElement("a"); a.setAttribute("data-id", id); a.href = "#"; - a.innerHTML = `${icon} ${label} `; + a.innerHTML = `${icon} ${label}`; a.onclick = () => this.#onClick(id); const li = document.createElement("li"); li.append(a); + if (info.hidden) { + li.style.display = "none"; + } + const parent = info.group ? groups[info.group] ?? (groups[info.group] = document.createElement("div")) : ul; - parent.append(a); + parent.append(li); }); - return [ul, ...Object.values(groups)]; + const bottomGroup = groups["bottom"]; + delete groups["bottom"]; + + for (let key in groups) { + const group = groups[key]; + const title = document.createElement("h4"); + Object.assign(title.style, { + color: "gray", + fontSize: "14px", + padding: "15px 0px 7px 10px", + borderBottom: "1px solid #ccc", + margin: 0, + marginBottom: "10px", + }); + title.innerHTML = header(key); + group.prepend(title); + } + + ul.append(...Object.values(groups)); + + return [ul, bottomGroup]; })()}