fix: dynamic accent color for gradient + avatar, replace presets with color picker

- settings.store: accentId → accentColor (hex); applyAccentColor() computes
  all derived tokens (hover=+28, muted=rgba 12%, text=dark/light by luminance,
  glow=rgba 8%); --accent-glow CSS var drives background gradient
- base.css: gradient uses var(--accent-glow) so it updates with accent color
- AccountSwitcher: getAccountColor() no longer returns lime green; uses
  neutral distinct palette [blue, violet, pink, orange, green, red, teal]
- SettingsView: replace preset swatches with native <input type="color">
  wrapped in a glass pill showing hex value; 7 quick-pick dots below for
  one-click presets; active dot has white ring + glow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
vodyanoysh 2026-03-31 21:22:58 +07:00
parent dc1183b034
commit 99b6ef52a0
4 changed files with 143 additions and 78 deletions

View file

@ -18,11 +18,11 @@ body {
-moz-osx-font-smoothing: grayscale;
user-select: none;
/* Rich gradient base — visible through glass panels */
/* Rich gradient base — accent-glow is set dynamically via JS */
background:
radial-gradient(ellipse 55% 45% at 12% 10%, rgba(168, 230, 0, 0.07) 0%, transparent 70%),
radial-gradient(ellipse 45% 55% at 88% 90%, rgba(0, 110, 220, 0.06) 0%, transparent 70%),
radial-gradient(ellipse 60% 40% at 50% 50%, rgba(100, 0, 180, 0.04) 0%, transparent 100%),
radial-gradient(ellipse 60% 50% at 15% 15%, var(--accent-glow, rgba(168,230,0,0.08)) 0%, transparent 70%),
radial-gradient(ellipse 45% 55% at 88% 90%, rgba(0, 110, 220, 0.05) 0%, transparent 70%),
radial-gradient(ellipse 60% 40% at 50% 50%, rgba(80, 0, 160, 0.04) 0%, transparent 100%),
#09090e;
}

View file

@ -14,7 +14,7 @@ function getInitial(email: string): string {
}
function getAccountColor(index: number): string {
const colors = ['#a8e600', '#00b4d8', '#e6a800', '#e066ff', '#ff6b6b', '#4ecdc4']
const colors = ['#38bdf8', '#a78bfa', '#f472b6', '#fb923c', '#4ade80', '#f87171', '#2dd4bf']
return colors[index % colors.length]
}
</script>

View file

@ -17,32 +17,45 @@ export const SWIPE_ACTION_INFO: Record<SwipeAction, { icon: string; color: strin
none: { icon: '', color: 'transparent' }
}
// ─── Accent color presets ────────────────────────────────
export type AccentPreset = {
id: string
label: string
accent: string
hover: string
muted: string
text: string
}
export const ACCENT_PRESETS: AccentPreset[] = [
{ id: 'lime', label: 'Лайм', accent: '#a8e600', hover: '#bdff1a', muted: 'rgba(168,230,0,0.12)', text: '#0d1a00' },
{ id: 'blue', label: 'Синий', accent: '#38bdf8', hover: '#7dd3fc', muted: 'rgba(56,189,248,0.12)', text: '#001a2e' },
{ id: 'violet', label: 'Фиолетовый', accent: '#a78bfa', hover: '#c4b5fd', muted: 'rgba(167,139,250,0.12)', text: '#0f0030' },
{ id: 'pink', label: 'Розовый', accent: '#f472b6', hover: '#f9a8d4', muted: 'rgba(244,114,182,0.12)', text: '#200015' },
{ id: 'orange', label: 'Оранжевый', accent: '#fb923c', hover: '#fdba74', muted: 'rgba(251,146,60,0.12)', text: '#1a0800' },
{ id: 'teal', label: 'Бирюзовый', accent: '#2dd4bf', hover: '#5eead4', muted: 'rgba(45,212,191,0.12)', text: '#001a16' },
{ id: 'red', label: 'Красный', accent: '#f87171', hover: '#fca5a5', muted: 'rgba(248,113,113,0.12)', text: '#200000' },
// ─── Accent color ────────────────────────────────────────
export const ACCENT_QUICK_PICKS = [
'#a8e600', // lime
'#38bdf8', // blue
'#a78bfa', // violet
'#f472b6', // pink
'#fb923c', // orange
'#2dd4bf', // teal
'#f87171', // red
]
function applyAccent(preset: AccentPreset): void {
const r = document.documentElement.style
r.setProperty('--accent', preset.accent)
r.setProperty('--accent-hover', preset.hover)
r.setProperty('--accent-muted', preset.muted)
r.setProperty('--accent-text', preset.text)
function hexToRgb(hex: string): [number, number, number] | null {
const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex)
if (!m) return null
return [parseInt(m[1], 16), parseInt(m[2], 16), parseInt(m[3], 16)]
}
function lightenHex(hex: string, amount: number): string {
const rgb = hexToRgb(hex)
if (!rgb) return hex
return '#' + rgb.map(c => Math.min(255, c + amount).toString(16).padStart(2, '0')).join('')
}
function getLuminance(r: number, g: number, b: number): number {
return 0.2126 * (r / 255) + 0.7152 * (g / 255) + 0.0722 * (b / 255)
}
function applyAccentColor(hex: string): void {
const rgb = hexToRgb(hex)
if (!rgb) return
const [r, g, b] = rgb
const lum = getLuminance(r, g, b)
const root = document.documentElement
root.style.setProperty('--accent', hex)
root.style.setProperty('--accent-hover', lightenHex(hex, 28))
root.style.setProperty('--accent-muted', `rgba(${r},${g},${b},0.12)`)
root.style.setProperty('--accent-text', lum > 0.35 ? '#0d0d0d' : '#ffffff')
root.style.setProperty('--accent-glow', `rgba(${r},${g},${b},0.08)`)
}
// ─── Storage ─────────────────────────────────────────────
@ -51,7 +64,7 @@ const STORAGE_KEY = 'vue-mail-settings'
function load(): {
swipeLeftAction?: SwipeAction
swipeRightAction?: SwipeAction
accentId?: string
accentColor?: string
} {
try {
return JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}')
@ -65,15 +78,13 @@ export const useSettingsStore = defineStore('settings', () => {
const swipeLeftAction = ref<SwipeAction>(saved.swipeLeftAction ?? 'delete')
const swipeRightAction = ref<SwipeAction>(saved.swipeRightAction ?? 'toggleRead')
const accentId = ref<string>(saved.accentId ?? 'lime')
const accentColor = ref<string>(saved.accentColor ?? '#a8e600')
// Apply saved accent immediately on store init
const initPreset = ACCENT_PRESETS.find(p => p.id === accentId.value) ?? ACCENT_PRESETS[0]
applyAccent(initPreset)
// Apply on init
applyAccentColor(accentColor.value)
watch(accentId, (id) => {
const preset = ACCENT_PRESETS.find(p => p.id === id) ?? ACCENT_PRESETS[0]
applyAccent(preset)
watch(accentColor, (hex) => {
applyAccentColor(hex)
persist()
})
@ -83,9 +94,9 @@ export const useSettingsStore = defineStore('settings', () => {
localStorage.setItem(STORAGE_KEY, JSON.stringify({
swipeLeftAction: swipeLeftAction.value,
swipeRightAction: swipeRightAction.value,
accentId: accentId.value,
accentColor: accentColor.value,
}))
}
return { swipeLeftAction, swipeRightAction, accentId }
return { swipeLeftAction, swipeRightAction, accentColor }
})

View file

@ -1,7 +1,7 @@
<script setup lang="ts">
import { useRouter } from 'vue-router'
import { useAccountsStore } from '../stores/accounts.store'
import { useSettingsStore, SWIPE_ACTION_LABELS, ACCENT_PRESETS, type SwipeAction } from '../stores/settings.store'
import { useSettingsStore, SWIPE_ACTION_LABELS, ACCENT_QUICK_PICKS, type SwipeAction } from '../stores/settings.store'
const router = useRouter()
const accountsStore = useAccountsStore()
@ -38,21 +38,29 @@ const swipeOptions: SwipeAction[] = ['delete', 'toggleRead', 'toggleFlag', 'none
<!-- Акцентный цвет -->
<section>
<h2>Акцентный цвет</h2>
<p class="section-desc">Выберите цвет выделения интерфейса</p>
<div class="accent-swatches">
<button
v-for="preset in ACCENT_PRESETS"
:key="preset.id"
class="accent-swatch"
:class="{ active: settingsStore.accentId === preset.id }"
:style="{ '--swatch-color': preset.accent }"
:title="preset.label"
@click="settingsStore.accentId = preset.id"
>
<svg v-if="settingsStore.accentId === preset.id" viewBox="0 0 16 16" width="10" height="10" fill="none">
<polyline points="3,8 6.5,12 13,4" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
</button>
<p class="section-desc">Выберите любой оттенок или используйте быстрый выбор</p>
<div class="color-picker-row">
<label class="color-input-wrap" title="Выбрать цвет">
<span class="color-preview" :style="{ background: settingsStore.accentColor }" />
<span class="color-hex">{{ settingsStore.accentColor.toUpperCase() }}</span>
<input
type="color"
:value="settingsStore.accentColor"
class="color-native"
@input="(e) => settingsStore.accentColor = (e.target as HTMLInputElement).value"
/>
</label>
<div class="quick-picks">
<button
v-for="hex in ACCENT_QUICK_PICKS"
:key="hex"
class="quick-dot"
:class="{ active: settingsStore.accentColor.toLowerCase() === hex.toLowerCase() }"
:style="{ '--dot-color': hex }"
:title="hex"
@click="settingsStore.accentColor = hex"
/>
</div>
</div>
</section>
@ -270,38 +278,84 @@ const swipeOptions: SwipeAction[] = ['delete', 'toggleRead', 'toggleFlag', 'none
border-color: var(--accent);
}
/* Accent swatches */
.accent-swatches {
/* Color picker */
.color-picker-row {
display: flex;
gap: 10px;
align-items: center;
gap: 14px;
flex-wrap: wrap;
}
.accent-swatch {
width: 34px;
height: 34px;
border-radius: 50%;
background: var(--swatch-color);
border: 2px solid transparent;
.color-input-wrap {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
padding: 8px 14px;
border-radius: var(--radius-md);
background: var(--glass-bg);
backdrop-filter: var(--blur-sm);
-webkit-backdrop-filter: var(--blur-sm);
border: 1px solid var(--glass-border-strong);
box-shadow: var(--glass-specular);
cursor: pointer;
position: relative;
transition: background var(--transition-fast);
}
.color-input-wrap:hover {
background: var(--glass-bg-hover);
}
.color-preview {
width: 24px;
height: 24px;
border-radius: 50%;
flex-shrink: 0;
box-shadow: 0 2px 8px rgba(0,0,0,0.4);
transition: box-shadow var(--transition-fast);
}
.color-hex {
font-family: var(--font-mono);
font-size: 12px;
color: var(--text-secondary);
letter-spacing: 0.5px;
}
.color-native {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
opacity: 0;
cursor: pointer;
border: none;
padding: 0;
background: none;
border-radius: inherit;
}
.quick-picks {
display: flex;
gap: 8px;
align-items: center;
}
.quick-dot {
width: 22px;
height: 22px;
border-radius: 50%;
background: var(--dot-color);
border: 2px solid transparent;
cursor: pointer;
transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
color: rgba(0, 0, 0, 0.7);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}
.accent-swatch:hover {
transform: scale(1.12);
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
.quick-dot:hover {
transform: scale(1.15);
}
.accent-swatch.active {
border-color: rgba(255, 255, 255, 0.7);
box-shadow:
0 0 0 1px var(--swatch-color),
0 4px 16px rgba(0, 0, 0, 0.5);
transform: scale(1.08);
.quick-dot.active {
border-color: rgba(255,255,255,0.75);
box-shadow: 0 0 0 1px var(--dot-color), 0 3px 10px rgba(0,0,0,0.5);
transform: scale(1.1);
}
</style>