1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| {% import ( "fmt" "strings"
"{{{ .Package }}}/app" "{{{ .Package }}}/app/controller/cutil"{{{ if .HasModule "brands" }}} "{{{ .Package }}}/app/lib/icons"{{{ end }}} "{{{ .Package }}}/app/util" ) %}
{% func SVG(k string) %}{% stripspace %}{{{ if .HasModule "brands" }}} {% if strings.HasPrefix(k, "brand-") %} {%s= icons.BrandLibrary().HTML(k) %} {% else %}{{{ end }}} {% if svg, ok := util.SVGLibrary[k]; ok %} {%s= svg %} {% else %} <!-- missing icon definition for [{%s k %}], using default icon -->{%s= strings.ReplaceAll(util.SVGLibrary["question"], "-question", "-"+k) %} {% endif %}{{{ if .HasModule "brands" }}} {% endif %}{{{ end }}} {% endstripspace %}{% endfunc %}
{% func SVGRef(k string, w int, h int, cls string, ps *cutil.PageState) %}{% stripspace %} {% if k != "" %} {% code ps.AddIcon(k) if w == 0 { w = 20 } if h == 0 { h = 20 } style := fmt.Sprintf("width: %dpx; height: %dpx;", w, h) %} {% if cls == "" %} <svg style="{%s style %}"><use xlink:href="#svg-{%s k %}" /></svg> {% else %} <svg class="{%s cls %}" style="{%s style %}"><use xlink:href="#svg-{%s k %}" /></svg> {% endif %} {% endif %} {% endstripspace %}{% endfunc %}
{% func Icon(k string, size int, cls string, ps *cutil.PageState) %}{% stripspace %} {% if strings.Contains(k, "/") %} <img alt="SVG icon [{%s k %}]" src="{%s k %}" style="width: {%d size %}px; height: {%d size %}px;" /> {% else %} {%= SVGRef(k, size, size, cls, ps) %} {% endif %} {% endstripspace %}{% endfunc %}
{% func SVGSimple(k string, size int, ps *cutil.PageState) %}{% stripspace %} {%= SVGRef(k, size, size, "", ps) %} {% endstripspace %}{% endfunc %}
{% func SVGButton(k string, ps *cutil.PageState) %}{% stripspace %} {%= SVGRef(k, 14, 14, "icon", ps) %} {% endstripspace %}{% endfunc %}
{% func SVGIcon(k string, ps *cutil.PageState) %}{% stripspace %} {%= SVGRef(k, 18, 18, "icon", ps) %} {% endstripspace %}{% endfunc %}
{% func SVGBreadcrumb(k string, ps *cutil.PageState) %}{% stripspace %} {%= SVGRef(k, 18, 18, "breadcrumb-icon", ps) %} {% endstripspace %}{% endfunc %}
{% func SVGInline(k string, size int, ps *cutil.PageState) %}{% stripspace %} {%= SVGRef(k, size, size, "inline", ps) %} {% endstripspace %}{% endfunc %}
{% func SVGLink(k string, ps *cutil.PageState) %}{% stripspace %} {%= SVGRef(k, 18, 18, "link", ps) %} {% endstripspace %}{% endfunc %}
{% func SVGLinkPadded(k string, ps *cutil.PageState) %}{% stripspace %} {%= SVGRef(k, 18, 18, "link padded", ps) %} {% endstripspace %}{% endfunc %}
{%- func IconGallery(as *app.State, ps *cutil.PageState) -%} <div class="flex-wrap mt"> {%- for _, k := range util.SVGIconKeys -%} <div class="icon-gallery-icon"> <div class="gallery-svg">{%= SVGRef(k, 64, 64, "icon", ps) %}</div> <div class="gallery-title">{%s k %}</div> </div> {%- endfor -%} </div> {%- endfunc -%}
|