Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix default avatar image size in PR diff page #28971

Merged
merged 5 commits into from
Feb 2, 2024

Conversation

yp05327
Copy link
Contributor

@yp05327 yp05327 commented Jan 29, 2024

Fix #28941

ps: didn't test. The repo is too big to migrate.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jan 29, 2024
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 29, 2024
@yp05327
Copy link
Contributor Author

yp05327 commented Jan 29, 2024

Only display default avatar:
image
It seems that it works well:
image

If I used the current code:
image
It is incorrect:
image

@yp05327 yp05327 added the topic/ui Change the appearance of the Gitea UI label Jan 29, 2024
@silverwind
Copy link
Member

Can we use the new helper for the other two cases of avatar_default rendering in templates:

templates/repo/issue/view_content/comments.tmpl:20:					<img src="{{AppSubUrl}}/assets/img/avatar_default.png" width="40" height="40">
templates/repo/issue/view_content.tmpl:15:					<img src="{{AppSubUrl}}/assets/img/avatar_default.png" width="40" height="40">

@@ -3,7 +3,7 @@
{{$createdStr:= TimeSinceUnix .CreatedUnix ctx.Locale}}
<div class="comment" id="{{.HashTag}}">
{{if .OriginalAuthor}}
<span class="avatar"><img src="{{AppSubUrl}}/assets/img/avatar_default.png"></span>
<span class="avatar">{{ctx.AvatarUtils.AvatarDefault}}</span>
Copy link
Contributor

@wxiaoguang wxiaoguang Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think it's worth to add a new helper function.

It could be something as simple as:

<img class="ui avatar gt-vm" width="28" height="28" src="{{AppSubUrl}}/assets/img/avatar_default.png">

There are already code using <img class="ui avatar"> (tmpl/js) directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first, I did as you said. But for other maintainers. they may consider where does this 28 come from?
Maybe we can merge this in to AvatarUtils.Avatar, set item to be nil or something else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of the helper function. We use helper functions for all other avatars, why not this one too?

Copy link
Contributor

@wxiaoguang wxiaoguang Jan 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real situation here is:

  • There are still not only one avatar_default.png usages in JS code, not in tmpl, so your new "helper function" won't cover them.
  • If we'd like to improve the "default avatar" in the future, developers still to need search the whole code base, don't forget the JS ones.
  • Using <img class="ui avatar gt-vm" is also readable and it is standard HTML. The 28 is the default width, even if you use a helper function, in many uses you still need to write the side (you see, you use 40 now ..... you could also ask "where it comes from", the same)

So, introducing a helper function here seems an over-engineering IMO:

  1. There are only a few (3?) cases, not too many, not reduce duplication really.
  2. It doesn't cover all cases, there will be still not only one avatar_default.png in other places. Developers still need to search avatar_default.png to avoid missing anything.
  3. It needs more lines of code, but doesn't really help to improve the readability or maintainability, standard HTML code is also very readable and maintainable.
  4. The current approach introduces garbage code like <span class="avatar">

Instead of introducing a new helper function, the new commit which uses existing helper function seems better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you see, you use 40 now

It comes from:
image
At least for me, it can be easily considered that the avatars should be 40 here, but not the default size.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Jan 30, 2024
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jan 31, 2024
@delvh delvh added the type/bug label Jan 31, 2024
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 2, 2024
@lunny lunny enabled auto-merge (squash) February 2, 2024 09:36
@lunny lunny merged commit 3aed8ae into go-gitea:main Feb 2, 2024
25 checks passed
@GiteaBot GiteaBot added this to the 1.22.0 milestone Feb 2, 2024
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Feb 2, 2024
zjjhot added a commit to zjjhot/gitea that referenced this pull request Feb 4, 2024
* giteaofficial/main:
  Add `must-change-password` cli parameter (go-gitea#27626)
  Include username in email headers (go-gitea#28981)
  Update tool dependencies (go-gitea#29030)
  Add artifacts v4 jwt to job message and accept it (go-gitea#28885)
  Pass es2020 to esbuild-loader as well (go-gitea#29027)
  Fix default avatar image size in PR diff page (go-gitea#28971)
  Update JS and PY dependencies, build for `es2020` browsers (go-gitea#28977)
silverwind pushed a commit to silverwind/gitea that referenced this pull request Feb 20, 2024
Fix go-gitea#28941

ps: didn't test. The repo is too big to migrate.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
@yp05327 yp05327 deleted the fix-avatar-image-size-in-diff-page branch March 13, 2024 02:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. topic/ui Change the appearance of the Gitea UI type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avatar size is incorrect in diff page
6 participants