Skip to content

Commit 7ea2a91

Browse files
authored
Improve branch list UI (#27319)
1. Put the `"octicon-shield-lock"` into the flex container, then it doesn't need a separate flex box 2. Remove some unnecessary `gt-df` helpers 3. Make `btn` button has the same flex behavior as `ui button` ![image](https://github.com/go-gitea/gitea/assets/2114189/60ce75f7-7fac-4157-9c42-91c7dee9300e) ![image](https://github.com/go-gitea/gitea/assets/2114189/ea606baf-6f52-41e1-b964-c4840d3b1529)
1 parent 15fa038 commit 7ea2a91

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

templates/repo/branch/list.tmpl

+9-13
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@
1919
<tbody>
2020
<tr>
2121
<td>
22-
<div class="gt-df gt-ac">
23-
{{if .DefaultBranchBranch.IsProtected}}
24-
<span class="gt-df gt-pr-2">{{svg "octicon-shield-lock"}}</span>
25-
{{end}}
22+
<div class="flex-text-block">
23+
{{if .DefaultBranchBranch.IsProtected}}{{svg "octicon-shield-lock"}}{{end}}
2624
<a class="gt-ellipsis" href="{{.RepoLink}}/src/branch/{{PathEscapeSegments .DefaultBranchBranch.DBBranch.Name}}">{{.DefaultBranchBranch.DBBranch.Name}}</a>
27-
<button class="btn interact-fg gt-df gt-p-3" data-clipboard-text="{{.DefaultBranchBranch.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
25+
<button class="btn interact-fg gt-px-2" data-clipboard-text="{{.DefaultBranchBranch.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
2826
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DefaultBranchBranch.DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DefaultBranchBranch.DBBranch.CommitID)}}
2927
</div>
3028
<p class="info gt-df gt-ac gt-my-2">{{svg "octicon-git-commit" 16 "gt-mr-2"}}<a href="{{.RepoLink}}/commit/{{PathEscape .DefaultBranchBranch.DBBranch.CommitID}}">{{ShortSha .DefaultBranchBranch.DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DefaultBranchBranch.DBBranch.CommitMessage .RepoLink .Repository.ComposeMetas}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DefaultBranchBranch.DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DefaultBranchBranch.DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DefaultBranchBranch.DBBranch.Pusher}}{{template "shared/user/namelink" .DefaultBranchBranch.DBBranch.Pusher}}{{end}}</p>
@@ -91,21 +89,19 @@
9189
<tr>
9290
<td class="eight wide">
9391
{{if .DBBranch.IsDeleted}}
94-
<div class="gt-df gt-ac">
92+
<div class="flex-text-block">
9593
<a class="gt-ellipsis" href="{{$.RepoLink}}/src/branch/{{PathEscapeSegments .DBBranch.Name}}">{{.DBBranch.Name}}</a>
96-
<button class="btn interact-fg gt-p-3" data-clipboard-text="{{.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
94+
<button class="btn interact-fg gt-px-2" data-clipboard-text="{{.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
9795
</div>
9896
<p class="info">{{ctx.Locale.Tr "repo.branch.deleted_by" .DBBranch.DeletedBy.Name}} {{TimeSinceUnix .DBBranch.DeletedUnix ctx.Locale}}</p>
9997
{{else}}
100-
<div class="gt-df gt-ac">
101-
{{if .IsProtected}}
102-
<span class="gt-df gt-pr-2">{{svg "octicon-shield-lock"}}</span>
103-
{{end}}
98+
<div class="flex-text-block">
99+
{{if .IsProtected}}{{svg "octicon-shield-lock"}}{{end}}
104100
<a class="gt-ellipsis" href="{{$.RepoLink}}/src/branch/{{PathEscapeSegments .DBBranch.Name}}">{{.DBBranch.Name}}</a>
105-
<button class="btn interact-fg gt-df gt-p-3" data-clipboard-text="{{.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
101+
<button class="btn interact-fg gt-px-2" data-clipboard-text="{{.DBBranch.Name}}">{{svg "octicon-copy" 14}}</button>
106102
{{template "repo/commit_statuses" dict "Status" (index $.CommitStatus .DBBranch.CommitID) "Statuses" (index $.CommitStatuses .DBBranch.CommitID)}}
107103
</div>
108-
<p class="info gt-df gt-ac gt-my-2">{{svg "octicon-git-commit" 16 "gt-mr-2"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DBBranch.CommitMessage $.RepoLink $.Repository.ComposeMetas}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} &nbsp;{{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
104+
<p class="info gt-df gt-ac gt-my-2">{{svg "octicon-git-commit" 16 "gt-mr-2"}}<a href="{{$.RepoLink}}/commit/{{PathEscape .DBBranch.CommitID}}">{{ShortSha .DBBranch.CommitID}}</a> · <span class="commit-message">{{RenderCommitMessage $.Context .DBBranch.CommitMessage $.RepoLink $.Repository.ComposeMetas}}</span> · {{ctx.Locale.Tr "org.repo_updated"}} {{TimeSince .DBBranch.CommitTime.AsTime ctx.Locale}}{{if .DBBranch.Pusher}} &nbsp;{{template "shared/user/avatarlink" dict "user" .DBBranch.Pusher}} &nbsp;{{template "shared/user/namelink" .DBBranch.Pusher}}{{end}}</p>
109105
{{end}}
110106
</td>
111107
<td class="two wide ui">

templates/repo/commit_status.tmpl

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<!-- make sure this matches the color logic in web_src/js/components/DashboardRepoList.vue -->
2-
<span class="gt-df">
32
{{if eq .State "pending"}}
43
{{svg "octicon-dot-fill" 18 "commit-status icon text yellow"}}
54
{{end}}
@@ -12,4 +11,3 @@
1211
{{if eq .State "failure"}}
1312
{{svg "octicon-x" 18 "commit-status icon text red"}}
1413
{{end}}
15-
</span>

web_src/css/base.css

+1
Original file line numberDiff line numberDiff line change
@@ -2242,6 +2242,7 @@ table th[data-sortt-desc] .svg {
22422242
right: 2em;
22432243
}
22442244

2245+
.btn,
22452246
.ui.ui.button,
22462247
.ui.ui.dropdown,
22472248
.ui.ui.label,

web_src/css/modules/button.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
color: var(--color-red);
3131
}
3232

33-
/* btn is a plain button without any opinionated styling */
33+
/* btn is a plain button without any opinionated styling, it only uses flex for vertical alignment like ".ui.button" in base.css */
3434

3535
.btn {
3636
background: transparent;

0 commit comments

Comments
 (0)