-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add header and features in welcome, refactor: useLanguage compo…
…sable
- Loading branch information
Showing
21 changed files
with
410 additions
and
89 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 3 additions & 28 deletions
31
src/features/settings/lang-switcher/ui/LanguageSwitcher.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<script setup lang="ts"> | ||
import { HeaderWelcome } from '@/widgets/layout'; | ||
</script> | ||
|
||
<template> | ||
<HeaderWelcome /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './useLanguage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { effectScope, onUnmounted, watch } from 'vue'; | ||
import type { Ref } from 'vue'; | ||
import type { Options } from '@/shared/ui/select/types'; | ||
import { useCookies } from '@vueuse/integrations/useCookies'; | ||
import { useI18n } from 'vue-i18n'; | ||
|
||
export function useLanguage(options: Options[], language: Ref<string>) { | ||
const scope = effectScope(); | ||
|
||
const cookies = useCookies(); | ||
const { locale } = useI18n(); | ||
|
||
scope.run(() => { | ||
// TODO: think to way of computed property instead | ||
// So anyway the problem in nested watchers is solved, issue #11 | ||
watch( | ||
() => locale.value, | ||
(newLocale) => { | ||
const selectedOption = options.find((option) => option.value === newLocale); | ||
if (selectedOption) { | ||
language.value = selectedOption.name; | ||
} | ||
}, | ||
{ immediate: true } | ||
); | ||
watch( | ||
() => language.value, | ||
(newLanguage) => { | ||
const selectedOption = options.find((option) => option.name === newLanguage); | ||
if (selectedOption) { | ||
locale.value = selectedOption.value; | ||
cookies.set('i18n', selectedOption.value); | ||
} | ||
} | ||
); | ||
}); | ||
onUnmounted(() => { | ||
scope.stop(); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.