diff options
author | silverwind <me@silverwind.io> | 2020-12-08 05:14:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 23:14:28 -0500 |
commit | e7938c9c44384e044afba14d5a86b1ba32520dd3 (patch) | |
tree | a813d29893239c867324d2e579022e99ad95deb2 /templates | |
parent | 9b22ada0a786494a69cf8aedb3576f9e252b2c79 (diff) | |
download | gitea-e7938c9c44384e044afba14d5a86b1ba32520dd3.tar.gz gitea-e7938c9c44384e044afba14d5a86b1ba32520dd3.zip |
Repo avatar fixes (#13891)
- Split up avatar rendering helpers for performance
- Fix showing repo SVG icon when no avatar is set
- Make repo SVG and avatar same size at 32px
- Fix fork line by adding vertical flexbox on repo title
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/explore/repo_list.tmpl | 65 | ||||
-rw-r--r-- | templates/repo/header.tmpl | 57 | ||||
-rw-r--r-- | templates/repo/icon.tmpl (renamed from templates/repo/header_icon.tmpl) | 2 |
3 files changed, 68 insertions, 56 deletions
diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index fe4b278e2c..bfec17ff29 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -1,37 +1,44 @@ <div class="ui repository list"> {{range .Repos}} <div class="item"> - <div class="ui header"> - {{avatar .}} - <a class="name" href="{{.Link}}"> - {{if or $.PageIsExplore $.PageIsProfileStarList }}{{if .Owner}}{{.Owner.Name}} / {{end}}{{end}}{{.Name}} - </a> - {{if .IsArchived}} - <span class="ui basic label">{{$.i18n.Tr "repo.desc.archived"}}</span> - {{end}} - {{if .IsTemplate}} - {{if .IsPrivate}} - <span class="ui basic label">{{$.i18n.Tr "repo.desc.private_template"}}</span> - {{else}} - {{if .Owner.Visibility.IsPrivate}} - <span class="ui basic label">{{$.i18n.Tr "repo.desc.internal_template"}}</span> - {{end}} + <div class="ui header df ac"> + <div class="repo-title"> + {{$avatar := (repoAvatar . 32 "mr-3")}} + {{if $avatar}} + {{$avatar}} {{end}} - {{else}} - {{if .IsPrivate}} - <span class="ui basic label">{{$.i18n.Tr "repo.desc.private"}}</span> - {{else}} - {{if .Owner.Visibility.IsPrivate}} - <span class="ui basic label">{{$.i18n.Tr "repo.desc.internal"}}</span> + <a class="name" href="{{.Link}}"> + {{if or $.PageIsExplore $.PageIsProfileStarList }}{{if .Owner}}{{.Owner.Name}} / {{end}}{{end}}{{.Name}} + </a> + <div class="labels df ac fw"> + {{if .IsArchived}} + <span class="ui basic label">{{$.i18n.Tr "repo.desc.archived"}}</span> {{end}} - {{end}} - {{end}} - {{if .IsFork}} - <span class="middle">{{svg "octicon-repo-forked"}}</span> - {{else if .IsMirror}} - <span class="middle">{{svg "octicon-mirror"}}</span> - {{end}} - <div class="ui right metas"> + {{if .IsTemplate}} + {{if .IsPrivate}} + <span class="ui basic label">{{$.i18n.Tr "repo.desc.private_template"}}</span> + {{else}} + {{if .Owner.Visibility.IsPrivate}} + <span class="ui basic label">{{$.i18n.Tr "repo.desc.internal_template"}}</span> + {{end}} + {{end}} + {{else}} + {{if .IsPrivate}} + <span class="ui basic label">{{$.i18n.Tr "repo.desc.private"}}</span> + {{else}} + {{if .Owner.Visibility.IsPrivate}} + <span class="ui basic label">{{$.i18n.Tr "repo.desc.internal"}}</span> + {{end}} + {{end}} + {{end}} + {{if .IsFork}} + {{svg "octicon-repo-forked"}} + {{else if .IsMirror}} + {{svg "octicon-mirror"}} + {{end}} + </div> + </div> + <div class="metas"> {{if .PrimaryLanguage }} <span class="text grey"><i class="color-icon" style="background-color: {{.PrimaryLanguage.Color}}"></i>{{ .PrimaryLanguage.Language }}</span> {{end}} diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 348c6b1ffa..8799cda655 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -2,35 +2,40 @@ {{with .Repository}} <div class="ui container"> <div class="repo-header"> - <div class="ui huge breadcrumb repo-title"> - {{if .Name}} - {{avatar .}} - {{else}} - {{template "repo/header_icon" .}} - {{end}} - <a href="{{AppSubUrl}}/{{.Owner.Name}}">{{.Owner.Name}}</a> - <div class="divider"> / </div> - <a href="{{$.RepoLink}}">{{.Name}}</a> - {{if .IsTemplate}} - {{if .IsPrivate}} - <span class="ui basic label">{{$.i18n.Tr "repo.desc.private_template"}}</span> + <div class="repo-title-wrap df fc"> + <div class="repo-title"> + {{$avatar := (repoAvatar . 32 "mr-3")}} + {{if $avatar}} + {{$avatar}} {{else}} - {{if .Owner.Visibility.IsPrivate}} - <span class="ui basic label">{{$.i18n.Tr "repo.desc.internal_template"}}</span> - {{end}} + {{template "repo/icon" .}} {{end}} - {{else}} - {{if .IsPrivate}} - <span class="ui basic label">{{$.i18n.Tr "repo.desc.private"}}</span> - {{else}} - {{if .Owner.Visibility.IsPrivate}} - <span class="ui basic label">{{$.i18n.Tr "repo.desc.internal"}}</span> + <a href="{{AppSubUrl}}/{{.Owner.Name}}">{{.Owner.Name}}</a> + <div class="mx-2">/</div> + <a href="{{$.RepoLink}}">{{.Name}}</a> + <div class="labels df ac fw"> + {{if .IsTemplate}} + {{if .IsPrivate}} + <span class="ui basic label">{{$.i18n.Tr "repo.desc.private_template"}}</span> + {{else}} + {{if .Owner.Visibility.IsPrivate}} + <span class="ui basic label">{{$.i18n.Tr "repo.desc.internal_template"}}</span> + {{end}} + {{end}} + {{else}} + {{if .IsPrivate}} + <span class="ui basic label">{{$.i18n.Tr "repo.desc.private"}}</span> + {{else}} + {{if .Owner.Visibility.IsPrivate}} + <span class="ui basic label">{{$.i18n.Tr "repo.desc.internal"}}</span> + {{end}} + {{end}} {{end}} - {{end}} - {{end}} - {{if .IsArchived}} - <span class="ui basic label">{{$.i18n.Tr "repo.desc.archived"}}</span> - {{end}} + {{if .IsArchived}} + <span class="ui basic label">{{$.i18n.Tr "repo.desc.archived"}}</span> + {{end}} + </div> + </div> {{if .IsMirror}}<div class="fork-flag">{{$.i18n.Tr "repo.mirror_from"}} <a target="_blank" rel="noopener noreferrer" href="{{if .SanitizedOriginalURL}}{{.SanitizedOriginalURL}}{{else}}{{MirrorAddress $.Mirror}}{{end}}">{{if .SanitizedOriginalURL}}{{.SanitizedOriginalURL}}{{else}}{{MirrorAddress $.Mirror}}{{end}}</a></div>{{end}} {{if .IsFork}}<div class="fork-flag">{{$.i18n.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{SubStr .BaseRepo.RelLink 1 -1}}</a></div>{{end}} {{if .IsGenerated}}<div class="fork-flag">{{$.i18n.Tr "repo.generated_from"}} <a href="{{.TemplateRepo.Link}}">{{SubStr .TemplateRepo.RelLink 1 -1}}</a></div>{{end}} diff --git a/templates/repo/header_icon.tmpl b/templates/repo/icon.tmpl index b9d49c209d..b4d8a24560 100644 --- a/templates/repo/header_icon.tmpl +++ b/templates/repo/icon.tmpl @@ -1,4 +1,4 @@ -<div class="repo-header-icon"> +<div class="repo-icon mr-3"> {{if $.IsTemplate}} {{svg "octicon-repo-template" 32}} {{else}} |