Skip to content

Commit 3de0bcc

Browse files
authored
Language switcher in login and register (#22)
1 parent 6d3e7aa commit 3de0bcc

3 files changed

Lines changed: 44 additions & 2 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<template>
2+
<div class="flex items-center gap-1">
3+
<button
4+
v-for="lang in availableLangs"
5+
:key="lang.code"
6+
@click="select(lang)"
7+
class="w-8 h-8 flex items-center justify-center rounded-full text-base transition-all cursor-pointer"
8+
:class="current === lang.code
9+
? 'bg-white/15 ring-1 ring-white/30 scale-110'
10+
: 'hover:bg-white/10 opacity-60 hover:opacity-100'"
11+
:aria-label="lang.name"
12+
:title="lang.name"
13+
>
14+
{{ lang.flag }}
15+
</button>
16+
</div>
17+
</template>
18+
19+
<script setup lang="ts">
20+
import { computed } from 'vue'
21+
import { useI18n } from 'vue-i18n'
22+
import { mainLanguages } from '@/locales'
23+
import { setLocale } from '@/plugins/i18n'
24+
import type { Language, Locale } from '@billsplit/types'
25+
26+
const { locale } = useI18n()
27+
28+
const availableLangs = computed(() => mainLanguages.filter(l => l.available))
29+
const current = computed(() => locale.value)
30+
31+
const select = (lang: Language) => {
32+
setLocale(lang.code as Locale)
33+
}
34+
</script>

apps/web/src/views/sign-in.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
2-
<div class="min-h-screen bg-black flex items-center justify-center px-4 py-8">
2+
<div class="min-h-screen bg-black flex items-center justify-center px-4 py-8 relative">
3+
<div class="absolute top-4 right-4">
4+
<LanguagePills />
5+
</div>
36
<div class="w-full max-w-lg">
47
<!-- Logo y título -->
58
<HeaderAuth :welcome-title="t('auth.welcomeTitle')" :welcome-subtitle="t('auth.welcomeSubtitle')" />
@@ -271,6 +274,7 @@ import { useAuthStore } from '@/stores/auth.store'
271274
import { useI18n } from 'vue-i18n'
272275
import { redirectTo } from '@/utils'
273276
import HeaderAuth from '@/components/auth/HeaderAuth.vue'
277+
import LanguagePills from '@/components/auth/LanguagePills.vue'
274278
import ErrorSuccessMessage from '@/components/auth/ErrorSuccessMessage.vue'
275279
import Divider from '@/components/auth/Divider.vue'
276280
import TC from '@/components/auth/TC.vue'

apps/web/src/views/sign-up.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
2-
<div class="min-h-screen bg-black flex items-center justify-center px-4 py-8">
2+
<div class="min-h-screen bg-black flex items-center justify-center px-4 py-8 relative">
3+
<div class="absolute top-4 right-4">
4+
<LanguagePills />
5+
</div>
36
<div class="w-full max-w-lg">
47
<HeaderAuth :welcome-title="t('auth.welcomeTitle')" :welcome-subtitle="t('auth.welcomeSubtitle')" />
58

@@ -231,6 +234,7 @@ import { useAuthStore } from '@/stores/auth.store'
231234
import { useAuth } from '@/composables/useAuth'
232235
import { useI18n } from 'vue-i18n'
233236
import HeaderAuth from '@/components/auth/HeaderAuth.vue'
237+
import LanguagePills from '@/components/auth/LanguagePills.vue'
234238
import ErrorSuccessMessage from '@/components/auth/ErrorSuccessMessage.vue'
235239
import Divider from '@/components/auth/Divider.vue'
236240
import TC from '@/components/auth/TC.vue'

0 commit comments

Comments
 (0)