github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/docs/themes/hugo-theme-relearn/layouts/partials/shortcodes/tabs.html (about) 1 {{- $page := .page }} 2 {{- if and (not $page) .context }} 3 {{- $page = .context }} 4 {{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'tabs' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#5180" $page.File.Filename }} 5 {{- end }} 6 {{- $groupid := .groupid | default (partial "make-random-md5.hugo" $page) | plainify | anchorize }} 7 {{- $color := .color }} 8 {{- $style := .style }} 9 {{- $title := .title }} 10 {{- $icon := .icon }} 11 {{- $tabs := slice }} 12 {{- range $tab := (.content | default slice) }} 13 {{- if and (not $tab.title) $tab.name }} 14 {{- warnf "%q: DEPRECATED parameter 'name' for shortcode 'tab' found, use 'title' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#5160" $page.File.Filename }} 15 {{- $tab = merge $tab (dict "title" .name) }} 16 {{- end }} 17 {{- with $tab }} 18 {{- $color := .color | default $color | default "" }} 19 {{- $style := .style | default $style | default (cond (ne $color "") "filled" "initial") }} 20 {{- $title := .title }} 21 {{- if not $title }} 22 {{- if eq $style "info" }}{{ $title = $style | T }}{{ end }} 23 {{- if eq $style "warning" }}{{ $title = $style | T }}{{ end }} 24 {{- if eq $style "note" }}{{ $title = $style | T }}{{ end }} 25 {{- if eq $style "tip" }}{{ $title = $style | T }}{{ end }} 26 {{- end }} 27 {{- $title = trim $title " " }} 28 {{- $icon := .icon | default "" }} 29 {{- if and (not $icon) (eq (len $icon) 0) }} 30 {{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} 31 {{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} 32 {{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }} 33 {{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }} 34 {{- end }} 35 {{- $icon = trim $icon " " }} 36 {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} 37 {{- $icon = printf "fa-fw fas fa-%s" $icon }} 38 {{- end }} 39 {{- $tabs = $tabs | append (dict 40 "color" $color 41 "content" .content 42 "icon" $icon 43 "itemid" (printf "%s%s" ($title | $page.RenderString | plainify | anchorize) ($icon | plainify | anchorize)) 44 "style" $style 45 "title" $title 46 ) }} 47 {{- end }} 48 {{- end }} 49 {{- $color = .color | default "" }} 50 {{- $style = .style | default (cond (ne $color "") "filled" "initial") }} 51 {{- $title = .title }} 52 {{- if not $title }} 53 {{- if eq $style "info" }}{{ $title = $style | T }}{{ end }} 54 {{- if eq $style "warning" }}{{ $title = $style | T }}{{ end }} 55 {{- if eq $style "note" }}{{ $title = $style | T }}{{ end }} 56 {{- if eq $style "tip" }}{{ $title = $style | T }}{{ end }} 57 {{- end }} 58 {{- $title = trim $title " " }} 59 {{- $icon = .icon | default "" }} 60 {{- if and (not $icon) (eq (len $icon) 0) }} 61 {{- if eq $style "info" }}{{ $icon = default "info-circle" }}{{ end }} 62 {{- if eq $style "warning" }}{{ $icon = default "exclamation-triangle" }}{{ end }} 63 {{- if eq $style "note" }}{{ $icon = default "exclamation-circle" }}{{ end }} 64 {{- if eq $style "tip" }}{{ $icon = default "lightbulb" }}{{ end }} 65 {{- end }} 66 {{- $icon = trim $icon " " }} 67 {{- if and $icon (not (findRE ".*?\\bfa-\\w.*?" $icon)) }} 68 {{- $icon = printf "fa-fw fas fa-%s" $icon }} 69 {{- end }} 70 {{- with $page }} 71 <div class="tab-panel" data-tab-group="{{ $groupid }}"> 72 <div class="tab-nav"> 73 <div class="tab-nav-title">{{ if $icon }}<i class="{{ $icon }}"></i>{{ end }}{{ if and $icon $title }} {{ end }}{{ $title | $page.RenderString }}{{ if (not $title) }}​{{ end }}</div> 74 {{- range $idx, $tab := $tabs }} 75 <button 76 data-tab-item="{{ .itemid }}" 77 class="tab-nav-button tab-panel-style cstyle {{ .style }}{{ cond (eq $idx 0) " active" ""}}"{{ if .color }} style="--VARIABLE-BOX-color: {{ .color }};"{{ end }}{{ if eq $idx 0 }} tabindex="-1"{{ end }} 78 onclick="switchTab('{{ $groupid }}','{{ .itemid }}')" 79 > 80 <span class="tab-nav-text">{{ if .icon }}<i class="{{ .icon }}"></i>{{ end }}{{ if and .icon .title }} {{ end }}{{ .title | $page.RenderString }}{{ if (not .title) }}​{{ end }}</span> 81 </button> 82 {{- end }} 83 </div> 84 <div class="tab-content-container"> 85 {{- range $idx, $tab := $tabs }} 86 <div 87 data-tab-item="{{ .itemid }}" 88 class="tab-content tab-panel-style cstyle {{ .style }}{{ cond (eq $idx 0) " active" ""}}"{{ if .color }} style="--VARIABLE-BOX-color: {{ .color }};"{{ end }}> 89 <div class="tab-content-text"> 90 {{ if ne "<" (substr (strings.TrimLeft " \n\r\t" .content) 0 1) }}<p>{{ end }}<!-- we add a DOM element here if there is none to make collapsing marings work --> 91 {{ .content | safeHTML }}</div><!-- no line break allowed here because of awkward behavior of Hugo 110 or this theme when tag shortcode is called standalone outside of tags shortcode ? --> 92 </div> 93 {{- end }} 94 </div> 95 </div> 96 {{- end }}