Cap Home's apps at five columns; Base's own pages start their own row
On a wide screen the Apps grid has at most five 96px columns (fewer where the screen is narrower) and the panel fits them, left-aligned under the greeting. Store, People and Settings are marked as Base's own (class="own"), and CSS starts Store on a new row in the first column with People and Settings beside it, on wide screens and phones alike: 5 + 5 + 3 today, 4 + 4 + 2 + 3 on a phone. TestHomeApps checks at most five columns (five from 1024px), the panel fitting them, and Base's own row; TestMobile checks four columns and the same row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5 files changed,
+37
−12
internal/browsertest/layout_test.go+14 −1internal/look/static/app.css+9 −3internal/web/home.go+4 −3internal/web/templates/home.html+1 −1internal/webtest/home_test.go+9 −4
diff --git a/internal/browsertest/layout_test.go b/internal/browsertest/layout_test.go| index 28fb7b4..b6e1f2d 100644 |
| --- a/internal/browsertest/layout_test.go |
| +++ b/internal/browsertest/layout_test.go |
| @@ -84,6 +84,13 @@ const sameColumnsJS = `function sameColumns(grid, icon, problems) { |
| if (!cols.some(c => Math.abs(c - r.left) <= 1)) problems.push(name + " at " + r.left + " is off the columns " + cols.join(",")); |
| if (r.width < 44 || r.height < 44) problems.push(name + " is " + r.width + "x" + r.height); |
| } |
| + // Base's own pages start a row of their own: Store in the first column, |
| + // People and Settings beside it. |
| + const own = grid.slice(-3).map(a => a.getBoundingClientRect()); |
| + const before = grid.length > 3 ? grid[grid.length - 4].getBoundingClientRect() : null; |
| + if (Math.abs(own[0].left - cols[0]) > 1) problems.push("Store is not in the first column"); |
| + if (before && own[0].top <= before.top) problems.push("Store does not start a new row"); |
| + if (Math.abs(own[1].top - own[0].top) > 0.5 || Math.abs(own[2].top - own[0].top) > 0.5 || Math.abs(own[1].left - cols[1]) > 1 || Math.abs(own[2].left - cols[2]) > 1) problems.push("People and Settings are not beside Store"); |
| return cols; |
| }` |
| @@ -105,7 +112,13 @@ const appsPanelJS = `((want) => { |
| const grid = [...panel.querySelectorAll(".app-grid a.app")]; |
| const got = grid.map(a => a.textContent.trim()); |
| if (JSON.stringify(got) !== JSON.stringify(want)) problems.push("grid " + JSON.stringify(got)); |
| - sameColumns(grid, 64, problems); |
| + const cols = sameColumns(grid, 64, problems); |
| + if (cols.length > 5) problems.push(cols.length + " columns, want at most 5"); |
| + if (vw >= 1024 && cols.length !== 5) problems.push(cols.length + " columns, want 5"); |
| + // The panel fits its columns, left-aligned under the greeting. |
| + const lastCol = Math.max(...grid.map(a => a.getBoundingClientRect().right)); |
| + if (p.right - lastCol > 32) problems.push("the panel runs " + (p.right - lastCol) + "px past its last column"); |
| + if (Math.abs(p.left - document.querySelector(".hello").getBoundingClientRect().left) > 1) problems.push("the panel is not left-aligned under the greeting"); |
| for (const a of grid) { |
| const r = a.getBoundingClientRect(); |
| if (r.left < p.left || r.right > p.right || r.top < p.top || r.bottom > p.bottom) problems.push(a.textContent.trim() + " is outside the panel"); |
diff --git a/internal/look/static/app.css b/internal/look/static/app.css| index 19bac21..e46f461 100644 |
| --- a/internal/look/static/app.css |
| +++ b/internal/look/static/app.css |
| @@ -317,8 +317,13 @@ button.alt[aria-busy="true"] { cursor: progress; } |
| in one grid of alike items that wraps (the Oficina apps, the installed |
| Store apps, then Base's own Store, People and Settings). On a phone the |
| same panel holds four columns (see the phone rules). */ |
| -.apps { width: 100%; max-width: 960px; margin-top: 28px; padding: 20px 20px 14px; border-radius: 22px; } |
| -.app-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px 8px; justify-items: center; } |
| +/* At most five columns of 96px: the panel fits them (fewer where the |
| + screen is narrower), left-aligned under the greeting. */ |
| +.apps { width: fit-content; max-width: 100%; margin-top: 28px; padding: 20px 20px 14px; border-radius: 22px; } |
| +.app-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, 96px); max-width: calc(5 * 96px + 4 * 8px); |
| + gap: 14px 8px; justify-items: center; } |
| +/* Base's own pages (Store, People, Settings) start a row of their own. */ |
| +.app-grid > li:not(.own) + li.own { grid-column-start: 1; } |
| /* Each cell fills its column, so every app is the same width whatever its label. */ |
| .app-grid > li { width: 100%; min-width: 0; display: flex; justify-content: center; } |
| .app { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 96px; padding: 6px 4px 4px; border-radius: 16px; |
| @@ -500,7 +505,8 @@ main { min-height: 100dvh; } |
| .steps { gap: 6px; } |
| .steps li { padding: 6px 10px; font-size: 13px; gap: 8px; } |
| .apps { margin-top: 22px; padding: 16px 6px 12px; max-width: none; border-radius: 26px; } |
| - .app-grid { grid-template-columns: repeat(4, 1fr); gap: 16px 0; } |
| + .apps { width: auto; } |
| + .app-grid { grid-template-columns: repeat(4, 1fr); max-width: none; gap: 16px 0; } |
| .app { width: 100%; max-width: 86px; padding: 4px 2px 2px; gap: 6px; font-size: 12px; } |
| .app .icon { width: 60px; height: 60px; } |
| .app .tile { border-radius: 15px; } |
diff --git a/internal/web/home.go b/internal/web/home.go| index d2fffee..cb4fd1a 100644 |
| --- a/internal/web/home.go |
| +++ b/internal/web/home.go |
| @@ -25,6 +25,7 @@ type tile struct { |
| Icon template.HTML |
| Image string |
| NewTab bool // an Oficina app, which opens in a new tab |
| + Own bool // one of Base's own pages, which start a row of their own |
| } |
| type homePage struct { |
| @@ -108,9 +109,9 @@ func (a *app) home(w http.ResponseWriter, r *http.Request) { |
| name := displayName(me) |
| page := homePage{Name: a.cfg.Name, Greeting: greeting(time.Now(), a.cfg.Timezone, name), Initials: initials(name)} |
| page.Dock = []tile{ |
| - {Name: "Store", Href: "/store", Tint: "teal", Icon: iconStore}, |
| - {Name: "People", Href: "/people", Tint: "violet", Icon: iconPeople}, |
| - {Name: "Settings", Href: "/settings", Tint: "mist", Icon: iconSettings}, |
| + {Name: "Store", Href: "/store", Tint: "teal", Icon: iconStore, Own: true}, |
| + {Name: "People", Href: "/people", Tint: "violet", Icon: iconPeople, Own: true}, |
| + {Name: "Settings", Href: "/settings", Tint: "mist", Icon: iconSettings, Own: true}, |
| } |
| for _, o := range a.cfg.OficinaApps { |
| page.Apps = append(page.Apps, tile{Name: o.Name, Href: o.Origin + "/", Image: "static/oficina/" + o.ID + ".svg", NewTab: true}) |
diff --git a/internal/web/templates/home.html b/internal/web/templates/home.html| index 9ce7f37..3a67ce9 100644 |
| --- a/internal/web/templates/home.html |
| +++ b/internal/web/templates/home.html |
| @@ -24,4 +24,4 @@ |
| <script type="module" src="{{asset "static/ask.js"}}"></script>{{end}} |
| </main>{{end}} |
| -{{define "app"}}<li><a class="app" href="{{.Href}}"{{if .NewTab}} target="_blank" rel="noopener"{{end}}>{{if .Image}}<span class="icon"><img src="{{asset .Image}}" alt=""></span>{{else}}<span class="icon tile t-{{.Tint}}">{{.Icon}}</span>{{end}}<span class="label">{{.Name}}</span></a></li>{{end}} |
| +{{define "app"}}<li{{if .Own}} class="own"{{end}}><a class="app" href="{{.Href}}"{{if .NewTab}} target="_blank" rel="noopener"{{end}}>{{if .Image}}<span class="icon"><img src="{{asset .Image}}" alt=""></span>{{else}}<span class="icon tile t-{{.Tint}}">{{.Icon}}</span>{{end}}<span class="label">{{.Name}}</span></a></li>{{end}} |
diff --git a/internal/webtest/home_test.go b/internal/webtest/home_test.go| index 80823e8..f83670d 100644 |
| --- a/internal/webtest/home_test.go |
| +++ b/internal/webtest/home_test.go |
| @@ -129,7 +129,7 @@ func TestHomeTileUsesRecordedHost(t *testing.T) { |
| var ( |
| appsRE = regexp.MustCompile(`(?s)<nav class="apps glass" aria-label="Apps">\s*<ul class="app-grid">(.*?)</ul>\s*</nav>`) |
| - itemRE = regexp.MustCompile(`<li><a class="app" href="([^"]*)"( target="_blank" rel="noopener")?><span class="icon[^"]*">(.*?)</span><span class="label">([^<]*)</span></a></li>`) |
| + itemRE = regexp.MustCompile(`<li( class="own")?><a class="app" href="([^"]*)"( target="_blank" rel="noopener")?><span class="icon[^"]*">(.*?)</span><span class="label">([^<]*)</span></a></li>`) |
| appIconRE = regexp.MustCompile(`^<img src="(/static/oficina/[a-z]+\.[0-9a-f]+\.svg)" alt="">$`) |
| oficinaApps = []config.OficinaApp{ |
| {ID: "fichas", Name: "Fichas", Origin: "https://fichas.oficina.works"}, |
| @@ -140,7 +140,7 @@ var ( |
| type homeItem struct { |
| Href, Icon, Name string |
| - NewTab bool |
| + NewTab, Own bool // Own: one of Base's own pages, which CSS starts on a row of their own |
| } |
| // homeApps is Home's apps panel: one grid of every app. |
| @@ -152,7 +152,7 @@ func homeApps(t *testing.T, body string) []homeItem { |
| } |
| var out []homeItem |
| for _, i := range itemRE.FindAllStringSubmatch(m[1], -1) { |
| - out = append(out, homeItem{Href: i[1], NewTab: i[2] != "", Icon: i[3], Name: i[4]}) |
| + out = append(out, homeItem{Own: i[1] != "", Href: i[2], NewTab: i[3] != "", Icon: i[4], Name: i[5]}) |
| } |
| return out |
| } |
| @@ -191,13 +191,18 @@ func TestHomeAppsPanel(t *testing.T) { |
| t.Errorf("%s: %d %q", icon[1], r.Code, r.Header.Get("Content-Type")) |
| } |
| } |
| + for _, g := range grid[:5] { |
| + if g.Own { |
| + t.Errorf("%s is marked as Base's own", g.Name) |
| + } |
| + } |
| for _, g := range grid[len(oficinaApps):5] { |
| if g.NewTab || !strings.HasPrefix(g.Href, "https://acme-") || !strings.HasPrefix(g.Icon, "<svg") { |
| t.Errorf("installed app %s: href %q, new tab %v, icon %.20q", g.Name, g.Href, g.NewTab, g.Icon) |
| } |
| } |
| for i, href := range []string{"/store", "/people", "/settings"} { |
| - if g := grid[5+i]; g.Href != href || g.NewTab || !strings.HasPrefix(g.Icon, "<svg") { |
| + if g := grid[5+i]; g.Href != href || g.NewTab || !g.Own || !strings.HasPrefix(g.Icon, "<svg") { |
| t.Errorf("Base's own %s: %+v", href, g) |
| } |
| } |