gitea/modules/fileicon/render.go
Giteabot 544450a212
fix some file icon ui (#36078) (#36088)
Backport #36078 by @a1012112796

fix #36071

looks that's because if an svg in hiden env, it's color added by
`fill="url(#a)"` will become not usefull. by ai helping, I think moving
it out of page by position is a good solution. fell free creat a new
pull request if you have a better soluton. Thanks.
<img width="2198" height="1120" alt="image"
src="https://github.com/user-attachments/assets/bbf7c171-0b7f-412a-a1bc-aea3f1629636"
/>

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-12-04 19:39:35 +00:00

42 lines
950 B
Go

// Copyright 2025 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package fileicon
import (
"html/template"
"strings"
"code.gitea.io/gitea/modules/setting"
)
type RenderedIconPool struct {
IconSVGs map[string]template.HTML
}
func NewRenderedIconPool() *RenderedIconPool {
return &RenderedIconPool{
IconSVGs: make(map[string]template.HTML),
}
}
func (p *RenderedIconPool) RenderToHTML() template.HTML {
if len(p.IconSVGs) == 0 {
return ""
}
sb := &strings.Builder{}
sb.WriteString(`<div class="svg-icon-container">`)
for _, icon := range p.IconSVGs {
sb.WriteString(string(icon))
}
sb.WriteString(`</div>`)
return template.HTML(sb.String())
}
func RenderEntryIconHTML(renderedIconPool *RenderedIconPool, entry *EntryInfo) template.HTML {
if setting.UI.FileIconTheme == "material" {
return DefaultMaterialIconProvider().EntryIconHTML(renderedIconPool, entry)
}
return BasicEntryIconHTML(entry)
}