diff --git a/.stylelintrc b/.stylelintrc index 0e1b38228f..427d89b5bc 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -5,6 +5,7 @@ rules: block-closing-brace-empty-line-before: null color-hex-length: null comment-empty-line-before: null + declaration-block-single-line-max-declarations: null declaration-empty-line-before: null indentation: 2 no-descending-specificity: null diff --git a/modules/templates/helper.go b/modules/templates/helper.go index f86287f10b..c5526b3dea 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -468,13 +468,23 @@ func NewTextFuncMap() []texttmpl.FuncMap { var widthRe = regexp.MustCompile(`width="[0-9]+?"`) var heightRe = regexp.MustCompile(`height="[0-9]+?"`) -// SVG render icons -func SVG(icon string, size int) template.HTML { +// SVG render icons - arguments icon name (string), size (int), class (string) +func SVG(icon string, others ...interface{}) template.HTML { + var size = others[0].(int) + + class := "" + if len(others) > 1 && others[1].(string) != "" { + class = others[1].(string) + } + if svgStr, ok := svg.SVGs[icon]; ok { if size != 16 { svgStr = widthRe.ReplaceAllString(svgStr, fmt.Sprintf(`width="%d"`, size)) svgStr = heightRe.ReplaceAllString(svgStr, fmt.Sprintf(`height="%d"`, size)) } + if class != "" { + svgStr = strings.Replace(svgStr, `class="`, fmt.Sprintf(`class="%s `, class), 1) + } return template.HTML(svgStr) } return template.HTML("") diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index 782331aad7..26f66d2cb5 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -1,12 +1,8 @@