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}}