apply mobile nav styling to desktop, maybe also fix misalignment ? (#9623)
Co-authored-by: Freeplay <Freeplay@duck.com> Reviewed-on: https://codeberg.org/calckey/calckey/pulls/9623 Co-authored-by: Free <freeplay@duck.com> Co-committed-by: Free <freeplay@duck.com>
This commit is contained in:
parent
4c0d30c368
commit
256fd485fd
|
@ -19,7 +19,7 @@
|
|||
<div ref="tabsEl" v-if="hasTabs" class="tabs">
|
||||
<button v-for="tab in tabs" :ref="(el) => tabRefs[tab.key] = el" v-tooltip.noDelay="tab.title" class="tab _button" :class="{ active: tab.key != null && tab.key === props.tab }" @mousedown="(ev) => onTabMousedown(tab, ev)" @click="(ev) => onTabClick(tab, ev)">
|
||||
<i v-if="tab.icon" class="icon" :class="tab.icon"></i>
|
||||
<span v-if="deviceKind !== 'desktop' || isTouchUsing || (!tab.iconOnly && !narrow)" class="title">{{ tab.title }}</span>
|
||||
<span class="title">{{ tab.title }}</span>
|
||||
</button>
|
||||
<div ref="tabHighlightEl" class="highlight"></div>
|
||||
</div>
|
||||
|
@ -38,8 +38,6 @@ import tinycolor from 'tinycolor2';
|
|||
import { popupMenu } from '@/os';
|
||||
import { scrollToTop } from '@/scripts/scroll';
|
||||
import { globalEvents } from '@/events';
|
||||
import { deviceKind } from '@/scripts/device-kind';
|
||||
import { isTouchUsing } from '@/scripts/touch';
|
||||
import { injectPageMetadata } from '@/scripts/page-metadata';
|
||||
import { $i, openAccountMenu as openAccountMenu_ } from '@/account';
|
||||
|
||||
|
@ -152,18 +150,14 @@ onMounted(() => {
|
|||
if (tabEl && tabHighlightEl) {
|
||||
// offsetWidth や offsetLeft は少数を丸めてしまうため getBoundingClientRect を使う必要がある
|
||||
// https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/offsetWidth#%E5%80%A4
|
||||
function transition() {
|
||||
window.requestAnimationFrame(() => {
|
||||
setTimeout(() => {
|
||||
const parentRect = tabsEl.getBoundingClientRect();
|
||||
const rect = tabEl.getBoundingClientRect();
|
||||
const left = (rect.left - parentRect.left + tabsEl?.scrollLeft);
|
||||
tabHighlightEl.style.width = rect.width + 'px';
|
||||
tabHighlightEl.style.left = left + 'px';
|
||||
tabsEl?.scrollTo({left: left - 80, behavior: "smooth"});
|
||||
})
|
||||
tabEl.removeEventListener("transitionend", transition);
|
||||
}
|
||||
tabEl.addEventListener("transitionend", transition);
|
||||
tabsEl?.scrollTo({left: left - 60, behavior: "smooth"});
|
||||
}, 200);
|
||||
}
|
||||
});
|
||||
}, {
|
||||
|
@ -234,14 +228,6 @@ onUnmounted(() => {
|
|||
display: inline-block;
|
||||
min-width: 20%;
|
||||
}
|
||||
> .tab {
|
||||
&:not(.active) > .title {
|
||||
font-size: 0;
|
||||
opacity: 0;
|
||||
margin-inline: 0;
|
||||
transition: font-size .2s, opacity .1s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -389,6 +375,12 @@ onUnmounted(() => {
|
|||
> .title {
|
||||
transition: font-size .2s, opacity .2s .15s;
|
||||
}
|
||||
&:not(.active) > .title {
|
||||
font-size: 0;
|
||||
opacity: 0;
|
||||
margin-inline: 0;
|
||||
transition: font-size .2s, opacity .1s;
|
||||
}
|
||||
}
|
||||
|
||||
> .highlight {
|
||||
|
|
Loading…
Reference in New Issue