2021-09-17 00:18:50 +08:00
|
|
|
<script setup lang="ts">
|
2022-02-21 21:36:34 +08:00
|
|
|
import { useToggle } from '@vueuse/core'
|
2021-09-17 00:18:50 +08:00
|
|
|
import VPLink from '../common/vp-link.vue'
|
|
|
|
import { useTranslation } from '../../composables/translation'
|
|
|
|
import ExpandIcon from '../icons/expand.vue'
|
|
|
|
|
2021-10-22 14:50:30 +08:00
|
|
|
const emit = defineEmits(['close'])
|
|
|
|
|
2023-03-10 14:43:22 +08:00
|
|
|
const { languageMap, langs, lang, switchLang, locale } = useTranslation()
|
2021-09-17 00:18:50 +08:00
|
|
|
|
|
|
|
const [show, toggle] = useToggle()
|
2021-10-22 14:50:30 +08:00
|
|
|
|
|
|
|
const onSwitchLang = (lang: string) => {
|
|
|
|
switchLang(lang)
|
|
|
|
emit('close')
|
|
|
|
}
|
2021-09-17 00:18:50 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="full-screen-translation">
|
|
|
|
<ElButton
|
2023-03-10 14:43:22 +08:00
|
|
|
:aria-label="locale.language"
|
|
|
|
:aria-expanded="show"
|
|
|
|
aria-controls="translation-items"
|
2021-09-17 00:18:50 +08:00
|
|
|
style="width: 100%; color: var(--text-color)"
|
2022-05-14 12:58:09 +08:00
|
|
|
text
|
2023-03-10 14:43:22 +08:00
|
|
|
@click="toggle()"
|
2021-09-17 00:18:50 +08:00
|
|
|
>
|
|
|
|
<div class="translation-toggler">
|
|
|
|
<span> Translations </span>
|
|
|
|
<ElIcon :size="14">
|
|
|
|
<ExpandIcon class="toggle-icon" :class="{ expanded: show }" />
|
|
|
|
</ElIcon>
|
|
|
|
</div>
|
|
|
|
</ElButton>
|
|
|
|
<div v-show="show" class="translation-items">
|
|
|
|
<p
|
2021-10-22 14:50:30 +08:00
|
|
|
v-for="l in langs"
|
2021-09-23 14:16:37 +08:00
|
|
|
:key="l"
|
2021-09-17 00:18:50 +08:00
|
|
|
:class="{ active: l === lang }"
|
2023-03-10 14:43:22 +08:00
|
|
|
tabindex="0"
|
|
|
|
role="link"
|
2021-09-23 14:16:37 +08:00
|
|
|
class="translation-item"
|
2021-10-22 14:50:30 +08:00
|
|
|
@click="onSwitchLang(l)"
|
2023-03-10 14:43:22 +08:00
|
|
|
@keydown.prevent.enter="onSwitchLang(l)"
|
|
|
|
@keydown.prevent.space="onSwitchLang(l)"
|
2021-09-17 00:18:50 +08:00
|
|
|
>
|
|
|
|
{{ languageMap[l] }}
|
|
|
|
</p>
|
|
|
|
<p class="translation-item">
|
2022-09-11 14:36:50 +08:00
|
|
|
<VPLink :href="`/${lang}/guide/translation`">
|
2023-03-10 14:43:22 +08:00
|
|
|
{{ locale.help }}
|
2021-09-17 00:18:50 +08:00
|
|
|
</VPLink>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.full-screen-translation {
|
|
|
|
border-bottom: 1px solid var(--border-color);
|
|
|
|
}
|
|
|
|
.translation-toggler {
|
|
|
|
width: 100%;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
line-height: 24px;
|
|
|
|
.toggle-icon {
|
|
|
|
transition: transform var(--el-transition-duration);
|
|
|
|
transform: rotate(180deg);
|
|
|
|
|
|
|
|
&.expanded {
|
|
|
|
transform: rotate(0deg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.translation-items {
|
|
|
|
padding-bottom: 12px;
|
|
|
|
.translation-item {
|
|
|
|
cursor: pointer;
|
|
|
|
margin: 0;
|
|
|
|
font-size: 14px;
|
|
|
|
line-height: 32px;
|
|
|
|
|
|
|
|
&.active {
|
|
|
|
font-weight: 500;
|
|
|
|
color: var(--brand-color);
|
|
|
|
}
|
|
|
|
|
|
|
|
.link-item {
|
|
|
|
font-weight: 500;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|