congo/layouts/partials/translations.html

61 lines
2.5 KiB
HTML
Raw Normal View History

{{- $ctx := "" -}}
{{- $dir := default "down" -}}
{{- if (reflect.IsMap . ) -}}
{{- $ctx = .ctx -}}
{{- $dir = cond (not .dir) nil .dir -}}
{{- else -}}
{{- $ctx = . -}}
{{- end -}}
{{ with page }}
{{ if .IsTranslated }}
{{ $currentLang := .Page.Lang }}
{{ if site.IsMultiLingual }}
2023-12-26 00:56:32 +00:00
<div class="group relative">
<button
2023-12-26 00:56:32 +00:00
class="group-dark:hover:text-primary-400 flex w-full items-center justify-end transition-colors group-hover:text-primary-600"
>
{{ partial "icon.html" "translate" }}<span class="text-sm">{{ .Lang | upper }}</span
><span class="text-[0.6rem]"
>{{ partial "icon.html" (cond (eq $dir "down") "chevron-down" "chevron-up") }}</span
>
</button>
{{ if eq $dir "down" }}
<div class="invisible w-full bg-transparent group-hover:visible"></div>
{{ end }}
<div
2023-12-26 00:56:32 +00:00
class="{{ cond (eq $dir "down") "top-8" "bottom-7" }} invisible absolute z-50 flex flex-col whitespace-nowrap rounded border border-neutral-300 bg-neutral text-start text-base shadow group-hover:visible ltr:right-0 rtl:left-0 dark:border-neutral-600 dark:bg-neutral-800"
>
{{ $siteLanguages := site.Languages }}
{{ $pageLang := .Page.Lang }}
{{ range .Page.AllTranslations }}
{{ $translation := . }}
{{ range $siteLanguages }}
{{ if eq $translation.Lang .Lang }}
{{ $selected := false }}
<div class="flex flex-grow">
{{ if eq $pageLang .Lang }}
<a
href="{{ $translation.RelPermalink }}"
2023-12-26 00:56:32 +00:00
class="flex w-full items-center justify-between bg-primary-100 px-2 py-1 dark:bg-primary-900"
>{{ .LanguageName }}<span
2023-12-26 00:56:32 +00:00
class="ms-2 w-6 text-primary-600 dark:text-primary-400"
>{{ partial "icon.html" "check" }}</span
></a
>
{{ else }}
<a
href="{{ $translation.RelPermalink }}"
class="w-full py-1 pe-10 ps-2 decoration-primary-500 hover:underline hover:decoration-2 hover:underline-offset-2"
>{{ .LanguageName }}</a
>
{{ end }}
</div>
{{ end }}
{{ end }}
{{ end }}
</div>
</div>
2022-01-11 01:00:27 +00:00
{{ end }}
{{ end }}
2022-01-11 01:00:27 +00:00
{{ end }}