LanguageSelector.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <v-select
  3. v-model="locale"
  4. :items="items"
  5. :key="`locale-${locale}`"
  6. density="compact"
  7. variant="plain"
  8. :hide-details="true"
  9. >
  10. <template v-slot:selection="data">
  11. <v-img :src="data.item.raw.logo" left :width="16" class="mr-2"/>
  12. <span>{{ data.item.title }}</span>
  13. </template>
  14. <template v-slot:item="{ props, item }">
  15. <v-list-item v-bind="props">
  16. <template v-slot:prepend>
  17. <v-img :src="item.raw.logo" :width="16" class="mr-2"/>
  18. </template>
  19. </v-list-item>
  20. </template>
  21. </v-select>
  22. </template>
  23. <script setup lang="ts">
  24. const items = [
  25. { value: 'fr', title: 'FR', logo: '/images/logos/french_flag.svg' },
  26. { value: 'en', title: 'EN', logo: '/images/logos/us-uk_flag.svg' },
  27. ]
  28. const { setLocale } = useI18n()
  29. const locale = ref('fr')
  30. watch(locale, () => {
  31. setLocale(locale.value)
  32. });
  33. </script>
  34. <style scoped lang="scss">
  35. :deep(.v-field__input) {
  36. padding: 0;
  37. }
  38. :deep(.v-field__append-inner) {
  39. padding-top: 3px !important;
  40. }
  41. :deep(.v-select__menu-icon) {
  42. font-size: 13px;
  43. margin-top: 8px;
  44. }
  45. :deep(.v-list) {
  46. width: 72px;
  47. }
  48. :deep(.v-list-item) {
  49. padding: 24px;
  50. }
  51. :deep(.v-list-item__content) {
  52. display: flex;
  53. flex-direction: row;
  54. .v-avatar {
  55. width: 18px;
  56. height: 18px;
  57. }
  58. }
  59. </style>