✨ show language select on start page
This commit is contained in:
2 files changed
+21
-20
No files matched your search
-19
@@ -1,28 +1,9 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
const { locale, locales, setLocale } = useI18n();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
class="min-h-screen bg-orange-50/40 text-stone-900 dark:bg-stone-950 dark:text-stone-100"
|
class="min-h-screen bg-orange-50/40 text-stone-900 dark:bg-stone-950 dark:text-stone-100"
|
||||||
>
|
>
|
||||||
<NuxtRouteAnnouncer />
|
<NuxtRouteAnnouncer />
|
||||||
<main class="mx-auto max-w-md px-4 py-8">
|
<main class="mx-auto max-w-md px-4 py-8">
|
||||||
<div class="mb-4 flex justify-end">
|
|
||||||
<select
|
|
||||||
:value="locale"
|
|
||||||
class="rounded-lg border border-stone-300 bg-white px-2 py-1 text-xs font-medium text-stone-600 shadow-sm dark:border-stone-700 dark:bg-stone-900 dark:text-stone-300"
|
|
||||||
@change="
|
|
||||||
setLocale(
|
|
||||||
($event.target as HTMLSelectElement).value as typeof locale,
|
|
||||||
)
|
|
||||||
"
|
|
||||||
>
|
|
||||||
<option v-for="loc in locales" :key="loc.code" :value="loc.code">
|
|
||||||
{{ loc.name }}
|
|
||||||
</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+21
-1
@@ -1,8 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
const { t } = useI18n();
|
const { t, locale, locales, setLocale } = useI18n();
|
||||||
const { name, setName } = useIdentity();
|
const { name, setName } = useIdentity();
|
||||||
const { pots: visitedPots } = useVisitedPots();
|
const { pots: visitedPots } = useVisitedPots();
|
||||||
|
|
||||||
|
const localeFlags: Record<string, string> = {
|
||||||
|
en: '🇬🇧',
|
||||||
|
de: '🇩🇪',
|
||||||
|
};
|
||||||
|
|
||||||
const potName = ref('');
|
const potName = ref('');
|
||||||
const currency = ref('EUR');
|
const currency = ref('EUR');
|
||||||
const creating = ref(false);
|
const creating = ref(false);
|
||||||
@@ -34,6 +39,21 @@ async function createPot() {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="space-y-8">
|
<div class="space-y-8">
|
||||||
|
<div class="flex justify-end gap-1">
|
||||||
|
<button
|
||||||
|
v-for="loc in locales"
|
||||||
|
:key="loc.code"
|
||||||
|
type="button"
|
||||||
|
class="rounded-lg px-1.5 py-1 text-lg leading-none transition-opacity"
|
||||||
|
:class="loc.code === locale ? 'opacity-100' : 'opacity-40 hover:opacity-70'"
|
||||||
|
:aria-label="loc.name"
|
||||||
|
:aria-current="loc.code === locale"
|
||||||
|
@click="setLocale(loc.code as typeof locale)"
|
||||||
|
>
|
||||||
|
{{ localeFlags[loc.code] ?? loc.code }}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="space-y-1 text-center">
|
<div class="space-y-1 text-center">
|
||||||
<div class="text-4xl">🍯</div>
|
<div class="text-4xl">🍯</div>
|
||||||
<h1 class="text-2xl font-bold text-stone-900 dark:text-stone-100">
|
<h1 class="text-2xl font-bold text-stone-900 dark:text-stone-100">
|
||||||
|
|||||||
Reference in new issue
Block a user