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:
parent
dc1183b034
commit
99b6ef52a0
4 changed files with 143 additions and 78 deletions
|
|
@ -18,11 +18,11 @@ body {
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
|
||||||
/* Rich gradient base — visible through glass panels */
|
/* Rich gradient base — accent-glow is set dynamically via JS */
|
||||||
background:
|
background:
|
||||||
radial-gradient(ellipse 55% 45% at 12% 10%, rgba(168, 230, 0, 0.07) 0%, transparent 70%),
|
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.06) 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(100, 0, 180, 0.04) 0%, transparent 100%),
|
radial-gradient(ellipse 60% 40% at 50% 50%, rgba(80, 0, 160, 0.04) 0%, transparent 100%),
|
||||||
#09090e;
|
#09090e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ function getInitial(email: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAccountColor(index: number): 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]
|
return colors[index % colors.length]
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -17,32 +17,45 @@ export const SWIPE_ACTION_INFO: Record<SwipeAction, { icon: string; color: strin
|
||||||
none: { icon: '', color: 'transparent' }
|
none: { icon: '', color: 'transparent' }
|
||||||
}
|
}
|
||||||
|
|
||||||
// ─── Accent color presets ────────────────────────────────
|
// ─── Accent color ────────────────────────────────────────
|
||||||
export type AccentPreset = {
|
export const ACCENT_QUICK_PICKS = [
|
||||||
id: string
|
'#a8e600', // lime
|
||||||
label: string
|
'#38bdf8', // blue
|
||||||
accent: string
|
'#a78bfa', // violet
|
||||||
hover: string
|
'#f472b6', // pink
|
||||||
muted: string
|
'#fb923c', // orange
|
||||||
text: string
|
'#2dd4bf', // teal
|
||||||
}
|
'#f87171', // red
|
||||||
|
|
||||||
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' },
|
|
||||||
]
|
]
|
||||||
|
|
||||||
function applyAccent(preset: AccentPreset): void {
|
function hexToRgb(hex: string): [number, number, number] | null {
|
||||||
const r = document.documentElement.style
|
const m = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(hex)
|
||||||
r.setProperty('--accent', preset.accent)
|
if (!m) return null
|
||||||
r.setProperty('--accent-hover', preset.hover)
|
return [parseInt(m[1], 16), parseInt(m[2], 16), parseInt(m[3], 16)]
|
||||||
r.setProperty('--accent-muted', preset.muted)
|
}
|
||||||
r.setProperty('--accent-text', preset.text)
|
|
||||||
|
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 ─────────────────────────────────────────────
|
// ─── Storage ─────────────────────────────────────────────
|
||||||
|
|
@ -51,7 +64,7 @@ const STORAGE_KEY = 'vue-mail-settings'
|
||||||
function load(): {
|
function load(): {
|
||||||
swipeLeftAction?: SwipeAction
|
swipeLeftAction?: SwipeAction
|
||||||
swipeRightAction?: SwipeAction
|
swipeRightAction?: SwipeAction
|
||||||
accentId?: string
|
accentColor?: string
|
||||||
} {
|
} {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}')
|
return JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}')
|
||||||
|
|
@ -65,15 +78,13 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||||
|
|
||||||
const swipeLeftAction = ref<SwipeAction>(saved.swipeLeftAction ?? 'delete')
|
const swipeLeftAction = ref<SwipeAction>(saved.swipeLeftAction ?? 'delete')
|
||||||
const swipeRightAction = ref<SwipeAction>(saved.swipeRightAction ?? 'toggleRead')
|
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
|
// Apply on init
|
||||||
const initPreset = ACCENT_PRESETS.find(p => p.id === accentId.value) ?? ACCENT_PRESETS[0]
|
applyAccentColor(accentColor.value)
|
||||||
applyAccent(initPreset)
|
|
||||||
|
|
||||||
watch(accentId, (id) => {
|
watch(accentColor, (hex) => {
|
||||||
const preset = ACCENT_PRESETS.find(p => p.id === id) ?? ACCENT_PRESETS[0]
|
applyAccentColor(hex)
|
||||||
applyAccent(preset)
|
|
||||||
persist()
|
persist()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -83,9 +94,9 @@ export const useSettingsStore = defineStore('settings', () => {
|
||||||
localStorage.setItem(STORAGE_KEY, JSON.stringify({
|
localStorage.setItem(STORAGE_KEY, JSON.stringify({
|
||||||
swipeLeftAction: swipeLeftAction.value,
|
swipeLeftAction: swipeLeftAction.value,
|
||||||
swipeRightAction: swipeRightAction.value,
|
swipeRightAction: swipeRightAction.value,
|
||||||
accentId: accentId.value,
|
accentColor: accentColor.value,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
return { swipeLeftAction, swipeRightAction, accentId }
|
return { swipeLeftAction, swipeRightAction, accentColor }
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { useAccountsStore } from '../stores/accounts.store'
|
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 router = useRouter()
|
||||||
const accountsStore = useAccountsStore()
|
const accountsStore = useAccountsStore()
|
||||||
|
|
@ -38,21 +38,29 @@ const swipeOptions: SwipeAction[] = ['delete', 'toggleRead', 'toggleFlag', 'none
|
||||||
<!-- Акцентный цвет -->
|
<!-- Акцентный цвет -->
|
||||||
<section>
|
<section>
|
||||||
<h2>Акцентный цвет</h2>
|
<h2>Акцентный цвет</h2>
|
||||||
<p class="section-desc">Выберите цвет выделения интерфейса</p>
|
<p class="section-desc">Выберите любой оттенок или используйте быстрый выбор</p>
|
||||||
<div class="accent-swatches">
|
<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
|
<button
|
||||||
v-for="preset in ACCENT_PRESETS"
|
v-for="hex in ACCENT_QUICK_PICKS"
|
||||||
:key="preset.id"
|
:key="hex"
|
||||||
class="accent-swatch"
|
class="quick-dot"
|
||||||
:class="{ active: settingsStore.accentId === preset.id }"
|
:class="{ active: settingsStore.accentColor.toLowerCase() === hex.toLowerCase() }"
|
||||||
:style="{ '--swatch-color': preset.accent }"
|
:style="{ '--dot-color': hex }"
|
||||||
:title="preset.label"
|
:title="hex"
|
||||||
@click="settingsStore.accentId = preset.id"
|
@click="settingsStore.accentColor = hex"
|
||||||
>
|
/>
|
||||||
<svg v-if="settingsStore.accentId === preset.id" viewBox="0 0 16 16" width="10" height="10" fill="none">
|
</div>
|
||||||
<polyline points="3,8 6.5,12 13,4" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
@ -270,38 +278,84 @@ const swipeOptions: SwipeAction[] = ['delete', 'toggleRead', 'toggleFlag', 'none
|
||||||
border-color: var(--accent);
|
border-color: var(--accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Accent swatches */
|
/* Color picker */
|
||||||
.accent-swatches {
|
.color-picker-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
.accent-swatch {
|
.color-input-wrap {
|
||||||
width: 34px;
|
|
||||||
height: 34px;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: var(--swatch-color);
|
|
||||||
border: 2px solid transparent;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
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;
|
cursor: pointer;
|
||||||
transition: transform var(--transition-fast), box-shadow var(--transition-fast), border-color var(--transition-fast);
|
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 6px rgba(0,0,0,0.4);
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
|
|
||||||
}
|
}
|
||||||
|
.quick-dot:hover {
|
||||||
.accent-swatch:hover {
|
transform: scale(1.15);
|
||||||
transform: scale(1.12);
|
|
||||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
|
|
||||||
}
|
}
|
||||||
|
.quick-dot.active {
|
||||||
.accent-swatch.active {
|
border-color: rgba(255,255,255,0.75);
|
||||||
border-color: rgba(255, 255, 255, 0.7);
|
box-shadow: 0 0 0 1px var(--dot-color), 0 3px 10px rgba(0,0,0,0.5);
|
||||||
box-shadow:
|
transform: scale(1.1);
|
||||||
0 0 0 1px var(--swatch-color),
|
|
||||||
0 4px 16px rgba(0, 0, 0, 0.5);
|
|
||||||
transform: scale(1.08);
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue