feat(tabs): support icon

This commit is contained in:
ZhenShuo Leo
2026-01-02 17:27:00 +08:00
parent b7dc7bc8a2
commit 2cac2bfe4a
2 changed files with 8 additions and 2 deletions

View File

@@ -1,7 +1,8 @@
{{- $label := .Get "label" -}}
{{- $icon := .Get "icon" -}}
{{- $index := .Parent.Store.Get "tab-index" | default 0 -}}
{{- $content := .InnerDeindent | strings.TrimSpace | .Page.RenderString -}}
{{- $tabs := .Parent.Store.Get "tabs" | default slice -}}
{{- .Parent.Store.Set "tabs" ($tabs | append (dict "label" $label "content" $content)) -}}
{{- .Parent.Store.Set "tabs" ($tabs | append (dict "label" $label "icon" $icon "content" $content)) -}}
{{- .Parent.Store.Set "tab-index" (add 1 $index) -}}

View File

@@ -13,7 +13,12 @@
role="tab"
aria-selected="{{ cond (eq $nTabs 0) "true" "false" }}"
data-tab-index="{{ $nTabs }}">
{{ index . "label" }}
<span class="flex items-center gap-1">
{{ with index . "icon" }}
{{ partial "icon.html" . }}
{{ end }}
{{ index . "label" }}
</span>
</button>
{{- end -}}
</div>