diff --git a/changelog.d/fixed-19282-sidebar-group-indent.md b/changelog.d/fixed-19282-sidebar-group-indent.md new file mode 100644 index 0000000000..a99ab0da40 --- /dev/null +++ b/changelog.d/fixed-19282-sidebar-group-indent.md @@ -0,0 +1 @@ +- Dashboard sidebar entries under Collaborate, Resources, Intelligence, Admin, Help and Filters now line up with the Dashboard group's entries (#19282). Only Dashboard entries carried a reorder grip, and that hidden grip was what indented them. Every sidebar entry now reserves the same grip-wide gutter through one shared `.oc-nav-item` rule, and a grip draws inside that gutter, so Dashboard and agent rows keep their position and the other groups move in to match. diff --git a/src/pkg/dashboard/sidebar_nav_indent_19282_test.go b/src/pkg/dashboard/sidebar_nav_indent_19282_test.go new file mode 100644 index 0000000000..998de2d6b3 --- /dev/null +++ b/src/pkg/dashboard/sidebar_nav_indent_19282_test.go @@ -0,0 +1,64 @@ +package dashboard + +import ( + "regexp" + "strings" + "testing" +) + +// cssRuleBody returns the declaration block of the first rule whose selector +// list is exactly selector, or "" when there is none. +func cssRuleBody(css, selector string) string { + re := regexp.MustCompile(`(?m)^\s*` + regexp.QuoteMeta(selector) + `\s*\{([^}]*)\}`) + m := re.FindStringSubmatch(css) + if m == nil { + return "" + } + return m[1] +} + +// TestSidebarNavItemsShareOneIndent guards #19282: only Dashboard entries got +// a reorder grip, and that hidden grip was the only thing indenting them, so +// Collaborate, Resources, Intelligence, Admin, Help and Filters entries sat +// flush left. Every entry now reserves the same grip-wide gutter through one +// .oc-nav-item rule, and a grip draws inside that gutter instead of adding to it. +func TestSidebarNavItemsShareOneIndent(t *testing.T) { + html := indexHTML(t) + + for _, want := range []string{ + "--oc-nav-grip-w:", + "--oc-nav-child-inset: calc(var(--oc-nav-grip-w) + var(--oc-nav-item-gap))", + } { + if !strings.Contains(html, want) { + t.Errorf("sidebar tokens missing %q", want) + } + } + + item := cssRuleBody(html, ".oc-nav-item") + if item == "" { + t.Fatal("no .oc-nav-item rule found") + } + if !strings.Contains(item, "calc(var(--oc-nav-item-pad-x) + var(--oc-nav-child-inset))") { + t.Errorf(".oc-nav-item must reserve the shared grip gutter in its left padding; got %q", item) + } + if !strings.Contains(item, "gap: var(--oc-nav-item-gap)") { + t.Errorf(".oc-nav-item gap must use --oc-nav-item-gap so the gutter matches the grip spacing; got %q", item) + } + + grip := cssRuleBody(html, ".oc-nav-item > .oc-nav-drag-handle:first-child") + if !strings.Contains(grip, "margin-left: calc(-1 * var(--oc-nav-child-inset))") { + t.Errorf("a leading grip must sit inside the shared gutter (negative inset margin); got %q", grip) + } + + handle := cssRuleBody(html, ".oc-nav-drag-handle, .oc-nav-hide-toggle") + if !strings.Contains(handle, "width: var(--oc-nav-grip-w)") { + t.Errorf("grip width must come from --oc-nav-grip-w so the gutter tracks it; got %q", handle) + } + + // No per-group indentation: the fix is one shared rule, not a pixel + // override per sidebar group. + perGroup := regexp.MustCompile(`#(dashboard-section|collaborate|hf)-nav-group[^{]*\.oc-nav-item[^{]*\{[^}]*padding`) + if perGroup.MatchString(html) { + t.Error("sidebar groups must not carry their own .oc-nav-item padding; use the shared gutter") + } +} diff --git a/src/pkg/dashboard/static-src/css/sidebar.css b/src/pkg/dashboard/static-src/css/sidebar.css index 45e033fbe7..a5e6b1e810 100644 --- a/src/pkg/dashboard/static-src/css/sidebar.css +++ b/src/pkg/dashboard/static-src/css/sidebar.css @@ -44,16 +44,29 @@ .oc-nav-label::after { content: ''; flex: 1; height: 1px; background: var(--border); } + /* Every sidebar entry reserves a leading gutter as wide as the reorder + grip plus the row gap. Reorderable entries (Dashboard group, agents) + draw their grip inside that gutter; entries without a grip (Collaborate, + Resources, Intelligence, Admin, Help, Filters) keep it empty, so all + groups line up at the same indent (#19282). */ + :root { + --oc-nav-grip-w: 1.25rem; + --oc-nav-item-gap: var(--sp-3); + --oc-nav-item-pad-x: 12px; + --oc-nav-child-inset: calc(var(--oc-nav-grip-w) + var(--oc-nav-item-gap)); + } .oc-nav-item { - display: flex; align-items: center; gap: var(--sp-3); - padding: 5px 12px; font-size: var(--fs-base); color: var(--muted); + display: flex; align-items: center; gap: var(--oc-nav-item-gap); + padding: 5px var(--oc-nav-item-pad-x) 5px calc(var(--oc-nav-item-pad-x) + var(--oc-nav-child-inset)); + font-size: var(--fs-base); color: var(--muted); cursor: pointer; text-decoration: none; border-radius: var(--r); transition: background 0.15s, color 0.15s; margin: 1px 8px; position: relative; min-height: 28px; overflow: hidden; } - .oc-nav-drag-handle, .oc-nav-hide-toggle { width: 1.25rem; height: 1.25rem; min-width: 1.25rem; padding: var(--sp-0); margin: var(--sp-0); border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--muted); line-height: 1; cursor: grab; opacity: 0; display: inline-flex; align-items: center; justify-content: center; touch-action: none; } + .oc-nav-drag-handle, .oc-nav-hide-toggle { width: var(--oc-nav-grip-w); height: var(--oc-nav-grip-w); min-width: var(--oc-nav-grip-w); padding: var(--sp-0); margin: var(--sp-0); border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--muted); line-height: 1; cursor: grab; opacity: 0; display: inline-flex; align-items: center; justify-content: center; touch-action: none; } .oc-nav-hide-toggle { cursor: pointer; margin-left: auto; font-size: var(--fs-xs); } + .oc-nav-item > .oc-nav-drag-handle:first-child { margin-left: calc(-1 * var(--oc-nav-child-inset)); } .oc-nav-item:hover .oc-nav-drag-handle, .oc-nav-drag-handle:focus-visible, .oc-nav-drag-handle[aria-pressed="true"], .oc-nav-item:hover .oc-nav-hide-toggle, .oc-nav-hide-toggle:focus-visible, .oc-nav-hide-toggle[aria-pressed="true"] { opacity: 1; color: var(--text); border-color: var(--border); background: var(--surface-2); outline: none; } .oc-nav-drag-handle:active, .oc-nav-drag-handle[aria-pressed="true"] { cursor: grabbing; background: var(--surface); } .oc-nav-hide-toggle:hover { color: var(--amber); } diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index f69b920f56..a212a8e8aa 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -253,16 +253,29 @@ .oc-nav-label::after { content: ''; flex: 1; height: 1px; background: var(--border); } + /* Every sidebar entry reserves a leading gutter as wide as the reorder + grip plus the row gap. Reorderable entries (Dashboard group, agents) + draw their grip inside that gutter; entries without a grip (Collaborate, + Resources, Intelligence, Admin, Help, Filters) keep it empty, so all + groups line up at the same indent (#19282). */ + :root { + --oc-nav-grip-w: 1.25rem; + --oc-nav-item-gap: var(--sp-3); + --oc-nav-item-pad-x: 12px; + --oc-nav-child-inset: calc(var(--oc-nav-grip-w) + var(--oc-nav-item-gap)); + } .oc-nav-item { - display: flex; align-items: center; gap: var(--sp-3); - padding: 5px 12px; font-size: var(--fs-base); color: var(--muted); + display: flex; align-items: center; gap: var(--oc-nav-item-gap); + padding: 5px var(--oc-nav-item-pad-x) 5px calc(var(--oc-nav-item-pad-x) + var(--oc-nav-child-inset)); + font-size: var(--fs-base); color: var(--muted); cursor: pointer; text-decoration: none; border-radius: var(--r); transition: background 0.15s, color 0.15s; margin: 1px 8px; position: relative; min-height: 28px; overflow: hidden; } - .oc-nav-drag-handle, .oc-nav-hide-toggle { width: 1.25rem; height: 1.25rem; min-width: 1.25rem; padding: var(--sp-0); margin: var(--sp-0); border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--muted); line-height: 1; cursor: grab; opacity: 0; display: inline-flex; align-items: center; justify-content: center; touch-action: none; } + .oc-nav-drag-handle, .oc-nav-hide-toggle { width: var(--oc-nav-grip-w); height: var(--oc-nav-grip-w); min-width: var(--oc-nav-grip-w); padding: var(--sp-0); margin: var(--sp-0); border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--muted); line-height: 1; cursor: grab; opacity: 0; display: inline-flex; align-items: center; justify-content: center; touch-action: none; } .oc-nav-hide-toggle { cursor: pointer; margin-left: auto; font-size: var(--fs-xs); } + .oc-nav-item > .oc-nav-drag-handle:first-child { margin-left: calc(-1 * var(--oc-nav-child-inset)); } .oc-nav-item:hover .oc-nav-drag-handle, .oc-nav-drag-handle:focus-visible, .oc-nav-drag-handle[aria-pressed="true"], .oc-nav-item:hover .oc-nav-hide-toggle, .oc-nav-hide-toggle:focus-visible, .oc-nav-hide-toggle[aria-pressed="true"] { opacity: 1; color: var(--text); border-color: var(--border); background: var(--surface-2); outline: none; } .oc-nav-drag-handle:active, .oc-nav-drag-handle[aria-pressed="true"] { cursor: grabbing; background: var(--surface); } .oc-nav-hide-toggle:hover { color: var(--amber); }