mirror of
https://example.com
synced 2024-11-27 19:36:38 +09:00
Merge branch 'develop' of https://codeberg.org/calckey/calckey into note-improvements
This commit is contained in:
commit
c644a08d39
2 changed files with 68 additions and 69 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "calckey",
|
"name": "calckey",
|
||||||
"version": "13.2.0-dev9",
|
"version": "13.2.0-dev10",
|
||||||
"codename": "aqua",
|
"codename": "aqua",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|
|
@ -1,34 +1,33 @@
|
||||||
<template>
|
<template>
|
||||||
<div ref="el" class="fdidabkb" :class="classes" :style="{ background: bg }" @click="onClick">
|
<div v-if="show" ref="el" class="fdidabkb" :class="{ slim: narrow, thin: thin_ }" :style="{ background: bg }" @click="onClick">
|
||||||
<div v-show="narrow" class="buttons left" @click="openAccountMenu">
|
<div v-if="narrow" class="buttons left" @click="openAccountMenu">
|
||||||
<MkAvatar v-if="displayMyAvatar && user" class="avatar" :user="user" :disable-preview="true"/>
|
<MkAvatar v-if="props.displayMyAvatar && $i" class="avatar" :user="$i" :disable-preview="true"/>
|
||||||
</div>
|
</div>
|
||||||
<template v-if="hasTabs">
|
<template v-if="metadata">
|
||||||
<div v-show="!hideTitle" class="titleContainer" @click="showTabsPopup">
|
<div v-if="!hideTitle" class="titleContainer" @click="showTabsPopup">
|
||||||
<MkAvatar v-if="metadata.avatar" class="avatar" :user="metadata.avatar" :disable-preview="true" :show-indicator="true"/>
|
<MkAvatar v-if="metadata.avatar" class="avatar" :user="metadata.avatar" :disable-preview="true" :show-indicator="true"/>
|
||||||
<i v-else-if="metadata.icon && !narrow" class="icon" :class="metadata.icon"></i>
|
<i v-else-if="metadata.icon && !narrow" class="icon" :class="metadata.icon"></i>
|
||||||
|
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<MkUserName v-if="metadata.userName" :user="metadata.userName" :nowrap="true" class="title"/>
|
<MkUserName v-if="metadata.userName" :user="metadata.userName" :nowrap="true" class="title"/>
|
||||||
<div v-else-if="metadata.title && !hasTabs && !narrow" class="title">{{ metadata.title }}</div>
|
<div v-else-if="metadata.title && !(tabs != null && tabs.length > 0 && narrow)" class="title">{{ metadata.title }}</div>
|
||||||
<div v-show="!narrow && metadata.subtitle" class="subtitle">{{ metadata.subtitle }}</div>
|
<div v-if="!narrow && metadata.subtitle" class="subtitle">
|
||||||
|
{{ metadata.subtitle }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ref="tabsEl" class="tabs" v-show="hasTabs">
|
</div>
|
||||||
<button v-for="tab in tabs" :key="tab.key" ref="tabRefs[tab.key]" v-tooltip.noDelay="tab.title"
|
<div ref="tabsEl" v-if="hasTabs" class="tabs">
|
||||||
class="tab _button" :class="{ active: isActiveTab(tab) }" @mousedown="onTabMousedown(tab)"
|
<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)">
|
||||||
@click="onTabClick(tab)">
|
<i v-if="tab.icon" class="icon" :class="tab.icon"></i>
|
||||||
<i v-if="tab.icon && !tab.iconOnly" class="icon" :class="tab.icon"></i>
|
|
||||||
<span class="title">{{ tab.title }}</span>
|
<span class="title">{{ tab.title }}</span>
|
||||||
</button>
|
</button>
|
||||||
<div ref="tabHighlightEl" class="highlight"></div>
|
<div ref="tabHighlightEl" class="highlight"></div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<div v-show="hasActions" class="buttons right">
|
<div class="buttons right">
|
||||||
<button v-for="(action, index) in actions" :key="index" v-tooltip.noDelay="action.text"
|
<template v-for="action in actions">
|
||||||
class="_button button" :class="{ highlighted: action.highlighted }" @click.stop="action.handler"
|
<button v-tooltip.noDelay="action.text" class="_button button" :class="{ highlighted: action.highlighted }" @click.stop="action.handler" @touchstart="preventDrag"><i :class="action.icon"></i></button>
|
||||||
@touchstart="preventDrag">
|
</template>
|
||||||
<i :class="action.icon"></i>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -145,35 +144,35 @@ onMounted(() => {
|
||||||
calcBg();
|
calcBg();
|
||||||
globalEvents.on('themeChanged', calcBg);
|
globalEvents.on('themeChanged', calcBg);
|
||||||
|
|
||||||
watch(() => [props.tab, props.tabs], () => {
|
const updateTabHighlight = () => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
const tabEl = tabRefs[props.tab];
|
const tabEl = tabRefs[props.tab];
|
||||||
if (tabEl && tabHighlightEl) {
|
if (tabEl && tabHighlightEl) {
|
||||||
// offsetWidth や offsetLeft は少数を丸めてしまうため getBoundingClientRect を使う必要がある
|
const tabSizeX = tabEl.scrollWidth + 20;
|
||||||
// https://developer.mozilla.org/ja/docs/Web/API/HTMLElement/offsetWidth#%E5%80%A4
|
tabEl.style.setProperty('--width', `${tabSizeX}px`);
|
||||||
const tabSizeX = tabEl.scrollWidth + 20; // + the tab's padding
|
|
||||||
tabEl.style = `--width: ${tabSizeX}px`;
|
|
||||||
setTimeout(() => {
|
|
||||||
const parentRect = tabsEl.getBoundingClientRect();
|
const parentRect = tabsEl.getBoundingClientRect();
|
||||||
const rect = tabEl.getBoundingClientRect();
|
const rect = tabEl.getBoundingClientRect();
|
||||||
const left = (rect.left - parentRect.left + tabsEl?.scrollLeft);
|
const left = (rect.left - parentRect.left + tabsEl.scrollLeft);
|
||||||
tabHighlightEl.style.width = tabSizeX + 'px';
|
tabHighlightEl.style.width = `${tabSizeX}px`;
|
||||||
tabHighlightEl.style.transform = `translateX(${left}px)`;
|
tabHighlightEl.style.transform = `translateX(${left}px)`;
|
||||||
window.requestAnimationFrame(() => {
|
tabsEl.scrollTo({left: left - 60, behavior: "smooth"});
|
||||||
tabsEl?.scrollTo({left: left - 60, behavior: "smooth"});
|
|
||||||
})
|
|
||||||
}, 200);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, {
|
};
|
||||||
immediate: true,
|
|
||||||
});
|
const updateTab = () => {
|
||||||
|
emit('update:tab', props.tab);
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(() => [props.tab, props.tabs], updateTabHighlight, { immediate: true });
|
||||||
|
watch(() => props.tab, updateTab);
|
||||||
|
|
||||||
if (el && el.parentElement) {
|
if (el && el.parentElement) {
|
||||||
narrow = el.parentElement.offsetWidth < 500;
|
narrow.value = el.parentElement.offsetWidth < 500;
|
||||||
ro = new ResizeObserver((entries, observer) => {
|
ro = new ResizeObserver((entries, observer) => {
|
||||||
if (el.parentElement && document.body.contains(el)) {
|
if (el.parentElement && document.body.contains(el)) {
|
||||||
narrow = el.parentElement.offsetWidth < 500;
|
narrow.value = el.parentElement.offsetWidth < 500;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ro.observe(el.parentElement);
|
ro.observe(el.parentElement);
|
||||||
|
|
Loading…
Reference in a new issue