Files
CRM_Montzar/apps/web/src/components/pipeline/DealCard.vue
T

231 lines
4.6 KiB
Vue
Raw Normal View History

<script setup lang="ts">
import { computed } from 'vue';
import UiIcon from '@/components/UiIcon.vue';
import type { PipelineAccent, PipelineDeal } from '@/lib/pipeline-board';
import { formatCurrencyParts, PIPELINE_ACCENT } from '@/lib/pipeline-board';
const props = defineProps<{
deal: PipelineDeal;
accent: PipelineAccent;
dragging?: boolean;
}>();
const emit = defineEmits<{
dragStart: [deal: PipelineDeal, event: DragEvent];
dragEnd: [];
open: [dealId: string];
menu: [dealId: string];
}>();
const money = computed(() =>
formatCurrencyParts(props.deal.amount, props.deal.currencyUnit ?? 'تومان'),
);
const colors = computed(() => PIPELINE_ACCENT[props.accent]);
</script>
<template>
<article
class="deal-card"
:class="{ dragging }"
draggable="true"
role="listitem"
:aria-grabbed="dragging ? 'true' : 'false'"
:style="{
'--badge-bg': colors.soft,
'--badge-fg': colors.text,
}"
@dragstart="emit('dragStart', deal, $event)"
@dragend="emit('dragEnd')"
@dblclick="emit('open', deal.id)"
>
<span class="badge" aria-hidden="true">{{ deal.initials }}</span>
<div class="titles">
<h3 @click.stop="emit('open', deal.id)">{{ deal.title }}</h3>
<p v-if="deal.description" class="desc">{{ deal.description }}</p>
</div>
<button
type="button"
class="menu"
aria-label="گزینه‌های معامله"
@click.stop="emit('menu', deal.id)"
>
<UiIcon name="dots-v" :size="16" />
</button>
<img
class="avatar"
src="/brand/user-avatar.png"
alt=""
width="32"
height="32"
/>
<span class="date">
{{ deal.date }}
<UiIcon name="calendar" :size="13" />
</span>
<div class="amount">
<strong>{{ money.number }}</strong>
<span>{{ money.unit }}</span>
</div>
</article>
</template>
<style scoped>
.deal-card {
--face: 32px;
display: grid;
grid-template-columns: var(--face) minmax(0, 1fr) auto;
grid-template-rows: auto auto;
column-gap: 0.5rem;
row-gap: 0.65rem;
align-items: center;
background: #fff;
border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
border-radius: var(--radius);
padding: 0.85rem 0.7rem 0.85rem 0.55rem;
min-width: 0;
overflow: hidden;
box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
cursor: grab;
transition:
box-shadow 0.18s ease,
border-color 0.18s ease,
transform 0.18s ease,
opacity 0.18s ease;
text-align: right;
direction: rtl;
}
.deal-card:hover {
border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
box-shadow: 0 6px 16px rgba(15, 23, 42, 0.07);
}
.deal-card:active {
cursor: grabbing;
}
.deal-card.dragging {
opacity: 0.95;
transform: scale(1.02);
box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.deal-card:focus-visible {
outline: 2px solid var(--accent);
outline-offset: 2px;
}
.badge,
.avatar {
width: var(--face);
height: var(--face);
max-width: var(--face);
border-radius: 999px;
justify-self: center;
}
.badge {
display: grid;
place-items: center;
background: var(--badge-bg);
color: var(--badge-fg);
font-size: 0.65rem;
font-weight: 800;
line-height: 1;
}
.avatar {
object-fit: cover;
border: 1px solid var(--line);
}
.titles {
min-width: 0;
text-align: right;
}
.titles h3 {
margin: 0;
font-size: 0.82rem;
font-weight: 800;
line-height: 1.4;
color: var(--ink);
cursor: pointer;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow-wrap: anywhere;
}
.desc {
margin: 0.1rem 0 0;
color: var(--muted);
font-size: 0.7rem;
line-height: 1.35;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.menu {
align-self: start;
justify-self: end;
border: 0;
background: none;
color: var(--muted);
width: auto;
height: auto;
padding: 0;
margin: 0;
line-height: 0;
cursor: pointer;
}
.menu:hover,
.menu:focus-visible {
color: var(--ink);
background: none;
outline: none;
}
.date {
display: flex;
align-items: center;
justify-content: flex-start;
gap: 0.25rem;
min-width: 0;
width: 100%;
color: var(--muted);
font-size: 0.68rem;
font-weight: 600;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.amount {
text-align: left;
display: grid;
justify-items: end;
gap: 0.02rem;
min-width: 0;
}
.amount strong {
font-size: 0.88rem;
font-weight: 800;
color: var(--ink);
letter-spacing: -0.01em;
max-width: 100%;
overflow-wrap: anywhere;
}
.amount span {
font-size: 0.65rem;
color: var(--muted);
font-weight: 600;
}
</style>