Commit 695cb925d1
695cb925d1f99f7735883046e455cdc436602cb1
parent: 545ba0bcde
Verified · cmc ci/build: success ci/quality: success ci/test: success
cmc <hello@cleberg.net> · 2026-11-25 20:31 UTC
web: collapse nav settings, admin, profile, and logout into avatar dropdown
Changed files (3)
internal/web/static/app.js
+2 −2 · view
| @@ -29,11 +29,11 @@ |
| 29 | 29 | }; |
| 30 | 30 | |
| 31 | 31 | // ---- 1. Popover hygiene (close others, click outside, Escape) ---- |
| 32 | | const popovers = () => document.querySelectorAll('details.popover, details.railpins, details.refmenu'); |
| 32 | const popovers = () => document.querySelectorAll('details.popover, details.railpins, details.railusermenu, details.railmore, details.refmenu'); |
| 33 | 33 | document.addEventListener('toggle', (e) => { |
| 34 | 34 | const d = e.target; |
| 35 | 35 | if (!(d instanceof HTMLDetailsElement) || !d.open) return; |
| 36 | | if (!d.matches('details.popover, details.railpins, details.refmenu')) return; |
| 36 | if (!d.matches('details.popover, details.railpins, details.railusermenu, details.railmore, details.refmenu')) return; |
| 37 | 37 | for (const other of popovers()) { |
| 38 | 38 | if (other !== d && other.open) other.open = false; |
| 39 | 39 | } |
internal/web/static/style.css
+26 · view
| @@ -2001,6 +2001,32 @@ button.react:hover { background: var(--surface); } |
| 2001 | 2001 | button.react.mine { border-color: var(--accent); background: var(--surface); color: var(--fg); } |
| 2002 | 2002 | |
| 2003 | 2003 | /* ---- rail pinned switcher ---- */ |
| 2004 | .railusermenu { position: relative; } |
| 2005 | .railusermenu > summary { list-style: none; cursor: pointer; } |
| 2006 | .railusermenu > summary::-webkit-details-marker { display: none; } |
| 2007 | .railavatar { |
| 2008 | display: flex; |
| 2009 | align-items: center; |
| 2010 | justify-content: center; |
| 2011 | width: var(--rail-hit); |
| 2012 | height: var(--rail-strip-h); |
| 2013 | } |
| 2014 | .railavatar:hover, .railusermenu[open] > .railavatar { background: var(--shell-hover); } |
| 2015 | .railavatar .avatar { width: var(--rail-mark); height: var(--rail-mark); } |
| 2016 | .raildrop a.railuser { |
| 2017 | width: 100%; |
| 2018 | height: auto; |
| 2019 | justify-content: flex-start; |
| 2020 | } |
| 2021 | .raildrop a[aria-current="page"] { |
| 2022 | box-shadow: inset 2px 0 0 var(--shell-mark); |
| 2023 | font-weight: 600; |
| 2024 | } |
| 2025 | .railsep { |
| 2026 | border: 0; |
| 2027 | border-top: 1px solid var(--shell-line); |
| 2028 | margin: var(--sp-1) 0; |
| 2029 | } |
| 2004 | 2030 | .railpins { position: relative; } |
| 2005 | 2031 | .railpins > summary { list-style: none; } |
| 2006 | 2032 | .railpins > summary::-webkit-details-marker { display: none; } |
internal/web/templates/layout.html
+11 −6 · view
| @@ -34,10 +34,6 @@ |
| 34 | 34 | <button type="button" class="cmdk-trigger" aria-label="Open command palette" title="Jump to… (⌘K)"><kbd>⌘K</kbd></button> |
| 35 | 35 | </form> |
| 36 | 36 | <span class="railgap"></span> |
| 37 | | <ul class="raillist"> |
| 38 | | {{if .Viewer}}<li class="railopt">{{template "raillink" (index $items 1)}}</li> |
| 39 | | {{if (index $items 2).Show}}<li class="railopt">{{template "raillink" (index $items 2)}}</li>{{end}}{{end}} |
| 40 | | </ul> |
| 41 | 37 | <div class="railfoot"> |
| 42 | 38 | {{if .Viewer}}<details class="railmore"> |
| 43 | 39 | <summary class="railicon" aria-label="More" title="More">{{template "icon" "ellipsis"}}<span class="vh">More</span></summary> |
| @@ -45,8 +41,17 @@ |
| 45 | 41 | {{range $items}}{{if .Show}}<a href="{{.Href}}">{{template "icon" .Icon}} {{.Name}}</a>{{end}}{{end}} |
| 46 | 42 | </div> |
| 47 | 43 | </details> |
| 48 | | <a class="railuser" href="/{{.Viewer}}" aria-label="Your profile" title="{{.Viewer}}"><span class="avatar">{{initial .Viewer}}</span></a> |
| 49 | | {{$logout := index $items 3}}<a class="railopt railicon" href="{{$logout.Href}}" aria-label="{{$logout.Name}}" title="{{$logout.Name}}">{{template "icon" $logout.Icon}}<span class="vh">{{$logout.Name}}</span></a> |
| 44 | <details class="railusermenu"> |
| 45 | <summary class="railavatar" aria-label="Account menu" title="{{.Viewer}}"><span class="avatar">{{initial .Viewer}}</span></summary> |
| 46 | <div class="raildrop"> |
| 47 | <a class="railuser" href="/{{.Viewer}}">{{template "icon" "person"}} <span><strong>{{.Viewer}}</strong></span></a> |
| 48 | <hr class="railsep"> |
| 49 | {{$settings := index $items 1}}<a{{if $settings.Current}} aria-current="page"{{end}} href="{{$settings.Href}}">{{template "icon" $settings.Icon}} {{$settings.Name}}</a> |
| 50 | {{$admin := index $items 2}}{{if $admin.Show}}<a{{if $admin.Current}} aria-current="page"{{end}} href="{{$admin.Href}}">{{template "icon" $admin.Icon}} {{$admin.Name}}</a>{{end}} |
| 51 | <hr class="railsep"> |
| 52 | {{$logout := index $items 3}}<a href="{{$logout.Href}}">{{template "icon" $logout.Icon}} {{$logout.Name}}</a> |
| 53 | </div> |
| 54 | </details> |
| 50 | 55 | {{else}}<a class="railicon" href="/login" aria-label="Sign in" title="Sign in">{{template "icon" "person"}}<span class="vh">Sign in</span></a>{{end}} |
| 51 | 56 | </div> |
| 52 | 57 | </nav> |