Skip to content

Commit

Permalink
Improve flex list UI (#26970)
Browse files Browse the repository at this point in the history
1. There is already `gt-ac`, so no need to introduce `flex-item-center`
2. The `flex-item-baseline` and `.flex-item-icon svg { margin-top: 1px
}` seem to be a tricky patch, they don't resolve the root problem, and
still cause misalignment in some cases.
* The root problem is: the "icon" needs to align with the sibling
"title"
    * So, make the "icon" and the "title" both have the same height 
3. `flex-text-inline` could only be used if the element is really
"inline", otherwise its `vertical-align` would make the box size change.
In most cases, `flex-text-block` is good enough.


![image](https://github.com/go-gitea/gitea/assets/2114189/1b7acfc2-b1c7-4e9c-a983-2fa932026479)

---------

Co-authored-by: silverwind <[email protected]>
Co-authored-by: Giteabot <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed Feb 17, 2024
1 parent a4b5cb3 commit 99934fd
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 26 deletions.
2 changes: 1 addition & 1 deletion templates/explore/user_list.tmpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="flex-list">
{{range .Users}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-leading">
{{ctx.AvatarUtils.Avatar . 48}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/org/member/members.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="flex-list">
{{range .Members}}
{{$isPublic := index $.MembersIsPublicMember .ID}}
<div class="flex-item {{if $.PublicOnly}}flex-item-center{{end}}">
<div class="flex-item {{if $.PublicOnly}}gt-ac{{end}}">
<div class="flex-item-leading">
<a href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 48}}</a>
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/org/team/members.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="ui attached segment">
<div class="flex-list">
{{range .Team.Members}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-leading">
<a href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 32}}</a>
</div>
Expand Down Expand Up @@ -56,7 +56,7 @@
<div class="ui attached segment">
<div class="flex-list">
{{range .Invites}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-main">
{{.Email}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/org/team/repositories.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div class="ui attached segment">
<div class="flex-list">
{{range .Team.Repos}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-leading">
{{template "repo/icon" .}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/actions/runs_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
{{end}}
{{range .Runs}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-leading">
{{template "repo/actions/status" (dict "status" .Status.String "locale" $.locale)}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/settings/branches.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<div class="ui attached segment">
<div class="flex-list">
{{range .ProtectedBranches}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-main">
<div class="flex-item-title">
<div class="ui basic primary label">{{.RuleName}}</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/settings/collaboration.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<div class="ui attached segment">
<div class="flex-list">
{{range .Collaborators}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-leading">
<a href="{{.HomeLink}}">{{ctx.AvatarUtils.Avatar . 32}}</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/repo/settings/options.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@
</div>
</div>
{{if not .Repository.IsMirror}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-main">
{{if .Repository.IsArchived}}
<div class="flex-item-title">{{.locale.Tr "repo.settings.unarchive.header"}}</div>
Expand Down
8 changes: 5 additions & 3 deletions templates/shared/issuelist.tmpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<div id="issue-list" class="flex-list">
{{$approvalCounts := .ApprovalCounts}}
{{range .Issues}}
<div class="flex-item flex-item-baseline">
<div class="flex-item-leading gt-ac">
<div class="flex-item">
<div class="flex-item-leading">
{{if $.CanWriteIssuesOrPulls}}
<div class="flex-item-icon">
<input type="checkbox" autocomplete="off" class="issue-checkbox gt-mr-4" data-issue-id={{.ID}} aria-label="{{$.locale.Tr "repo.issues.action_check"}} &quot;{{.Title}}&quot;">
</div>
{{end}}
<div class="flex-item-icon">
{{template "shared/issueicon" .}}
Expand Down Expand Up @@ -44,7 +46,7 @@
{{end}}
{{if .NumComments}}
<div class="text grey">
<a class="gt-no-underline muted flex-text-inline" href="{{if .Link}}{{.Link}}{{else}}{{$.Link}}/{{.Index}}{{end}}">
<a class="gt-no-underline muted flex-text-block" href="{{if .Link}}{{.Link}}{{else}}{{$.Link}}/{{.Index}}{{end}}">
{{svg "octicon-comment" 16}}{{.NumComments}}
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/shared/secrets/add_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{{if .Secrets}}
<div class="flex-list">
{{range .Secrets}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-leading">
{{svg "octicon-key" 32}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/shared/variables/variable_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{{if .Variables}}
<div class="flex-list">
{{range .Variables}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-leading">
{{svg "octicon-pencil" 32}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/user/settings/applications_oauth2_list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{.locale.Tr "settings.oauth2_application_create_description"}}
</div>
{{range .Applications}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-leading">
{{svg "octicon-apps" 32}}
</div>
Expand Down
2 changes: 1 addition & 1 deletion templates/user/settings/security/openid.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{{.locale.Tr "settings.openid_desc"}}
</div>
{{range .OpenIDs}}
<div class="flex-item flex-item-center">
<div class="flex-item gt-ac">
<div class="flex-item-leading">
{{svg "fontawesome-openid" 20}}
</div>
Expand Down
15 changes: 5 additions & 10 deletions web_src/css/shared/flex-list.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
padding: 1em 0;
}

.flex-item-baseline {
align-items: baseline;
}

.flex-item-center {
align-items: center;
}

.flex-item .flex-item-leading {
display: flex;
align-items: flex-start;
Expand All @@ -41,8 +33,10 @@
color: var(--color-primary) !important;
}

.flex-item .flex-item-icon svg {
margin-top: 1px;
.flex-item .flex-item-icon {
display: flex;
align-items: center;
height: 20px; /* match the default flex-item-title height */
}

.flex-item .flex-item-trailing {
Expand All @@ -65,6 +59,7 @@
font-weight: var(--font-weight-semibold);
word-break: break-word;
min-width: 0;
min-height: 20px;
}

.flex-item .flex-item-title a {
Expand Down

0 comments on commit 99934fd

Please sign in to comment.