287 lines
6.6 KiB
Vue
287 lines
6.6 KiB
Vue
<script setup lang="ts">
|
|
import { computed } from 'vue'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { useCartStore } from '@/stores/cart'
|
|
import { useOrderStore } from '@/stores/order'
|
|
import {
|
|
DESKTOP_NAV_ITEMS,
|
|
isNavItemActive,
|
|
resolveNavPath,
|
|
} from '@/utils/navigation'
|
|
import IconHeadset from '@/components/icons/IconHeadset.vue'
|
|
|
|
const route = useRoute()
|
|
const router = useRouter()
|
|
const cartStore = useCartStore()
|
|
const orderStore = useOrderStore()
|
|
|
|
const cartCount = computed(() => cartStore.itemCount)
|
|
const draftCheckCount = computed(() => orderStore.draftChecks.length)
|
|
const activeCompanyId = computed(
|
|
() => cartStore.selectedCompanyId || cartStore.activeCart?.companyId || null,
|
|
)
|
|
|
|
function navigate(item: (typeof DESKTOP_NAV_ITEMS)[number]) {
|
|
router.push(resolveNavPath(item, activeCompanyId.value))
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<aside class="desktop-sidebar" aria-label="ناوبری اصلی">
|
|
<div class="desktop-sidebar__brand">
|
|
<span class="desktop-sidebar__logo-mark" aria-hidden="true">پ</span>
|
|
<strong class="desktop-sidebar__title">پارس بافت</strong>
|
|
</div>
|
|
|
|
<nav class="desktop-sidebar__nav">
|
|
<button
|
|
v-for="item in DESKTOP_NAV_ITEMS"
|
|
:key="item.name"
|
|
type="button"
|
|
class="desktop-sidebar__item"
|
|
:class="{ active: isNavItemActive(item.name, item.path, route.path) }"
|
|
:aria-current="isNavItemActive(item.name, item.path, route.path) ? 'page' : undefined"
|
|
:aria-label="item.label"
|
|
:title="item.label"
|
|
@click="navigate(item)"
|
|
>
|
|
<span class="desktop-sidebar__icon">
|
|
<component :is="item.icon" :size="20" />
|
|
</span>
|
|
<span class="desktop-sidebar__label">{{ item.label }}</span>
|
|
<span v-if="item.name === 'cart' && cartCount > 0" class="desktop-sidebar__badge">
|
|
{{ cartCount }}
|
|
</span>
|
|
<span v-if="item.name === 'checks' && draftCheckCount > 0" class="desktop-sidebar__badge">
|
|
{{ draftCheckCount }}
|
|
</span>
|
|
</button>
|
|
</nav>
|
|
|
|
<div class="desktop-sidebar__support">
|
|
<span class="desktop-sidebar__support-icon" aria-hidden="true">
|
|
<IconHeadset :size="22" />
|
|
</span>
|
|
<strong class="desktop-sidebar__support-title">پشتیبانی و راهنما</strong>
|
|
<p class="desktop-sidebar__support-text">
|
|
در صورت نیاز به راهنمایی یا گزارش مشکل با تیم پشتیبانی تماس بگیرید.
|
|
</p>
|
|
<a href="tel:02112345678" class="desktop-sidebar__support-btn">تماس با پشتیبانی</a>
|
|
</div>
|
|
</aside>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.desktop-sidebar {
|
|
display: none;
|
|
flex-direction: column;
|
|
width: var(--sidebar-width);
|
|
flex-shrink: 0;
|
|
height: 100%;
|
|
background: var(--color-surface);
|
|
border-inline-start: 1px solid var(--color-border);
|
|
padding: 0;
|
|
overflow-y: auto;
|
|
}
|
|
|
|
@media (min-width: 768px) {
|
|
.desktop-sidebar {
|
|
display: flex;
|
|
}
|
|
}
|
|
|
|
.desktop-sidebar__brand {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-start;
|
|
gap: 10px;
|
|
flex-shrink: 0;
|
|
height: var(--header-height);
|
|
min-height: var(--header-height);
|
|
max-height: var(--header-height);
|
|
box-sizing: border-box;
|
|
padding: 0 20px;
|
|
/* Border drawn by shared shell rule so it aligns with the top header */
|
|
border-bottom: none;
|
|
}
|
|
|
|
@media (min-width: 1200px) {
|
|
.desktop-sidebar__brand {
|
|
padding: 0 28px;
|
|
}
|
|
}
|
|
|
|
.desktop-sidebar__logo-mark {
|
|
width: 36px;
|
|
height: 36px;
|
|
border-radius: var(--radius-sm);
|
|
background: var(--color-primary);
|
|
color: var(--color-surface);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 1.125rem;
|
|
font-weight: 700;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.desktop-sidebar__title {
|
|
display: block;
|
|
font-size: 1rem;
|
|
font-weight: 700;
|
|
color: var(--color-primary);
|
|
}
|
|
|
|
.desktop-sidebar__nav {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 4px;
|
|
flex: 1;
|
|
padding: 12px 12px 0;
|
|
}
|
|
|
|
@media (min-width: 1200px) {
|
|
.desktop-sidebar__nav {
|
|
padding: 16px 16px 0;
|
|
}
|
|
}
|
|
|
|
.desktop-sidebar__item {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-start;
|
|
gap: 12px;
|
|
width: 100%;
|
|
padding: 11px 12px;
|
|
border: none;
|
|
border-radius: var(--radius-md);
|
|
background: none;
|
|
cursor: pointer;
|
|
color: var(--color-text-secondary);
|
|
text-align: start;
|
|
transition:
|
|
background 0.15s,
|
|
color 0.15s;
|
|
position: relative;
|
|
}
|
|
|
|
@media (min-width: 1200px) {
|
|
.desktop-sidebar__item {
|
|
padding: 11px 14px;
|
|
}
|
|
}
|
|
|
|
.desktop-sidebar__item:hover {
|
|
background: var(--color-elevated);
|
|
color: var(--color-text);
|
|
}
|
|
|
|
.desktop-sidebar__item:focus-visible {
|
|
outline: 2px solid var(--color-primary);
|
|
outline-offset: 2px;
|
|
}
|
|
|
|
.desktop-sidebar__item.active {
|
|
background: var(--color-primary-soft);
|
|
color: var(--color-primary);
|
|
font-weight: 600;
|
|
}
|
|
|
|
.desktop-sidebar__item.active .desktop-sidebar__icon {
|
|
color: var(--color-primary);
|
|
}
|
|
|
|
.desktop-sidebar__icon {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 22px;
|
|
height: 22px;
|
|
flex-shrink: 0;
|
|
color: inherit;
|
|
}
|
|
|
|
.desktop-sidebar__label {
|
|
display: block;
|
|
font-size: 0.875rem;
|
|
font-weight: inherit;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.desktop-sidebar__badge {
|
|
margin-inline-start: auto;
|
|
background: var(--color-danger);
|
|
color: var(--color-surface);
|
|
font-size: 0.6875rem;
|
|
font-weight: 700;
|
|
min-width: 20px;
|
|
height: 20px;
|
|
border-radius: 999px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 0 4px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.desktop-sidebar__support {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
margin: auto 12px 20px;
|
|
padding: 14px;
|
|
background: var(--color-primary-soft);
|
|
border-radius: var(--radius-lg);
|
|
}
|
|
|
|
@media (min-width: 1200px) {
|
|
.desktop-sidebar__support {
|
|
margin: auto 16px 24px;
|
|
padding: 16px;
|
|
}
|
|
}
|
|
|
|
.desktop-sidebar__support-icon {
|
|
width: 36px;
|
|
height: 36px;
|
|
border-radius: 50%;
|
|
background: var(--color-primary);
|
|
color: var(--color-surface);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.desktop-sidebar__support-title {
|
|
font-size: 0.875rem;
|
|
font-weight: 700;
|
|
color: var(--color-text);
|
|
}
|
|
|
|
.desktop-sidebar__support-text {
|
|
margin: 0;
|
|
font-size: 0.6875rem;
|
|
line-height: 1.5;
|
|
color: var(--color-text-muted);
|
|
}
|
|
|
|
.desktop-sidebar__support-btn {
|
|
display: block;
|
|
margin-top: 4px;
|
|
padding: 10px 12px;
|
|
border-radius: var(--radius-sm);
|
|
border: 1px solid var(--color-border);
|
|
background: var(--color-surface);
|
|
color: var(--color-primary);
|
|
font-size: 0.8125rem;
|
|
font-weight: 600;
|
|
text-align: center;
|
|
text-decoration: none;
|
|
transition: opacity 0.15s;
|
|
}
|
|
|
|
.desktop-sidebar__support-btn:hover {
|
|
opacity: 0.9;
|
|
}
|
|
</style>
|