From b4f8da533e1771eb1e0d222d8d586b4220447e4c Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 20 Dec 2020 19:00:03 +0100 Subject: [PATCH] Search and Diff CSS enhancements (#14050) * Search and Diff CSS enhancements - Use flexbox for language stats - Improve labels and code boxes on repo and code search - Use flexbox on diff header and improve suppressed diff text - Add dedicated color for diff expander * more diff tweaks, less vertical padding on header * more minor tweaks * always show fold icon, image diff improvments * remove margin Co-authored-by: Lunny Xiao Co-authored-by: techknowlogick --- templates/explore/code.tmpl | 8 +-- templates/explore/repo_list.tmpl | 8 +-- templates/repo/diff/box.tmpl | 50 ++++++++++--------- templates/repo/diff/image_diff.tmpl | 12 ++--- templates/repo/diff/stats.tmpl | 2 +- templates/repo/search.tmpl | 8 +-- templates/repo/sub_menu.tmpl | 19 +++---- templates/shared/searchbottom.tmpl | 6 +-- web_src/less/_base.less | 63 ++++++++++++------------ web_src/less/_explore.less | 15 ++---- web_src/less/_repository.less | 45 +++++++++-------- web_src/less/_review.less | 9 +--- web_src/less/helpers.less | 4 ++ web_src/less/themes/theme-arc-green.less | 33 +++---------- 14 files changed, 129 insertions(+), 153 deletions(-) diff --git a/templates/explore/code.tmpl b/templates/explore/code.tmpl index 049564557..1c41dd843 100644 --- a/templates/explore/code.tmpl +++ b/templates/explore/code.tmpl @@ -16,10 +16,10 @@

{{.i18n.Tr "explore.code_search_results" (.Keyword|Escape) | Str2html }}

-
+
{{range $term := .SearchResultLanguages}} - - + + {{$term.Language}}
{{$term.Count}}
@@ -31,7 +31,7 @@

{{$repo.FullName}} - {{.Filename}} - {{$.i18n.Tr "repo.diff.view_file"}} + {{$.i18n.Tr "repo.diff.view_file"}}

diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index bfec17ff2..91dc3d8bf 100644 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -38,12 +38,12 @@ {{end}}
-
+
{{if .PrimaryLanguage }} - {{ .PrimaryLanguage.Language }} + {{ .PrimaryLanguage.Language }} {{end}} - {{svg "octicon-star"}} {{.NumStars}} - {{svg "octicon-git-branch"}} {{.NumForks}} + {{svg "octicon-star" 16 "mr-3"}}{{.NumStars}} + {{svg "octicon-git-branch" 16 "mr-3"}}{{.NumForks}}
diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 40e9d277b..ef152fa58 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -33,10 +33,10 @@ {{end}}
-
    +
      {{range .Diff.Files}}
    1. -
      +
      {{if not .IsBin}} {{template "repo/diff/stats" dict "file" . "root" $}} {{else}} @@ -45,7 +45,7 @@
        - {{.Name}} + {{.Name}}
    2. {{end}}
    @@ -53,23 +53,28 @@ {{if $file.IsIncomplete}}

    -
    + + {{svg "octicon-chevron-down" 18}} + +
    {{if not $file.IsRenamed}} {{template "repo/diff/stats" dict "file" . "root" $}} {{end}}
    - {{$file.Name}} -
    {{$.i18n.Tr "repo.diff.file_suppressed"}}
    - {{if $file.IsProtected}} - {{$.i18n.Tr "repo.diff.protected"}} - {{end}} - {{if and (not $file.IsSubmodule) (not $.PageIsWiki)}} - {{if $file.IsDeleted}} - {{$.i18n.Tr "repo.diff.view_file"}} - {{else}} - {{$.i18n.Tr "repo.diff.view_file"}} + {{$file.Name}} +
    +
    {{$.i18n.Tr "repo.diff.file_suppressed"}}
    + {{if $file.IsProtected}} + {{$.i18n.Tr "repo.diff.protected"}} {{end}} - {{end}} + {{if and (not $file.IsSubmodule) (not $.PageIsWiki)}} + {{if $file.IsDeleted}} + {{$.i18n.Tr "repo.diff.view_file"}} + {{else}} + {{$.i18n.Tr "repo.diff.view_file"}} + {{end}} + {{end}} +

    {{else}} @@ -82,21 +87,19 @@ {{else}} {{$isImage = (call $.IsImageFileInHead $file.Name)}} {{end}} - {{if or (not $file.IsBin) $isImage}} - + {{svg "octicon-chevron-down" 18}} - {{end}} -
    +
    {{if $file.IsBin}} {{$.i18n.Tr "repo.diff.bin"}} {{else if not $file.IsRenamed}} {{template "repo/diff/stats" dict "file" . "root" $}} {{end}}
    - {{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}} + {{if $file.IsRenamed}}{{$file.OldName}} → {{end}}{{$file.Name}}{{if .IsLFSFile}} ({{$.i18n.Tr "repo.stored_lfs"}}){{end}}
    -
    +
    {{if $file.IsProtected}} {{$.i18n.Tr "repo.diff.protected"}} {{end}} @@ -111,8 +114,8 @@
    {{if ne $file.Type 4}} -
    - +
    +
    {{if $isImage}} {{template "repo/diff/image_diff" dict "file" . "root" $}} @@ -130,7 +133,6 @@ {{end}} -
    {{end}} {{if .Diff.IsIncomplete}} diff --git a/templates/repo/diff/image_diff.tmpl b/templates/repo/diff/image_diff.tmpl index 6afb985e9..eda208d74 100644 --- a/templates/repo/diff/image_diff.tmpl +++ b/templates/repo/diff/image_diff.tmpl @@ -2,22 +2,22 @@ {{ $imagePathNew := printf "%s/%s" .root.RawPath (EscapePound .file.Name) }} - - - - - -
    + {{.root.i18n.Tr "repo.diff.file_before"}} + {{.root.i18n.Tr "repo.diff.file_after"}}
    + {{if or .file.IsDeleted (not .file.IsCreated)}} {{end}} + {{if or .file.IsCreated (not .file.IsDeleted)}} @@ -29,7 +29,7 @@ {{ $imageInfoHead := (call .root.ImageInfo .file.Name) }} {{if or $imageInfoBase $imageInfoHead }}
    + {{if $imageInfoBase }} {{ $classWidth := "" }} {{ $classHeight := "" }} @@ -52,7 +52,7 @@ {{.root.i18n.Tr "repo.diff.file_byte_size"}}: {{FileSize $imageInfoBase.ByteSize}} {{end}} + {{if $imageInfoHead }} {{ $classWidth := "" }} {{ $classHeight := "" }} diff --git a/templates/repo/diff/stats.tmpl b/templates/repo/diff/stats.tmpl index 97503f0ea..1c9b2abd3 100644 --- a/templates/repo/diff/stats.tmpl +++ b/templates/repo/diff/stats.tmpl @@ -1,4 +1,4 @@ {{Add .file.Addition .file.Deletion}} - +
    diff --git a/templates/repo/search.tmpl b/templates/repo/search.tmpl index c2172ec78..b66391a5a 100644 --- a/templates/repo/search.tmpl +++ b/templates/repo/search.tmpl @@ -16,10 +16,10 @@

    {{.i18n.Tr "repo.search.results" (.Keyword|Escape) .RepoLink .RepoName | Str2html }}

    -
    +
    {{range $term := .SearchResultLanguages}} - - + + {{$term.Language}}
    {{$term.Count}}
    @@ -30,7 +30,7 @@

    {{.Filename}} - {{$.i18n.Tr "repo.diff.view_file"}} + {{$.i18n.Tr "repo.diff.view_file"}}

    diff --git a/templates/repo/sub_menu.tmpl b/templates/repo/sub_menu.tmpl index 6c455a4d5..5bb71ba49 100644 --- a/templates/repo/sub_menu.tmpl +++ b/templates/repo/sub_menu.tmpl @@ -23,15 +23,16 @@