Skip to content

Commit 888296b

Browse files
committed
fix
1 parent d05e06e commit 888296b

File tree

10 files changed

+46
-11
lines changed

10 files changed

+46
-11
lines changed

modules/fileicon/basic.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@ import (
1010
"code.gitea.io/gitea/modules/svg"
1111
)
1212

13+
func BasicThemeFolderIconName(isOpen bool) string {
14+
if isOpen {
15+
return "octicon-file-directory-open-fill"
16+
} else {
17+
return "octicon-file-directory-fill"
18+
}
19+
}
20+
21+
func BasicThemeFolderIcon(isOpen bool) template.HTML {
22+
return svg.RenderHTML(BasicThemeFolderIconName(isOpen))
23+
}
24+
1325
func BasicThemeIcon(entry *git.TreeEntry) template.HTML {
1426
svgName := "octicon-file"
1527
switch {
@@ -19,7 +31,7 @@ func BasicThemeIcon(entry *git.TreeEntry) template.HTML {
1931
svgName = "octicon-file-directory-symlink"
2032
}
2133
case entry.IsDir():
22-
svgName = "octicon-file-directory-fill"
34+
svgName = BasicThemeFolderIconName(false)
2335
case entry.IsSubModule():
2436
svgName = "octicon-file-submodule"
2537
}

modules/fileicon/material.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ func (m *MaterialIconProvider) renderFileIconSVG(ctx reqctx.RequestContext, name
8585
return template.HTML(svg)
8686
}
8787

88+
func (m *MaterialIconProvider) FolderIcon(ctx reqctx.RequestContext, isOpen bool) template.HTML {
89+
return svg.RenderHTML("material-folder-generic", 16, BasicThemeFolderIconName(isOpen))
90+
}
91+
8892
func (m *MaterialIconProvider) FileIcon(ctx reqctx.RequestContext, entry *git.TreeEntry) template.HTML {
8993
if m.rules == nil {
9094
return BasicThemeIcon(entry)
@@ -102,14 +106,14 @@ func (m *MaterialIconProvider) FileIcon(ctx reqctx.RequestContext, entry *git.Tr
102106
if name == "folder" {
103107
// the material icon pack's "folder" icon doesn't look good, so use our built-in one
104108
// keep the old "octicon-xxx" class name to make some "theme plugin selector" could still work
105-
return svg.RenderHTML("material-folder-generic", 16, "octicon-file-directory-fill")
109+
return m.FolderIcon(ctx, false)
106110
}
107111
if iconSVG, ok := m.svgs[name]; ok && iconSVG != "" {
108112
// keep the old "octicon-xxx" class name to make some "theme plugin selector" could still work
109113
extraClass := "octicon-file"
110114
switch {
111115
case entry.IsDir():
112-
extraClass = "octicon-file-directory-fill"
116+
extraClass = BasicThemeFolderIconName(false)
113117
case entry.IsSubModule():
114118
extraClass = "octicon-file-submodule"
115119
}

modules/templates/util_render.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ func (ut *RenderUtils) RenderLabel(label *issues_model.Label) template.HTML {
181181
textColor, itemColor, itemHTML)
182182
}
183183

184+
func (ut *RenderUtils) RenderFolderIcon(isOpen bool) template.HTML {
185+
if setting.UI.FileIconTheme == "material" {
186+
return fileicon.DefaultMaterialIconProvider().FolderIcon(ut.ctx, isOpen)
187+
}
188+
return fileicon.BasicThemeFolderIcon(isOpen)
189+
}
190+
184191
func (ut *RenderUtils) RenderFileIcon(entry *git.TreeEntry) template.HTML {
185192
if setting.UI.FileIconTheme == "material" {
186193
return fileicon.DefaultMaterialIconProvider().FileIcon(ut.ctx, entry)

templates/admin/repo/unadopted.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<div class="ui aligned divided list">
2222
{{range $dirI, $dir := .Dirs}}
2323
<div class="item tw-flex tw-items-center">
24-
<span class="tw-flex-1"> {{svg "octicon-file-directory-fill"}} {{$dir}}</span>
24+
<span class="tw-flex-1"> {{ctx.RenderUtils.RenderFolderIcon false}} {{$dir}}</span>
2525
<div>
2626
<button class="ui button primary show-modal tw-p-2" data-modal="#adopt-unadopted-modal-{{$dirI}}">{{svg "octicon-plus"}} {{ctx.Locale.Tr "repo.adopt_preexisting_label"}}</button>
2727
<div class="ui g-modal-confirm modal" id="adopt-unadopted-modal-{{$dirI}}">

templates/repo/diff/box.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
const diffTreeIcon = `.octicon-sidebar-${diffTreeVisible ? 'expand' : 'collapse'}`;
1616
diffTreeBtn.querySelector(diffTreeIcon).classList.remove('tw-hidden');
1717
diffTreeBtn.setAttribute('data-tooltip-content', diffTreeBtn.getAttribute(diffTreeVisible ? 'data-hide-text' : 'data-show-text'));
18+
window.config.pageData.folderIcon = {{ctx.RenderUtils.RenderFolderIcon false}};
19+
window.config.pageData.openFolderIcon = {{ctx.RenderUtils.RenderFolderIcon true}};
1820
</script>
1921
{{end}}
2022
{{if not .DiffNotAvailable}}

templates/repo/view.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{{template "base/head" .}}
2+
<script type="module">
3+
window.config.pageData.folderIcon = {{ctx.RenderUtils.RenderFolderIcon false}};
4+
window.config.pageData.openFolderIcon = {{ctx.RenderUtils.RenderFolderIcon true}};
5+
</script>
26
<div role="main" aria-label="{{.Title}}" class="page-content repository file list {{if .IsBlame}}blame{{end}}">
37
{{template "repo/header" .}}
48
<div class="ui container {{if or .TreeNames .IsBlame}}fluid padded{{end}}">

templates/repo/view_list.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</div>
77
{{if .HasParentPath}}
88
<a class="repo-file-line parent-link silenced" href="{{.BranchLink}}{{if .ParentPath}}{{PathEscapeSegments .ParentPath}}{{end}}">
9-
{{svg "octicon-file-directory-fill"}} ..
9+
{{ctx.RenderUtils.RenderFolderIcon false}} ..
1010
</a>
1111
{{end}}
1212
{{range $item := .Files}}

templates/user/settings/repos.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<span><a href="{{$repo.BaseRepo.Link}}">{{$repo.BaseRepo.OwnerName}}/{{$repo.BaseRepo.Name}}</a></span>
3131
{{end}}
3232
{{else}}
33-
<span class="icon tw-inline-block tw-pt-2">{{svg "octicon-file-directory-fill"}}</span>
33+
<span class="icon tw-inline-block tw-pt-2">{{ctx.RenderUtils.RenderFolderIcon false}}</span>
3434
<span class="name tw-inline-block tw-pt-2">{{$.ContextUser.Name}}/{{$dir}}</span>
3535
<div class="tw-float-right">
3636
{{if $.allowAdopt}}

web_src/js/components/DiffFileTreeItem.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ defineProps<{
88
item: Item,
99
}>();
1010
11+
const {pageData} = window.config;
1112
const store = diffTreeStore();
1213
const collapsed = ref(false);
1314
@@ -44,10 +45,8 @@ function getIconForDiffStatus(pType: FileStatus) {
4445
<div class="item-directory" :title="item.name" @click.stop="collapsed = !collapsed">
4546
<!-- directory -->
4647
<SvgIcon :name="collapsed ? 'octicon-chevron-right' : 'octicon-chevron-down'"/>
47-
<SvgIcon
48-
class="text primary"
49-
:name="collapsed ? 'octicon-file-directory-fill' : 'octicon-file-directory-open-fill'"
50-
/>
48+
<span v-if="collapsed" class="item-icon" v-html="pageData.folderIcon"/>
49+
<span v-else class="item-icon" v-html="pageData.openFolderIcon"/>
5150
<span class="gt-ellipsis">{{ item.name }}</span>
5251
</div>
5352

@@ -89,6 +88,10 @@ a:hover {
8988
user-select: none;
9089
}
9190
91+
.item-directory .item-icon {
92+
display: contents;
93+
}
94+
9295
.item-file,
9396
.item-directory {
9497
display: flex;

web_src/js/components/ViewFileTreeItem.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ type Item = {
1111
children?: Item[];
1212
};
1313
14+
const {pageData} = window.config;
15+
1416
const props = defineProps<{
1517
item: Item,
1618
navigateViewContent:(treePath: string) => void,
@@ -83,7 +85,8 @@ onMounted(async () => {
8385
<SvgIcon v-else :name="collapsed ? 'octicon-chevron-right' : 'octicon-chevron-down'" @click.stop="doLoadChildren"/>
8486
</div>
8587
<div class="item-content">
86-
<SvgIcon v-if="isDirectory" class="text primary" :name="collapsed ? 'octicon-file-directory-fill' : 'octicon-file-directory-open-fill'"/>
88+
<span v-if="isDirectory && collapsed" class="item-icon" v-html="pageData.folderIcon"/>
89+
<span v-else-if="isDirectory && !collapsed" class="item-icon" v-html="pageData.openFolderIcon"/>
8790
<span v-else class="item-icon" v-html="item.fileIcon"/>
8891
<span class="gt-ellipsis tw-flex-1">{{ item.entryName }}</span>
8992
</div>

0 commit comments

Comments
 (0)