chore: include logic for mobile

userquin/feat-add-external-translation-repo-links
userquin 1 year ago
parent 6884837907
commit 5c82a01203

@ -1,12 +1,12 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue' import { computed, ref } from 'vue'
import { useLangs } from '../composables/langs' import { useLangs } from '../composables/langs'
import VPLink from './VPLink.vue' import VPLink from './VPLink.vue'
import VPSocialLink from "./VPSocialLink.vue";
const { localeLinks, currentLang } = useLangs({ correspondingLink: true }) const { localeLinks, currentLang } = useLangs({ correspondingLink: true })
const isOpen = ref(false) const isOpen = ref(false)
// for helping translate const repo = computed(() => !!currentLang.value.repo || (localeLinks.value.length > 1 && localeLinks.value.some(l => !!l.repo)))
// const repoLink = computed(() => currentLang.value.repo || (localeLinks.value.length > 1 && localeLinks.value.some(l => !!l.repo)))
function toggle() { function toggle() {
isOpen.value = !isOpen.value isOpen.value = !isOpen.value
@ -17,17 +17,26 @@ function toggle() {
<div <div
v-if="localeLinks.length && currentLang.label" v-if="localeLinks.length && currentLang.label"
class="VPNavScreenTranslations" class="VPNavScreenTranslations"
:class="{ open: isOpen }" :class="{ open: isOpen, repo }"
> >
<button class="title" @click="toggle"> <button class="title" :class="{ repo: !!currentLang.repo }" @click="toggle">
<span v-if="currentLang.repo" class="repo">
<span class="vpi-languages icon lang" /> <span class="vpi-languages icon lang" />
{{ currentLang.label }} <span>{{ currentLang.label }}</span>
<span class="vpi-chevron-down icon chevron" /> <span class="vpi-chevron-down icon chevron" />
</span>
<template v-else>
<span class="vpi-languages icon lang" />
<span>{{ currentLang.label }}</span>
<span class="vpi-chevron-down icon chevron" />
</template>
<VPSocialLink v-if="currentLang.repo" icon="github" :link="currentLang.repo.link" :ariaLabel="currentLang.repo.title" />
</button> </button>
<ul class="list"> <ul class="list">
<li v-for="locale in localeLinks" :key="locale.link" class="item"> <li v-for="locale in localeLinks" :key="locale.link" :class="{ repo: !!locale.repo }" class="item">
<VPLink class="link" :href="locale.link">{{ locale.text }}</VPLink> <VPLink class="link" :href="locale.link">{{ locale.text }}</VPLink>
<VPSocialLink v-if="locale.repo" icon="github" :link="locale.repo.link" :ariaLabel="locale.repo.title" />
</li> </li>
</ul> </ul>
</div> </div>
@ -39,16 +48,34 @@ function toggle() {
overflow: hidden; overflow: hidden;
} }
.VPNavScreenTranslations.repo {
height: 40px;
}
.VPNavScreenTranslations.open { .VPNavScreenTranslations.open {
height: auto; height: auto;
} }
.title { .title, .title.repo .repo {
display: flex; display: flex;
align-items: center; align-items: center;
font-size: 14px; font-size: 14px;
font-weight: 500; font-weight: 500;
color: var(--vp-c-text-1); color: var(--vp-c-text-1);
}
.VPNavScreenTranslations .title .vpi-chevron-down {
transition: transform 0.25s;
transform: rotate(90deg);
}
.VPNavScreenTranslations.open .title .vpi-chevron-down {
transform: rotate(-90deg);
}
.title.repo {
width: 100%;
justify-content: space-between;
} }
.icon { .icon {
@ -67,6 +94,12 @@ function toggle() {
padding: 4px 0 0 24px; padding: 4px 0 0 24px;
} }
.list .item.repo {
display: flex;
align-items: center;
justify-content: space-between;
}
.link { .link {
line-height: 32px; line-height: 32px;
font-size: 13px; font-size: 13px;

Loading…
Cancel
Save