From 6af81144e8703f7f2c6cd1dbc0d64d476d83fca2 Mon Sep 17 00:00:00 2001 From: whereareiam Date: Thu, 22 Oct 2026 22:01:52 +0200 Subject: [PATCH] fix(navbar): name the current page after the logo GitHub's header names the page after the logo (Dashboard, Issues, Pull requests, Settings, Site administration, Explore) or, on notifications and create pages, the page itself. Forgejo's Explore link sat there on every page; it stays in the navigation drawer. The bold context title is shared with the owner name on profile and organization pages. Co-Authored-By: Claude Opus 5.5 --- src/build-output.test.ts | 19 +++++++++++++++++++ styles/components/navbar.ts | 10 ++++++++++ styles/pages/user-profile.css | 10 ---------- templates/base/head_navbar.tmpl | 24 +++++++++++++++++++++--- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/build-output.test.ts b/src/build-output.test.ts index a1a0b6b9..1e069fb5 100644 --- a/src/build-output.test.ts +++ b/src/build-output.test.ts @@ -426,6 +426,25 @@ describe("Forgejo 15 native integration", () => { } }); + it("names the current page after the logo as GitHub does, keeping Explore in the drawer", () => { + const navbar = fs.readFileSync(path.join(ROOT_DIR, "templates", "base", "head_navbar.tmpl"), "utf-8"); + const drawer = fs.readFileSync(path.join(ROOT_DIR, "templates", "base", "navbar_drawer.tmpl"), "utf-8"); + for (const [flag, label] of [ + ["PageIsDashboard", "dashboard"], + ["PageIsIssues", "issues"], + ["PageIsPulls", "pull_requests"], + ["PageIsUserSettings", "settings"], + ["PageIsAdmin", "admin_panel"], + ["PageIsExplore", "explore"], + ]) + expect(navbar).toMatch( + new RegExp(`\\.${flag}\\}\\}\\s*{{.Title}}'); + expect(navbar).not.toContain("profile-navbar-name"); + expect(drawer).toContain('{{ctx.Locale.Tr "explore"}}'); + }); + it("does not emit selector families from the newer Gitea markup", () => { const css = fs.readFileSync(path.join(DIST_DIR, `${PREFIX}light.css`), "utf-8"); diff --git a/styles/components/navbar.ts b/styles/components/navbar.ts index 81bf7a36..ff7b6895 100644 --- a/styles/components/navbar.ts +++ b/styles/components/navbar.ts @@ -42,6 +42,16 @@ const navbarRight = css` background: ${themeVars.github.control.transparent.bgColor.hover}; } } + /* GitHub names the current context after the logo: the owner, or the page (Dashboard, Issues, Notifications). Like + the repository breadcrumb, the name starts 6px into its link. */ + .navbar-left > .navbar-context-title { + padding-inline: 6px; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-weight: 600; + } /* GitHub's header search: a 197px field first on the right from 1012px, a search button below that. */ .navbar-search { width: 197px; diff --git a/styles/pages/user-profile.css b/styles/pages/user-profile.css index 68d36ba1..89fd93cf 100644 --- a/styles/pages/user-profile.css +++ b/styles/pages/user-profile.css @@ -373,16 +373,6 @@ } } -#navbar .profile-navbar-name { - /* Like the repository breadcrumb: the name starts 6px into its link. */ - padding-inline: 6px; - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - font-weight: 600; -} - .github-profile .profile-readme-heading { margin-bottom: 16px; font-family: var(--fonts-monospace); diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index 3b665489..480e6e1d 100644 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -35,13 +35,31 @@ {{end}} {{else if $isOrganization}} - {{.Org.Name}} + {{.Org.Name}} {{else if $isUserProfile}} - {{.ContextUser.Name}} + {{.ContextUser.Name}} {{else if and .IsSigned .HideNavbarLinks}} {{/* No links */}} {{else if .IsSigned}} - {{ctx.Locale.Tr "explore"}} + {{/* GitHub names the page here; Explore stays in the navigation drawer. */}} + {{if .PageIsDashboard}} + {{ctx.Locale.Tr "dashboard"}} + {{else if .PageIsIssues}} + {{ctx.Locale.Tr "issues"}} + {{else if .PageIsPulls}} + {{ctx.Locale.Tr "pull_requests"}} + {{else if .PageIsMilestonesDashboard}} + {{ctx.Locale.Tr "milestones"}} + {{else if .PageIsUserSettings}} + {{ctx.Locale.Tr "settings"}} + {{else if .PageIsAdmin}} + {{ctx.Locale.Tr "admin_panel"}} + {{else if .PageIsExplore}} + {{ctx.Locale.Tr "explore"}} + {{else if .Title}} + {{/* Notifications and the create pages set no page flag; their title is the page's name. */}} + {{.Title}} + {{end}} {{else if .IsLandingPageOrganizations}} {{ctx.Locale.Tr "explore"}} {{else}}