236 lines
6 KiB
Vue
236 lines
6 KiB
Vue
<script setup lang="ts">
|
|
import { useAccountsStore } from '../../stores/accounts.store'
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
import AppIcon from '../AppIcon.vue'
|
|
|
|
const emit = defineEmits<{
|
|
addAccount: []
|
|
}>()
|
|
|
|
const accountsStore = useAccountsStore()
|
|
const router = useRouter()
|
|
const route = useRoute()
|
|
|
|
function getInitial(email: string): string {
|
|
return email.charAt(0).toUpperCase()
|
|
}
|
|
|
|
function getAccountColor(index: number): string {
|
|
const colors = ['#38bdf8', '#a78bfa', '#f472b6', '#fb923c', '#4ade80', '#f87171', '#2dd4bf']
|
|
return colors[index % colors.length]
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="account-switcher">
|
|
<button
|
|
v-for="(account, index) in accountsStore.accounts"
|
|
:key="account.id"
|
|
class="account-btn"
|
|
:class="{ active: accountsStore.activeAccountId === account.id }"
|
|
v-tooltip="account.email"
|
|
@click="accountsStore.setActive(account.id)"
|
|
>
|
|
<span
|
|
class="account-avatar"
|
|
:style="{ background: account.color ?? getAccountColor(index) }"
|
|
>
|
|
{{ getInitial(account.email) }}
|
|
</span>
|
|
</button>
|
|
|
|
<button class="account-btn add-btn" v-tooltip="'Добавить аккаунт'" @click="emit('addAccount')">
|
|
<AppIcon name="plus" :size="16" class="add-icon" />
|
|
</button>
|
|
|
|
<div class="spacer" />
|
|
|
|
<button
|
|
class="account-btn nav-btn"
|
|
:class="{ 'nav-active': route.path === '/' || route.path === '' }"
|
|
v-tooltip="'Почта'"
|
|
@click="router.push('/')"
|
|
>
|
|
<AppIcon name="envelope" :size="15" class="nav-icon" />
|
|
</button>
|
|
|
|
<button
|
|
class="account-btn nav-btn"
|
|
:class="{ 'nav-active': route.path === '/calendar' }"
|
|
v-tooltip="'Календарь'"
|
|
@click="router.push('/calendar')"
|
|
>
|
|
<AppIcon name="calendar" :size="15" class="nav-icon" />
|
|
</button>
|
|
|
|
<button class="account-btn settings-btn" v-tooltip="'Настройки'" @click="router.push('/settings')">
|
|
<AppIcon name="settings" :size="15" class="settings-icon" />
|
|
</button>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.account-switcher {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
padding: 10px 0;
|
|
gap: 6px;
|
|
height: 100%;
|
|
}
|
|
|
|
.spacer {
|
|
flex: 1;
|
|
}
|
|
|
|
.account-btn {
|
|
position: relative;
|
|
width: 40px;
|
|
height: 40px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: var(--radius-md);
|
|
transition:
|
|
background var(--transition-fast),
|
|
box-shadow var(--transition-fast);
|
|
}
|
|
|
|
.account-btn:hover {
|
|
background: var(--glass-bg-hover);
|
|
}
|
|
|
|
.account-avatar {
|
|
width: 30px;
|
|
height: 30px;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
color: #0d1a00;
|
|
transition: box-shadow var(--transition-fast), filter var(--transition-fast);
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
|
|
}
|
|
|
|
.account-btn.active .account-avatar {
|
|
box-shadow:
|
|
0 0 0 2px rgba(9, 9, 14, 0.8),
|
|
0 0 0 3.5px var(--accent),
|
|
0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent);
|
|
}
|
|
|
|
.account-btn:not(.active):hover .account-avatar {
|
|
filter: brightness(1.1);
|
|
}
|
|
|
|
|
|
.add-btn,
|
|
.settings-btn {
|
|
border-radius: 50%;
|
|
width: 32px;
|
|
height: 32px;
|
|
background: rgba(255, 255, 255, 0.05);
|
|
border: 1px solid rgba(255, 255, 255, 0.08);
|
|
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
|
|
transition:
|
|
background var(--transition-fast),
|
|
border-color var(--transition-fast),
|
|
box-shadow var(--transition-fast);
|
|
}
|
|
|
|
.add-btn:hover,
|
|
.settings-btn:hover {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-color: rgba(255, 255, 255, 0.15);
|
|
box-shadow:
|
|
inset 0 1px 0 rgba(255, 255, 255, 0.1),
|
|
0 2px 8px rgba(0, 0, 0, 0.2);
|
|
}
|
|
|
|
.add-btn:active,
|
|
.settings-btn:active {
|
|
background: rgba(255, 255, 255, 0.03);
|
|
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
|
|
transform: scale(0.92);
|
|
}
|
|
|
|
.add-icon,
|
|
.settings-icon,
|
|
.nav-icon {
|
|
color: var(--text-muted);
|
|
transition: color var(--transition-fast);
|
|
}
|
|
|
|
.add-btn:hover .add-icon,
|
|
.settings-btn:hover .settings-icon,
|
|
.nav-btn:hover .nav-icon {
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.nav-btn.nav-active {
|
|
background: var(--accent-muted);
|
|
border-color: color-mix(in srgb, var(--accent) 35%, transparent);
|
|
}
|
|
|
|
.nav-btn.nav-active .nav-icon {
|
|
color: var(--accent);
|
|
}
|
|
|
|
/* ── Material 3 (Navigation Rail) ── */
|
|
html[data-design='material3'] .account-btn:hover {
|
|
background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, transparent);
|
|
}
|
|
|
|
html[data-design='material3'] .account-avatar {
|
|
box-shadow: none;
|
|
}
|
|
|
|
html[data-design='material3'] .account-btn.active .account-avatar {
|
|
box-shadow:
|
|
0 0 0 2px var(--md-sys-color-surface-container-low),
|
|
0 0 0 3.5px var(--md-sys-color-primary);
|
|
}
|
|
|
|
html[data-design='material3'] .add-btn,
|
|
html[data-design='material3'] .settings-btn {
|
|
background: var(--md-sys-color-surface-container-high);
|
|
border: 1px solid var(--md-sys-color-outline-variant);
|
|
box-shadow: none;
|
|
}
|
|
|
|
html[data-design='material3'] .add-btn:hover,
|
|
html[data-design='material3'] .settings-btn:hover {
|
|
background: color-mix(in srgb, var(--md-sys-color-on-surface) 8%, var(--md-sys-color-surface-container-high));
|
|
border-color: var(--md-sys-color-outline);
|
|
box-shadow: none;
|
|
}
|
|
|
|
html[data-design='material3'] .add-btn:active,
|
|
html[data-design='material3'] .settings-btn:active {
|
|
background: color-mix(in srgb, var(--md-sys-color-on-surface) 10%, var(--md-sys-color-surface-container-high));
|
|
box-shadow: none;
|
|
}
|
|
|
|
html[data-design='material3'] .add-icon,
|
|
html[data-design='material3'] .settings-icon,
|
|
html[data-design='material3'] .nav-icon {
|
|
color: var(--md-sys-color-on-surface-variant);
|
|
}
|
|
|
|
html[data-design='material3'] .add-btn:hover .add-icon,
|
|
html[data-design='material3'] .settings-btn:hover .settings-icon,
|
|
html[data-design='material3'] .nav-btn:hover .nav-icon {
|
|
color: var(--md-sys-color-on-surface);
|
|
}
|
|
|
|
html[data-design='material3'] .nav-btn.nav-active {
|
|
background: var(--md-sys-color-secondary-container);
|
|
border-color: transparent;
|
|
}
|
|
|
|
html[data-design='material3'] .nav-btn.nav-active .nav-icon {
|
|
color: var(--md-sys-color-on-secondary-container);
|
|
}
|
|
</style>
|