Skip to content

Commit

Permalink
feat(toggle): add the alignment parameter: start, center or end
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Aug 28, 2023
1 parent df8a070 commit b3f51cd
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions layouts/partials/bootstrap/toggle.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,28 @@
{{- $name := "" }}
{{- $style := "tabs" }}
{{- $fill := true }}
{{- $alignment := "" }}
{{- if .IsNamedParams }}
{{- $name = .Get "name" }}
{{- with .Get "style" }}{{ $style = . }}{{ end }}
{{- with .Get "alignment" }}{{ $alignment = . }}{{ end }}
{{- if isset .Params "fill" }}{{ $fill = .Get "fill" }}{{ end }}
{{- else }}
{{- $name = .Get 0 }}
{{- with .Get 1 }}{{ $style = . }}{{ end }}
{{- end }}
{{- $items := .Page.Store.Get (printf "toggle-%s-items" $name) }}
{{- $items = sort $items "Weight" }}
{{- $classes := slice
"nav"
"mb-2"
(printf "nav-%s" $style)
}}
{{- if $fill }}{{ $classes = $classes | append "nav-fill" }}{{ end }}
{{- with $alignment }}{{ $classes = $classes | append (printf "justify-content-%s" .) }}{{ end }}
<div class="toggle mb-3">
<ul
class="nav nav-{{ $style }} mb-3{{ cond $fill ` nav-fill` `` }}"
class="{{ delimit $classes ` ` }}"
id="toggle-{{ $name }}"
role="tablist">
{{- range $i, $item := $items }}
Expand All @@ -39,7 +48,7 @@
{{- range $i, $item := $items }}
{{- $idPrefix := printf "toggle-%s-%s" $name .Id }}
<div
class="tab-pane fade{{ cond (eq $i 0) ` show active` `` }}"
class="tab-pane fade{{ cond (eq $i 0) ` show active` `` }}{{ cond (eq $alignment ``) `` (printf ` text-%s` $alignment) }}"
id="{{ $idPrefix }}-tab-pane"
role="tabpanel"
aria-labelledby="{{ $idPrefix }}-tab"
Expand Down

0 comments on commit b3f51cd

Please sign in to comment.