feat(landing): Change language switcher
This commit is contained in:
@@ -40,14 +40,22 @@
|
||||
/>
|
||||
|
||||
<template #right>
|
||||
<USelectMenu
|
||||
v-model="selectedLocale"
|
||||
:items="localeItems"
|
||||
class="w-[90px] sm:w-[100px]"
|
||||
:ui="{
|
||||
base: 'text-sm'
|
||||
<UDropdownMenu
|
||||
:items="localeMenuItems"
|
||||
:modal="false"
|
||||
:ui="{ content: 'min-w-32' }"
|
||||
:content="{
|
||||
align: 'end'
|
||||
}"
|
||||
/>
|
||||
>
|
||||
<UButton
|
||||
icon="i-lucide-globe"
|
||||
color="neutral"
|
||||
variant="ghost"
|
||||
:aria-label="$t('common.changeLanguage')"
|
||||
class="text-gray-600 dark:text-gray-300 hover:text-primary-600 dark:hover:text-primary-400"
|
||||
/>
|
||||
</UDropdownMenu>
|
||||
<UColorModeButton
|
||||
:ui="{
|
||||
base: 'text-gray-600 dark:text-gray-300 hover:text-primary-600 dark:hover:text-primary-400'
|
||||
@@ -176,28 +184,20 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { NavigationMenuItem } from '@nuxt/ui'
|
||||
import type { NavigationMenuItem, DropdownMenuItem } from '@nuxt/ui'
|
||||
|
||||
const { t, locale, locales, setLocale } = useI18n()
|
||||
|
||||
// Locale selector items
|
||||
const localeItems = computed(() =>
|
||||
// Locale dropdown menu items
|
||||
const localeMenuItems = computed<DropdownMenuItem[]>(() =>
|
||||
(locales.value as Array<{ code: string; name: string }>).map((l) => ({
|
||||
label: l.name,
|
||||
value: l.code
|
||||
icon: locale.value === l.code ? 'i-lucide-check' : undefined,
|
||||
active: locale.value === l.code,
|
||||
onSelect: () => setLocale(l.code as 'en' | 'de')
|
||||
}))
|
||||
)
|
||||
|
||||
// Selected locale for the dropdown
|
||||
const selectedLocale = computed({
|
||||
get: () => localeItems.value.find((l) => l.value === locale.value),
|
||||
set: (item) => {
|
||||
if (item) {
|
||||
setLocale(item.value as 'en' | 'de')
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Track scroll position for header styling
|
||||
const isScrolled = ref(false)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
},
|
||||
"common": {
|
||||
"skipToContent": "Zum Hauptinhalt springen",
|
||||
"changeLanguage": "Sprache ändern",
|
||||
"stayInformed": "Informiert bleiben",
|
||||
"learnMore": "Mehr erfahren",
|
||||
"contact": "Kontakt aufnehmen",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
},
|
||||
"common": {
|
||||
"skipToContent": "Skip to main content",
|
||||
"changeLanguage": "Change language",
|
||||
"stayInformed": "Stay informed",
|
||||
"learnMore": "Learn more",
|
||||
"contact": "Contact us",
|
||||
|
||||
Reference in New Issue
Block a user