نظرِ برجسته
پیشنمایش تمامصفحهبخشِ نظرِ مشتری با یک نقلقولِ بزرگ روی سطحِ تیره با پترنِ شبکه، عکسِ گوینده و عددِ نتیجه؛ با دکمهٔ قبلی و بعدی بین داستانها.
۱. نصب کامپوننتها
این بلاک از ۵ آیتم دیگ استفاده میکند: background-patternbuttoncontrol-sizeiconspersian
npx digdesign@latest add https://docs.digdesign.ir/r/background-pattern.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.jsonpnpm dlx digdesign@latest add https://docs.digdesign.ir/r/background-pattern.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.jsonyarn dlx digdesign@latest add https://docs.digdesign.ir/r/background-pattern.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.jsonbunx --bun digdesign@latest add https://docs.digdesign.ir/r/background-pattern.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.jsonnpx digdesign@latest add background-pattern button control-size persian --framework vuepnpm dlx digdesign@latest add background-pattern button control-size persian --framework vueyarn dlx digdesign@latest add background-pattern button control-size persian --framework vuebunx --bun digdesign@latest add background-pattern button control-size persian --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 background-pattern button control-size icons persian --framework angularpnpm dlx digdesign@latest add background-pattern button control-size icons persian --framework angularyarn dlx digdesign@latest add background-pattern button control-size icons persian --framework angularbunx --bun digdesign@latest add background-pattern button control-size icons persian --framework angularnpx digdesign@latest add background-pattern button control-size persian --framework androidpnpm dlx digdesign@latest add background-pattern button control-size persian --framework androidyarn dlx digdesign@latest add background-pattern button control-size persian --framework androidbunx --bun digdesign@latest add background-pattern button control-size persian --framework android۲. کد صفحه
کد را در صفحهٔ پروژهتان بگذارید (React: app/<route>/page.tsx) و متنها، داده و هندلرها را با محصول خودتان عوض کنید. با سوییچر فریمورک کدِ همین صفحه در فریمورک دیگر را ببینید.
"use client"
import * as React from "react"
import { ChevronLeftIcon, ChevronRightIcon, QuoteIcon } from "@/components/icons"
import { GridPattern } from "@/components/ui/background-pattern"
import { Button } from "@/components/ui/button"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { toFaDigits } from "@/lib/persian"
import { stockImages, type StockImageName } from "@/lib/stock-images"
const QUOTES: { text: string; name: string; role: string; photo: StockImageName; metric: string; metricLabel: string }[] = [
{ text: "آوند حسابوکتابِ چهار شعبه را یکجا کرد؛ حالا هر صبح با یک نگاه میدانم دیروز چه گذشت.", name: "سارا محمدی", role: "مدیرِ کافه رست", photo: "personWoman2", metric: "۲۰٪", metricLabel: "کاهشِ هزینه در شش ماه" },
{ text: "قبل از آوند، پایانِ ماه یعنی دو شب بیداری. الان حقوق و بیمه را در یک ساعت میبندیم.", name: "علی کاظمی", role: "مدیرِ منابعِ انسانی", photo: "personMan2", metric: "۹ ساعت", metricLabel: "صرفهجویی در هفته" },
]
/**
* نظرِ برجستهٔ مشتری: یک نقلقولِ بزرگ روی سطحِ تیره با پترنِ شبکه، عکسِ تمامقدِ گوینده
* و عددِ نتیجه؛ با دکمههای قبلی/بعدی بین داستانها جابهجا میشود.
*/
export default function TestimonialSpotlightBlock() {
const [index, setIndex] = React.useState(0)
const quote = QUOTES[index]
const go = (step: number) => setIndex((value) => (value + step + QUOTES.length) % QUOTES.length)
return (
<ControlSizeProvider size="xl" asChild>
<section aria-roledescription="نمایشگر" aria-label="داستانِ مشتریها" className="mx-auto w-full max-w-6xl px-4 py-24 sm:px-6">
<div className="relative grid grid-cols-1 overflow-hidden rounded-xl bg-inverse text-[var(--dig-white)] [--border:var(--inverse-border)] [--muted-foreground:var(--dig-neutral-400)] md:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)]">
<GridPattern size={40} />
<div className="relative flex flex-col gap-8 p-8 sm:p-12" aria-live="polite">
<QuoteIcon aria-hidden className="size-10 text-[var(--dig-violet-400)]" />
{/* یک اندازه برای همهٔ نقلقولها و شکستنِ طبیعیِ خط؛ text-balance خطها را کوتاه و هر نقلقول را یکجور میکرد. */}
<blockquote className="min-h-[3lh] text-xl leading-relaxed font-bold sm:text-2xl sm:leading-relaxed">{quote.text}</blockquote>
<div className="flex flex-wrap items-end justify-between gap-6">
<div className="flex flex-col">
<span className="font-semibold">{quote.name}</span>
<span className="text-sm text-muted-foreground">{quote.role}</span>
</div>
<div className="flex flex-col items-end">
<span className="text-3xl font-black tabular-nums text-[var(--dig-green-400)]">{quote.metric}</span>
<span className="text-sm text-muted-foreground">{quote.metricLabel}</span>
</div>
</div>
<div className="flex items-center gap-3">
<Button variant="outline" size="icon" aria-label="داستانِ قبلی" onClick={() => go(-1)} className="bg-inverse text-[var(--dig-white)] hover:bg-inverse-raised">
<ChevronRightIcon className="ltr:rotate-180" />
</Button>
<Button variant="outline" size="icon" aria-label="داستانِ بعدی" onClick={() => go(1)} className="bg-inverse text-[var(--dig-white)] hover:bg-inverse-raised">
<ChevronLeftIcon className="ltr:rotate-180" />
</Button>
<span className="text-sm text-muted-foreground tabular-nums">
{toFaDigits(index + 1)} از {toFaDigits(QUOTES.length)}
</span>
</div>
</div>
{/* eslint-disable-next-line @next/next/no-img-element -- عکس از کتابخانهٔ تصویرِ دیگ */}
<img key={quote.photo} src={stockImages[quote.photo].src} alt={quote.name} className="relative aspect-[4/3] size-full object-cover md:aspect-auto" />
</div>
</section>
</ControlSizeProvider>
)
}
<script setup lang="ts">
import { computed, ref } from "vue"
import Button from "@/components/ui/Button.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import GridPattern from "@/components/ui/GridPattern.vue"
import { DigIcon } from "@/lib/icons"
import { toFaDigits } from "@/lib/persian"
// تصویرها از کتابخانهٔ تصویرِ دیگ (همان آدرسهای نسخهٔ React)
const stockImages = {
personWoman2: { src: "https://docs.digdesign.ir/images/person-woman-2.webp", alt: "پرترهٔ زنی با کتِ طوسی" },
personMan2: { src: "https://docs.digdesign.ir/images/person-man-2.webp", alt: "پرترهٔ مردی با تیشرتِ سفید" },
}
const QUOTES: { text: string; name: string; role: string; photo: keyof typeof stockImages; metric: string; metricLabel: string }[] = [
{ text: "آوند حسابوکتابِ چهار شعبه را یکجا کرد؛ حالا هر صبح با یک نگاه میدانم دیروز چه گذشت.", name: "سارا محمدی", role: "مدیرِ کافه رست", photo: "personWoman2", metric: "۲۰٪", metricLabel: "کاهشِ هزینه در شش ماه" },
{ text: "قبل از آوند، پایانِ ماه یعنی دو شب بیداری. الان حقوق و بیمه را در یک ساعت میبندیم.", name: "علی کاظمی", role: "مدیرِ منابعِ انسانی", photo: "personMan2", metric: "۹ ساعت", metricLabel: "صرفهجویی در هفته" },
]
/**
* نظرِ برجستهٔ مشتری: یک نقلقولِ بزرگ روی سطحِ تیره با پترنِ شبکه، عکسِ تمامقدِ گوینده
* و عددِ نتیجه؛ با دکمههای قبلی/بعدی بین داستانها جابهجا میشود.
* همان صفحهٔ `testimonial-spotlight` نسخهٔ React.
*/
const index = ref(0)
const quote = computed(() => QUOTES[index.value])
const go = (step: number) => {
index.value = (index.value + step + QUOTES.length) % QUOTES.length
}
</script>
<template>
<ControlSize size="xl" as-child>
<section aria-roledescription="نمایشگر" aria-label="داستانِ مشتریها" class="mx-auto w-full max-w-6xl px-4 py-24 sm:px-6">
<div class="relative grid grid-cols-1 overflow-hidden rounded-xl bg-inverse text-[var(--dig-white)] [--border:var(--inverse-border)] [--muted-foreground:var(--dig-neutral-400)] md:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)]">
<GridPattern :size="40" />
<div class="relative flex flex-col gap-8 p-8 sm:p-12" aria-live="polite">
<DigIcon name="quote" class="size-10 text-[var(--dig-violet-400)]" />
<!-- یک اندازه برای همهٔ نقلقولها و شکستنِ طبیعیِ خط؛ text-balance خطها را کوتاه و هر نقلقول را یکجور میکرد. -->
<blockquote class="min-h-[3lh] text-xl leading-relaxed font-bold sm:text-2xl sm:leading-relaxed">{{ quote.text }}</blockquote>
<div class="flex flex-wrap items-end justify-between gap-6">
<div class="flex flex-col">
<span class="font-semibold">{{ quote.name }}</span>
<span class="text-sm text-muted-foreground">{{ quote.role }}</span>
</div>
<div class="flex flex-col items-end">
<span class="text-3xl font-black tabular-nums text-[var(--dig-green-400)]">{{ quote.metric }}</span>
<span class="text-sm text-muted-foreground">{{ quote.metricLabel }}</span>
</div>
</div>
<div class="flex items-center gap-3">
<Button variant="outline" size="icon" aria-label="داستانِ قبلی" class="bg-inverse text-[var(--dig-white)] hover:bg-inverse-raised" @click="go(-1)">
<DigIcon name="chevron-right" class="ltr:rotate-180" />
</Button>
<Button variant="outline" size="icon" aria-label="داستانِ بعدی" class="bg-inverse text-[var(--dig-white)] hover:bg-inverse-raised" @click="go(1)">
<DigIcon name="chevron-left" class="ltr:rotate-180" />
</Button>
<span class="text-sm text-muted-foreground tabular-nums">{{ toFaDigits(index + 1) }} از {{ toFaDigits(QUOTES.length) }}</span>
</div>
</div>
<img :key="quote.photo" :src="stockImages[quote.photo].src" :alt="quote.name" class="relative aspect-[4/3] size-full object-cover md:aspect-auto" />
</div>
</section>
</ControlSize>
</template>
کدِ این بلاک هنوز برای Svelte نوشته نشده است.
این موارد هنوز برای Svelte آماده نیستند: background-patterncontrol-sizepersianآیکون chevron-leftآیکون chevron-rightآیکون quote
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="svelte" ایجنت آن را با کامپوننتهای Svelte میسازد.
import {
ChangeDetectionStrategy,
Component,
computed,
signal,
} from "@angular/core"
import { DigButton } from "@/components/ui/button"
import { DigControlSize } from "@/components/ui/control-size"
import { DigGridPattern } from "@/components/ui/background-pattern"
import { DigIcon } from "@/lib/icons"
import { toFaDigits } from "@/lib/persian"
// تصویرها از کتابخانهٔ تصویرِ دیگ (همان آدرسهای نسخهٔ React)
const stockImages = {
personWoman2: {
src: "https://docs.digdesign.ir/images/person-woman-2.webp",
alt: "پرترهٔ زنی با کتِ طوسی",
},
personMan2: {
src: "https://docs.digdesign.ir/images/person-man-2.webp",
alt: "پرترهٔ مردی با تیشرتِ سفید",
},
}
const QUOTES: {
text: string
name: string
role: string
photo: keyof typeof stockImages
metric: string
metricLabel: string
}[] = [
{
text: "آوند حسابوکتابِ چهار شعبه را یکجا کرد؛ حالا هر صبح با یک نگاه میدانم دیروز چه گذشت.",
name: "سارا محمدی",
role: "مدیرِ کافه رست",
photo: "personWoman2",
metric: "۲۰٪",
metricLabel: "کاهشِ هزینه در شش ماه",
},
{
text: "قبل از آوند، پایانِ ماه یعنی دو شب بیداری. الان حقوق و بیمه را در یک ساعت میبندیم.",
name: "علی کاظمی",
role: "مدیرِ منابعِ انسانی",
photo: "personMan2",
metric: "۹ ساعت",
metricLabel: "صرفهجویی در هفته",
},
]
@Component({
selector: "dig-block-testimonial-spotlight",
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [DigButton, DigControlSize, DigGridPattern, DigIcon],
template: `
<section
digControlSize="xl"
aria-roledescription="نمایشگر"
aria-label="داستانِ مشتریها"
class="mx-auto w-full max-w-6xl px-4 py-24 sm:px-6"
>
<div
class="relative grid grid-cols-1 overflow-hidden rounded-xl bg-inverse text-[var(--dig-white)] [--border:var(--inverse-border)] [--muted-foreground:var(--dig-neutral-400)] md:grid-cols-[minmax(0,1.5fr)_minmax(0,1fr)]"
>
<div digGridPattern [size]="40"></div>
<div
class="relative flex flex-col gap-8 p-8 sm:p-12"
aria-live="polite"
>
<svg
digIcon="quote"
class="size-10 text-[var(--dig-violet-400)]"
></svg>
<!-- یک اندازه برای همهٔ نقلقولها و شکستنِ طبیعیِ خط؛ text-balance خطها را کوتاه و هر نقلقول را یکجور میکرد. -->
<blockquote
class="min-h-[3lh] text-xl leading-relaxed font-bold sm:text-2xl sm:leading-relaxed"
>
{{ quote().text }}
</blockquote>
<div class="flex flex-wrap items-end justify-between gap-6">
<div class="flex flex-col">
<span class="font-semibold">{{ quote().name }}</span>
<span class="text-sm text-muted-foreground">{{
quote().role
}}</span>
</div>
<div class="flex flex-col items-end">
<span
class="text-3xl font-black tabular-nums text-[var(--dig-green-400)]"
>{{ quote().metric }}</span
>
<span class="text-sm text-muted-foreground">{{
quote().metricLabel
}}</span>
</div>
</div>
<div class="flex items-center gap-3">
<button
digButton
type="button"
variant="outline"
size="icon"
aria-label="داستانِ قبلی"
class="bg-inverse text-[var(--dig-white)] hover:bg-inverse-raised"
(click)="go(-1)"
>
<svg digIcon="chevron-right" class="ltr:rotate-180"></svg>
</button>
<button
digButton
type="button"
variant="outline"
size="icon"
aria-label="داستانِ بعدی"
class="bg-inverse text-[var(--dig-white)] hover:bg-inverse-raised"
(click)="go(1)"
>
<svg digIcon="chevron-left" class="ltr:rotate-180"></svg>
</button>
<span class="text-sm text-muted-foreground tabular-nums"
>{{ toFaDigits(index() + 1) }} از
{{ toFaDigits(QUOTES.length) }}</span
>
</div>
</div>
<img
[src]="stockImages[quote().photo].src"
[alt]="quote().name"
class="relative aspect-[4/3] size-full object-cover md:aspect-auto"
/>
</div>
</section>
`,
})
export class TestimonialSpotlightBlock {
readonly stockImages = stockImages
readonly QUOTES = QUOTES
readonly toFaDigits = toFaDigits
readonly index = signal(0)
readonly quote = computed(() => QUOTES[this.index()])
go(step: number) {
this.index.update((index) => (index + step + QUOTES.length) % QUOTES.length)
}
}
کدِ این بلاک هنوز برای Android نوشته نشده است.
همهٔ کامپوننتهای لازم برای Android آمادهاند؛ با MCP میتوانید همین صفحه را از روی نسخهٔ React بسازید.
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="android" ایجنت آن را با کامپوننتهای Android میسازد.