Skip to content

Commit

Permalink
feat: add header and features in welcome, refactor: useLanguage compo…
Browse files Browse the repository at this point in the history
…sable
  • Loading branch information
mnenie committed Aug 13, 2024
1 parent 22b6d0c commit 80d53aa
Show file tree
Hide file tree
Showing 21 changed files with 410 additions and 89 deletions.
1 change: 1 addition & 0 deletions public/icons/github-d.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions public/icons/github-l.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/icons/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion src/app/providers/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,16 @@ const routes = [
}
},
{
name: '404',
name: RouteNames.welcome,
path: '/welcome',
component: () => import('@/pages/Home.vue'),
meta: {
layout: LayoutsEnum.welcome,
requiresAuth: true
}
},
{
name: RouteNames.error,
path: '/:pathMatch(.*)*',
component: () => import('@/pages/404.vue'),
meta: {
Expand Down
3 changes: 3 additions & 0 deletions src/features/kanban/ui/ChooseStatus.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ const activeStatus = computed(() => {
background-color: var(--zinc-600);
border: 1px solid var(--zinc-600);
}
.active {
border: 1px solid var(--zinc-300);
}
}
}
</style>
31 changes: 3 additions & 28 deletions src/features/settings/lang-switcher/ui/LanguageSwitcher.vue
Original file line number Diff line number Diff line change
@@ -1,42 +1,17 @@
<script setup lang="ts">
import { ref, shallowReactive } from 'vue';
import { useLanguage } from '@/shared/lib/composables';
import { UiSelect } from '@/shared/ui';
import { ref, shallowReactive, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useCookies } from '@vueuse/integrations/useCookies';
import type { Options } from '@/shared/ui/select/types';
const { locale } = useI18n();
const options = shallowReactive<Options[]>([
{ name: 'English', value: 'en-US' },
{ name: 'Русский', value: 'ru-RU' },
{ name: '简体中文', value: 'zh-CN' }
]);
const cookies = useCookies();
const language = ref('');
// TODO: think to way of computed property intead
watch(
() => locale.value,
() => {
const selectedOptionByValue = options.find((option) => option.value === locale.value);
selectedOptionByValue ? (language.value = selectedOptionByValue.name) : '';
watch(
() => language.value,
(name) => {
const selectedOptionByName = options.find((option) => option.name === name);
if (selectedOptionByName) {
locale.value = selectedOptionByName.value;
cookies.set('i18n', selectedOptionByName.value);
}
}
);
},
{ immediate: true }
);
useLanguage(options, language);
</script>

<template>
Expand Down
7 changes: 7 additions & 0 deletions src/pages/Home.vue
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>
1 change: 1 addition & 0 deletions src/shared/config/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ export enum RouteNames {
members = 'members',
templates = 'templates',
favorites = 'favorites',
welcome = 'welcome',
error = 'error'
}
1 change: 1 addition & 0 deletions src/shared/lib/composables/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './useLanguage';
40 changes: 40 additions & 0 deletions src/shared/lib/composables/useLanguage.ts
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();
});
}
7 changes: 7 additions & 0 deletions src/shared/lib/i18n/locales/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,12 @@ export default {
clear: 'Clear the board',
update: 'Apply changes'
}
},
welcome: {
header: {
links: ['About', 'Kanban', 'Members', 'Collaborative', 'Chats', 'Plans'],
login: 'Log In',
reg: 'Get started'
}
}
};
7 changes: 7 additions & 0 deletions src/shared/lib/i18n/locales/ru-RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,5 +182,12 @@ export default {
clear: 'Очистить доску',
update: 'Применить изменения'
}
},
welcome: {
header: {
links: ['О нас', 'Канбан', 'Участники', 'Совместная работа', 'Чаты', 'Планы'],
login: 'Войти',
reg: 'Зарегистрироваться'
}
}
};
7 changes: 7 additions & 0 deletions src/shared/lib/i18n/locales/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,5 +176,12 @@ export default {
clear: '清空看板',
update: '应用更改'
}
},
welcome: {
header: {
links: ['关于我们', '看板', '成员', '协作', '聊天', '计划'],
login: '登录',
reg: '注册'
}
}
};
2 changes: 1 addition & 1 deletion src/shared/ui/button/UiButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ withDefaults(
color: var(--zinc-100);
@include on-hover {
background-color: var(--zinc-700);
background-color: rgba(var(--zinc-rgb-600), 0.4);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/ui/dropdown/UiDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ defineSlots<{
</div>
<Transition name="dropdown">
<div v-if="isOpen" :class="$style.inside">
<div :class="$style.header">
<div v-if="$slots.header" :class="$style.header">
<slot name="header" />
</div>
<div :class="$style.content" @click="onDropdownContent">
Expand Down
Loading

0 comments on commit 80d53aa

Please sign in to comment.