Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/build-output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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*<a class="item navbar-context-title[^>]*>{{ctx\\.Locale\\.Tr "${label}"}}`)
);
expect(navbar).toContain('<span class="item navbar-context-title not-mobile">{{.Title}}</span>');
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");

Expand Down
10 changes: 10 additions & 0 deletions styles/components/navbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 0 additions & 10 deletions styles/pages/user-profile.css
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 21 additions & 3 deletions templates/base/head_navbar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,31 @@
</div>
{{end}}
{{else if $isOrganization}}
<a class="item profile-navbar-name not-mobile" href="{{.Org.HomeLink}}">{{.Org.Name}}</a>
<a class="item navbar-context-title not-mobile" href="{{.Org.HomeLink}}">{{.Org.Name}}</a>
{{else if $isUserProfile}}
<a class="item profile-navbar-name not-mobile" href="{{.ContextUser.HomeLink}}">{{.ContextUser.Name}}</a>
<a class="item navbar-context-title not-mobile" href="{{.ContextUser.HomeLink}}">{{.ContextUser.Name}}</a>
{{else if and .IsSigned .HideNavbarLinks}}
{{/* No links */}}
{{else if .IsSigned}}
<a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/repos">{{ctx.Locale.Tr "explore"}}</a>
{{/* GitHub names the page here; Explore stays in the navigation drawer. */}}
{{if .PageIsDashboard}}
<a class="item navbar-context-title not-mobile" href="{{AppSubUrl}}/">{{ctx.Locale.Tr "dashboard"}}</a>
{{else if .PageIsIssues}}
<a class="item navbar-context-title not-mobile" href="{{AppSubUrl}}/issues">{{ctx.Locale.Tr "issues"}}</a>
{{else if .PageIsPulls}}
<a class="item navbar-context-title not-mobile" href="{{AppSubUrl}}/pulls">{{ctx.Locale.Tr "pull_requests"}}</a>
{{else if .PageIsMilestonesDashboard}}
<a class="item navbar-context-title not-mobile" href="{{AppSubUrl}}/milestones">{{ctx.Locale.Tr "milestones"}}</a>
{{else if .PageIsUserSettings}}
<a class="item navbar-context-title not-mobile" href="{{AppSubUrl}}/user/settings">{{ctx.Locale.Tr "settings"}}</a>
{{else if .PageIsAdmin}}
<a class="item navbar-context-title not-mobile" href="{{AppSubUrl}}/admin">{{ctx.Locale.Tr "admin_panel"}}</a>
{{else if .PageIsExplore}}
<a class="item navbar-context-title not-mobile" href="{{AppSubUrl}}/explore/repos">{{ctx.Locale.Tr "explore"}}</a>
{{else if .Title}}
{{/* Notifications and the create pages set no page flag; their title is the page's name. */}}
<span class="item navbar-context-title not-mobile">{{.Title}}</span>
{{end}}
{{else if .IsLandingPageOrganizations}}
<a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/organizations">{{ctx.Locale.Tr "explore"}}</a>
{{else}}
Expand Down
Loading