From 389e83f7eb68c43f6f0313b20acde547aef12442 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Thu, 23 Mar 2023 11:24:16 +0800 Subject: [PATCH] Improve `` to make it output `svg` node and optimize performance (#23570) Before, the Vue `` always outputs DOM nodes like: ```html ``` The `span` is redundant and I guess such layout and the inconsistent `class/class-name` attributes would cause bugs sooner or later. This PR makes the `` clear, and it's faster than before, because it doesn't need to parse the whole SVG string. Before:
![image](https://user-images.githubusercontent.com/2114189/226156474-ce2c57cd-b869-486a-b75b-1eebdac8cdf7.png)
After: ![image](https://user-images.githubusercontent.com/2114189/226155774-108f49ed-7512-40c3-94a2-a6e8da18063d.png) --------- Co-authored-by: silverwind --- templates/projects/view.tmpl | 2 +- templates/repo/projects/view.tmpl | 2 +- templates/user/settings/keys_gpg.tmpl | 2 +- templates/user/settings/keys_ssh.tmpl | 2 +- web_src/css/base.css | 12 ----- web_src/js/components/ActionRunStatus.vue | 4 +- web_src/js/components/ContextPopup.vue | 2 +- web_src/js/svg.js | 53 +++++++++++++++++++++-- web_src/js/svg.test.js | 22 +++++++++- 9 files changed, 77 insertions(+), 24 deletions(-) diff --git a/templates/projects/view.tmpl b/templates/projects/view.tmpl index b776f89efa..b778e0a242 100644 --- a/templates/projects/view.tmpl +++ b/templates/projects/view.tmpl @@ -224,7 +224,7 @@ {{- range index $.LinkedPRs .ID}} diff --git a/templates/repo/projects/view.tmpl b/templates/repo/projects/view.tmpl index 0248b9c6d2..99831f3dd9 100644 --- a/templates/repo/projects/view.tmpl +++ b/templates/repo/projects/view.tmpl @@ -235,7 +235,7 @@ {{- range index $.LinkedPRs .ID}} diff --git a/templates/user/settings/keys_gpg.tmpl b/templates/user/settings/keys_gpg.tmpl index ddb4960642..d143d5ed99 100644 --- a/templates/user/settings/keys_gpg.tmpl +++ b/templates/user/settings/keys_gpg.tmpl @@ -54,7 +54,7 @@ {{end}}
- {{svg "octicon-key" 32}} + {{svg "octicon-key" 32}}
{{if .Verified}} diff --git a/templates/user/settings/keys_ssh.tmpl b/templates/user/settings/keys_ssh.tmpl index 262b6e0d73..71b9b6a86b 100644 --- a/templates/user/settings/keys_ssh.tmpl +++ b/templates/user/settings/keys_ssh.tmpl @@ -47,7 +47,7 @@
- {{svg "octicon-key" 32}} + {{svg "octicon-key" 32}}
{{if .Verified}} diff --git a/web_src/css/base.css b/web_src/css/base.css index 1077a0eebd..e3b3fece37 100644 --- a/web_src/css/base.css +++ b/web_src/css/base.css @@ -2420,18 +2420,6 @@ a.ui.basic.label:hover { height: 2.1666em !important; } -span.green .svg { - color: var(--color-green); -} - -span.red .svg { - color: var(--color-red); -} - -span.purple .svg { - color: var(--color-purple); -} - .migrate .svg.gitea-git { color: var(--color-git); } diff --git a/web_src/js/components/ActionRunStatus.vue b/web_src/js/components/ActionRunStatus.vue index 3717b64956..b72dfb1aa6 100644 --- a/web_src/js/components/ActionRunStatus.vue +++ b/web_src/js/components/ActionRunStatus.vue @@ -1,10 +1,10 @@