github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/docs/themes/hugo-theme-relearn/layouts/partials/topbar/func/button.html (about) 1 {{- $page := .page }} 2 {{- $class := .class | default "" }} 3 {{- $href := (trim .href " ") | default "" }} 4 {{- $onempty := cond (isset . "onempty") .onempty "disable" }} 5 {{- $onwidths := cond (isset . "onwidths") .onwidths "show" }} 6 {{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }} 7 {{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }} 8 {{- $target := .target | default "" }} 9 {{- $type := .type | default "" }} 10 {{- $isDisabled := not $href }} 11 {{- $isButton := false }} 12 {{- if or (not $href) (strings.HasPrefix $href "javascript:") }} 13 {{- $isButton = true }} 14 {{- $href = substr $href (len "javascript:") }} 15 {{- if not $type }} 16 {{- $type = "button" }} 17 {{- end }} 18 {{- else if and (eq (len $target) 0) (or (strings.HasPrefix $href "http://") (strings.HasPrefix $href "https://") ) }} 19 {{- $target = "_blank" }} 20 {{- if isset $page.Site.Params "externallinktarget" }} 21 {{- $target = $page.Site.Params.externalLinkTarget }} 22 {{- end }} 23 {{- end }} 24 {{- $title := (trim .title " ") | default "" }} 25 {{- $hint := (trim .hint " ") | default "" }} 26 {{- $icon := (trim .icon " ") | default "" }} 27 {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} 28 {{- $icon = printf "fa-fw fas fa-%s" $icon }} 29 {{- end }} 30 {{- $content := .content }} 31 <div class="topbar-button {{ $class }}" data-content-empty="{{ $onempty }}" data-width-s="{{ $onwidths }}" data-width-m="{{ $onwidthm }}" data-width-l="{{ $onwidthl }}"> 32 {{- if $isDisabled -}} 33 <span class="topbar-control"> 34 {{- else if $isButton -}} 35 <button class="topbar-control"{{ if $href }} onclick="{{ $href | safeJS }}"{{ end }}{{ if gt (len $type) 0 }} type="{{ $type }}"{{ end }} title="{{ $hint }}"> 36 {{- else -}} 37 <a class="topbar-control"{{ if $href }} href="{{ $href }}"{{ if gt (len $target) 0 }} target="{{ $target }}"{{ end }}{{ end }} title="{{ $hint }}"> 38 {{- end }} 39 {{- if and $icon }}<i class="{{ $icon }}"></i>{{ end }} 40 {{- if and $icon $title }} {{ end }} 41 {{- if $title }}<span class="title">{{- $title | safeHTML }}</span>{{ end }} 42 {{- if $isDisabled -}} 43 </span> 44 {{- else if $isButton -}} 45 </button> 46 {{- else -}} 47 </a> 48 {{- end }} 49 {{- if $content }} 50 <div class="topbar-content"> 51 <div class="topbar-content-wrapper"> 52 {{- $content }} 53 </div> 54 </div> 55 {{- end }} 56 </div>