mirror of
https://github.com/imfing/hextra.git
synced 2025-08-23 13:36:41 -04:00
feat(navbar): language switcher (#760)
* feat(navbar): language switcher * docs: add language-switch * chore: just for the demo * fix: drop conflicting CSS * fix: use constant * fix: pre-existing bug with rtl on mobile * docs: add comment to explain the algo * chore: more readable algo * review Co-authored-by: Xin <5097752+imfing@users.noreply.github.com> * feat: different icons * feat: icon as param * fix: inconsitency with rtl * fix: render inside the sidebar * chore: remove the demo --------- Co-authored-by: Xin <5097752+imfing@users.noreply.github.com>
This commit is contained in:

committed by
GitHub

parent
b2ff662c8e
commit
363b1e50ff
@@ -1,4 +1,9 @@
|
||||
{{- $page := .context -}}
|
||||
{{- $iconName := .iconName | default "globe-alt" -}}
|
||||
{{- $iconHeight := .iconHeight | default 12 -}}
|
||||
{{- $location := .location -}}
|
||||
|
||||
{{- $class := .class | default "hx:h-7 hx:px-2 hx:text-xs hx:text-gray-600 hx:transition-colors hx:dark:text-gray-400 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50" -}}
|
||||
|
||||
{{- $grow := .grow -}}
|
||||
{{- $hideLabel := .hideLabel | default false -}}
|
||||
@@ -10,12 +15,13 @@
|
||||
<button
|
||||
title="{{ $changeLanguage }}"
|
||||
data-state="closed"
|
||||
class="hextra-language-switcher hx:cursor-pointer 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 hx:dark:text-gray-400 hx:hover:bg-gray-100 hx:hover:text-gray-900 hx:dark:hover:bg-primary-100/5 hx:dark:hover:text-gray-50 hx:grow"
|
||||
data-location="{{ $location }}"
|
||||
class="hextra-language-switcher hx:cursor-pointer hx:rounded-md hx:text-left hx:font-medium {{ $class }} hx:grow"
|
||||
type="button"
|
||||
aria-label="{{ $changeLanguage }}"
|
||||
>
|
||||
<div class="hx:flex hx:items-center hx:gap-2 hx:capitalize">
|
||||
{{- partial "utils/icon" (dict "name" "globe-alt" "attributes" "height=12") -}}
|
||||
{{- partial "utils/icon" (dict "name" $iconName "attributes" (printf "height=%d" $iconHeight)) -}}
|
||||
{{- if not $hideLabel }}<span>{{ site.Language.LanguageName }}</span>{{ end -}}
|
||||
</div>
|
||||
</button>
|
||||
|
Reference in New Issue
Block a user