summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2024-04-24 00:18:41 +0800
committerGitHub <noreply@github.com>2024-04-24 00:18:41 +0800
commitb79e3db264e5734d8cc038be898d45186b3afcbd (patch)
tree792a169c1504bcda5d967ffc029b8cbd2f619e93 /templates
parentdd2aaadce3ecd3134a1ba0c82c5aaa05d6c11b2b (diff)
downloadgitea-b79e3db264e5734d8cc038be898d45186b3afcbd.tar.gz
gitea-b79e3db264e5734d8cc038be898d45186b3afcbd.zip
Initial support for colorblindness-friendly themes (#30625)
Initial support for #25680 This PR only adds some simple styles from GitHub, it is big enough and it focuses on adding the necessary framework-level supports. More styles could be fine-tuned later.
Diffstat (limited to 'templates')
-rw-r--r--templates/base/head.tmpl2
-rw-r--r--templates/base/head_style.tmpl2
-rw-r--r--templates/status/500.tmpl4
-rw-r--r--templates/user/settings/appearance.tmpl43
4 files changed, 19 insertions, 32 deletions
diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl
index 2de8f58235..174267fd2f 100644
--- a/templates/base/head.tmpl
+++ b/templates/base/head.tmpl
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html lang="{{ctx.Locale.Lang}}" data-theme="{{ThemeName .SignedUser}}">
+<html lang="{{ctx.Locale.Lang}}" data-theme="{{UserThemeName .SignedUser}}">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{if .Title}}{{.Title}} - {{end}}{{if .Repository.Name}}{{.Repository.Name}} - {{end}}{{AppName}}</title>
diff --git a/templates/base/head_style.tmpl b/templates/base/head_style.tmpl
index 0793eaca20..f97e1880ce 100644
--- a/templates/base/head_style.tmpl
+++ b/templates/base/head_style.tmpl
@@ -1,2 +1,2 @@
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/index.css?v={{AssetVersion}}">
-<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/theme-{{ThemeName .SignedUser | PathEscape}}.css?v={{AssetVersion}}">
+<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/theme-{{UserThemeName .SignedUser | PathEscape}}.css?v={{AssetVersion}}">
diff --git a/templates/status/500.tmpl b/templates/status/500.tmpl
index 576b6eebbb..566fddcec1 100644
--- a/templates/status/500.tmpl
+++ b/templates/status/500.tmpl
@@ -1,12 +1,12 @@
{{/* This page should only depend the minimal template functions/variables, to avoid triggering new panics.
-* base template functions: AppName, AssetUrlPrefix, AssetVersion, AppSubUrl, ThemeName
+* base template functions: AppName, AssetUrlPrefix, AssetVersion, AppSubUrl, UserThemeName
* ctx.Locale
* .Flash
* .ErrorMsg
* .SignedUser (optional)
*/}}
<!DOCTYPE html>
-<html lang="{{ctx.Locale.Lang}}" data-theme="{{ThemeName .SignedUser}}">
+<html lang="{{ctx.Locale.Lang}}" data-theme="{{UserThemeName .SignedUser}}">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Internal Server Error - {{AppName}}</title>
diff --git a/templates/user/settings/appearance.tmpl b/templates/user/settings/appearance.tmpl
index 0997d721e1..4fa248910a 100644
--- a/templates/user/settings/appearance.tmpl
+++ b/templates/user/settings/appearance.tmpl
@@ -1,4 +1,4 @@
-{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings sshkeys")}}
+{{template "user/settings/layout_head" (dict "ctxData" . "pageClass" "user settings")}}
<div class="user-setting-content">
<!-- Theme -->
@@ -6,39 +6,26 @@
{{ctx.Locale.Tr "settings.manage_themes"}}
</h4>
<div class="ui attached segment">
- <div class="ui email list">
- <div class="item">
- {{ctx.Locale.Tr "settings.theme_desc"}}
- </div>
-
<form class="ui form" action="{{.Link}}/theme" method="post">
{{.CsrfTokenHtml}}
- <div class="field">
- <label for="ui">{{ctx.Locale.Tr "settings.ui"}}</label>
- <div class="ui selection dropdown" id="ui">
- <input name="theme" type="hidden" value="{{.SignedUser.Theme}}">
- {{svg "octicon-triangle-down" 14 "dropdown icon"}}
- <div class="text">
- {{range $i,$a := .AllThemes}}
- {{if eq $.SignedUser.Theme $a}}{{$a}}{{end}}
- {{end}}
- </div>
-
- <div class="menu">
- {{range $i,$a := .AllThemes}}
- <div class="item{{if eq $.SignedUser.Theme $a}} active selected{{end}}" data-value="{{$a}}">
- {{$a}}
- </div>
- {{end}}
- </div>
- </div>
- </div>
-
+ <div class="field">
+ {{ctx.Locale.Tr "settings.theme_desc"}}
+ <a class="muted" target="_blank" href="https://github.com/go-gitea/gitea/blob/main/web_src/css/themes/" data-tooltip-content="{{ctx.Locale.Tr "settings.theme_colorblindness_prompt"}}">
+ {{svg "octicon-question"}} {{ctx.Locale.Tr "settings.theme_colorblindness_help"}}
+ </a>
+ </div>
+ <div class="field">
+ <label>{{ctx.Locale.Tr "settings.ui"}}</label>
+ <select name="theme" class="ui dropdown">
+ {{range $theme := .AllThemes}}
+ <option value="{{$theme}}" {{Iif (eq $.SignedUser.Theme $theme) "selected"}}>{{$theme}}</option>
+ {{end}}
+ </select>
+ </div>
<div class="field">
<button class="ui primary button">{{ctx.Locale.Tr "settings.update_theme"}}</button>
</div>
</form>
- </div>
</div>
<!-- Language -->