Added logic for font size in theme toggle when in navbar.

This commit is contained in:
Jason A. Dour 2024-11-17 17:34:13 -05:00
parent 5c0698c3c0
commit da56d153aa
No known key found for this signature in database
GPG Key ID: 486487B5A49FA0A9

View File

@ -1,6 +1,10 @@
{{- $navbar := .navbar | default false -}}
{{- $height := 12 -}}
{{- if $navbar -}}{{- $height = 24 -}}{{- end -}}
{{- $height_px := 12 -}}
{{- $height_tw := "hx-text-xs" -}}
{{- if $navbar -}}
{{- $height_px = 24 -}}
{{- $height_tw = "hx-text-sm" -}}
{{- end -}}
{{- $hideLabel := .hideLabel | default false -}}
{{- $changeTheme := (T "changeTheme") | default "Change theme" -}}
@ -11,14 +15,14 @@
<button
title="{{ $changeTheme }}"
data-theme="light"
class="theme-toggle hx-group hx-h-7 hx-rounded-md hx-px-2 hx-text-left hx-text-xs hx-font-medium hx-text-gray-600 hx-transition-colors dark:hx-text-gray-400 hover:hx-bg-gray-100 hover:hx-text-gray-900 dark:hover:hx-bg-primary-100/5 dark:hover:hx-text-gray-50"
class="theme-toggle hx-group hx-h-7 hx-rounded-md hx-px-2 hx-text-left {{ $height_tw }} hx-font-medium hx-text-gray-600 hx-transition-colors dark:hx-text-gray-400 hover:hx-bg-gray-100 hover:hx-text-gray-900 dark:hover:hx-bg-primary-100/5 dark:hover:hx-text-gray-50"
type="button"
aria-label="{{ $changeTheme }}"
>
<div class="hx-flex hx-items-center hx-gap-2 hx-capitalize">
{{- partial "utils/icon.html" (dict "name" "sun" "attributes" (printf "height=%d class=\"group-data-[theme=light]:hx-hidden\"" $height)) -}}
{{- partial "utils/icon.html" (dict "name" "sun" "attributes" (printf "height=%d class=\"group-data-[theme=light]:hx-hidden\"" $height_px)) -}}
{{- if not $hideLabel }}<span class="group-data-[theme=light]:hx-hidden">{{ $light }}</span>{{ end -}}
{{- partial "utils/icon.html" (dict "name" "moon" "attributes" (printf "height=%d class=\"group-data-[theme=dark]:hx-hidden\"" $height)) -}}
{{- partial "utils/icon.html" (dict "name" "moon" "attributes" (printf "height=%d class=\"group-data-[theme=dark]:hx-hidden\"" $height_px)) -}}
{{- if not $hideLabel }}<span class="group-data-[theme=dark]:hx-hidden">{{ $dark }}</span>{{ end -}}
</div>
</button>