@@ -62,7 +62,7 @@ func (m *MaterialIconProvider) loadData() {
62
62
log .Debug ("Loaded material icon rules and SVG images" )
63
63
}
64
64
65
- func (m * MaterialIconProvider ) renderFileIconSVG (ctx reqctx.RequestContext , name , svg string ) template.HTML {
65
+ func (m * MaterialIconProvider ) renderFileIconSVG (ctx reqctx.RequestContext , name , svg , extraClass string ) template.HTML {
66
66
data := ctx .GetData ()
67
67
renderedSVGs , _ := data ["_RenderedSVGs" ].(map [string ]bool )
68
68
if renderedSVGs == nil {
@@ -75,7 +75,7 @@ func (m *MaterialIconProvider) renderFileIconSVG(ctx reqctx.RequestContext, name
75
75
panic ("Invalid SVG icon" )
76
76
}
77
77
svgID := "svg-mfi-" + name
78
- svgCommonAttrs := `class="svg fileicon " width="16" height="16" aria-hidden="true"`
78
+ svgCommonAttrs := `class="svg git-entry-icon ` + extraClass + ` " width="16" height="16" aria-hidden="true"`
79
79
posOuterBefore := strings .IndexByte (svg , '>' )
80
80
if renderedSVGs [svgID ] && posOuterBefore != - 1 {
81
81
return template .HTML (`<svg ` + svgCommonAttrs + `><use xlink:href="#` + svgID + `"></use></svg>` )
@@ -92,18 +92,28 @@ func (m *MaterialIconProvider) FileIcon(ctx reqctx.RequestContext, entry *git.Tr
92
92
93
93
if entry .IsLink () {
94
94
if te , err := entry .FollowLink (); err == nil && te .IsDir () {
95
- return svg .RenderHTML ("material-folder-symlink" )
95
+ // keep the old "octicon-xxx" class name to make some "theme plugin selector" could still work
96
+ return svg .RenderHTML ("material-folder-symlink" , 16 , "octicon-file-directory-symlink" )
96
97
}
97
98
return svg .RenderHTML ("octicon-file-symlink-file" ) // TODO: find some better icons for them
98
99
}
99
100
100
101
name := m .findIconNameByGit (entry )
101
102
if name == "folder" {
102
103
// the material icon pack's "folder" icon doesn't look good, so use our built-in one
103
- return svg .RenderHTML ("material-folder-generic" )
104
+ // 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" )
104
106
}
105
107
if iconSVG , ok := m .svgs [name ]; ok && iconSVG != "" {
106
- return m .renderFileIconSVG (ctx , name , iconSVG )
108
+ // keep the old "octicon-xxx" class name to make some "theme plugin selector" could still work
109
+ extraClass := "octicon-file"
110
+ switch {
111
+ case entry .IsDir ():
112
+ extraClass = "octicon-file-directory-fill"
113
+ case entry .IsSubModule ():
114
+ extraClass = "octicon-file-submodule"
115
+ }
116
+ return m .renderFileIconSVG (ctx , name , iconSVG , extraClass )
107
117
}
108
118
return svg .RenderHTML ("octicon-file" )
109
119
}
0 commit comments