Skip to content

Commit 3f5459a

Browse files
wxiaoguangsilverwind
authored andcommitted
refactor
1 parent ed52eca commit 3f5459a

File tree

11 files changed

+124
-175
lines changed

11 files changed

+124
-175
lines changed

templates/base/head_navbar.tmpl

Lines changed: 62 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,83 @@
1+
{{$notificationUnreadCount := 0}}
2+
{{if and .IsSigned .NotificationUnreadCount}}
3+
{{$notificationUnreadCount = call .NotificationUnreadCount}}
4+
{{end}}
5+
16
<nav id="navbar" class="ui secondary stackable menu" aria-label="{{.locale.Tr "aria.navbar"}}">
2-
{{$notificationUnreadCount := 0}}
3-
{{if .IsSigned}}
4-
{{if .NotificationUnreadCount}}{{$notificationUnreadCount = call .NotificationUnreadCount}}{{end}}
5-
{{end}}
6-
<div class="item brand gt-sb">
7+
<div class="item">
8+
<!-- the logo -->
79
<a href="{{AppSubUrl}}/" aria-label="{{if .IsSigned}}{{.locale.Tr "dashboard"}}{{else}}{{.locale.Tr "home"}}{{end}}">
810
<img width="30" height="30" src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{.locale.Tr "logo"}}" aria-hidden="true">
911
</a>
10-
<div class="gt-df gt-ac">
12+
13+
<!-- mobile right menu, it must be here because in mobile view, each item is a flex column, the first item is a full row column -->
14+
<div class="ui secondary menu navbar-mobile-right">
1115
{{if .IsSigned}}
12-
<a href="{{AppSubUrl}}/notifications" class="mobile-only gt-mr-4 gt-mt-3" data-tooltip-content="{{.locale.Tr "notifications"}}" aria-label="{{.locale.Tr "notifications"}}">
13-
<span class="fitted item">
14-
{{svg "octicon-bell"}}
15-
<span class="notification_count{{if not $notificationUnreadCount}} gt-hidden{{end}}">
16-
{{$notificationUnreadCount}}
17-
</span>
18-
</span>
16+
<a class="item" href="{{AppSubUrl}}/notifications" data-tooltip-content="{{.locale.Tr "notifications"}}" aria-label="{{.locale.Tr "notifications"}}">
17+
{{svg "octicon-bell"}}
18+
<span class="notification_count{{if not $notificationUnreadCount}} gt-hidden{{end}}">{{$notificationUnreadCount}}</span>
1919
</a>
2020
{{end}}
21-
<button class="ui icon button mobile-only" id="navbar-expand-toggle">
22-
{{svg "octicon-three-bars"}}
23-
</button>
21+
<div class="item gt-pr-0">
22+
<button class="ui icon button" id="navbar-expand-toggle">{{svg "octicon-three-bars"}}</button>
23+
</div>
2424
</div>
2525
</div>
2626

27+
<!-- navbar links -->
2728
{{if and .IsSigned .MustChangePassword}}
2829
{{/* No links */}}
2930
{{else if .IsSigned}}
3031
{{if not .UnitIssuesGlobalDisabled}}
31-
<a class="item{{if .PageIsIssues}} active{{end}}" href="{{AppSubUrl}}/issues">{{.locale.Tr "issues"}}</a>
32+
<a class="item{{if .PageIsIssues}} active{{end}}" href="{{AppSubUrl}}/issues">{{.locale.Tr "issues"}}</a>
3233
{{end}}
3334
{{if not .UnitPullsGlobalDisabled}}
34-
<a class="item{{if .PageIsPulls}} active{{end}}" href="{{AppSubUrl}}/pulls">{{.locale.Tr "pull_requests"}}</a>
35+
<a class="item{{if .PageIsPulls}} active{{end}}" href="{{AppSubUrl}}/pulls">{{.locale.Tr "pull_requests"}}</a>
3536
{{end}}
3637
{{if not (and .UnitIssuesGlobalDisabled .UnitPullsGlobalDisabled)}}
37-
{{if .ShowMilestonesDashboardPage}}<a class="item{{if .PageIsMilestonesDashboard}} active{{end}}" href="{{AppSubUrl}}/milestones">{{.locale.Tr "milestones"}}</a>{{end}}
38+
{{if .ShowMilestonesDashboardPage}}
39+
<a class="item{{if .PageIsMilestonesDashboard}} active{{end}}" href="{{AppSubUrl}}/milestones">{{.locale.Tr "milestones"}}</a>
40+
{{end}}
3841
{{end}}
3942
<a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.locale.Tr "explore"}}</a>
4043
{{else if .IsLandingPageOrganizations}}
4144
<a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/organizations">{{.locale.Tr "explore"}}</a>
4245
{{else}}
4346
<a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/repos">{{.locale.Tr "explore"}}</a>
4447
{{end}}
48+
4549
{{template "custom/extra_links" .}}
46-
{{if and .IsSigned .MustChangePassword}}
47-
<div class="right stackable menu">
48-
<div class="ui dropdown jump item" tabindex="-1" data-tooltip-content="{{.locale.Tr "user_profile_and_more"}}">
50+
51+
{{if not .IsSigned}}
52+
<a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io">{{.locale.Tr "help"}}</a>
53+
{{end}}
54+
55+
<!-- the full dropdown menus -->
56+
<div class="right menu gt-pr-4">
57+
{{if and .IsSigned .MustChangePassword}}
58+
<div class="ui dropdown jump item" data-tooltip-content="{{.locale.Tr "user_profile_and_more"}}">
4959
<span class="text">
50-
{{avatar $.Context .SignedUser 24 "tiny"}}
51-
<span class="sr-only">{{.locale.Tr "user_profile_and_more"}}</span>
52-
<span class="mobile-only">{{.SignedUser.Name}}</span>
53-
<span class="fitted not-mobile" tabindex="-1">{{svg "octicon-triangle-down"}}</span>
60+
{{avatar $.Context .SignedUser 24 "gt-mr-0"}}
61+
<span class="mobile-only gt-ml-2">{{.SignedUser.Name}}</span>
62+
<span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
5463
</span>
55-
<div class="menu user-menu" tabindex="-1">
64+
<div class="menu user-menu">
5665
<div class="ui header">
5766
{{.locale.Tr "signed_in_as"}} <strong>{{.SignedUser.Name}}</strong>
5867
</div>
5968

6069
<div class="divider"></div>
6170
<a class="item link-action" href data-url="{{AppSubUrl}}/user/logout" data-redirect="{{AppSubUrl}}/">
6271
{{svg "octicon-sign-out"}}
63-
{{.locale.Tr "sign_out"}}<!-- Sign Out -->
72+
{{.locale.Tr "sign_out"}}
6473
</a>
6574
</div><!-- end content avatar menu -->
6675
</div><!-- end dropdown avatar menu -->
67-
</div>
68-
{{else if .IsSigned}}
69-
<div class="right stackable menu gt-mr-4">
76+
{{else if .IsSigned}}
7077
{{if EnableTimetracking}}
71-
<a class="active-stopwatch-trigger item ui gt-mx-0{{if not .ActiveStopwatch}} gt-hidden{{end}}" href="{{.ActiveStopwatch.IssueLink}}">
72-
<span class="fitted gt-relative">
73-
{{svg "octicon-stopwatch"}}
74-
<span class="header-stopwatch-dot"></span>
75-
<span class="sr-mobile-only">{{.locale.Tr "active_stopwatch"}}</span>
76-
</span>
78+
<a class="active-stopwatch-trigger item ui gt-mx-0{{if not .ActiveStopwatch}} gt-hidden{{end}}" href="{{.ActiveStopwatch.IssueLink}}" title="{{.locale.Tr "active_stopwatch"}}">
79+
{{svg "octicon-stopwatch"}}<span class="header-stopwatch-dot"></span>
80+
<span class="mobile-only">{{.locale.Tr "active_stopwatch"}}</span>
7781
</a>
7882
<div class="active-stopwatch-popup tippy-target">
7983
<div class="gt-df gt-ac">
@@ -88,15 +92,15 @@
8892
{{.CsrfTokenHtml}}
8993
<button
9094
type="submit"
91-
class="ui button mini compact basic icon fitted"
95+
class="ui button mini compact basic icon"
9296
data-tooltip-content="{{.locale.Tr "repo.issues.stop_tracking"}}"
9397
>{{svg "octicon-square-fill"}}</button>
9498
</form>
9599
<form class="stopwatch-cancel" method="POST" action="{{.ActiveStopwatch.IssueLink}}/times/stopwatch/cancel">
96100
{{.CsrfTokenHtml}}
97101
<button
98102
type="submit"
99-
class="ui button mini compact basic icon fitted"
103+
class="ui button mini compact basic icon"
100104
data-tooltip-content="{{.locale.Tr "repo.issues.cancel_tracking"}}"
101105
>{{svg "octicon-trash"}}</button>
102106
</form>
@@ -105,53 +109,48 @@
105109
{{end}}
106110

107111
<a href="{{AppSubUrl}}/notifications" class="item not-mobile gt-mx-0" data-tooltip-content="{{.locale.Tr "notifications"}}" aria-label="{{.locale.Tr "notifications"}}">
108-
<span class="fitted item">
109-
{{svg "octicon-bell"}}
110-
<span class="notification_count{{if not $notificationUnreadCount}} gt-hidden{{end}}">
111-
{{$notificationUnreadCount}}
112-
</span>
113-
</span>
112+
{{svg "octicon-bell"}}
113+
<span class="notification_count{{if not $notificationUnreadCount}} gt-hidden{{end}}">{{$notificationUnreadCount}}</span>
114114
</a>
115115

116116
<div class="ui dropdown jump item gt-mx-0 gt-pr-3" data-tooltip-content="{{.locale.Tr "create_new"}}">
117117
<span class="text">
118-
<span class="fitted">{{svg "octicon-plus"}}</span>
119-
<span class="sr-mobile-only">{{.locale.Tr "create_new"}}</span>
120-
<span class="fitted not-mobile">{{svg "octicon-triangle-down"}}</span>
118+
{{svg "octicon-plus"}}
119+
<span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
120+
<span class="mobile-only">{{.locale.Tr "create_new"}}</span>
121121
</span>
122122
<div class="menu">
123123
<a class="item" href="{{AppSubUrl}}/repo/create">
124-
<span class="fitted">{{svg "octicon-plus"}}</span> {{.locale.Tr "new_repo"}}
124+
{{svg "octicon-plus"}} {{.locale.Tr "new_repo"}}
125125
</a>
126126
{{if not .DisableMigrations}}
127127
<a class="item" href="{{AppSubUrl}}/repo/migrate">
128-
<span class="fitted">{{svg "octicon-repo-push"}}</span> {{.locale.Tr "new_migrate"}}
128+
{{svg "octicon-repo-push"}} {{.locale.Tr "new_migrate"}}
129129
</a>
130130
{{end}}
131131
{{if .SignedUser.CanCreateOrganization}}
132132
<a class="item" href="{{AppSubUrl}}/org/create">
133-
<span class="fitted">{{svg "octicon-organization"}}</span> {{.locale.Tr "new_org"}}
133+
{{svg "octicon-organization"}} {{.locale.Tr "new_org"}}
134134
</a>
135135
{{end}}
136136
</div><!-- end content create new menu -->
137137
</div><!-- end dropdown menu create new -->
138138

139139
<div class="ui dropdown jump item gt-mx-0 gt-pr-3" data-tooltip-content="{{.locale.Tr "user_profile_and_more"}}">
140140
<span class="text">
141-
{{avatar $.Context .SignedUser 24 "tiny"}}
142-
<span class="sr-only">{{.locale.Tr "user_profile_and_more"}}</span>
143-
<span class="mobile-only">{{.SignedUser.Name}}</span>
144-
<span class="fitted not-mobile" tabindex="-1">{{svg "octicon-triangle-down"}}</span>
141+
{{avatar $.Context .SignedUser 24 "gt-mr-0"}}
142+
<span class="mobile-only gt-ml-2">{{.SignedUser.Name}}</span>
143+
<span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
145144
</span>
146-
<div class="menu user-menu" tabindex="-1">
145+
<div class="menu user-menu">
147146
<div class="ui header">
148147
{{.locale.Tr "signed_in_as"}} <strong>{{.SignedUser.Name}}</strong>
149148
</div>
150149

151150
<div class="divider"></div>
152151
<a class="item" href="{{.SignedUser.HomeLink}}">
153152
{{svg "octicon-person"}}
154-
{{.locale.Tr "your_profile"}}<!-- Your profile -->
153+
{{.locale.Tr "your_profile"}}
155154
</a>
156155
{{if not .DisableStars}}
157156
<a class="item" href="{{.SignedUser.HomeLink}}?tab=stars">
@@ -161,15 +160,15 @@
161160
{{end}}
162161
<a class="item" href="{{AppSubUrl}}/notifications/subscriptions">
163162
{{svg "octicon-bell"}}
164-
{{.locale.Tr "notification.subscriptions"}}<!-- Subscriptions -->
163+
{{.locale.Tr "notification.subscriptions"}}
165164
</a>
166165
<a class="{{if .PageIsUserSettings}}active {{end}}item" href="{{AppSubUrl}}/user/settings">
167166
{{svg "octicon-tools"}}
168-
{{.locale.Tr "your_settings"}}<!-- Your settings -->
167+
{{.locale.Tr "your_settings"}}
169168
</a>
170169
<a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io">
171170
{{svg "octicon-question"}}
172-
{{.locale.Tr "help"}}<!-- Help -->
171+
{{.locale.Tr "help"}}
173172
</a>
174173
{{if .IsAdmin}}
175174
<div class="divider"></div>
@@ -187,10 +186,7 @@
187186
</a>
188187
</div><!-- end content avatar menu -->
189188
</div><!-- end dropdown avatar menu -->
190-
</div><!-- end signed user right menu -->
191-
{{else}}
192-
<a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io">{{.locale.Tr "help"}}</a>
193-
<div class="right stackable menu">
189+
{{else}}
194190
{{if .ShowRegistrationButton}}
195191
<a class="item{{if .PageIsSignUp}} active{{end}}" href="{{AppSubUrl}}/user/sign_up">
196192
{{svg "octicon-person"}} {{.locale.Tr "register"}}
@@ -199,6 +195,6 @@
199195
<a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="{{AppSubUrl}}/user/login{{if not .PageIsSignIn}}?redirect_to={{.CurrentURL}}{{end}}">
200196
{{svg "octicon-sign-in"}} {{.locale.Tr "sign_in"}}
201197
</a>
202-
</div><!-- end anonymous user right menu -->
203-
{{end}}
198+
{{end}}
199+
</div><!-- end full right menu -->
204200
</nav>

templates/org/home.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
{{if .Org.Website}}<div class="item">{{svg "octicon-link"}} <a target="_blank" rel="noopener noreferrer me" href="{{.Org.Website}}">{{.Org.Website}}</a></div>{{end}}
2020
</div>
2121
</div>
22-
<div class="right stackable menu">
22+
<div class="right menu">
2323
<form method="post" action="{{.Link}}?action={{if $.IsFollowing}}unfollow{{else}}follow{{end}}&redirect_to={{$.Link}}">
2424
{{$.CsrfTokenHtml}}
2525
<button type="submit" class="ui basic button gt-mr-0">

templates/repo/settings/lfs_file_find.tmpl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<a class="ui primary sha label" href="{{$.RepoLink}}/commit/{{.String}}">{{ShortSha .String}}</a>
3030
{{end}}
3131
{{end}}
32-
<div class="mobile-only"></div>
3332
{{$.locale.Tr "repo.diff.commit"}}
3433
<a class="ui primary sha label" href="{{$.RepoLink}}/commit/{{.SHA}}">{{ShortSha .SHA}}</a>
3534
</td>

templates/status/500.tmpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@
1515
</head>
1616
<body>
1717
<div class="full height">
18-
<nav id="navbar" class="ui secondary stackable menu">
18+
<nav class="ui secondary menu">
1919
<div class="ui container gt-df">
20-
<div class="item brand gt-f1">
20+
<div class="item gt-f1">
2121
<a href="{{AppSubUrl}}/" aria-label="{{.locale.Tr "home"}}">
2222
<img width="30" height="30" src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{.locale.Tr "logo"}}" aria-hidden="true">
2323
</a>
2424
</div>
25-
<button class="item ui icon button">{{svg "octicon-three-bars"}}</button>{{/* a fake button to make the UI looks better*/}}
25+
<div class="item">
26+
<button class="ui icon button disabled">{{svg "octicon-three-bars"}}</button>{{/* a fake button to make the UI looks better*/}}
27+
</div>
2628
</div>
2729
</nav>
2830
<div role="main" class="page-content status-page-500">

templates/user/dashboard/navbar.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
{{end}}
7878

7979
{{if .ContextUser.IsOrganization}}
80-
<div class="right stackable menu">
80+
<div class="right menu">
8181
<a class="{{if .PageIsNews}}active {{end}}item gt-ml-auto" href="{{.ContextUser.DashboardLink}}{{if .Team}}/{{PathEscape .Team.Name}}{{end}}">
8282
{{svg "octicon-rss"}}&nbsp;{{.locale.Tr "activities"}}
8383
</a>

0 commit comments

Comments
 (0)