نمونهکار
پیشنمایش تمامصفحهصفحهٔ نمونهکار: سرِ صفحه با آمار، فیلترِ نوعِ پروژه با سگمنت و گریدِ نامتقارن از پروژهها با عکسِ بزرگ، مشتری، سال و برچسب.
۱. نصب کامپوننتها
این بلاک از ۷ آیتم دیگ استفاده میکند: badgebuttoncontrol-sizeiconspersianrevealtoggle-group
npx digdesign@latest add https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.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/reveal.json https://docs.digdesign.ir/r/toggle-group.jsonpnpm dlx digdesign@latest add https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.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/reveal.json https://docs.digdesign.ir/r/toggle-group.jsonyarn dlx digdesign@latest add https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.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/reveal.json https://docs.digdesign.ir/r/toggle-group.jsonbunx --bun digdesign@latest add https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/button.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/reveal.json https://docs.digdesign.ir/r/toggle-group.jsonnpx digdesign@latest add badge button control-size persian reveal toggle-group --framework vuepnpm dlx digdesign@latest add badge button control-size persian reveal toggle-group --framework vueyarn dlx digdesign@latest add badge button control-size persian reveal toggle-group --framework vuebunx --bun digdesign@latest add badge button control-size persian reveal 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 badge button control-size icons persian reveal toggle-group --framework angularpnpm dlx digdesign@latest add badge button control-size icons persian reveal toggle-group --framework angularyarn dlx digdesign@latest add badge button control-size icons persian reveal toggle-group --framework angularbunx --bun digdesign@latest add badge button control-size icons persian reveal toggle-group --framework angularnpx digdesign@latest add badge button control-size persian toggle-group --framework androidpnpm dlx digdesign@latest add badge button control-size persian toggle-group --framework androidyarn dlx digdesign@latest add badge button control-size persian toggle-group --framework androidbunx --bun digdesign@latest add badge button control-size persian toggle-group --framework android۲. کد صفحه
کد را در صفحهٔ پروژهتان بگذارید (React: app/<route>/page.tsx) و متنها، داده و هندلرها را با محصول خودتان عوض کنید. با سوییچر فریمورک کدِ همین صفحه در فریمورک دیگر را ببینید.
"use client"
import * as React from "react"
import { ArrowUpIcon } from "@/components/icons"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { Reveal } from "@/components/ui/reveal"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
import { toFaDigits } from "@/lib/persian"
import { stockImages, type StockImageName } from "@/lib/stock-images"
type Project = { title: string; client: string; kind: string; year: number; image: StockImageName; tags: string[]; wide?: boolean }
const PROJECTS: Project[] = [
{ title: "اپِ بانکی نو", client: "بانکِ آینده", kind: "اپ موبایل", year: 1404, image: "projectMobileApp", tags: ["UX", "طراحی رابط"], wide: true },
{ title: "داشبوردِ فروش", client: "فروشگاهِ بوم", kind: "وباپ", year: 1404, image: "projectDashboard", tags: ["داده", "طراحی رابط"] },
{ title: "هویتِ بصری کافه", client: "کافه رست", kind: "برند", year: 1403, image: "projectCafeBrand", tags: ["لوگو", "بستهبندی"] },
{ title: "سایتِ معماری", client: "استودیو پی", kind: "وبسایت", year: 1403, image: "studioSunlit", tags: ["وب", "عکاسی"], wide: true },
{ title: "کاتالوگِ سفال", client: "خانهٔ سفال", kind: "برند", year: 1402, image: "productVase", tags: ["چاپ", "عکاسی"] },
{ title: "پنلِ حسابداری", client: "آوند", kind: "وباپ", year: 1402, image: "coverFinanceDesk", tags: ["UX", "داده"] },
]
const KINDS = ["همه", "اپ موبایل", "وباپ", "وبسایت", "برند"]
/**
* نمونهکار: سرِ صفحه با آمارِ کوتاه، فیلترِ نوعِ پروژه با سگمنت و گریدِ نامتقارن که
* بعضی پروژهها دو ستون میگیرند؛ هر کارت عکسِ بزرگ، نامِ مشتری، سال و برچسب دارد.
*/
export default function PortfolioBlock() {
const [kind, setKind] = React.useState("همه")
const visible = PROJECTS.filter((project) => kind === "همه" || project.kind === kind)
return (
<ControlSizeProvider size="xl" asChild>
<main className="mx-auto flex w-full max-w-6xl flex-col gap-12 px-4 py-16 sm:px-6">
<header className="flex flex-wrap items-end justify-between gap-8">
<div className="flex max-w-2xl flex-col gap-4">
<h1 className="text-4xl leading-snug font-black text-balance sm:text-5xl sm:leading-snug">کارهایی که دوستشان داریم</h1>
<p className="text-lg leading-8 text-muted-foreground">منتخبی از ۱۲۰ پروژه برای استارتاپها، بانکها و برندهای کوچک.</p>
</div>
<dl className="flex gap-10">
{[
{ value: "۱۲۰+", label: "پروژه" },
{ value: "۹", label: "سال تجربه" },
].map((stat) => (
<div key={stat.label} className="flex flex-col">
<dd className="text-3xl font-black tabular-nums">{stat.value}</dd>
<dt className="text-sm text-muted-foreground">{stat.label}</dt>
</div>
))}
</dl>
</header>
<div className="max-w-full overflow-x-auto">
<ControlSizeProvider size="lg" mobileSize="default" asChild>
<ToggleGroup type="single" variant="segmented" value={kind} onValueChange={(value) => value && setKind(value as string)} aria-label="نوعِ پروژه">
{KINDS.map((item) => (
<ToggleGroupItem key={item} value={item} className="whitespace-nowrap">
{item}
</ToggleGroupItem>
))}
</ToggleGroup>
</ControlSizeProvider>
</div>
<ul className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
{visible.map((project, index) => (
<Reveal asChild key={project.title} delay={(index % 3) * 100}>
<li className={project.wide && kind === "همه" ? "lg:col-span-2" : ""}>
<a href="#" className="group flex flex-col gap-4">
<span className="relative overflow-hidden rounded-xl">
{/* eslint-disable-next-line @next/next/no-img-element -- عکس از کتابخانهٔ تصویرِ دیگ */}
<img src={stockImages[project.image].src} alt={stockImages[project.image].alt} loading="lazy" className="aspect-[4/3] w-full object-cover transition-transform duration-500 group-hover:scale-105 lg:aspect-auto lg:h-80" />
<span aria-hidden className="absolute end-4 top-4 flex size-10 items-center justify-center rounded-full bg-card text-foreground shadow-card transition-transform group-hover:-translate-y-0.5 [&>svg]:size-4">
<ArrowUpIcon className="-rotate-45" />
</span>
</span>
<span className="flex items-start justify-between gap-3">
<span className="flex flex-col gap-1">
<span className="text-lg font-bold">{project.title}</span>
<span className="text-sm text-muted-foreground">
{project.client} · {toFaDigits(project.year)}
</span>
</span>
<span className="flex flex-wrap justify-end gap-1.5">
{project.tags.map((tag) => (
<Badge key={tag} variant="soft">
{tag}
</Badge>
))}
</span>
</span>
</a>
</li>
</Reveal>
))}
</ul>
<div className="flex justify-center pt-4">
<Button variant="outline">پروژههای بیشتر</Button>
</div>
</main>
</ControlSizeProvider>
)
}
<script setup lang="ts">
import { computed, ref } from "vue"
import Badge from "@/components/ui/Badge.vue"
import Button from "@/components/ui/Button.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import Reveal from "@/components/ui/Reveal.vue"
import ToggleGroup from "@/components/ui/ToggleGroup.vue"
import ToggleGroupItem from "@/components/ui/ToggleGroupItem.vue"
import { DigIcon } from "@/lib/icons"
import { toFaDigits } from "@/lib/persian"
const IMAGES = "https://docs.digdesign.ir/images"
type Project = { title: string; client: string; kind: string; year: number; image: string; alt: string; tags: string[]; wide?: boolean }
const PROJECTS: Project[] = [
{ title: "اپِ بانکی نو", client: "بانکِ آینده", kind: "اپ موبایل", year: 1404, image: `${IMAGES}/project-mobile-app.webp`, alt: "گوشیِ موبایل با رابطِ یک اپ روی سطحِ سفید", tags: ["UX", "طراحی رابط"], wide: true },
{ title: "داشبوردِ فروش", client: "فروشگاهِ بوم", kind: "وباپ", year: 1404, image: `${IMAGES}/project-dashboard.webp`, alt: "لپتاپ با نمودارهای تحلیلی", tags: ["داده", "طراحی رابط"] },
{ title: "هویتِ بصری کافه", client: "کافه رست", kind: "برند", year: 1403, image: `${IMAGES}/project-cafe-brand.webp`, alt: "لیوانهای کاغذیِ قهوه با درِ سیاه و سفید", tags: ["لوگو", "بستهبندی"] },
{ title: "سایتِ معماری", client: "استودیو پی", kind: "وبسایت", year: 1403, image: `${IMAGES}/studio-sunlit.webp`, alt: "استودیوی آفتابگیر با میزِ چوبی و چهارپایه", tags: ["وب", "عکاسی"], wide: true },
{ title: "کاتالوگِ سفال", client: "خانهٔ سفال", kind: "برند", year: 1402, image: `${IMAGES}/product-vase.webp`, alt: "دو گلدانِ سرامیکیِ سفید کنارِ پارچهٔ کرم", tags: ["چاپ", "عکاسی"] },
{ title: "پنلِ حسابداری", client: "آوند", kind: "وباپ", year: 1402, image: `${IMAGES}/cover-finance-desk.webp`, alt: "میزِ کار با موبایل، ماشینحساب و نمودارهای مالی", tags: ["UX", "داده"] },
]
const KINDS = ["همه", "اپ موبایل", "وباپ", "وبسایت", "برند"]
const STATS = [
{ value: "۱۲۰+", label: "پروژه" },
{ value: "۹", label: "سال تجربه" },
]
/**
* نمونهکار: سرِ صفحه با آمارِ کوتاه، فیلترِ نوعِ پروژه با سگمنت و گریدِ نامتقارن که
* بعضی پروژهها دو ستون میگیرند؛ هر کارت عکسِ بزرگ، نامِ مشتری، سال و برچسب دارد.
*/
const kind = ref("همه")
const visible = computed(() => PROJECTS.filter((project) => kind.value === "همه" || project.kind === kind.value))
function onKind(value: string | string[] | undefined) {
if (value) kind.value = value as string
}
</script>
<template>
<ControlSize size="xl" as-child>
<main class="mx-auto flex w-full max-w-6xl flex-col gap-12 px-4 py-16 sm:px-6">
<header class="flex flex-wrap items-end justify-between gap-8">
<div class="flex max-w-2xl flex-col gap-4">
<h1 class="text-4xl leading-snug font-black text-balance sm:text-5xl sm:leading-snug">کارهایی که دوستشان داریم</h1>
<p class="text-lg leading-8 text-muted-foreground">منتخبی از ۱۲۰ پروژه برای استارتاپها، بانکها و برندهای کوچک.</p>
</div>
<dl class="flex gap-10">
<div v-for="stat in STATS" :key="stat.label" class="flex flex-col">
<dd class="text-3xl font-black tabular-nums">{{ stat.value }}</dd>
<dt class="text-sm text-muted-foreground">{{ stat.label }}</dt>
</div>
</dl>
</header>
<div class="max-w-full overflow-x-auto">
<ControlSize size="lg" mobile-size="default" as-child>
<ToggleGroup type="single" variant="segmented" :value="kind" aria-label="نوعِ پروژه" @update:value="onKind">
<ToggleGroupItem v-for="item in KINDS" :key="item" :value="item" class="whitespace-nowrap">{{ item }}</ToggleGroupItem>
</ToggleGroup>
</ControlSize>
</div>
<ul class="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
<Reveal v-for="(project, index) in visible" :key="project.title" as-child :delay="(index % 3) * 100">
<li :class="project.wide && kind === 'همه' ? 'lg:col-span-2' : ''">
<a href="#" class="group flex flex-col gap-4">
<span class="relative overflow-hidden rounded-xl">
<img :src="project.image" :alt="project.alt" loading="lazy" class="aspect-[4/3] w-full object-cover transition-transform duration-500 group-hover:scale-105 lg:aspect-auto lg:h-80" />
<span aria-hidden="true" class="absolute end-4 top-4 flex size-10 items-center justify-center rounded-full bg-card text-foreground shadow-card transition-transform group-hover:-translate-y-0.5 [&>svg]:size-4">
<DigIcon name="arrow-up" class="-rotate-45" />
</span>
</span>
<span class="flex items-start justify-between gap-3">
<span class="flex flex-col gap-1">
<span class="text-lg font-bold">{{ project.title }}</span>
<span class="text-sm text-muted-foreground">{{ project.client }} · {{ toFaDigits(project.year) }}</span>
</span>
<span class="flex flex-wrap justify-end gap-1.5">
<Badge v-for="tag in project.tags" :key="tag" variant="soft">{{ tag }}</Badge>
</span>
</span>
</a>
</li>
</Reveal>
</ul>
<div class="flex justify-center pt-4">
<Button variant="outline">پروژههای بیشتر</Button>
</div>
</main>
</ControlSize>
</template>
کدِ این بلاک هنوز برای Svelte نوشته نشده است.
این موارد هنوز برای Svelte آماده نیستند: badgecontrol-sizepersianrevealtoggle-groupآیکون arrow-up
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="svelte" ایجنت آن را با کامپوننتهای Svelte میسازد.
import {
ChangeDetectionStrategy,
Component,
computed,
signal,
} from "@angular/core"
import { DigBadge } from "@/components/ui/badge"
import { DigButton } from "@/components/ui/button"
import { DigControlSize } from "@/components/ui/control-size"
import { DigIcon } from "@/lib/icons"
import { DigReveal } from "@/components/ui/reveal"
import {
DigToggleGroup,
DigToggleGroupItem,
} from "@/components/ui/toggle-group"
import { toFaDigits } from "@/lib/persian"
const IMAGES = "https://docs.digdesign.ir/images"
type Project = {
title: string
client: string
kind: string
year: number
image: string
alt: string
tags: string[]
wide?: boolean
}
const PROJECTS: Project[] = [
{
title: "اپِ بانکی نو",
client: "بانکِ آینده",
kind: "اپ موبایل",
year: 1404,
image: `${IMAGES}/project-mobile-app.webp`,
alt: "گوشیِ موبایل با رابطِ یک اپ روی سطحِ سفید",
tags: ["UX", "طراحی رابط"],
wide: true,
},
{
title: "داشبوردِ فروش",
client: "فروشگاهِ بوم",
kind: "وباپ",
year: 1404,
image: `${IMAGES}/project-dashboard.webp`,
alt: "لپتاپ با نمودارهای تحلیلی",
tags: ["داده", "طراحی رابط"],
},
{
title: "هویتِ بصری کافه",
client: "کافه رست",
kind: "برند",
year: 1403,
image: `${IMAGES}/project-cafe-brand.webp`,
alt: "لیوانهای کاغذیِ قهوه با درِ سیاه و سفید",
tags: ["لوگو", "بستهبندی"],
},
{
title: "سایتِ معماری",
client: "استودیو پی",
kind: "وبسایت",
year: 1403,
image: `${IMAGES}/studio-sunlit.webp`,
alt: "استودیوی آفتابگیر با میزِ چوبی و چهارپایه",
tags: ["وب", "عکاسی"],
wide: true,
},
{
title: "کاتالوگِ سفال",
client: "خانهٔ سفال",
kind: "برند",
year: 1402,
image: `${IMAGES}/product-vase.webp`,
alt: "دو گلدانِ سرامیکیِ سفید کنارِ پارچهٔ کرم",
tags: ["چاپ", "عکاسی"],
},
{
title: "پنلِ حسابداری",
client: "آوند",
kind: "وباپ",
year: 1402,
image: `${IMAGES}/cover-finance-desk.webp`,
alt: "میزِ کار با موبایل، ماشینحساب و نمودارهای مالی",
tags: ["UX", "داده"],
},
]
const KINDS = ["همه", "اپ موبایل", "وباپ", "وبسایت", "برند"]
const STATS = [
{ value: "۱۲۰+", label: "پروژه" },
{ value: "۹", label: "سال تجربه" },
]
@Component({
selector: "dig-block-portfolio",
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [
DigBadge,
DigButton,
DigControlSize,
DigIcon,
DigReveal,
DigToggleGroup,
DigToggleGroupItem,
],
template: `
<main
digControlSize="xl"
class="mx-auto flex w-full max-w-6xl flex-col gap-12 px-4 py-16 sm:px-6"
>
<header class="flex flex-wrap items-end justify-between gap-8">
<div class="flex max-w-2xl flex-col gap-4">
<h1
class="text-4xl leading-snug font-black text-balance sm:text-5xl sm:leading-snug"
>
کارهایی که دوستشان داریم
</h1>
<p class="text-lg leading-8 text-muted-foreground">
منتخبی از ۱۲۰ پروژه برای استارتاپها، بانکها و برندهای کوچک.
</p>
</div>
<dl class="flex gap-10">
@for (stat of STATS; track stat.label) {
<div class="flex flex-col">
<dd class="text-3xl font-black tabular-nums">{{ stat.value }}</dd>
<dt class="text-sm text-muted-foreground">{{ stat.label }}</dt>
</div>
}
</dl>
</header>
<div class="max-w-full overflow-x-auto">
<div
digToggleGroup
mobileSize="default"
digControlSize="lg"
type="single"
variant="segmented"
[value]="kind()"
aria-label="نوعِ پروژه"
(valueChange)="onKind($event)"
>
@for (item of KINDS; track item) {
<button digToggleGroupItem [value]="item" class="whitespace-nowrap">
{{ item }}
</button>
}
</div>
</div>
<ul class="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
@for (project of visible(); track project.title; let index = $index) {
<li
[delay]="(index % 3) * 100"
digReveal
[class]="project.wide && kind() === 'همه' ? 'lg:col-span-2' : ''"
>
<a href="#" class="group flex flex-col gap-4">
<span class="relative overflow-hidden rounded-xl">
<img
[src]="project.image"
[alt]="project.alt"
loading="lazy"
class="aspect-[4/3] w-full object-cover transition-transform duration-500 group-hover:scale-105 lg:aspect-auto lg:h-80"
/>
<span
aria-hidden="true"
class="absolute end-4 top-4 flex size-10 items-center justify-center rounded-full bg-card text-foreground shadow-card transition-transform group-hover:-translate-y-0.5 [&>svg]:size-4"
>
<svg digIcon="arrow-up" class="-rotate-45"></svg>
</span>
</span>
<span class="flex items-start justify-between gap-3">
<span class="flex flex-col gap-1">
<span class="text-lg font-bold">{{ project.title }}</span>
<span class="text-sm text-muted-foreground"
>{{ project.client }} · {{ toFaDigits(project.year) }}</span
>
</span>
<span class="flex flex-wrap justify-end gap-1.5">
@for (tag of project.tags; track tag) {
<span digBadge variant="soft">{{ tag }}</span>
}
</span>
</span>
</a>
</li>
}
</ul>
<div class="flex justify-center pt-4">
<button digButton type="button" variant="outline">
پروژههای بیشتر
</button>
</div>
</main>
`,
})
export class PortfolioBlock {
readonly KINDS = KINDS
readonly STATS = STATS
readonly toFaDigits = toFaDigits
readonly kind = signal("همه")
readonly visible = computed(() =>
PROJECTS.filter(
(project) => this.kind() === "همه" || project.kind === this.kind()
)
)
onKind(value: string | string[] | undefined) {
if (typeof value === "string" && KINDS.includes(value)) this.kind.set(value)
}
}
کدِ این بلاک هنوز برای Android نوشته نشده است.
این موارد هنوز برای Android آماده نیستند: reveal
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="android" ایجنت آن را با کامپوننتهای Android میسازد.