From 63c1b7c1e7ad4db7f5fa58de15199689fdc40841 Mon Sep 17 00:00:00 2001 From: Jeff Emmett Date: Sat, 21 Mar 2026 23:17:17 -0700 Subject: [PATCH] refactor(shell): convert settings & history panels to dropdown menus Replace full-height slide-in panels with compact dropdowns that appear beneath header icons. Both icons now grouped in header-right with mutual exclusion and click-outside-to-close behavior. Co-Authored-By: Claude Opus 4.6 --- server/shell.ts | 25 +++++++----- shared/components/rstack-history-panel.ts | 47 +++++++++++----------- shared/components/rstack-space-settings.ts | 46 +++++++++++---------- website/public/shell.css | 13 +++++- 4 files changed, 74 insertions(+), 57 deletions(-) diff --git a/server/shell.ts b/server/shell.ts index ecf2294..469a51f 100644 --- a/server/shell.ts +++ b/server/shell.ts @@ -227,7 +227,7 @@ export function renderShell(opts: ShellOptions): string {
- ${spaceEncrypted ? '🔒' : ''} + ${spaceEncrypted ? '🔒' : ''}
@@ -237,12 +237,17 @@ export function renderShell(opts: ShellOptions): string { - +
+ + +
+
+ + +
- -
@@ -281,16 +286,16 @@ export function renderShell(opts: ShellOptions): string { window.__rspaceInstallPrompt = () => { e.prompt(); return e.userChoice; }; window.dispatchEvent(new CustomEvent("rspace-install-available")); }); - // ── Settings panel toggle ── + // ── Settings panel toggle (close history first) ── document.getElementById('settings-btn')?.addEventListener('click', () => { - const panel = document.querySelector('rstack-space-settings'); - if (panel) panel.toggle(); + document.querySelector('rstack-history-panel')?.close(); + document.querySelector('rstack-space-settings')?.toggle(); }); - // ── History panel toggle ── + // ── History panel toggle (close settings first) ── document.getElementById('history-btn')?.addEventListener('click', () => { - const panel = document.querySelector('rstack-history-panel'); - if (panel) panel.toggle(); + document.querySelector('rstack-space-settings')?.close(); + document.querySelector('rstack-history-panel')?.toggle(); }); // Wire history panel to offline runtime doc (module pages) diff --git a/shared/components/rstack-history-panel.ts b/shared/components/rstack-history-panel.ts index cf1908b..20148ac 100644 --- a/shared/components/rstack-history-panel.ts +++ b/shared/components/rstack-history-panel.ts @@ -51,17 +51,28 @@ export class RStackHistoryPanel extends HTMLElement { } } + private _clickOutsideHandler = (e: MouseEvent) => { + const path = e.composedPath(); + if (!path.includes(this) && !path.includes(document.getElementById("history-btn")!)) { + this.close(); + } + }; + connectedCallback() { if (!this.shadowRoot) this.attachShadow({ mode: "open" }); this._render(); } + disconnectedCallback() { + document.removeEventListener("click", this._clickOutsideHandler, true); + } + open() { this._open = true; this._refreshHistory(); this._render(); - // Toggle active state on button document.getElementById("history-btn")?.classList.add("active"); + document.addEventListener("click", this._clickOutsideHandler, true); } close() { @@ -69,6 +80,7 @@ export class RStackHistoryPanel extends HTMLElement { this._timeMachineSnapshot = null; this._render(); document.getElementById("history-btn")?.classList.remove("active"); + document.removeEventListener("click", this._clickOutsideHandler, true); } toggle() { @@ -277,7 +289,6 @@ export class RStackHistoryPanel extends HTMLElement { this.shadowRoot.innerHTML = ` -

History

@@ -354,7 +365,6 @@ export class RStackHistoryPanel extends HTMLElement { const sr = this.shadowRoot!; sr.getElementById("close-btn")?.addEventListener("click", () => this.close()); - sr.getElementById("overlay")?.addEventListener("click", () => this.close()); // Tab switching sr.querySelectorAll(".tab").forEach(btn => { @@ -406,37 +416,28 @@ const PANEL_CSS = ` display: contents; } -.overlay { - position: fixed; - inset: 0; - background: rgba(0, 0, 0, 0.5); - z-index: 200000; - animation: fadeIn 0.2s ease; -} - .panel { - position: fixed; - top: 0; + position: absolute; + top: 100%; right: 0; - bottom: 0; width: min(420px, 92vw); + max-height: calc(100vh - 72px); background: var(--rs-bg-surface, #1e293b); - border-left: 1px solid var(--rs-border, #334155); + border: 1px solid var(--rs-border, #334155); + border-radius: 12px; + box-shadow: 0 8px 32px rgba(0,0,0,0.3); z-index: 200001; display: flex; flex-direction: column; - animation: slideIn 0.25s ease; + animation: dropDown 0.2s ease; color: var(--rs-text-primary, #e2e8f0); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; + margin-top: 6px; } -@keyframes slideIn { - from { transform: translateX(100%); } - to { transform: translateX(0); } -} -@keyframes fadeIn { - from { opacity: 0; } - to { opacity: 1; } +@keyframes dropDown { + from { opacity: 0; transform: translateY(-8px); } + to { opacity: 1; transform: translateY(0); } } .panel-header { diff --git a/shared/components/rstack-space-settings.ts b/shared/components/rstack-space-settings.ts index 3aa60f7..bd54a7e 100644 --- a/shared/components/rstack-space-settings.ts +++ b/shared/components/rstack-space-settings.ts @@ -77,6 +77,13 @@ export class RStackSpaceSettings extends HTMLElement { } } + private _clickOutsideHandler = (e: MouseEvent) => { + const path = e.composedPath(); + if (!path.includes(this) && !path.includes(document.getElementById("settings-btn")!)) { + this.close(); + } + }; + connectedCallback() { this._space = this.getAttribute("space") || ""; this._moduleId = this.getAttribute("module-id") || ""; @@ -84,16 +91,22 @@ export class RStackSpaceSettings extends HTMLElement { this._render(); } + disconnectedCallback() { + document.removeEventListener("click", this._clickOutsideHandler, true); + } + open() { this._open = true; this._loadData(); this._loadModuleConfig(); this._render(); + document.addEventListener("click", this._clickOutsideHandler, true); } close() { this._open = false; this._render(); + document.removeEventListener("click", this._clickOutsideHandler, true); } toggle() { @@ -355,7 +368,6 @@ export class RStackSpaceSettings extends HTMLElement { this.shadowRoot.innerHTML = ` -

${panelTitle}

@@ -426,7 +438,6 @@ export class RStackSpaceSettings extends HTMLElement { const sr = this.shadowRoot!; sr.getElementById("close-btn")?.addEventListener("click", () => this.close()); - sr.getElementById("overlay")?.addEventListener("click", () => this.close()); // Toggle add mode sr.querySelectorAll(".toggle-btn").forEach(btn => { @@ -656,37 +667,28 @@ const PANEL_CSS = ` display: contents; } -.overlay { - position: fixed; - inset: 0; - background: rgba(0, 0, 0, 0.5); - z-index: 200000; - animation: fadeIn 0.2s ease; -} - .panel { - position: fixed; - top: 0; + position: absolute; + top: 100%; right: 0; - bottom: 0; width: min(380px, 90vw); + max-height: calc(100vh - 72px); background: var(--rs-bg-surface); - border-left: 1px solid var(--rs-border); + border: 1px solid var(--rs-border); + border-radius: 12px; + box-shadow: 0 8px 32px rgba(0,0,0,0.3); z-index: 200001; display: flex; flex-direction: column; - animation: slideIn 0.25s ease; + animation: dropDown 0.2s ease; color: var(--rs-text-primary); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; + margin-top: 6px; } -@keyframes slideIn { - from { transform: translateX(100%); } - to { transform: translateX(0); } -} -@keyframes fadeIn { - from { opacity: 0; } - to { opacity: 1; } +@keyframes dropDown { + from { opacity: 0; transform: translateY(-8px); } + to { opacity: 1; transform: translateY(0); } } .panel-header { diff --git a/website/public/shell.css b/website/public/shell.css index 7e86d48..6e73985 100644 --- a/website/public/shell.css +++ b/website/public/shell.css @@ -105,6 +105,14 @@ body { -webkit-text-fill-color: transparent; } +/* ── Dropdown wrapper (positions panel relative to button) ── */ + +.rstack-header__dropdown-wrap { + position: relative; + display: flex; + align-items: center; +} + /* ── Header icon buttons (settings gear, history clock) ── */ .rstack-header__settings-btn, @@ -441,8 +449,9 @@ body.rstack-sidebar-open #toolbar { flex-wrap: wrap; gap: 6px; } - /* Hide settings gear on mobile — accessible via identity dropdown */ - .rstack-header__settings-btn { display: none; } + /* Hide settings/history on mobile — accessible via identity dropdown */ + .rstack-header__settings-btn, + .rstack-header__history-btn { display: none; } /* Sidebar overlays on mobile — no push offsets */ body.rstack-sidebar-open .rstack-tab-row { left: 0; } body.rstack-sidebar-open #app { margin-left: 0; }