407 lines
8.7 KiB
Vue
407 lines
8.7 KiB
Vue
<script setup lang="ts">
|
||
import { computed } from 'vue';
|
||
import { RouterLink } from 'vue-router';
|
||
import UiIcon from '@/components/UiIcon.vue';
|
||
import MentoAiAvatar from '@/components/brand/MentoAiAvatar.vue';
|
||
import type { HomeDashboardAlertDto } from '@mento/shared';
|
||
|
||
const props = defineProps<{
|
||
greeting: string;
|
||
firstName: string;
|
||
userInitial: string;
|
||
alerts: HomeDashboardAlertDto[];
|
||
askQuery: string;
|
||
}>();
|
||
|
||
const emit = defineEmits<{
|
||
'update:askQuery': [value: string];
|
||
ask: [];
|
||
}>();
|
||
|
||
type HeroChip = {
|
||
key: string;
|
||
tone: HomeDashboardAlertDto['tone'];
|
||
title: string;
|
||
subtitle?: string;
|
||
link: string;
|
||
};
|
||
|
||
const defaultChips: HeroChip[] = [
|
||
{
|
||
key: 'demo-urgent',
|
||
tone: 'urgent',
|
||
title: 'شرکت آماده تصمیمگیریه',
|
||
subtitle: 'امروز تماس بگیر',
|
||
link: '/pipeline',
|
||
},
|
||
{
|
||
key: 'demo-warning',
|
||
tone: 'warning',
|
||
title: '۳ معامله بیشتر از ۵ روزه',
|
||
subtitle: 'پیگیری نشدن',
|
||
link: '/pipeline',
|
||
},
|
||
{
|
||
key: 'demo-success',
|
||
tone: 'success',
|
||
title: 'این ماه از تارگت جلوتری',
|
||
link: '/sales/forecast',
|
||
},
|
||
];
|
||
|
||
const chips = computed<HeroChip[]>(() => {
|
||
const fromApi = props.alerts.slice(0, 3).map((a) => {
|
||
const parts = a.text.split(/\s*[—\-–]\s*|\n/);
|
||
const title = parts[0]?.trim() || a.text;
|
||
const subtitle = parts.slice(1).join(' ').trim() || undefined;
|
||
return {
|
||
key: a.key,
|
||
tone: a.tone,
|
||
title,
|
||
subtitle,
|
||
link: a.link || '/',
|
||
};
|
||
});
|
||
if (fromApi.length >= 3) return fromApi;
|
||
const usedTones = new Set(fromApi.map((c) => c.tone));
|
||
const fillers = defaultChips.filter((c) => !usedTones.has(c.tone));
|
||
return [...fromApi, ...fillers].slice(0, 3);
|
||
});
|
||
|
||
function alertIcon(tone: string) {
|
||
if (tone === 'urgent') return 'fire' as const;
|
||
if (tone === 'warning') return 'warning' as const;
|
||
if (tone === 'success') return 'trend' as const;
|
||
return 'sparkle' as const;
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<header class="hero">
|
||
<div class="hero-surface" aria-hidden="true">
|
||
<div class="hero-glow" />
|
||
<div class="hero-mist" />
|
||
</div>
|
||
|
||
<div class="hero-body">
|
||
<div class="hero-greet">
|
||
<span class="hero-avatar">
|
||
<img src="/brand/user-avatar.png" :alt="firstName" width="72" height="72" />
|
||
<i class="online" />
|
||
</span>
|
||
<div class="greet-text">
|
||
<h1>{{ greeting }} {{ firstName }} 👋</h1>
|
||
<p>منتو اینا رو برات پیدا کرده</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="hero-chips">
|
||
<RouterLink
|
||
v-for="chip in chips"
|
||
:key="chip.key"
|
||
class="chip"
|
||
:class="`chip-${chip.tone}`"
|
||
:to="chip.link"
|
||
>
|
||
<span class="chip-ico"><UiIcon :name="alertIcon(chip.tone)" :size="13" /></span>
|
||
<span class="chip-text">
|
||
<strong>{{ chip.title }}</strong>
|
||
<small v-if="chip.subtitle">{{ chip.subtitle }}</small>
|
||
</span>
|
||
</RouterLink>
|
||
</div>
|
||
|
||
<form class="hero-ask" @submit.prevent="emit('ask')">
|
||
<UiIcon name="sparkle" :size="18" class="ask-ico" />
|
||
<input
|
||
:value="askQuery"
|
||
type="search"
|
||
placeholder="از منتو بپرس..."
|
||
@input="emit('update:askQuery', ($event.target as HTMLInputElement).value)"
|
||
/>
|
||
<kbd>⌘K</kbd>
|
||
</form>
|
||
</div>
|
||
|
||
<MentoAiAvatar class="hero-bot" :size="156" />
|
||
</header>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.hero {
|
||
position: relative;
|
||
display: grid;
|
||
/* RTL: body سمت راست، ربات سمت چپ — فضای اضافه برای پاپآپ */
|
||
grid-template-columns: minmax(0, 1fr) 210px;
|
||
gap: 0.7rem 1rem;
|
||
align-items: start;
|
||
min-height: 0;
|
||
padding: 0.8rem 1.5rem 0.9rem;
|
||
border-radius: 28px;
|
||
overflow: visible;
|
||
color: #fff;
|
||
background: transparent;
|
||
isolation: isolate;
|
||
}
|
||
|
||
.hero-surface {
|
||
position: absolute;
|
||
inset: 0;
|
||
z-index: 0;
|
||
border-radius: 28px;
|
||
overflow: hidden;
|
||
background-color: #134e4a;
|
||
background-image:
|
||
radial-gradient(ellipse 55% 90% at 8% 55%, rgba(103, 232, 249, 0.55) 0%, rgba(45, 212, 191, 0.22) 35%, transparent 68%),
|
||
radial-gradient(ellipse 50% 80% at 92% 40%, rgba(153, 246, 228, 0.28) 0%, transparent 55%),
|
||
radial-gradient(ellipse 70% 60% at 45% 30%, rgba(45, 212, 191, 0.18) 0%, transparent 60%),
|
||
radial-gradient(ellipse 60% 50% at 60% 85%, rgba(15, 23, 42, 0.28) 0%, transparent 55%),
|
||
linear-gradient(
|
||
105deg,
|
||
#0b3d3a 0%,
|
||
#115e59 22%,
|
||
#0f766e 48%,
|
||
#134e4a 72%,
|
||
#0f3f3c 100%
|
||
);
|
||
box-shadow:
|
||
0 16px 36px rgba(15, 118, 110, 0.22),
|
||
inset 0 1px 0 rgba(255, 255, 255, 0.18),
|
||
inset 0 0 0 1px rgba(255, 255, 255, 0.08);
|
||
}
|
||
|
||
.hero-glow {
|
||
position: absolute;
|
||
width: 320px;
|
||
height: 320px;
|
||
border-radius: 999px;
|
||
inset-inline-end: -70px;
|
||
top: 40%;
|
||
transform: translateY(-50%);
|
||
background:
|
||
radial-gradient(circle, rgba(165, 243, 252, 0.65) 0%, rgba(34, 211, 238, 0.28) 32%, transparent 68%);
|
||
filter: blur(8px);
|
||
pointer-events: none;
|
||
}
|
||
|
||
.hero-mist {
|
||
position: absolute;
|
||
inset: 0;
|
||
background:
|
||
radial-gradient(ellipse 40% 35% at 25% 20%, rgba(255, 255, 255, 0.14) 0%, transparent 70%),
|
||
radial-gradient(ellipse 35% 40% at 70% 75%, rgba(204, 251, 241, 0.12) 0%, transparent 70%),
|
||
radial-gradient(ellipse 50% 45% at 50% 50%, rgba(15, 118, 110, 0.35) 0%, transparent 75%);
|
||
pointer-events: none;
|
||
}
|
||
|
||
.hero-body,
|
||
.hero-bot {
|
||
position: relative;
|
||
z-index: 1;
|
||
}
|
||
|
||
.hero-body {
|
||
display: grid;
|
||
gap: 0.75rem;
|
||
min-width: 0;
|
||
padding-top: 0;
|
||
}
|
||
|
||
.hero-greet {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 0.9rem;
|
||
}
|
||
|
||
.hero-avatar {
|
||
position: relative;
|
||
width: 72px;
|
||
height: 72px;
|
||
border-radius: 999px;
|
||
flex-shrink: 0;
|
||
box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
|
||
}
|
||
|
||
.hero-avatar img {
|
||
width: 100%;
|
||
height: 100%;
|
||
object-fit: cover;
|
||
display: block;
|
||
border-radius: 999px;
|
||
border: 3px solid rgba(255, 255, 255, 0.65);
|
||
background: rgba(255, 255, 255, 0.22);
|
||
box-sizing: border-box;
|
||
}
|
||
|
||
.online {
|
||
position: absolute;
|
||
bottom: 3px;
|
||
inset-inline-start: 3px;
|
||
width: 14px;
|
||
height: 14px;
|
||
border-radius: 999px;
|
||
background: #22c55e;
|
||
border: 2px solid #fff;
|
||
z-index: 1;
|
||
}
|
||
|
||
.greet-text h1 {
|
||
margin: 0;
|
||
font-size: clamp(1.35rem, 2vw, 1.75rem);
|
||
font-weight: 800;
|
||
letter-spacing: -0.01em;
|
||
color: #fff;
|
||
}
|
||
|
||
.greet-text p {
|
||
margin: 0.25rem 0 0;
|
||
color: rgba(255, 255, 255, 0.88);
|
||
font-size: 0.9rem;
|
||
font-weight: 500;
|
||
}
|
||
|
||
.hero-chips {
|
||
display: grid;
|
||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||
gap: 0.4rem;
|
||
max-width: 580px;
|
||
}
|
||
|
||
.chip {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 0.4rem;
|
||
min-width: 0;
|
||
padding: 0.4rem 0.5rem;
|
||
border-radius: 12px;
|
||
background: #fff;
|
||
color: #0f172a;
|
||
text-decoration: none;
|
||
box-shadow: 0 6px 14px rgba(15, 23, 42, 0.07);
|
||
}
|
||
|
||
.chip-text {
|
||
display: grid;
|
||
gap: 0.04rem;
|
||
min-width: 0;
|
||
}
|
||
|
||
.chip-text strong {
|
||
font-size: 0.68rem;
|
||
font-weight: 700;
|
||
line-height: 1.3;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.chip-text small {
|
||
font-size: 0.6rem;
|
||
color: #64748b;
|
||
font-weight: 500;
|
||
line-height: 1.25;
|
||
overflow: hidden;
|
||
text-overflow: ellipsis;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.chip-ico {
|
||
width: 22px;
|
||
height: 22px;
|
||
border-radius: 8px;
|
||
display: grid;
|
||
place-items: center;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.chip-urgent .chip-ico {
|
||
background: #fee2e2;
|
||
color: #ef4444;
|
||
}
|
||
|
||
.chip-warning .chip-ico {
|
||
background: #fef3c7;
|
||
color: #d97706;
|
||
}
|
||
|
||
.chip-success .chip-ico,
|
||
.chip-info .chip-ico {
|
||
background: #dcfce7;
|
||
color: #16a34a;
|
||
}
|
||
|
||
.hero-ask {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 0.55rem;
|
||
max-width: 520px;
|
||
width: 100%;
|
||
background: #fff;
|
||
color: #0f172a;
|
||
border-radius: 999px;
|
||
padding: 0.55rem 0.9rem;
|
||
box-shadow: 0 10px 24px rgba(15, 23, 42, 0.1);
|
||
}
|
||
|
||
.ask-ico {
|
||
color: #14b8a6;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.hero-ask input {
|
||
border: 0;
|
||
background: transparent;
|
||
flex: 1;
|
||
outline: none;
|
||
font-size: 0.9rem;
|
||
min-width: 0;
|
||
}
|
||
|
||
.hero-ask input::placeholder {
|
||
color: #94a3b8;
|
||
}
|
||
|
||
.hero-ask kbd {
|
||
font-size: 0.68rem;
|
||
color: #94a3b8;
|
||
background: #f1f5f9;
|
||
border: 1px solid #e2e8f0;
|
||
border-radius: 7px;
|
||
padding: 0.14rem 0.38rem;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
.hero-bot {
|
||
position: relative;
|
||
z-index: 1;
|
||
/* در RTL ستون ربات سمت چپ است؛ end = لبه بیرونی چپ */
|
||
justify-self: end;
|
||
align-self: center;
|
||
margin-inline-start: 0;
|
||
margin-inline-end: 0.35rem;
|
||
overflow: visible;
|
||
}
|
||
|
||
@media (max-width: 900px) {
|
||
.hero {
|
||
grid-template-columns: minmax(0, 1fr) 160px;
|
||
}
|
||
|
||
.hero-chips {
|
||
grid-template-columns: 1fr;
|
||
max-width: 420px;
|
||
}
|
||
}
|
||
|
||
@media (max-width: 700px) {
|
||
.hero {
|
||
grid-template-columns: 1fr;
|
||
min-height: auto;
|
||
}
|
||
|
||
.hero-bot {
|
||
display: none;
|
||
}
|
||
}
|
||
</style>
|