Calendar's app switcher lists the suite's apps as tiles
Paul asked: "Can the 'All apps' dropdown just be a list of apps rather than a dropdown with a single-item list?" The switcher now carries estilo's chrome.SuiteApps for the configured hub directory: Docs, Sheets, Slides, Calendar, Memoria and Calls, each at its own host under the directory's, Calendar marked current with a hidden "(this app)", then "All apps" below a divider. It still appears only when HOME_DIRECTORY_ORIGIN is set. The tiles' icons are /static/estilo/brand/<slug>.svg, so brand.Handler is now mounted at brand.Prefix on the bare mux, sessionless like sky's drawings; CSP img-src 'self' already covers it. TestAllAppsLinksToDirectory becomes TestTheSwitcherShowsTheSuite: six tiles in order with hrefs, icons and names, one aria-current with the hidden label, All apps after the <hr>, the icon served with no session, and no switcher without a directory. Seen to fail with the Apps field and with the brand mount removed. estilo is pinned to the estilo feat/switcher-tiles branch commit 0e4003429d57 until that merges; re-pin to estilo main then. The bump also brings estilo's newer chrome.css (switcher phone layout, rail account), re-vendored with scripts/writeestilo.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6 files changed,
+96
−19
go.mod+1 −1go.sum+2 −2internal/calendar/chrome_calendar.go+4 −1internal/calendar/home_consumer_test.go+46 −15internal/calendar/routes.go+4 −0internal/calendar/static/chrome.css+39 −0
CI passed — run details
diff --git a/go.mod b/go.mod| index 7cca2e8..523be64 100644 |
| --- a/go.mod |
| +++ b/go.mod |
| @@ -14,7 +14,7 @@ require ( |
| gorm.io/gorm v1.31.2 |
| ) |
| -require amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768 |
| +require amadan.net/oficina/estilo.git v0.0.0-20261024214622-0e4003429d57 |
| require ( |
| github.com/BurntSushi/toml v1.6.0 // indirect |
diff --git a/go.sum b/go.sum| index 5322bf1..4d0460f 100644 |
| --- a/go.sum |
| +++ b/go.sum |
| @@ -1,5 +1,5 @@ |
| -amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768 h1:bVscoa9fH5LdLDjlyecZhrX7JzWPT0blb57MH0FIm2U= |
| -amadan.net/oficina/estilo.git v0.0.0-20261001093750-530cb932e768/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw= |
| +amadan.net/oficina/estilo.git v0.0.0-20261024214622-0e4003429d57 h1:5z3h+F5H9gpa4gLWxJKFaLFwNiNsI7zDKoRx9VPnwvI= |
| +amadan.net/oficina/estilo.git v0.0.0-20261024214622-0e4003429d57/go.mod h1:4u0jNBtIdMLOsJyrScfqoEuYDJF7BBM3qM9YWbzt6aw= |
| amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c h1:3yxO2D8BxDLMGfFV2o6Sp9Z91yLnjDCIuRKHVWORa8A= |
| amadan.net/oficina/home/connect v0.0.0-20261001093757-2bec942ddd0c/go.mod h1:YroavXe43Wietec+po8mtSk4a9Bir2h31Q3iAf4MWxI= |
| amadan.net/oficina/home/handoff v0.0.0-20260908102137-481d2d57f489 h1:RPKtyry/71i06o8L+gjAaUyexbmG56kO1YPs601URAM= |
diff --git a/internal/calendar/chrome_calendar.go b/internal/calendar/chrome_calendar.go| index b231000..22e0423 100644 |
| --- a/internal/calendar/chrome_calendar.go |
| +++ b/internal/calendar/chrome_calendar.go |
| @@ -34,8 +34,11 @@ func calendarChrome(r *http.Request, signedIn bool, address string, mode chrome. |
| bar.SignIn = &chrome.Link{Href: "/signin?return_to=" + template.URLQueryEscaper(r.URL.RequestURI()), Label: "Sign in"} |
| return bar |
| } |
| + // The app switcher, only with a hub directory configured: the suite's |
| + // six apps as tiles, each at its own host under the directory's |
| + // (estilo's chrome.SuiteApps), Calendar marked current, then "All apps". |
| if directory != "" { |
| - bar.Switcher = &chrome.Switcher{Label: "Oficina apps", AllApps: estilomenu.Item{Href: strings.TrimSuffix(directory, "/") + "/", Label: "All apps"}} |
| + bar.Switcher = &chrome.Switcher{Label: "Oficina apps", CurrentLabel: "(this app)", Apps: chrome.SuiteApps(directory, "calendar"), AllApps: estilomenu.Item{Href: strings.TrimSuffix(directory, "/") + "/", Label: "All apps"}} |
| } |
| // A live session whose person could not be resolved (a removed Home |
| // person on an error page) still gets the menu, to sign out from, but |
diff --git a/internal/calendar/home_consumer_test.go b/internal/calendar/home_consumer_test.go| index ced5f50..60e16e7 100644 |
| --- a/internal/calendar/home_consumer_test.go |
| +++ b/internal/calendar/home_consumer_test.go |
| @@ -7,8 +7,8 @@ import ( |
| "io" |
| "log/slog" |
| "net/http" |
| + "net/http/httptest" |
| "path/filepath" |
| - "regexp" |
| "strings" |
| "testing" |
| @@ -70,23 +70,54 @@ func TestHomeSigninWhenSignedInReturnsToPage(t *testing.T) { |
| } |
| } |
| -// "All apps" is the estilo switcher's item (shared-chrome spec §6), linking |
| -// to the hub directory's root: HOME_DIRECTORY_ORIGIN (an origin, which |
| -// connect refuses with a path or a trailing slash) plus "/". No directory, |
| -// no switcher. |
| -func TestAllAppsLinksToDirectory(t *testing.T) { |
| - item := regexp.MustCompile(`<details estilo-switcher[\s\S]*?<a estilo-menu-item href="([^"]*)"><span estilo-menu-label>All apps</span></a>`) |
| - for _, configured := range []string{homeTestDirectory} { |
| - f := newHomeConsumerFixture(t, configured) |
| - f.local(t) |
| - m := item.FindStringSubmatch(f.do("GET", "/day/2026-09-10", "").Body.String()) |
| - if m == nil { |
| - t.Fatalf("HOME_DIRECTORY_ORIGIN=%s: no All apps item in the estilo switcher", configured) |
| +// The switcher (shared-chrome spec §6) appears only with a hub directory |
| +// configured. It shows the suite's six apps as tiles, each at its own host |
| +// under the directory's, Calendar marked current, then below a divider |
| +// "All apps", linking to the directory's root: HOME_DIRECTORY_ORIGIN (an |
| +// origin, which connect refuses with a path or a trailing slash) plus "/". |
| +// The tiles' icons are served sessionless. |
| +func TestTheSwitcherShowsTheSuite(t *testing.T) { |
| + f := newHomeConsumerFixture(t, homeTestDirectory) |
| + f.local(t) |
| + body := f.do("GET", "/day/2026-09-10", "").Body.String() |
| + start := strings.Index(body, `<details estilo-switcher`) |
| + if start < 0 { |
| + t.Fatal("no switcher with a directory configured", body) |
| + } |
| + panel := body[start:] |
| + panel = panel[:strings.Index(panel, "</details>")] |
| + grid, allApps, ok := strings.Cut(panel, "<hr>") |
| + if !ok || !strings.Contains(allApps, `<a estilo-menu-item href="`+homeTestDirectory+`/"><span estilo-menu-label>All apps</span></a>`) { |
| + t.Error("the switcher does not offer All apps, at the directory's root, below the tiles", panel) |
| + } |
| + var tiles []string |
| + for _, tile := range strings.Split(grid, "<a estilo-switcher-app ")[1:] { |
| + tiles = append(tiles, tile[:strings.Index(tile, "</a>")]) |
| + } |
| + slugs := []string{"docs", "sheets", "slides", "calendar", "memoria", "calls"} |
| + names := []string{"Docs", "Sheets", "Slides", "Calendar", "Memoria", "Calls"} |
| + if len(tiles) != len(slugs) { |
| + t.Fatalf("%d tiles, want %d: %s", len(tiles), len(slugs), grid) |
| + } |
| + for i, slug := range slugs { |
| + head := `href="https://` + slug + `.directory.example.test/"` |
| + if slug == "calendar" { |
| + head += ` aria-current="true"` |
| } |
| - if m[1] != homeTestDirectory+"/" { |
| - t.Errorf("HOME_DIRECTORY_ORIGIN=%s: All apps links to %q, want %q", configured, m[1], homeTestDirectory+"/") |
| + head += `><img src="/static/estilo/brand/` + slug + `.svg" alt="" width="32" height="32"><span>` + names[i] |
| + if !strings.HasPrefix(tiles[i], head) { |
| + t.Errorf("tile %d = %s, want it to start %s", i, tiles[i], head) |
| } |
| } |
| + if strings.Count(grid, "aria-current") != 1 || !strings.Contains(tiles[3], "<span estilo-visually-hidden> (this app)</span>") { |
| + t.Error("Calendar is not the one current tile", grid) |
| + } |
| + |
| + icon := httptest.NewRecorder() |
| + f.app.mux.ServeHTTP(icon, httptest.NewRequest("GET", homeTestOrigin+"/static/estilo/brand/calls.svg", nil)) |
| + if icon.Code != http.StatusOK || !strings.Contains(icon.Body.String(), "<svg") { |
| + t.Errorf("a tile's icon, with no session, is %d", icon.Code) |
| + } |
| bare := newHomeConsumerFixture(t, "") |
| bare.local(t) |
diff --git a/internal/calendar/routes.go b/internal/calendar/routes.go| index 2ad2dd1..d77014f 100644 |
| --- a/internal/calendar/routes.go |
| +++ b/internal/calendar/routes.go |
| @@ -1,6 +1,7 @@ |
| package calendar |
| import ( |
| + "amadan.net/oficina/estilo.git/brand" |
| "amadan.net/oficina/estilo.git/sky" |
| "amadan.net/oficina/estilo.git/theme" |
| "amadan.net/oficina/home/connect" |
| @@ -181,6 +182,9 @@ func (a *App) routes(h *handlers, authPlugin *rauth.Auth, list allowlist, origin |
| // reachable signed out. More specific than "GET /static/", so the |
| // app's own asset handler never sees these paths. |
| mux.Handle("GET "+sky.Prefix, sky.Handler()) |
| + // The app switcher's tile icons, the suite's own marks: sessionless |
| + // for the same reason, and likewise more specific than "GET /static/". |
| + mux.Handle("GET "+brand.Prefix, brand.Handler()) |
| mux.HandleFunc("GET /static/credits.css", serveCreditsCSS) |
| a.mountTick(mux, h) |
| mux.Handle("/", a.scheduled.middleware(r)) |
diff --git a/internal/calendar/static/chrome.css b/internal/calendar/static/chrome.css| index 74bd3d7..d16395d 100644 |
| --- a/internal/calendar/static/chrome.css |
| +++ b/internal/calendar/static/chrome.css |
| @@ -184,6 +184,15 @@ |
| [estilo-switcher-app]:focus-visible { background: var(--rst-accent-soft); } |
| [estilo-switcher-app][aria-current] { background: var(--rst-accent-soft); font-weight: 600; } |
| [estilo-switcher-app] img { border-radius: 21%; } |
| +/* Three 5.5rem tiles hung from the trigger overflow a phone's inline start |
| + (at 320px, and sooner when the corner is the wider "Sign in" link), so |
| + below 30rem the panel spans the bar instead, as menubar panels do, and |
| + the three columns share its width. */ |
| +@media (max-width: 30rem) { |
| + [estilo-switcher] { position: static; } |
| + [estilo-switcher-panel] { inset-inline: 0.5rem; inline-size: auto; min-inline-size: 0; max-inline-size: none; } |
| + [estilo-switcher-grid] { grid-template-columns: repeat(3, minmax(0, 1fr)); } |
| +} |
| /* The account menu. The account is always the last thing at the inline |
| end of the bar: the "same corner" rule. */ |
| @@ -208,6 +217,36 @@ |
| [estilo-menu-identity-name] + [estilo-menu-identity-address] { font-size: var(--rst-fs-xs); } |
| [estilo-bar-signin] { flex: none; } |
| +/* The account at a sidebar rail's foot (Account.Rail), for an app whose |
| + chrome is a rail rather than the bar. The trigger is a row the rail's |
| + width: the avatar, then who is signed in, cut short with an ellipsis. |
| + It stays in the page flow, so its highlight stays square. The panel is |
| + the foot's own width, edge to edge with the trigger: hung from the |
| + inline end of a foot narrower than the bar's 15rem panel it ran off |
| + the window's start edge, and from the inline start it ran past the |
| + rail, whose overflow-y: auto clips it (Fichas' first screenshot). */ |
| +[estilo-account~="rail"] > [estilo-bar-trigger] { |
| + justify-content: flex-start; |
| + gap: var(--rst-sp-2); |
| + inline-size: 100%; |
| + block-size: auto; |
| + min-block-size: 2.5rem; |
| + color: var(--rst-text); |
| +} |
| +[estilo-account-who] { min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } |
| +[estilo-account~="rail"] > [estilo-account-panel] { inset-inline: 0; inline-size: auto; min-inline-size: 0; max-inline-size: none; } |
| +/* A drop-up where the rail is the viewport's height (rastrillo's shell |
| + breakpoint): below the foot there is only the window's edge. Below |
| + 800px the rail is a disclosure at the top of the page, with the page |
| + under it and too little above, so the panel opens downward there. */ |
| +@media (min-width: 800px) { |
| + [estilo-account~="rail"] > [estilo-account-panel] { |
| + inset-block-start: auto; |
| + inset-block-end: calc(100% + 4px); |
| + max-block-size: max(calc(100dvh - 5rem), 8rem); |
| + } |
| +} |
| + |
| /* Visually hidden, still announced. */ |
| [estilo-visually-hidden] { position: absolute; clip-path: inset(50%); inline-size: 1px; block-size: 1px; overflow: hidden; white-space: nowrap; } |