diff --git a/src/renderer/src/assets/styles/base.css b/src/renderer/src/assets/styles/base.css index 533c403..0d816e7 100644 --- a/src/renderer/src/assets/styles/base.css +++ b/src/renderer/src/assets/styles/base.css @@ -108,6 +108,43 @@ textarea:focus { 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 ─────────────────────────────────────────── */ .truncate { overflow: hidden; diff --git a/src/renderer/src/components/layout/TitleBar.vue b/src/renderer/src/components/layout/TitleBar.vue index e5df2e3..b33fab6 100644 --- a/src/renderer/src/components/layout/TitleBar.vue +++ b/src/renderer/src/components/layout/TitleBar.vue @@ -18,13 +18,13 @@ function close(): void { Aero Mail
- - -
diff --git a/src/renderer/src/components/messages/MessageList.vue b/src/renderer/src/components/messages/MessageList.vue index cbab8d4..df7ac5b 100644 --- a/src/renderer/src/components/messages/MessageList.vue +++ b/src/renderer/src/components/messages/MessageList.vue @@ -190,7 +190,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis v-if="activeUnread > 0 || messagesStore.unreadOnly" class="message-count" :class="{ 'unread-active': messagesStore.unreadOnly }" - title="Только непрочитанные" + v-tooltip="'Только непрочитанные'" @click="messagesStore.toggleUnreadOnly()" > {{ activeUnread }} @@ -199,7 +199,7 @@ async function handleSwipeAction(action: SwipeAction, messageId: string): Promis - diff --git a/src/renderer/src/directives/tooltip.ts b/src/renderer/src/directives/tooltip.ts new file mode 100644 index 0000000..8e53010 --- /dev/null +++ b/src/renderer/src/directives/tooltip.ts @@ -0,0 +1,106 @@ +import type { ObjectDirective } from 'vue' + +// Единственный DOM-элемент тултипа на весь app +let tipEl: HTMLDivElement | null = null +let showTimer: ReturnType | null = null +let hideTimer: ReturnType | 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 = { + 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) + } + }, +} diff --git a/src/renderer/src/main.ts b/src/renderer/src/main.ts index d76a600..29ba2cd 100644 --- a/src/renderer/src/main.ts +++ b/src/renderer/src/main.ts @@ -2,6 +2,7 @@ import { createApp } from 'vue' import { createPinia } from 'pinia' import { createRouter, createWebHashHistory } from 'vue-router' import App from './App.vue' +import { vTooltip } from './directives/tooltip' import './assets/styles/variables.css' import './assets/styles/base.css' @@ -24,4 +25,5 @@ const router = createRouter({ const app = createApp(App) app.use(createPinia()) app.use(router) +app.directive('tooltip', vTooltip) app.mount('#app') diff --git a/src/renderer/src/views/SettingsView.vue b/src/renderer/src/views/SettingsView.vue index 493bfae..971fda6 100644 --- a/src/renderer/src/views/SettingsView.vue +++ b/src/renderer/src/views/SettingsView.vue @@ -52,7 +52,7 @@ const swipeOptions: { value: SwipeAction; label: string }[] = ( class="quick-dot" :class="{ active: settingsStore.accentColor.toLowerCase() === hex.toLowerCase() }" :style="{ '--dot-color': hex }" - :title="hex" + v-tooltip="hex" @click="settingsStore.accentColor = hex" /> @@ -79,7 +79,7 @@ const swipeOptions: { value: SwipeAction; label: string }[] = (