Заменить нативные тултипы на кастомные liquid glass

- Директива v-tooltip: показывает тултип через 350мс, рендерит в document.body
  (нет clipping от overflow:hidden родителей), правильно позиционирует у края экрана
- Стиль liquid glass: тёмный непрозрачный фон + specular border + box-shadow,
  плавная анимация появления (scale + translateY)
- Заменены все title= атрибуты в MessageList, ThreadListItem, TitleBar,
  AccountSwitcher, MessageHeader, SettingsView

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
d.a.kolesov 2026-04-02 07:12:44 +07:00
parent e17a0f71b7
commit 79382a643e
9 changed files with 159 additions and 14 deletions

View file

@ -108,6 +108,43 @@ textarea:focus {
background: rgba(255, 255, 255, 0.22); background: rgba(255, 255, 255, 0.22);
} }
/* ── Custom tooltip ────────────────────────────────────── */
.app-tooltip {
position: fixed;
z-index: 9999;
max-width: 220px;
padding: 5px 10px;
font-size: 11.5px;
font-weight: 500;
line-height: 1.4;
color: rgba(255, 255, 255, 0.88);
white-space: nowrap;
pointer-events: none;
/* Liquid glass: тёмный непрозрачный фон + frosted border */
background:
linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.02) 100%),
rgba(14, 14, 22, 0.92);
border: 1px solid rgba(255, 255, 255, 0.16);
border-radius: 7px;
box-shadow:
inset 0 1px 0 rgba(255, 255, 255, 0.20),
0 0 0 1px rgba(0, 0, 0, 0.35),
0 6px 20px rgba(0, 0, 0, 0.50),
0 2px 6px rgba(0, 0, 0, 0.30);
opacity: 0;
transform: translateY(4px) scale(0.96);
transition:
opacity 110ms ease,
transform 140ms cubic-bezier(0.34, 1.15, 0.64, 1);
}
.app-tooltip--visible {
opacity: 1;
transform: translateY(0) scale(1);
}
/* ── Utilities ─────────────────────────────────────────── */ /* ── Utilities ─────────────────────────────────────────── */
.truncate { .truncate {
overflow: hidden; overflow: hidden;

View file

@ -18,13 +18,13 @@ function close(): void {
<span class="app-title">Aero Mail</span> <span class="app-title">Aero Mail</span>
</div> </div>
<div class="titlebar-controls"> <div class="titlebar-controls">
<button class="control-btn minimize" title="Свернуть" @click="minimize"> <button class="control-btn minimize" v-tooltip="'Свернуть'" @click="minimize">
&#x2500; &#x2500;
</button> </button>
<button class="control-btn maximize" title="Развернуть" @click="maximize"> <button class="control-btn maximize" v-tooltip="'Развернуть'" @click="maximize">
&#x25A1; &#x25A1;
</button> </button>
<button class="control-btn close" title="Закрыть" @click="close"> <button class="control-btn close" v-tooltip="'Закрыть'" @click="close">
&#x2715; &#x2715;
</button> </button>
</div> </div>

View file

@ -190,7 +190,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
v-if="activeUnread > 0 || messagesStore.unreadOnly" v-if="activeUnread > 0 || messagesStore.unreadOnly"
class="message-count" class="message-count"
:class="{ 'unread-active': messagesStore.unreadOnly }" :class="{ 'unread-active': messagesStore.unreadOnly }"
title="Только непрочитанные" v-tooltip="'Только непрочитанные'"
@click="messagesStore.toggleUnreadOnly()" @click="messagesStore.toggleUnreadOnly()"
> >
{{ activeUnread }} {{ activeUnread }}
@ -199,7 +199,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
<button <button
class="icon-btn select-mode-btn" class="icon-btn select-mode-btn"
:class="{ active: selectMode }" :class="{ active: selectMode }"
title="Режим выбора" v-tooltip="'Режим выбора'"
@click="selectMode = !selectMode" @click="selectMode = !selectMode"
> >
<span class="select-icon" :class="{ checked: selectMode }"> <span class="select-icon" :class="{ checked: selectMode }">
@ -212,7 +212,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis
class="icon-btn" class="icon-btn"
:class="{ spinning: messagesStore.loading }" :class="{ spinning: messagesStore.loading }"
:disabled="messagesStore.loading" :disabled="messagesStore.loading"
title="Обновить" v-tooltip="'Обновить'"
@click="refresh" @click="refresh"
> >
<AppIcon name="refresh" :size="14" /> <AppIcon name="refresh" :size="14" />

View file

@ -77,7 +77,7 @@ const snippet = computed(() => props.thread.latest.snippet || '')
<!-- Сортировка по дате --> <!-- Сортировка по дате -->
<button <button
class="thread-filter-btn" class="thread-filter-btn"
:title="sortDesc ? 'Новые сверху' : 'Старые сверху'" v-tooltip="sortDesc ? 'Новые сверху' : 'Старые сверху'"
@click.stop="$emit('toggleSort')" @click.stop="$emit('toggleSort')"
> >
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" <svg width="10" height="10" viewBox="0 0 24 24" fill="none"
@ -100,7 +100,7 @@ const snippet = computed(() => props.thread.latest.snippet || '')
<button <button
class="thread-filter-btn" class="thread-filter-btn"
:class="{ active: unreadOnly }" :class="{ active: unreadOnly }"
title="Только непрочитанные" v-tooltip="'Только непрочитанные'"
@click.stop="$emit('toggleUnread')" @click.stop="$emit('toggleUnread')"
> >
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" <svg width="10" height="10" viewBox="0 0 24 24" fill="none"

View file

@ -138,7 +138,7 @@ onUnmounted(() => {
<button <button
class="popup-copy" class="popup-copy"
:class="{ done: copyDone }" :class="{ done: copyDone }"
:title="copyDone ? 'Скопировано!' : 'Скопировать email'" v-tooltip="copyDone ? 'Скопировано!' : 'Скопировать email'"
@click.stop="copyEmail" @click.stop="copyEmail"
> >
<!-- Copy icon --> <!-- Copy icon -->

View file

@ -27,7 +27,7 @@ function getAccountColor(index: number): string {
:key="account.id" :key="account.id"
class="account-btn" class="account-btn"
:class="{ active: accountsStore.activeAccountId === account.id }" :class="{ active: accountsStore.activeAccountId === account.id }"
:title="account.email" v-tooltip="account.email"
@click="accountsStore.setActive(account.id)" @click="accountsStore.setActive(account.id)"
> >
<span <span
@ -40,11 +40,11 @@ function getAccountColor(index: number): string {
<div class="spacer" /> <div class="spacer" />
<button class="account-btn add-btn" title="Добавить аккаунт" @click="emit('addAccount')"> <button class="account-btn add-btn" v-tooltip="'Добавить аккаунт'" @click="emit('addAccount')">
<AppIcon name="plus" :size="16" class="add-icon" /> <AppIcon name="plus" :size="16" class="add-icon" />
</button> </button>
<button class="account-btn settings-btn" title="Настройки" @click="router.push('/settings')"> <button class="account-btn settings-btn" v-tooltip="'Настройки'" @click="router.push('/settings')">
<AppIcon name="settings" :size="15" class="settings-icon" /> <AppIcon name="settings" :size="15" class="settings-icon" />
</button> </button>
</div> </div>

View file

@ -0,0 +1,106 @@
import type { ObjectDirective } from 'vue'
// Единственный DOM-элемент тултипа на весь app
let tipEl: HTMLDivElement | null = null
let showTimer: ReturnType<typeof setTimeout> | null = null
let hideTimer: ReturnType<typeof setTimeout> | null = null
function getEl(): HTMLDivElement {
if (!tipEl) {
tipEl = document.createElement('div')
tipEl.className = 'app-tooltip'
document.body.appendChild(tipEl)
}
return tipEl
}
function reposition(anchor: HTMLElement): void {
const tip = getEl()
const ar = anchor.getBoundingClientRect()
const tr = tip.getBoundingClientRect()
const gap = 7
const margin = 8
// По умолчанию — снизу по центру
let top = ar.bottom + gap
let left = ar.left + ar.width / 2 - tr.width / 2
// Не хватает места снизу — показываем сверху
if (top + tr.height + margin > window.innerHeight) {
top = ar.top - tr.height - gap
}
// Зажимаем горизонтально
left = Math.max(margin, Math.min(left, window.innerWidth - tr.width - margin))
tip.style.top = `${top}px`
tip.style.left = `${left}px`
}
function show(anchor: HTMLElement, text: string): void {
if (!text) return
if (hideTimer) { clearTimeout(hideTimer); hideTimer = null }
const tip = getEl()
tip.textContent = text
// Ждём один кадр, чтобы браузер успел посчитать ширину текста
requestAnimationFrame(() => {
tip.classList.add('app-tooltip--visible')
reposition(anchor)
})
}
function hide(): void {
if (showTimer) { clearTimeout(showTimer); showTimer = null }
hideTimer = setTimeout(() => {
getEl().classList.remove('app-tooltip--visible')
}, 80)
}
// ── Директива ─────────────────────────────────────────────
interface TooltipState {
text: string
enter: () => void
leave: () => void
}
const DATA_KEY = '__tooltip__'
export const vTooltip: ObjectDirective<HTMLElement & { [DATA_KEY]?: TooltipState }, string> = {
mounted(el, binding) {
const state: TooltipState = {
text: binding.value ?? '',
enter: () => {
showTimer = setTimeout(() => show(el, state.text), 350)
},
leave: () => {
if (showTimer) { clearTimeout(showTimer); showTimer = null }
hide()
},
}
el[DATA_KEY] = state
// Убираем нативный тултип
el.removeAttribute('title')
el.addEventListener('mouseenter', state.enter)
el.addEventListener('mouseleave', state.leave)
el.addEventListener('mousedown', state.leave)
},
updated(el, binding) {
const state = el[DATA_KEY]
if (state) state.text = binding.value ?? ''
},
beforeUnmount(el) {
const state = el[DATA_KEY]
if (state) {
el.removeEventListener('mouseenter', state.enter)
el.removeEventListener('mouseleave', state.leave)
el.removeEventListener('mousedown', state.leave)
}
},
}

View file

@ -2,6 +2,7 @@ import { createApp } from 'vue'
import { createPinia } from 'pinia' import { createPinia } from 'pinia'
import { createRouter, createWebHashHistory } from 'vue-router' import { createRouter, createWebHashHistory } from 'vue-router'
import App from './App.vue' import App from './App.vue'
import { vTooltip } from './directives/tooltip'
import './assets/styles/variables.css' import './assets/styles/variables.css'
import './assets/styles/base.css' import './assets/styles/base.css'
@ -24,4 +25,5 @@ const router = createRouter({
const app = createApp(App) const app = createApp(App)
app.use(createPinia()) app.use(createPinia())
app.use(router) app.use(router)
app.directive('tooltip', vTooltip)
app.mount('#app') app.mount('#app')

View file

@ -52,7 +52,7 @@ const swipeOptions: { value: SwipeAction; label: string }[] = (
class="quick-dot" class="quick-dot"
:class="{ active: settingsStore.accentColor.toLowerCase() === hex.toLowerCase() }" :class="{ active: settingsStore.accentColor.toLowerCase() === hex.toLowerCase() }"
:style="{ '--dot-color': hex }" :style="{ '--dot-color': hex }"
:title="hex" v-tooltip="hex"
@click="settingsStore.accentColor = hex" @click="settingsStore.accentColor = hex"
/> />
</div> </div>
@ -79,7 +79,7 @@ const swipeOptions: { value: SwipeAction; label: string }[] = (
<button <button
v-if="settingsStore.uiScale !== 1" v-if="settingsStore.uiScale !== 1"
class="scale-reset" class="scale-reset"
title="Сбросить" v-tooltip="'Сбросить'"
@click="settingsStore.uiScale = 1" @click="settingsStore.uiScale = 1"
>↺</button> >↺</button>
</div> </div>