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'])
|
|
|
|
|
2021-09-17 00:18:50 +08:00
|
|
|
const { languageMap, langs, lang, switchLang, helpTranslate } = useTranslation()
|
|
|
|
|
|
|
|
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
|
|
|
|
type="text"
|
|
|
|
style="width: 100%; color: var(--text-color)"
|
2021-09-23 14:16:37 +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 }"
|
2021-09-23 14:16:37 +08:00
|
|
|
class="translation-item"
|
2021-10-22 14:50:30 +08:00
|
|
|
@click="onSwitchLang(l)"
|
2021-09-17 00:18:50 +08:00
|
|
|
>
|
|
|
|
{{ languageMap[l] }}
|
|
|
|
</p>
|
|
|
|
<p class="translation-item">
|
|
|
|
<VPLink href="https://crowdin.com/project/element-plus">
|
|
|
|
{{ helpTranslate }}
|
|
|
|
</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>
|