1
1
mirror of https://github.com/go-gitea/gitea synced 2025-11-06 14:28:14 +00:00

Support selecting theme on the footer (#35741)

Fixes: https://github.com/go-gitea/gitea/pull/27576
This commit is contained in:
wxiaoguang
2025-10-28 18:25:00 +08:00
committed by GitHub
parent cddff73bbd
commit 6b5563c54a
33 changed files with 254 additions and 59 deletions

View File

@@ -23,8 +23,10 @@ import (
"code.gitea.io/gitea/modules/markup/markdown"
"code.gitea.io/gitea/modules/reqctx"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/svg"
"code.gitea.io/gitea/modules/translation"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/services/webtheme"
)
type RenderUtils struct {
@@ -259,3 +261,18 @@ func (ut *RenderUtils) RenderLabels(labels []*issues_model.Label, repoLink strin
htmlCode += "</span>"
return template.HTML(htmlCode)
}
func (ut *RenderUtils) RenderThemeItem(info *webtheme.ThemeMetaInfo, iconSize int) template.HTML {
svgName := "octicon-paintbrush"
switch info.ColorScheme {
case "dark":
svgName = "octicon-moon"
case "light":
svgName = "octicon-sun"
case "auto":
svgName = "gitea-eclipse"
}
icon := svg.RenderHTML(svgName, iconSize)
extraIcon := svg.RenderHTML(info.GetExtraIconName(), iconSize)
return htmlutil.HTMLFormat(`<div class="theme-menu-item" data-tooltip-content="%s">%s %s %s</div>`, info.GetDescription(), icon, info.DisplayName, extraIcon)
}