/
45case
/
ptable
Обзор
Документация
Войти
/
45case
/
ptable
Код
Запросы
3
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
dev
src/entities/element/lib/getElementNameFitStyle.ts
24 строки
693 B
Olya
feat: клик по легенде категорий/фаз и корректная окраска по температуре
17 июл 2026, 11:22
17 июл 2026, 11:22
4fc2553
Код
Авторство
О чём код?
import type { StyleValue } from "vue"; export function getElementNameFitStyle(name: string, isWide = false): StyleValue { const length = name.length; const fitBudget = isWide ? 8 : 10; if (length <= 7) { return {}; } if (length <= fitBudget) { return { letterSpacing: "-0.02em" }; } const excess = length - fitBudget; const letterSpacing = Math.max(-0.09, -0.025 - excess * 0.007); const scaleX = Math.max(isWide ? 0.78 : 0.82, 1 - excess * (isWide ? 0.016 : 0.013)); const translateRatio = length >= 11 ? -117 : -40; return { letterSpacing: `${letterSpacing}em`, transform: `translateX(${letterSpacing * translateRatio}%) scaleX(${scaleX})`, }; }