Skip to content

Commit e82f3ca

Browse files
authored
Always use HTML attributes for avatar size (#31509)
Many avatars were rendered in HTML with certain width/height but then resized again in CSS. This was pointless so I removed all these cases and made the HTML size match the previous render size. Also did a few CSS cleanups in the tribute rendering: <img width="648" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/cb2fafb3-5e20-46e9-814f-07df20038beb">
1 parent 08579d6 commit e82f3ca

File tree

10 files changed

+11
-59
lines changed

10 files changed

+11
-59
lines changed

templates/repo/editor/commit_form.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="commit-form-wrapper">
2-
{{ctx.AvatarUtils.Avatar .SignedUser 48 "commit-avatar"}}
2+
{{ctx.AvatarUtils.Avatar .SignedUser 40 "commit-avatar"}}
33
<div class="commit-form">
44
<h3>{{- if .CanCommitToBranch.WillSign}}
55
<span title="{{ctx.Locale.Tr "repo.signing.will_sign" .CanCommitToBranch.SigningKey}}">{{svg "octicon-lock" 24}}</span>

templates/repo/graph/commits.tmpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@
5858
{{end}}
5959
{{end}}
6060
</span>
61-
<span class="author tw-flex tw-items-center tw-mr-2">
61+
<span class="author tw-flex tw-items-center tw-mr-2 tw-gap-[1px]">
6262
{{$userName := $commit.Commit.Author.Name}}
6363
{{if $commit.User}}
6464
{{if and $commit.User.FullName DefaultShowFullName}}
6565
{{$userName = $commit.User.FullName}}
6666
{{end}}
67-
<span class="tw-mr-1">{{ctx.AvatarUtils.Avatar $commit.User}}</span>
67+
{{ctx.AvatarUtils.Avatar $commit.User 18}}
6868
<a href="{{$commit.User.HomeLink}}">{{$userName}}</a>
6969
{{else}}
70-
<span class="tw-mr-1">{{ctx.AvatarUtils.AvatarByEmail $commit.Commit.Author.Email $userName}}</span>
70+
{{ctx.AvatarUtils.AvatarByEmail $commit.Commit.Author.Email $userName 18}}
7171
{{$userName}}
7272
{{end}}
7373
</span>

templates/repo/shabox_badge.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<div title="{{if eq .verification.TrustStatus "trusted"}}{{else if eq .verification.TrustStatus "untrusted"}}{{ctx.Locale.Tr "repo.commits.signed_by_untrusted_user"}}: {{else}}{{ctx.Locale.Tr "repo.commits.signed_by_untrusted_user_unmatched"}}: {{end}}{{.verification.Reason}}">
44
{{if ne .verification.SigningUser.ID 0}}
55
{{svg "gitea-lock"}}
6-
{{ctx.AvatarUtils.Avatar .verification.SigningUser 28 "signature"}}
6+
{{ctx.AvatarUtils.Avatar .verification.SigningUser 16 "signature"}}
77
{{else}}
88
<span title="{{ctx.Locale.Tr "gpg.default_key"}}">{{svg "gitea-lock-cog"}}</span>
9-
{{ctx.AvatarUtils.AvatarByEmail .verification.SigningEmail "" 28 "signature"}}
9+
{{ctx.AvatarUtils.AvatarByEmail .verification.SigningEmail "" 16 "signature"}}
1010
{{end}}
1111
</div>
1212
{{else}}

templates/repo/user_cards.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{range .Cards}}
99
<li class="item ui segment">
1010
<a href="{{.HomeLink}}">
11-
{{ctx.AvatarUtils.Avatar .}}
11+
{{ctx.AvatarUtils.Avatar . 48}}
1212
</a>
1313
<h3 class="name"><a href="{{.HomeLink}}">{{.DisplayName}}</a></h3>
1414

web_src/css/features/gitgraph.css

-6
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,6 @@
123123
padding-bottom: 1px;
124124
}
125125

126-
#git-graph-container #rev-list .author img.ui.avatar {
127-
width: auto;
128-
height: 18px;
129-
max-width: none;
130-
}
131-
132126
#git-graph-container #graph-raw-list {
133127
margin: 0;
134128
}

web_src/css/features/tribute.css

+1-11
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
.tribute-container li span.fullname {
1818
font-weight: var(--font-weight-normal);
1919
font-size: 0.8rem;
20-
margin-left: 3px;
2120
}
2221

2322
.tribute-container li.highlight,
@@ -29,14 +28,5 @@
2928
.tribute-item {
3029
display: flex;
3130
align-items: center;
32-
}
33-
34-
.tribute-item .emoji,
35-
.tribute-item img[src*="/avatar/"] {
36-
margin-right: 0.5rem;
37-
}
38-
39-
.tribute-container img {
40-
width: 1.5rem !important;
41-
height: 1.5rem !important;
31+
gap: 6px;
4232
}

web_src/css/modules/comment.css

-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@
5050
background: none;
5151
}
5252

53-
.ui.comments .comment .avatar {
54-
width: 30px;
55-
}
56-
5753
.ui.comments .comment > .content {
5854
display: flex;
5955
flex-direction: column;

web_src/css/org.css

-2
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@
127127
}
128128

129129
.page-content.organization .members .ui.avatar {
130-
width: 48px;
131-
height: 48px;
132130
margin-right: 5px;
133131
margin-bottom: 5px;
134132
}

web_src/css/repo.css

+2-28
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,12 @@ td .commit-summary {
460460
}
461461

462462
.repository.file.editor .commit-form-wrapper {
463-
padding-left: 64px;
463+
padding-left: 48px;
464464
}
465465

466466
.repository.file.editor .commit-form-wrapper .commit-avatar {
467467
float: left;
468-
margin-left: -64px;
469-
width: 3em;
470-
height: auto;
468+
margin-left: -48px;
471469
}
472470

473471
.repository.file.editor .commit-form-wrapper .commit-form {
@@ -535,10 +533,6 @@ td .commit-summary {
535533
min-width: 100px;
536534
}
537535

538-
#new-issue .comment .avatar {
539-
width: 3em;
540-
}
541-
542536
.repository.new.issue .comment.form .content::before,
543537
.repository.new.issue .comment.form .content::after {
544538
right: 100%;
@@ -1216,16 +1210,6 @@ td .commit-summary {
12161210
border: 1px solid var(--color-light-border);
12171211
}
12181212

1219-
.repository #commits-table td.sha .sha.label .ui.signature.avatar,
1220-
.repository #repo-files-table .sha.label .ui.signature.avatar,
1221-
.repository #repo-file-commit-box .sha.label .ui.signature.avatar,
1222-
.repository #rev-list .sha.label .ui.signature.avatar,
1223-
.repository .timeline-item.commits-list .singular-commit .sha.label .ui.signature.avatar {
1224-
height: 16px;
1225-
margin-bottom: 0;
1226-
width: 16px;
1227-
}
1228-
12291213
.repository #commits-table td.sha .sha.label .detail.icon,
12301214
.repository #repo-files-table .sha.label .detail.icon,
12311215
.repository #repo-file-commit-box .sha.label .detail.icon,
@@ -1242,14 +1226,6 @@ td .commit-summary {
12421226
border-bottom-left-radius: 0;
12431227
}
12441228

1245-
.repository #commits-table td.sha .sha.label .detail.icon img,
1246-
.repository #repo-files-table .sha.label .detail.icon img,
1247-
.repository #repo-file-commit-box .sha.label .detail.icon img,
1248-
.repository #rev-list .sha.label .detail.icon img,
1249-
.repository .timeline-item.commits-list .singular-commit .sha.label .detail.icon img {
1250-
margin-right: 0;
1251-
}
1252-
12531229
.repository #commits-table td.sha .sha.label .detail.icon .svg,
12541230
.repository #repo-files-table .sha.label .detail.icon .svg,
12551231
.repository #repo-file-commit-box .sha.label .detail.icon .svg,
@@ -1931,8 +1907,6 @@ td .commit-summary {
19311907
}
19321908

19331909
.user-cards .list .item .avatar {
1934-
width: 48px;
1935-
height: 48px;
19361910
float: left;
19371911
display: block;
19381912
margin-right: 10px;

web_src/js/features/tribute.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function makeCollections({mentions, emoji}) {
3636
menuItemTemplate: (item) => {
3737
return `
3838
<div class="tribute-item">
39-
<img src="${htmlEscape(item.original.avatar)}" class="tw-mr-2"/>
39+
<img src="${htmlEscape(item.original.avatar)}" width="21" height="21"/>
4040
<span class="name">${htmlEscape(item.original.name)}</span>
4141
${item.original.fullname && item.original.fullname !== '' ? `<span class="fullname">${htmlEscape(item.original.fullname)}</span>` : ''}
4242
</div>

0 commit comments

Comments
 (0)