داشبوردِ عملکردِ تیم
پیشنمایش تمامصفحهسلام و تاریخ، سه شاخص با آیکون و تغییر، نمودارِ ناحیهایِ این هفته/هفتهٔ قبل، کارهای جاری با وضعیت و ساعت، و ستونِ کنار با کارتِ همتیمی، فعالیتها با پیام و فایل و نوشتنِ پیام.
۱. نصب کامپوننتها
این بلاک از ۹ آیتم دیگ استفاده میکند: avatarbuttoncardchart-presetscontrol-sizeiconspersiantext-fieldtoggle-group
npx digdesign@latest add https://docs.digdesign.ir/r/avatar.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/card.json https://docs.digdesign.ir/r/chart-presets.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/text-field.json https://docs.digdesign.ir/r/toggle-group.jsonpnpm dlx digdesign@latest add https://docs.digdesign.ir/r/avatar.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/card.json https://docs.digdesign.ir/r/chart-presets.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/text-field.json https://docs.digdesign.ir/r/toggle-group.jsonyarn dlx digdesign@latest add https://docs.digdesign.ir/r/avatar.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/card.json https://docs.digdesign.ir/r/chart-presets.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/text-field.json https://docs.digdesign.ir/r/toggle-group.jsonbunx --bun digdesign@latest add https://docs.digdesign.ir/r/avatar.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/card.json https://docs.digdesign.ir/r/chart-presets.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/text-field.json https://docs.digdesign.ir/r/toggle-group.jsonnpx digdesign@latest add avatar button card chart-presets control-size persian text-field toggle-group --framework vuepnpm dlx digdesign@latest add avatar button card chart-presets control-size persian text-field toggle-group --framework vueyarn dlx digdesign@latest add avatar button card chart-presets control-size persian text-field toggle-group --framework vuebunx --bun digdesign@latest add avatar button card chart-presets control-size persian text-field toggle-group --framework vuenpx digdesign@latest add button --framework sveltepnpm dlx digdesign@latest add button --framework svelteyarn dlx digdesign@latest add button --framework sveltebunx --bun digdesign@latest add button --framework sveltenpx digdesign@latest add avatar button card chart-presets control-size icons input persian text-field toggle-group --framework angularpnpm dlx digdesign@latest add avatar button card chart-presets control-size icons input persian text-field toggle-group --framework angularyarn dlx digdesign@latest add avatar button card chart-presets control-size icons input persian text-field toggle-group --framework angularbunx --bun digdesign@latest add avatar button card chart-presets control-size icons input persian text-field toggle-group --framework angularnpx digdesign@latest add avatar button card chart-presets control-size persian text-field toggle-group --framework androidpnpm dlx digdesign@latest add avatar button card chart-presets control-size persian text-field toggle-group --framework androidyarn dlx digdesign@latest add avatar button card chart-presets control-size persian text-field toggle-group --framework androidbunx --bun digdesign@latest add avatar button card chart-presets control-size persian text-field toggle-group --framework android۲. کد صفحه
کد را در صفحهٔ پروژهتان بگذارید (React: app/<route>/page.tsx) و متنها، داده و هندلرها را با محصول خودتان عوض کنید. با سوییچر فریمورک کدِ همین صفحه در فریمورک دیگر را ببینید.
"use client"
import * as React from "react"
import { ActivityIcon, CalendarIcon, ClockIcon, DownloadIcon, MoreHorizontalIcon, PaperclipIcon, PhoneIcon, ThumbsUpIcon, TrendingUpIcon } from "@/components/icons"
import { Avatar } from "@/components/ui/avatar"
import { Button } from "@/components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { AreaChart } from "@/components/ui/chart-presets"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { TextField } from "@/components/ui/text-field"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
import { toFaDigits } from "@/lib/persian"
import { avatarPhoto, stockImages } from "@/lib/stock-images"
const KPIS = [
{ icon: <ThumbsUpIcon />, label: "انجامشده", value: "۱۸ کار", delta: "+۸ کار", good: true },
{ icon: <ClockIcon />, label: "ساعتِ ثبتشده", value: "۳۱ ساعت", delta: "−۶ ساعت", good: false },
{ icon: <TrendingUpIcon />, label: "بهرهوری", value: "٪۹۳", delta: "+٪۱۲", good: true },
]
const PERFORMANCE = [
{ label: "شنبه", now: 4, last: 6 },
{ label: "یکشنبه", now: 5, last: 4 },
{ label: "دوشنبه", now: 7, last: 6 },
{ label: "سهشنبه", now: 9, last: 5 },
{ label: "چهارشنبه", now: 7, last: 3 },
{ label: "پنجشنبه", now: 6, last: 4 },
{ label: "جمعه", now: 8, last: 5 },
]
type Status = "progress" | "hold" | "done"
const STATUS: Record<Status, { label: string; dot: string }> = {
progress: { label: "در جریان", dot: "bg-[var(--dig-orange-500)]" },
hold: { label: "متوقف", dot: "bg-[var(--dig-blue-500)]" },
done: { label: "انجام شد", dot: "bg-success" },
}
const TASKS: { id: string; title: string; status: Status; hours: number; icon: React.ReactNode }[] = [
{ id: "t1", title: "بازبینیِ محصول برای بازارِ تازه", status: "progress", hours: 4, icon: <ActivityIcon /> },
{ id: "t2", title: "پژوهشِ کاربر برای اپِ بانکی", status: "hold", hours: 8, icon: <CalendarIcon /> },
{ id: "t3", title: "طراحی و توسعهٔ داشبوردِ فروش", status: "done", hours: 32, icon: <TrendingUpIcon /> },
]
const ACTIVITY = [
{ name: "امیر رضایی", gender: "male" as const, action: "روی پروژهٔ بانکِ آینده نظر داد", time: "۱۰:۱۵", message: "هفتهٔ بعد پروژهٔ تازه را شروع میکنیم؛ جزئیات را بعد میگویم." },
{ name: "سارا محمدی", gender: "female" as const, action: "فایلی به پروژهٔ کافه رست افزود", time: "۰۹:۴۰", file: { name: "صفحه-اصلی.fig", size: "۱۳٫۴ مگابایت" } },
{ name: "نگار احمدی", gender: "female" as const, action: "روی داشبوردِ فروش نظر داد", time: "دیروز" },
]
/**
* داشبوردِ عملکردِ تیم: سلام و توضیحِ کوتاه با تاریخ، سه شاخص با آیکون و تغییرِ رنگی (کلمهٔ «کار»
* و «ساعت» کنارِ عدد)، نمودارِ ناحیهایِ این هفته در برابرِ هفتهٔ قبل، کارهای جاری با وضعیتِ نقطهای و
* ساعت، و ستونِ کنار با کارتِ همتیمی (تماس و تماسِ تصویری)، فعالیتها با پیام و فایل، و نوشتنِ پیام.
*/
export default function DashboardTeamBlock() {
const [range, setRange] = React.useState("week")
const [message, setMessage] = React.useState("")
return (
<ControlSizeProvider size="xl" asChild>
<main className="mx-auto grid w-full max-w-6xl grid-cols-1 items-start gap-6 p-4 sm:p-6 lg:grid-cols-[minmax(0,1fr)_21rem]">
<div className="flex min-w-0 flex-col gap-8">
<header className="flex flex-wrap items-start justify-between gap-x-4 gap-y-4">
<div className="flex flex-col gap-1">
<h1 className="text-2xl leading-snug font-black sm:text-3xl">سلام آرمیتا</h1>
<p className="text-muted-foreground">پیشرفتِ تیم را اینجا ببین؛ تا هدفِ هفته چیزی نمانده.</p>
</div>
<span className="flex items-center gap-2 rounded-full border border-border px-4 py-2 text-sm [&>svg]:size-4 [&>svg]:text-muted-foreground">
<CalendarIcon aria-hidden />
۱۶ مهر ۱۴۰۵
</span>
</header>
<ul className="grid grid-cols-1 divide-y divide-border border-y border-border sm:grid-cols-3 sm:divide-x sm:divide-y-0 rtl:sm:divide-x-reverse">
{KPIS.map((kpi) => (
<li key={kpi.label} className="flex items-center gap-3 py-5 sm:px-5 sm:first:ps-0">
<span aria-hidden className="flex size-12 shrink-0 items-center justify-center rounded-full bg-muted [&>svg]:size-5">
{kpi.icon}
</span>
<span className="flex flex-col gap-0.5">
<span className="text-sm text-muted-foreground">{kpi.label}</span>
<span className="flex items-baseline gap-2">
<span className="text-xl font-black">{kpi.value}</span>
<span className={`text-xs font-semibold ${kpi.good ? "text-success-subtle-foreground" : "text-destructive"}`}>{kpi.delta}</span>
</span>
</span>
</li>
))}
</ul>
<section aria-labelledby="perf-title" className="flex flex-col gap-4">
<div className="flex items-center justify-between gap-3">
<h2 id="perf-title" className="text-lg font-bold">
عملکرد (ساعت)
</h2>
<ControlSizeProvider size="lg" mobileSize="default" asChild>
<ToggleGroup type="single" variant="segmented" value={range} onValueChange={(value) => value && setRange(value as string)} aria-label="بازه">
<ToggleGroupItem value="week">هفته</ToggleGroupItem>
<ToggleGroupItem value="days">۴ روز</ToggleGroupItem>
</ToggleGroup>
</ControlSizeProvider>
</div>
<AreaChart
className="h-60"
data={range === "days" ? PERFORMANCE.slice(-4) : PERFORMANCE}
categoryKey="label"
smooth
showPoints={false}
series={[
{ key: "now", label: "این هفته", color: "var(--dig-blue-500)" },
{ key: "last", label: "هفتهٔ قبل", color: "var(--dig-amber-500)" },
]}
valueFormatter={(value) => `${toFaDigits(value)} ساعت`}
/>
</section>
<section aria-labelledby="tasks-title" className="flex flex-col gap-2">
<div className="flex items-center gap-4">
<h2 id="tasks-title" className="text-lg font-bold">
کارهای جاری
</h2>
<span className="text-sm text-muted-foreground">٪۳۰ انجام شده</span>
</div>
<ul className="flex flex-col">
{TASKS.map((task) => (
<li key={task.id} className="flex items-center gap-3 py-3">
<span aria-hidden className="flex size-12 shrink-0 items-center justify-center rounded-full bg-muted [&>svg]:size-5">
{task.icon}
</span>
<span className="flex min-w-0 flex-1 flex-col gap-1 sm:flex-row sm:items-center sm:gap-4">
<span className="flex-1 truncate font-medium">{task.title}</span>
<span className="flex items-center gap-4 text-sm">
<span className="flex w-24 items-center gap-2">
<span aria-hidden className={`size-2 rounded-full ${STATUS[task.status].dot}`} />
{STATUS[task.status].label}
</span>
<span className="flex items-center gap-1 text-muted-foreground tabular-nums [&>svg]:size-4">
<ClockIcon aria-hidden />
{toFaDigits(task.hours)} ساعت
</span>
</span>
</span>
<Button variant="ghost" size="icon" aria-label={`گزینههای «${task.title}»`} className="shrink-0">
<MoreHorizontalIcon />
</Button>
</li>
))}
</ul>
</section>
</div>
<aside className="flex flex-col gap-6">
{/* کارتِ همتیمی، نه پروفایلِ خودِ کاربر؛ برچسبِ بالا این را میگوید تا با «سلام آرمیتا» قاطی نشود. */}
<Card className="items-center bg-subtle text-center shadow-none">
<CardContent className="flex flex-col items-center gap-4">
<span className="text-xs font-medium text-muted-foreground">همتیمیِ برترِ این هفته</span>
<span className="relative">
<Avatar alt="مهسا کریمی" src={stockImages.personWoman1.src} className="size-24 ring-4 ring-card" />
<span aria-label="آنلاین" className="absolute end-1 bottom-1 size-4 rounded-full bg-success ring-2 ring-subtle" />
</span>
<span className="flex flex-col">
<span className="font-bold">مهسا کریمی</span>
<bdi dir="ltr" className="text-sm text-muted-foreground">
@mahsa.karimi
</bdi>
</span>
<div className="flex gap-3">
<Button variant="outline" size="icon" aria-label="تماس" className="rounded-full bg-card">
<PhoneIcon />
</Button>
<Button variant="outline" size="icon" aria-label="گزینههای بیشتر" className="rounded-full bg-card">
<MoreHorizontalIcon />
</Button>
</div>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle className="text-lg">فعالیتها</CardTitle>
</CardHeader>
<CardContent className="flex flex-col gap-5">
<ul className="flex flex-col gap-5">
{ACTIVITY.map((item) => (
<li key={item.name + item.time} className="flex items-start gap-3">
<Avatar alt={item.name} src={avatarPhoto(item.name, item.gender)} className="size-10" />
<span className="flex min-w-0 flex-1 flex-col gap-2">
<span className="flex flex-col gap-0.5">
<span className="flex items-center justify-between gap-2">
<span className="text-sm font-bold">{item.name}</span>
<span className="text-xs text-muted-foreground tabular-nums">{item.time}</span>
</span>
<span className="text-sm text-muted-foreground">{item.action}</span>
</span>
{item.message && <span className="rounded-xl rounded-ss-sm bg-[color-mix(in_oklab,var(--dig-blue-500)_10%,var(--card))] p-3 text-sm leading-6">{item.message}</span>}
{item.file && (
<span className="flex items-center gap-3 rounded-xl bg-[color-mix(in_oklab,var(--dig-blue-500)_10%,var(--card))] p-3">
<span className="flex min-w-0 flex-1 flex-col">
<span className="truncate text-sm font-semibold">{item.file.name}</span>
<span className="text-xs text-muted-foreground">{item.file.size}</span>
</span>
<ControlSizeProvider size="lg" asChild>
<Button variant="ghost" size="icon" aria-label={`دریافتِ ${item.file.name}`} className="shrink-0">
<DownloadIcon />
</Button>
</ControlSizeProvider>
</span>
)}
</span>
</li>
))}
</ul>
<form
className="mt-5 flex items-end gap-2 border-t border-border pt-5"
onSubmit={(event) => {
event.preventDefault()
setMessage("")
}}
>
<TextField aria-label="پیام به تیم" placeholder="پیامی بنویس…" value={message} onValueChange={setMessage} className="flex-1" startContent={<PaperclipIcon aria-hidden />} />
</form>
</CardContent>
</Card>
</aside>
</main>
</ControlSizeProvider>
)
}
<script setup lang="ts">
import { computed, ref } from "vue"
import Avatar from "@/components/ui/Avatar.vue"
import AreaChart from "@/components/ui/AreaChart.vue"
import Button from "@/components/ui/Button.vue"
import Card from "@/components/ui/Card.vue"
import CardContent from "@/components/ui/CardContent.vue"
import CardHeader from "@/components/ui/CardHeader.vue"
import CardTitle from "@/components/ui/CardTitle.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import TextField from "@/components/ui/TextField.vue"
import ToggleGroup from "@/components/ui/ToggleGroup.vue"
import ToggleGroupItem from "@/components/ui/ToggleGroupItem.vue"
import { DigIcon, type DigIconName } from "@/lib/icons"
import { toFaDigits } from "@/lib/persian"
// stock-images:begin
/** تصویرهای کتابخانهٔ دیگ (همان آدرسهای `stockImages` نسخهٔ React). */
const stockImages: Record<string, { src: string; alt: string }> = {
personWoman1: { src: "https://docs.digdesign.ir/images/person-woman-1.webp", alt: "پرترهٔ زنی با روسری" },
personWoman2: { src: "https://docs.digdesign.ir/images/person-woman-2.webp", alt: "پرترهٔ زنی با کتِ طوسی" },
personWoman3: { src: "https://docs.digdesign.ir/images/person-woman-3.webp", alt: "پرترهٔ زنی خندان" },
personMan1: { src: "https://docs.digdesign.ir/images/person-man-1.webp", alt: "پرترهٔ مردی با لبخند" },
personMan2: { src: "https://docs.digdesign.ir/images/person-man-2.webp", alt: "پرترهٔ مردی با تیشرتِ سفید" },
}
// stock-images:end
/** همان `avatarPhoto` نسخهٔ React: از روی نام، یکی از عکسهای آماده را انتخاب میکند (گاهی هیچ، تا حروفِ اولِ نام بنشیند). */
function avatarPhoto(name: string, gender: "male" | "female"): string | undefined {
let hash = 0
for (const char of name) hash = (hash * 31 + char.charCodeAt(0)) >>> 0
if (hash % 4 === 3) return undefined
const pool = gender === "female" ? ["personWoman1", "personWoman2", "personWoman3"] : ["personMan1", "personMan2"]
return stockImages[pool[hash % pool.length]].src
}
const KPIS: { icon: DigIconName; label: string; value: string; delta: string; good: boolean }[] = [
{ icon: "thumbs-up", label: "انجامشده", value: "۱۸ کار", delta: "+۸ کار", good: true },
{ icon: "clock", label: "ساعتِ ثبتشده", value: "۳۱ ساعت", delta: "−۶ ساعت", good: false },
{ icon: "trending-up", label: "بهرهوری", value: "٪۹۳", delta: "+٪۱۲", good: true },
]
const PERFORMANCE = [
{ label: "شنبه", now: 4, last: 6 },
{ label: "یکشنبه", now: 5, last: 4 },
{ label: "دوشنبه", now: 7, last: 6 },
{ label: "سهشنبه", now: 9, last: 5 },
{ label: "چهارشنبه", now: 7, last: 3 },
{ label: "پنجشنبه", now: 6, last: 4 },
{ label: "جمعه", now: 8, last: 5 },
]
type Status = "progress" | "hold" | "done"
const STATUS: Record<Status, { label: string; dot: string }> = {
progress: { label: "در جریان", dot: "bg-[var(--dig-orange-500)]" },
hold: { label: "متوقف", dot: "bg-[var(--dig-blue-500)]" },
done: { label: "انجام شد", dot: "bg-success" },
}
const TASKS: { id: string; title: string; status: Status; hours: number; icon: DigIconName }[] = [
{ id: "t1", title: "بازبینیِ محصول برای بازارِ تازه", status: "progress", hours: 4, icon: "activity" },
{ id: "t2", title: "پژوهشِ کاربر برای اپِ بانکی", status: "hold", hours: 8, icon: "calendar" },
{ id: "t3", title: "طراحی و توسعهٔ داشبوردِ فروش", status: "done", hours: 32, icon: "trending-up" },
]
const ACTIVITY: { name: string; gender: "male" | "female"; action: string; time: string; message?: string; file?: { name: string; size: string } }[] = [
{ name: "امیر رضایی", gender: "male", action: "روی پروژهٔ بانکِ آینده نظر داد", time: "۱۰:۱۵", message: "هفتهٔ بعد پروژهٔ تازه را شروع میکنیم؛ جزئیات را بعد میگویم." },
{ name: "سارا محمدی", gender: "female", action: "فایلی به پروژهٔ کافه رست افزود", time: "۰۹:۴۰", file: { name: "صفحه-اصلی.fig", size: "۱۳٫۴ مگابایت" } },
{ name: "نگار احمدی", gender: "female", action: "روی داشبوردِ فروش نظر داد", time: "دیروز" },
]
/**
* داشبوردِ عملکردِ تیم: سلام و توضیحِ کوتاه با تاریخ، سه شاخص با آیکون و تغییرِ رنگی (کلمهٔ «کار»
* و «ساعت» کنارِ عدد)، نمودارِ ناحیهایِ این هفته در برابرِ هفتهٔ قبل، کارهای جاری با وضعیتِ نقطهای و
* ساعت، و ستونِ کنار با کارتِ همتیمی (تماس و تماسِ تصویری)، فعالیتها با پیام و فایل، و نوشتنِ پیام.
* همان صفحهٔ `dashboard-team` نسخهٔ React.
*/
const range = ref("week")
const message = ref("")
const chartData = computed(() => (range.value === "days" ? PERFORMANCE.slice(-4) : PERFORMANCE))
function onRangeChange(value: string | string[] | undefined) {
if (value) range.value = value as string
}
</script>
<template>
<ControlSize size="xl" as-child>
<main class="mx-auto grid w-full max-w-6xl grid-cols-1 items-start gap-6 p-4 sm:p-6 lg:grid-cols-[minmax(0,1fr)_21rem]">
<div class="flex min-w-0 flex-col gap-8">
<header class="flex flex-wrap items-start justify-between gap-x-4 gap-y-4">
<div class="flex flex-col gap-1">
<h1 class="text-2xl leading-snug font-black sm:text-3xl">سلام آرمیتا</h1>
<p class="text-muted-foreground">پیشرفتِ تیم را اینجا ببین؛ تا هدفِ هفته چیزی نمانده.</p>
</div>
<span class="flex items-center gap-2 rounded-full border border-border px-4 py-2 text-sm [&>svg]:size-4 [&>svg]:text-muted-foreground">
<DigIcon name="calendar" aria-hidden="true" />
۱۶ مهر ۱۴۰۵
</span>
</header>
<ul class="grid grid-cols-1 divide-y divide-border border-y border-border sm:grid-cols-3 sm:divide-x sm:divide-y-0 rtl:sm:divide-x-reverse">
<li v-for="kpi in KPIS" :key="kpi.label" class="flex items-center gap-3 py-5 sm:px-5 sm:first:ps-0">
<span aria-hidden="true" class="flex size-12 shrink-0 items-center justify-center rounded-full bg-muted [&>svg]:size-5">
<DigIcon :name="kpi.icon" />
</span>
<span class="flex flex-col gap-0.5">
<span class="text-sm text-muted-foreground">{{ kpi.label }}</span>
<span class="flex items-baseline gap-2">
<span class="text-xl font-black">{{ kpi.value }}</span>
<span :class="`text-xs font-semibold ${kpi.good ? 'text-success-subtle-foreground' : 'text-destructive'}`">{{ kpi.delta }}</span>
</span>
</span>
</li>
</ul>
<section aria-labelledby="perf-title" class="flex flex-col gap-4">
<div class="flex items-center justify-between gap-3">
<h2 id="perf-title" class="text-lg font-bold">عملکرد (ساعت)</h2>
<ControlSize size="lg" mobile-size="default" as-child>
<ToggleGroup type="single" variant="segmented" :value="range" aria-label="بازه" @update:value="onRangeChange">
<ToggleGroupItem value="week">هفته</ToggleGroupItem>
<ToggleGroupItem value="days">۴ روز</ToggleGroupItem>
</ToggleGroup>
</ControlSize>
</div>
<AreaChart
class="h-60"
:data="chartData"
category-key="label"
curve="smooth"
:show-points="false"
:series="[
{ key: 'now', label: 'این هفته', color: 'var(--dig-blue-500)' },
{ key: 'last', label: 'هفتهٔ قبل', color: 'var(--dig-amber-500)' },
]"
:value-formatter="(value: number) => `${toFaDigits(value)} ساعت`"
/>
</section>
<section aria-labelledby="tasks-title" class="flex flex-col gap-2">
<div class="flex items-center gap-4">
<h2 id="tasks-title" class="text-lg font-bold">کارهای جاری</h2>
<span class="text-sm text-muted-foreground">٪۳۰ انجام شده</span>
</div>
<ul class="flex flex-col">
<li v-for="task in TASKS" :key="task.id" class="flex items-center gap-3 py-3">
<span aria-hidden="true" class="flex size-12 shrink-0 items-center justify-center rounded-full bg-muted [&>svg]:size-5">
<DigIcon :name="task.icon" />
</span>
<span class="flex min-w-0 flex-1 flex-col gap-1 sm:flex-row sm:items-center sm:gap-4">
<span class="flex-1 truncate font-medium">{{ task.title }}</span>
<span class="flex items-center gap-4 text-sm">
<span class="flex w-24 items-center gap-2">
<span aria-hidden="true" :class="`size-2 rounded-full ${STATUS[task.status].dot}`" />
{{ STATUS[task.status].label }}
</span>
<span class="flex items-center gap-1 text-muted-foreground tabular-nums [&>svg]:size-4">
<DigIcon name="clock" aria-hidden="true" />
{{ toFaDigits(task.hours) }} ساعت
</span>
</span>
</span>
<Button variant="ghost" size="icon" :aria-label="`گزینههای «${task.title}»`" class="shrink-0">
<DigIcon name="more-horizontal" />
</Button>
</li>
</ul>
</section>
</div>
<aside class="flex flex-col gap-6">
<!-- کارتِ همتیمی، نه پروفایلِ خودِ کاربر؛ برچسبِ بالا این را میگوید تا با «سلام آرمیتا» قاطی نشود. -->
<Card class="items-center bg-subtle text-center shadow-none">
<CardContent class="flex flex-col items-center gap-4">
<span class="text-xs font-medium text-muted-foreground">همتیمیِ برترِ این هفته</span>
<span class="relative">
<Avatar alt="مهسا کریمی" :src="stockImages.personWoman1.src" class="size-24 ring-4 ring-card" />
<span aria-label="آنلاین" class="absolute end-1 bottom-1 size-4 rounded-full bg-success ring-2 ring-subtle" />
</span>
<span class="flex flex-col">
<span class="font-bold">مهسا کریمی</span>
<bdi dir="ltr" class="text-sm text-muted-foreground">@mahsa.karimi</bdi>
</span>
<div class="flex gap-3">
<Button variant="outline" size="icon" aria-label="تماس" class="rounded-full bg-card">
<DigIcon name="phone" />
</Button>
<Button variant="outline" size="icon" aria-label="گزینههای بیشتر" class="rounded-full bg-card">
<DigIcon name="more-horizontal" />
</Button>
</div>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle class="text-lg">فعالیتها</CardTitle>
</CardHeader>
<CardContent class="flex flex-col gap-5">
<ul class="flex flex-col gap-5">
<li v-for="item in ACTIVITY" :key="item.name + item.time" class="flex items-start gap-3">
<Avatar :alt="item.name" :src="avatarPhoto(item.name, item.gender)" class="size-10" />
<span class="flex min-w-0 flex-1 flex-col gap-2">
<span class="flex flex-col gap-0.5">
<span class="flex items-center justify-between gap-2">
<span class="text-sm font-bold">{{ item.name }}</span>
<span class="text-xs text-muted-foreground tabular-nums">{{ item.time }}</span>
</span>
<span class="text-sm text-muted-foreground">{{ item.action }}</span>
</span>
<span v-if="item.message" class="rounded-xl rounded-ss-sm bg-[color-mix(in_oklab,var(--dig-blue-500)_10%,var(--card))] p-3 text-sm leading-6">{{ item.message }}</span>
<span v-if="item.file" class="flex items-center gap-3 rounded-xl bg-[color-mix(in_oklab,var(--dig-blue-500)_10%,var(--card))] p-3">
<span class="flex min-w-0 flex-1 flex-col">
<span class="truncate text-sm font-semibold">{{ item.file.name }}</span>
<span class="text-xs text-muted-foreground">{{ item.file.size }}</span>
</span>
<ControlSize size="lg" as-child>
<Button variant="ghost" size="icon" :aria-label="`دریافتِ ${item.file.name}`" class="shrink-0">
<DigIcon name="download" />
</Button>
</ControlSize>
</span>
</span>
</li>
</ul>
<form class="mt-5 flex items-end gap-2 border-t border-border pt-5" @submit.prevent="message = ''">
<TextField v-model="message" aria-label="پیام به تیم" placeholder="پیامی بنویس…" class="flex-1">
<template #startContent><DigIcon name="paperclip" aria-hidden="true" /></template>
</TextField>
</form>
</CardContent>
</Card>
</aside>
</main>
</ControlSize>
</template>
کدِ این بلاک هنوز برای Svelte نوشته نشده است.
این موارد هنوز برای Svelte آماده نیستند: avatarcardchart-presetscontrol-sizepersiantext-fieldtoggle-groupآیکون activityآیکون calendarآیکون clockآیکون downloadآیکون more-horizontalآیکون paperclipآیکون phoneآیکون thumbs-upآیکون trending-up
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="svelte" ایجنت آن را با کامپوننتهای Svelte میسازد.
import {
Component,
ChangeDetectionStrategy,
signal,
computed,
} from "@angular/core"
import { DigControlSize } from "@/components/ui/control-size"
import { DigIcon, type DigIconName } from "@/lib/icons"
import {
DigToggleGroup,
DigToggleGroupItem,
} from "@/components/ui/toggle-group"
import { DigAreaChart } from "@/components/ui/chart-presets"
import { DigButton } from "@/components/ui/button"
import {
DigCard,
DigCardContent,
DigCardHeader,
DigCardTitle,
} from "@/components/ui/card"
import { DigAvatar } from "@/components/ui/avatar"
import { DigTextField } from "@/components/ui/text-field"
import { DigInputStart, DigInput, DigInputField } from "@/components/ui/input"
import { toFaDigits } from "@/lib/persian"
const stockImages: Record<string, { src: string; alt: string }> = {
personWoman1: {
src: "https://docs.digdesign.ir/images/person-woman-1.webp",
alt: "پرترهٔ زنی با روسری",
},
personWoman2: {
src: "https://docs.digdesign.ir/images/person-woman-2.webp",
alt: "پرترهٔ زنی با کتِ طوسی",
},
personWoman3: {
src: "https://docs.digdesign.ir/images/person-woman-3.webp",
alt: "پرترهٔ زنی خندان",
},
personMan1: {
src: "https://docs.digdesign.ir/images/person-man-1.webp",
alt: "پرترهٔ مردی با لبخند",
},
personMan2: {
src: "https://docs.digdesign.ir/images/person-man-2.webp",
alt: "پرترهٔ مردی با تیشرتِ سفید",
},
}
function avatarPhoto(
name: string,
gender: "male" | "female"
): string | undefined {
let hash = 0
for (const char of name) hash = (hash * 31 + char.charCodeAt(0)) >>> 0
if (hash % 4 === 3) return undefined
const pool =
gender === "female"
? ["personWoman1", "personWoman2", "personWoman3"]
: ["personMan1", "personMan2"]
return stockImages[pool[hash % pool.length]].src
}
const KPIS: {
icon: DigIconName
label: string
value: string
delta: string
good: boolean
}[] = [
{
icon: "thumbs-up",
label: "انجامشده",
value: "۱۸ کار",
delta: "+۸ کار",
good: true,
},
{
icon: "clock",
label: "ساعتِ ثبتشده",
value: "۳۱ ساعت",
delta: "−۶ ساعت",
good: false,
},
{
icon: "trending-up",
label: "بهرهوری",
value: "٪۹۳",
delta: "+٪۱۲",
good: true,
},
]
const PERFORMANCE = [
{ label: "شنبه", now: 4, last: 6 },
{ label: "یکشنبه", now: 5, last: 4 },
{ label: "دوشنبه", now: 7, last: 6 },
{ label: "سهشنبه", now: 9, last: 5 },
{ label: "چهارشنبه", now: 7, last: 3 },
{ label: "پنجشنبه", now: 6, last: 4 },
{ label: "جمعه", now: 8, last: 5 },
]
type Status = "progress" | "hold" | "done"
const STATUS: Record<Status, { label: string; dot: string }> = {
progress: { label: "در جریان", dot: "bg-[var(--dig-orange-500)]" },
hold: { label: "متوقف", dot: "bg-[var(--dig-blue-500)]" },
done: { label: "انجام شد", dot: "bg-success" },
}
const TASKS: {
id: string
title: string
status: Status
hours: number
icon: DigIconName
}[] = [
{
id: "t1",
title: "بازبینیِ محصول برای بازارِ تازه",
status: "progress",
hours: 4,
icon: "activity",
},
{
id: "t2",
title: "پژوهشِ کاربر برای اپِ بانکی",
status: "hold",
hours: 8,
icon: "calendar",
},
{
id: "t3",
title: "طراحی و توسعهٔ داشبوردِ فروش",
status: "done",
hours: 32,
icon: "trending-up",
},
]
const ACTIVITY: {
name: string
gender: "male" | "female"
action: string
time: string
message?: string
file?: { name: string; size: string }
}[] = [
{
name: "امیر رضایی",
gender: "male",
action: "روی پروژهٔ بانکِ آینده نظر داد",
time: "۱۰:۱۵",
message: "هفتهٔ بعد پروژهٔ تازه را شروع میکنیم؛ جزئیات را بعد میگویم.",
},
{
name: "سارا محمدی",
gender: "female",
action: "فایلی به پروژهٔ کافه رست افزود",
time: "۰۹:۴۰",
file: { name: "صفحه-اصلی.fig", size: "۱۳٫۴ مگابایت" },
},
{
name: "نگار احمدی",
gender: "female",
action: "روی داشبوردِ فروش نظر داد",
time: "دیروز",
},
]
@Component({
selector: "dig-block-dashboard-team",
imports: [
DigControlSize,
DigIcon,
DigToggleGroup,
DigToggleGroupItem,
DigAreaChart,
DigButton,
DigCard,
DigCardContent,
DigCardHeader,
DigCardTitle,
DigAvatar,
DigTextField,
DigInputStart,
DigInput,
DigInputField,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<main digControlSize="xl" class="mx-auto grid w-full max-w-6xl grid-cols-1 items-start gap-6 p-4 sm:p-6 lg:grid-cols-[minmax(0,1fr)_21rem]"><div class="flex min-w-0 flex-col gap-8"><header class="flex flex-wrap items-start justify-between gap-x-4 gap-y-4"><div class="flex flex-col gap-1"><h1 class="text-2xl leading-snug font-black sm:text-3xl">سلام آرمیتا</h1>
<p class="text-muted-foreground">پیشرفتِ تیم را اینجا ببین؛ تا هدفِ هفته چیزی نمانده.</p></div>
<span class="flex items-center gap-2 rounded-full border border-border px-4 py-2 text-sm [&>svg]:size-4 [&>svg]:text-muted-foreground"><svg digIcon="calendar" aria-hidden="true"></svg>
۱۶ مهر ۱۴۰۵
</span></header>
<ul class="grid grid-cols-1 divide-y divide-border border-y border-border sm:grid-cols-3 sm:divide-x sm:divide-y-0 rtl:sm:divide-x-reverse">@for (kpi of KPIS; track kpi.label) {
<li class="flex items-center gap-3 py-5 sm:px-5 sm:first:ps-0"><span aria-hidden="true" class="flex size-12 shrink-0 items-center justify-center rounded-full bg-muted [&>svg]:size-5"><svg [digIcon]="kpi.icon"></svg></span>
<span class="flex flex-col gap-0.5"><span class="text-sm text-muted-foreground">{{ kpi.label }}</span>
<span class="flex items-baseline gap-2"><span class="text-xl font-black">{{ kpi.value }}</span>
<span [class]="\`text-xs font-semibold \${kpi.good ? 'text-success-subtle-foreground' : 'text-destructive'}\`">{{ kpi.delta }}</span></span></span></li>
}</ul>
<section aria-labelledby="perf-title" class="flex flex-col gap-4"><div class="flex items-center justify-between gap-3"><h2 id="perf-title" class="text-lg font-bold">عملکرد (ساعت)</h2>
<div digControlSize="lg" mobileSize="default"><div digToggleGroup type="single" variant="segmented" [value]="range()" aria-label="بازه" (valueChange)="onRangeChange($event)"><button digToggleGroupItem value="week">هفته</button>
<button digToggleGroupItem value="days">۴ روز</button></div></div></div>
<div digAreaChart class="h-60" [data]="chartData()" categoryKey="label" curve="smooth" [showPoints]="false" [series]="[
{ key: 'now', label: 'این هفته', color: 'var(--dig-blue-500)' },
{ key: 'last', label: 'هفتهٔ قبل', color: 'var(--dig-amber-500)' },
]" [valueFormatter]="(value) => \`\${toFaDigits(value)} ساعت\`"></div></section>
<section aria-labelledby="tasks-title" class="flex flex-col gap-2"><div class="flex items-center gap-4"><h2 id="tasks-title" class="text-lg font-bold">کارهای جاری</h2>
<span class="text-sm text-muted-foreground">٪۳۰ انجام شده</span></div>
<ul class="flex flex-col">@for (task of TASKS; track task.id) {
<li class="flex items-center gap-3 py-3"><span aria-hidden="true" class="flex size-12 shrink-0 items-center justify-center rounded-full bg-muted [&>svg]:size-5"><svg [digIcon]="task.icon"></svg></span>
<span class="flex min-w-0 flex-1 flex-col gap-1 sm:flex-row sm:items-center sm:gap-4"><span class="flex-1 truncate font-medium">{{ task.title }}</span>
<span class="flex items-center gap-4 text-sm"><span class="flex w-24 items-center gap-2"><span aria-hidden="true" [class]="\`size-2 rounded-full \${STATUS[task.status].dot}\`"></span>
{{ STATUS[task.status].label }}</span>
<span class="flex items-center gap-1 text-muted-foreground tabular-nums [&>svg]:size-4"><svg digIcon="clock" aria-hidden="true"></svg>
{{ toFaDigits(task.hours) }} ساعت
</span></span></span>
<button digButton type="button" variant="ghost" size="icon" [attr.aria-label]="\`گزینههای «\${task.title}»\`" class="shrink-0"><svg digIcon="more-horizontal"></svg></button></li>
}</ul></section></div>
<aside class="flex flex-col gap-6"><!-- کارتِ همتیمی، نه پروفایلِ خودِ کاربر؛ برچسبِ بالا این را میگوید تا با «سلام آرمیتا» قاطی نشود. -->
<div digCard class="items-center bg-subtle text-center shadow-none"><div digCardContent class="flex flex-col items-center gap-4"><span class="text-xs font-medium text-muted-foreground">همتیمیِ برترِ این هفته</span>
<span class="relative"><span digAvatar alt="مهسا کریمی" [src]="stockImages.personWoman1.src" class="size-24 ring-4 ring-card"></span>
<span aria-label="آنلاین" class="absolute end-1 bottom-1 size-4 rounded-full bg-success ring-2 ring-subtle"></span></span>
<span class="flex flex-col"><span class="font-bold">مهسا کریمی</span>
<bdi dir="ltr" class="text-sm text-muted-foreground">@mahsa.karimi</bdi></span>
<div class="flex gap-3"><button digButton type="button" variant="outline" size="icon" aria-label="تماس" class="rounded-full bg-card"><svg digIcon="phone"></svg></button>
<button digButton type="button" variant="outline" size="icon" aria-label="گزینههای بیشتر" class="rounded-full bg-card"><svg digIcon="more-horizontal"></svg></button></div></div></div>
<div digCard><div digCardHeader><div digCardTitle class="text-lg">فعالیتها</div></div>
<div digCardContent class="flex flex-col gap-5"><ul class="flex flex-col gap-5">@for (item of ACTIVITY; track item.name + item.time) {
<li class="flex items-start gap-3"><span digAvatar [alt]="item.name" [src]="avatarPhoto(item.name, item.gender)" class="size-10"></span>
<span class="flex min-w-0 flex-1 flex-col gap-2"><span class="flex flex-col gap-0.5"><span class="flex items-center justify-between gap-2"><span class="text-sm font-bold">{{ item.name }}</span>
<span class="text-xs text-muted-foreground tabular-nums">{{ item.time }}</span></span>
<span class="text-sm text-muted-foreground">{{ item.action }}</span></span>
@if (item.message) {
<span class="rounded-xl rounded-ss-sm bg-[color-mix(in_oklab,var(--dig-blue-500)_10%,var(--card))] p-3 text-sm leading-6">{{ item.message }}</span>
}
@if (item.file) {
<span class="flex items-center gap-3 rounded-xl bg-[color-mix(in_oklab,var(--dig-blue-500)_10%,var(--card))] p-3"><span class="flex min-w-0 flex-1 flex-col"><span class="truncate text-sm font-semibold">{{ item.file.name }}</span>
<span class="text-xs text-muted-foreground">{{ item.file.size }}</span></span>
<button digControlSize="lg" digButton type="button" variant="ghost" size="icon" [attr.aria-label]="\`دریافتِ \${item.file.name}\`" class="shrink-0"><svg digIcon="download"></svg></button></span>
}</span></li>
}</ul>
<form class="mt-5 flex items-end gap-2 border-t border-border pt-5" (submit)="$event.preventDefault(); message.set('')"><div digTextField class="flex-1"><dig-input><input digInput [value]="message()" (valueChange)="message.set($event)" aria-label="پیام به تیم" placeholder="پیامی بنویس…" /><span digInputStart><svg digIcon="paperclip" aria-hidden="true"></svg></span></dig-input></div></form></div></div></aside></main>
`,
})
export class DashboardTeamBlock {
readonly toFaDigits = toFaDigits
readonly ACTIVITY = ACTIVITY
readonly TASKS = TASKS
readonly STATUS = STATUS
readonly KPIS = KPIS
readonly avatarPhoto = avatarPhoto
readonly stockImages = stockImages
readonly range = signal("week")
readonly message = signal("")
readonly chartData = computed(() =>
this.range() === "days" ? PERFORMANCE.slice(-4) : PERFORMANCE
)
onRangeChange(value: string | string[] | undefined) {
if (value) this.range.set(value as string)
}
}
کدِ این بلاک هنوز برای Android نوشته نشده است.
همهٔ کامپوننتهای لازم برای Android آمادهاند؛ با MCP میتوانید همین صفحه را از روی نسخهٔ React بسازید.
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="android" ایجنت آن را با کامپوننتهای Android میسازد.