Fix icon size in navbar theme toggle.

- Add navbar boolean to theme-toggle partial arguments.
- Add logic in theme-toggle to set icon size based on navbar boolean.
This commit is contained in:
Jason A. Dour 2024-11-16 18:34:30 -05:00
parent ebdaf0fd4a
commit 5c0698c3c0
No known key found for this signature in database
GPG Key ID: 486487B5A49FA0A9
2 changed files with 6 additions and 3 deletions

View File

@ -32,7 +32,7 @@
{{- if eq .Params.type "search" -}} {{- if eq .Params.type "search" -}}
{{- partial "search.html" (dict "params" .Params) -}} {{- partial "search.html" (dict "params" .Params) -}}
{{- else if eq .Params.type "theme-toggle" -}} {{- else if eq .Params.type "theme-toggle" -}}
{{- partial "theme-toggle.html" (dict "hideLabel" (.Params.hideLabel | default true)) -}} {{- partial "theme-toggle.html" (dict "navbar" true "hideLabel" (.Params.hideLabel | default true)) -}}
{{- else -}} {{- else -}}
{{- $link := .URL -}} {{- $link := .URL -}}
{{- $external := strings.HasPrefix $link "http" -}} {{- $external := strings.HasPrefix $link "http" -}}

View File

@ -1,3 +1,6 @@
{{- $navbar := .navbar | default false -}}
{{- $height := 12 -}}
{{- if $navbar -}}{{- $height = 24 -}}{{- end -}}
{{- $hideLabel := .hideLabel | default false -}} {{- $hideLabel := .hideLabel | default false -}}
{{- $changeTheme := (T "changeTheme") | default "Change theme" -}} {{- $changeTheme := (T "changeTheme") | default "Change theme" -}}
@ -13,9 +16,9 @@
aria-label="{{ $changeTheme }}" aria-label="{{ $changeTheme }}"
> >
<div class="hx-flex hx-items-center hx-gap-2 hx-capitalize"> <div class="hx-flex hx-items-center hx-gap-2 hx-capitalize">
{{- partial "utils/icon.html" (dict "name" "sun" "attributes" "height=12 class=\"group-data-[theme=light]:hx-hidden\"") -}} {{- partial "utils/icon.html" (dict "name" "sun" "attributes" (printf "height=%d class=\"group-data-[theme=light]:hx-hidden\"" $height)) -}}
{{- if not $hideLabel }}<span class="group-data-[theme=light]:hx-hidden">{{ $light }}</span>{{ end -}} {{- if not $hideLabel }}<span class="group-data-[theme=light]:hx-hidden">{{ $light }}</span>{{ end -}}
{{- partial "utils/icon.html" (dict "name" "moon" "attributes" "height=12 class=\"group-data-[theme=dark]:hx-hidden\"") -}} {{- partial "utils/icon.html" (dict "name" "moon" "attributes" (printf "height=%d class=\"group-data-[theme=dark]:hx-hidden\"" $height)) -}}
{{- if not $hideLabel }}<span class="group-data-[theme=dark]:hx-hidden">{{ $dark }}</span>{{ end -}} {{- if not $hideLabel }}<span class="group-data-[theme=dark]:hx-hidden">{{ $dark }}</span>{{ end -}}
</div> </div>
</button> </button>