Revamped the theming system with new SCSS variables for consistent styling across light and dark themes. Replaced static color values with dynamic variables for maintainability and improved theme adaptability. Updated components and layouts to use the new variables. - Moved theme plugin logic for optimized handling of theme cookies and attributes. - Enhanced `useThemes` composable for simplified client-side updates and SSR support. - Replaced redundant SCSS color definitions with centralized variables. - Improved page structure by introducing `ui-title` for reusable section headers. - Unified transitions and border-radius for consistent design language. Breaking Changes: Theming system restructured—migrate to `$main`, `$primary`, and related variables for SCSS colors. Remove usage of `--color-*` variables in templates and styles.
143 lines
No EOL
3.1 KiB
Vue
143 lines
No EOL
3.1 KiB
Vue
<template>
|
|
<div class="switcher" ref="switcherRef">
|
|
<div
|
|
@click="setSwitcherVisible(!isSwitcherVisible)"
|
|
class="switcher__button"
|
|
:class="[{ active: isSwitcherVisible }]"
|
|
>
|
|
<client-only>
|
|
<!-- <icon name="fluent:globe-20-filled" size="20" />-->
|
|
<nuxt-img
|
|
format="webp"
|
|
densities="x1"
|
|
v-if="currentLocale"
|
|
:src="currentLocale.flag"
|
|
:alt="currentLocale.code"
|
|
/>
|
|
<!-- <skeletons-ui-language-switcher v-else />-->
|
|
<template #fallback>
|
|
<!-- <skeletons-ui-language-switcher />-->
|
|
</template>
|
|
</client-only>
|
|
</div>
|
|
<client-only>
|
|
<div
|
|
class="switcher__menu"
|
|
:class="[{active: isSwitcherVisible}]"
|
|
>
|
|
<div class="switcher__menu-wrapper">
|
|
<nuxt-img
|
|
class="switcher__menu-button"
|
|
v-for="locale of locales"
|
|
:key="locale.code"
|
|
format="webp"
|
|
densities="x1"
|
|
@click="uiSwitchLanguage(locale.code)"
|
|
:src="locale.flag"
|
|
:alt="locale.code"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</client-only>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import {onClickOutside} from '@vueuse/core';
|
|
import {useLanguageSwitch} from '@composables/languages';
|
|
|
|
const languageStore = useLanguageStore();
|
|
|
|
const locales = computed(() => languageStore.languages);
|
|
const currentLocale = computed(() => languageStore.currentLocale);
|
|
|
|
const isSwitcherVisible = ref<boolean>(false);
|
|
const setSwitcherVisible = (state: boolean) => {
|
|
isSwitcherVisible.value = state;
|
|
};
|
|
|
|
const switcherRef = ref(null);
|
|
onClickOutside(switcherRef, () => isSwitcherVisible.value = false);
|
|
|
|
const { switchLanguage } = useLanguageSwitch();
|
|
|
|
const uiSwitchLanguage = (localeCode: string) => {
|
|
switchLanguage(localeCode);
|
|
setSwitcherVisible(false);
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.switcher {
|
|
position: relative;
|
|
z-index: 1;
|
|
width: 44px;
|
|
flex-shrink: 0;
|
|
|
|
&__button {
|
|
width: 100%;
|
|
cursor: pointer;
|
|
display: flex;
|
|
gap: 5px;
|
|
padding: 5px;
|
|
border-radius: $less_border_radius;
|
|
|
|
@include hover {
|
|
background-color: $primary_shadow;
|
|
}
|
|
|
|
&.active {
|
|
background-color: $primary_shadow;
|
|
}
|
|
|
|
& img {
|
|
width: 100%;
|
|
}
|
|
}
|
|
|
|
&__menu {
|
|
position: absolute;
|
|
z-index: 3;
|
|
top: 110%;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
width: 100%;
|
|
overflow: hidden;
|
|
border-radius: $less_border_radius;
|
|
display: grid;
|
|
grid-template-rows: 0fr;
|
|
transition: grid-template-rows 0.2s ease;
|
|
|
|
&-wrapper {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
&.active {
|
|
grid-template-rows: 1fr;
|
|
}
|
|
|
|
& > * {
|
|
min-height: 0;
|
|
}
|
|
|
|
&-button {
|
|
width: 100%;
|
|
cursor: pointer;
|
|
padding: 3px 5px;
|
|
background-color: $link_secondary;
|
|
|
|
&:first-child {
|
|
padding-top: 5px;
|
|
}
|
|
&:last-child {
|
|
padding-bottom: 5px;
|
|
}
|
|
|
|
@include hover {
|
|
background-color: $link_secondary_hover;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style> |