بلاک‌ها · معرفی محصول
ری‌اکت ۱۹ و Next.js با پیاده‌سازی دسترس‌پذیری داخلی دیگویو ۳ با Composition APISvelte ۵ با runesانگولار با signals و دایرکتیوهای standaloneجتپک کامپوز با KotliniOS — هنوز پورت نشده

قیمت به ازای کاربر

پیش‌نمایش تمام‌صفحه

قیمت‌گذاریِ وابسته به تعداد: اسلایدرِ تعدادِ کاربر، سگمنتِ ماهانه/سالانه و کارتِ تیرهٔ قیمتِ زنده با صرفه‌جوییِ سالانه.

۱. نصب کامپوننت‌ها

این بلاک از ۷ آیتم دیگ استفاده می‌کند: badgebuttoncontrol-sizeiconspersianslidertoggle-group

پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
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/slider.json https://docs.digdesign.ir/r/toggle-group.json
pnpm 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/slider.json https://docs.digdesign.ir/r/toggle-group.json
yarn 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/slider.json https://docs.digdesign.ir/r/toggle-group.json
bunx --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/slider.json https://docs.digdesign.ir/r/toggle-group.json
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add badge button control-size persian slider toggle-group --framework vue
pnpm dlx digdesign@latest add badge button control-size persian slider toggle-group --framework vue
yarn dlx digdesign@latest add badge button control-size persian slider toggle-group --framework vue
bunx --bun digdesign@latest add badge button control-size persian slider toggle-group --framework vue
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add button --framework svelte
pnpm dlx digdesign@latest add button --framework svelte
yarn dlx digdesign@latest add button --framework svelte
bunx --bun digdesign@latest add button --framework svelte
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add badge button control-size icons persian slider toggle-group --framework angular
pnpm dlx digdesign@latest add badge button control-size icons persian slider toggle-group --framework angular
yarn dlx digdesign@latest add badge button control-size icons persian slider toggle-group --framework angular
bunx --bun digdesign@latest add badge button control-size icons persian slider toggle-group --framework angular
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add badge button control-size persian slider toggle-group --framework android
pnpm dlx digdesign@latest add badge button control-size persian slider toggle-group --framework android
yarn dlx digdesign@latest add badge button control-size persian slider toggle-group --framework android
bunx --bun digdesign@latest add badge button control-size persian slider toggle-group --framework android

۲. کد صفحه

کد را در صفحهٔ پروژه‌تان بگذارید (React: app/<route>/page.tsx) و متن‌ها، داده و هندلرها را با محصول خودتان عوض کنید. با سوییچر فریم‌ورک کدِ همین صفحه در فریم‌ورک دیگر را ببینید.

pricing-calculator.tsx
"use client"

import * as React from "react"

import { CheckIcon } from "@/components/icons"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { Slider } from "@/components/ui/slider"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
import { formatCurrency, toFaDigits } from "@/lib/persian"

const PER_SEAT = 95_000
const INCLUDED = ["فاکتور و گزارشِ نامحدود", "اتصال به همهٔ بانک‌ها", "پشتیبانی آنلاین", "نسخهٔ پشتیبانِ روزانه"]

/**
 * قیمت‌گذاری وابسته به تعداد: اسلایدرِ تعدادِ کاربر و سگمنتِ ماهانه/سالانه، و کارتِ
 * تیره که قیمتِ هر ماه، تخفیفِ سالانه و جمعِ پرداخت را زنده نشان می‌دهد.
 */
export default function PricingCalculatorBlock() {
  const [seats, setSeats] = React.useState([8])
  const [period, setPeriod] = React.useState("yearly")
  const yearly = period === "yearly"
  const monthly = seats[0] * PER_SEAT * (yearly ? 0.8 : 1)

  return (
    <ControlSizeProvider size="xl" asChild>
      <main className="mx-auto flex w-full max-w-5xl flex-col gap-12 px-4 py-20 sm:px-6">
        <header className="mx-auto flex max-w-2xl flex-col items-center gap-3 text-center">
          <h1 className="text-4xl font-black text-balance">فقط به اندازهٔ تیمت پول بده</h1>
          <p className="text-lg leading-8 text-muted-foreground">هر کاربر {formatCurrency(PER_SEAT)} در ماه؛ همهٔ امکانات برای همه.</p>
        </header>
        <div className="grid grid-cols-1 items-stretch gap-4 md:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]">
          <section className="flex flex-col gap-7 rounded-xl border border-border bg-card p-6 sm:p-7">
            <div className="flex flex-col gap-4">
              <div className="flex items-baseline justify-between gap-2">
                <span id="pc-seats" className="font-medium">
                  تعدادِ کاربر
                </span>
                <span className="text-3xl font-black tabular-nums">{toFaDigits(seats[0])}</span>
              </div>
              <Slider aria-labelledby="pc-seats" value={seats} onValueChange={setSeats} min={1} max={50} />
              <div className="flex justify-between text-xs text-muted-foreground">
                <span>{toFaDigits(1)}</span>
                <span>{toFaDigits(50)}</span>
              </div>
            </div>
            <div className="flex flex-col gap-3">
              <span id="pc-period" className="font-medium">
                دورهٔ پرداخت
              </span>
              <ControlSizeProvider size="lg" mobileSize="default" asChild>
                <ToggleGroup type="single" variant="segmented" value={period} onValueChange={(value) => value && setPeriod(value as string)} aria-labelledby="pc-period" className="w-full">
                  <ToggleGroupItem value="monthly" className="flex-1">
                    ماهانه
                  </ToggleGroupItem>
                  <ToggleGroupItem value="yearly" className="flex-1 gap-2">
                    سالانه
                    <Badge variant="soft" color="success">
                      ٪۲۰ کمتر
                    </Badge>
                  </ToggleGroupItem>
                </ToggleGroup>
              </ControlSizeProvider>
            </div>
            <ul className="mt-auto flex flex-col gap-2.5 border-t border-border pt-5 text-base">
              {INCLUDED.map((item) => (
                <li key={item} className="flex items-center gap-2">
                  <CheckIcon aria-hidden className="size-4 text-success-subtle-foreground" />
                  {item}
                </li>
              ))}
            </ul>
          </section>
          <section aria-live="polite" className="flex flex-col gap-5 rounded-xl bg-inverse p-6 text-[var(--dig-white)] [--border:var(--inverse-border)] [--muted-foreground:var(--dig-neutral-400)] [--primary-foreground:var(--dig-graphite-950)] [--primary:var(--dig-white)] sm:p-7">
            <span className="text-base text-muted-foreground">هزینهٔ تو</span>
            <div className="flex items-baseline gap-2">
              <span className="text-4xl font-black tabular-nums">{formatCurrency(Math.round(monthly))}</span>
              <span className="text-muted-foreground">در ماه</span>
            </div>
            <dl className="flex flex-col gap-3 border-t border-border pt-5 text-base">
              <div className="flex justify-between gap-2">
                <dt className="text-muted-foreground">پرداختِ {yearly ? "سالانه" : "ماهانه"}</dt>
                <dd className="tabular-nums">{formatCurrency(Math.round(yearly ? monthly * 12 : monthly))}</dd>
              </div>
              {yearly && (
                <div className="flex justify-between gap-2">
                  <dt className="text-muted-foreground">صرفه‌جویی</dt>
                  <dd className="text-[var(--dig-green-400)] tabular-nums">{formatCurrency(Math.round(seats[0] * PER_SEAT * 12 * 0.2))}</dd>
                </div>
              )}
            </dl>
            <Button fullWidth className="mt-auto">
              شروعِ ۱۴ روز رایگان
            </Button>
          </section>
        </div>
      </main>
    </ControlSizeProvider>
  )
}
pricing-calculator.vue
<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 Slider from "@/components/ui/Slider.vue"
import ToggleGroup from "@/components/ui/ToggleGroup.vue"
import ToggleGroupItem from "@/components/ui/ToggleGroupItem.vue"
import { DigIcon } from "@/lib/icons"
import { formatCurrency, toFaDigits } from "@/lib/persian"

const PER_SEAT = 95_000
const INCLUDED = ["فاکتور و گزارشِ نامحدود", "اتصال به همهٔ بانک‌ها", "پشتیبانی آنلاین", "نسخهٔ پشتیبانِ روزانه"]

/**
 * قیمت‌گذاری وابسته به تعداد: اسلایدرِ تعدادِ کاربر و سگمنتِ ماهانه/سالانه، و کارتِ
 * تیره که قیمتِ هر ماه، تخفیفِ سالانه و جمعِ پرداخت را زنده نشان می‌دهد.
 */
const seats = ref([8])
const period = ref("yearly")
const yearly = computed(() => period.value === "yearly")
const monthly = computed(() => seats.value[0] * PER_SEAT * (yearly.value ? 0.8 : 1))

function onPeriod(value: string | string[] | undefined) {
  if (value) period.value = value as string
}
</script>

<template>
  <ControlSize size="xl" as-child>
    <main class="mx-auto flex w-full max-w-5xl flex-col gap-12 px-4 py-20 sm:px-6">
      <header class="mx-auto flex max-w-2xl flex-col items-center gap-3 text-center">
        <h1 class="text-4xl font-black text-balance">فقط به اندازهٔ تیمت پول بده</h1>
        <p class="text-lg leading-8 text-muted-foreground">هر کاربر {{ formatCurrency(PER_SEAT) }} در ماه؛ همهٔ امکانات برای همه.</p>
      </header>
      <div class="grid grid-cols-1 items-stretch gap-4 md:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]">
        <section class="flex flex-col gap-7 rounded-xl border border-border bg-card p-6 sm:p-7">
          <div class="flex flex-col gap-4">
            <div class="flex items-baseline justify-between gap-2">
              <span id="pc-seats" class="font-medium">تعدادِ کاربر</span>
              <span class="text-3xl font-black tabular-nums">{{ toFaDigits(seats[0]) }}</span>
            </div>
            <Slider aria-labelledby="pc-seats" :value="seats" :min="1" :max="50" @update:value="(value) => (seats = value)" />
            <div class="flex justify-between text-xs text-muted-foreground">
              <span>{{ toFaDigits(1) }}</span>
              <span>{{ toFaDigits(50) }}</span>
            </div>
          </div>
          <div class="flex flex-col gap-3">
            <span id="pc-period" class="font-medium">دورهٔ پرداخت</span>
            <ControlSize size="lg" mobile-size="default" as-child>
              <ToggleGroup type="single" variant="segmented" :value="period" aria-labelledby="pc-period" class="w-full" @update:value="onPeriod">
                <ToggleGroupItem value="monthly" class="flex-1">ماهانه</ToggleGroupItem>
                <ToggleGroupItem value="yearly" class="flex-1 gap-2">
                  سالانه
                  <Badge variant="soft" color="success">٪۲۰ کمتر</Badge>
                </ToggleGroupItem>
              </ToggleGroup>
            </ControlSize>
          </div>
          <ul class="mt-auto flex flex-col gap-2.5 border-t border-border pt-5 text-base">
            <li v-for="item in INCLUDED" :key="item" class="flex items-center gap-2">
              <DigIcon name="check" aria-hidden="true" class="size-4 text-success-subtle-foreground" />
              {{ item }}
            </li>
          </ul>
        </section>
        <section aria-live="polite" class="flex flex-col gap-5 rounded-xl bg-inverse p-6 text-[var(--dig-white)] [--border:var(--inverse-border)] [--muted-foreground:var(--dig-neutral-400)] [--primary-foreground:var(--dig-graphite-950)] [--primary:var(--dig-white)] sm:p-7">
          <span class="text-base text-muted-foreground">هزینهٔ تو</span>
          <div class="flex items-baseline gap-2">
            <span class="text-4xl font-black tabular-nums">{{ formatCurrency(Math.round(monthly)) }}</span>
            <span class="text-muted-foreground">در ماه</span>
          </div>
          <dl class="flex flex-col gap-3 border-t border-border pt-5 text-base">
            <div class="flex justify-between gap-2">
              <dt class="text-muted-foreground">پرداختِ {{ yearly ? "سالانه" : "ماهانه" }}</dt>
              <dd class="tabular-nums">{{ formatCurrency(Math.round(yearly ? monthly * 12 : monthly)) }}</dd>
            </div>
            <div v-if="yearly" class="flex justify-between gap-2">
              <dt class="text-muted-foreground">صرفه‌جویی</dt>
              <dd class="text-[var(--dig-green-400)] tabular-nums">{{ formatCurrency(Math.round(seats[0] * PER_SEAT * 12 * 0.2)) }}</dd>
            </div>
          </dl>
          <Button full-width class="mt-auto">شروعِ ۱۴ روز رایگان</Button>
        </section>
      </div>
    </main>
  </ControlSize>
</template>

کدِ این بلاک هنوز برای Svelte نوشته نشده است.

این موارد هنوز برای Svelte آماده نیستند: badgecontrol-sizepersianslidertoggle-groupآیکون check

کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="svelte" ایجنت آن را با کامپوننت‌های Svelte می‌سازد.

pricing-calculator.ts
import {
  ChangeDetectionStrategy,
  Component,
  computed,
  signal,
} from "@angular/core"

import { DigIcon } from "@/lib/icons"
import { formatCurrency, toFaDigits } from "@/lib/persian"
import { DigBadge } from "@/components/ui/badge"
import { DigButton } from "@/components/ui/button"
import { DigControlSize } from "@/components/ui/control-size"
import { DigSlider } from "@/components/ui/slider"
import {
  DigToggleGroup,
  DigToggleGroupItem,
} from "@/components/ui/toggle-group"

const PER_SEAT = 95_000
const INCLUDED = [
  "فاکتور و گزارشِ نامحدود",
  "اتصال به همهٔ بانک‌ها",
  "پشتیبانی آنلاین",
  "نسخهٔ پشتیبانِ روزانه",
]

@Component({
  selector: "dig-block-pricing-calculator",
  imports: [
    DigBadge,
    DigButton,
    DigControlSize,
    DigIcon,
    DigSlider,
    DigToggleGroup,
    DigToggleGroupItem,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <main
      digControlSize="xl"
      class="mx-auto flex w-full max-w-5xl flex-col gap-12 px-4 py-20 sm:px-6"
    >
      <header
        class="mx-auto flex max-w-2xl flex-col items-center gap-3 text-center"
      >
        <h1 class="text-4xl font-black text-balance">
          فقط به اندازهٔ تیمت پول بده
        </h1>
        <p class="text-lg leading-8 text-muted-foreground">
          هر کاربر {{ formatCurrency(PER_SEAT) }} در ماه؛ همهٔ امکانات برای همه.
        </p>
      </header>
      <div
        class="grid grid-cols-1 items-stretch gap-4 md:grid-cols-[minmax(0,1.2fr)_minmax(0,1fr)]"
      >
        <section
          class="flex flex-col gap-7 rounded-xl border border-border bg-card p-6 sm:p-7"
        >
          <div class="flex flex-col gap-4">
            <div class="flex items-baseline justify-between gap-2">
              <span id="pc-seats" class="font-medium">تعدادِ کاربر</span>
              <span class="text-3xl font-black tabular-nums">{{
                toFaDigits(seats()[0])
              }}</span>
            </div>
            <div
              digSlider
              aria-labelledby="pc-seats"
              [value]="seats()"
              [min]="1"
              [max]="50"
              (valueChange)="onSeats($event)"
            ></div>
            <div class="flex justify-between text-xs text-muted-foreground">
              <span>{{ toFaDigits(1) }}</span>
              <span>{{ toFaDigits(50) }}</span>
            </div>
          </div>
          <div class="flex flex-col gap-3">
            <span id="pc-period" class="font-medium">دورهٔ پرداخت</span>
            <div digControlSize="lg" mobileSize="default">
              <div
                digToggleGroup
                type="single"
                variant="segmented"
                [value]="period()"
                aria-labelledby="pc-period"
                class="w-full"
                (valueChange)="onPeriod($event)"
              >
                <button
                  digToggleGroupItem
                  type="button"
                  value="monthly"
                  class="flex-1"
                >
                  ماهانه
                </button>
                <button
                  digToggleGroupItem
                  type="button"
                  value="yearly"
                  class="flex-1 gap-2"
                >
                  سالانه
                  <span digBadge variant="soft" color="success">٪۲۰ کمتر</span>
                </button>
              </div>
            </div>
          </div>
          <ul
            class="mt-auto flex flex-col gap-2.5 border-t border-border pt-5 text-base"
          >
            @for (item of INCLUDED; track item) {
              <li class="flex items-center gap-2">
                <svg
                  digIcon="check"
                  aria-hidden="true"
                  class="size-4 text-success-subtle-foreground"
                ></svg>
                {{ item }}
              </li>
            }
          </ul>
        </section>
        <section
          aria-live="polite"
          class="flex flex-col gap-5 rounded-xl bg-inverse p-6 text-[var(--dig-white)] [--border:var(--inverse-border)] [--muted-foreground:var(--dig-neutral-400)] [--primary-foreground:var(--dig-graphite-950)] [--primary:var(--dig-white)] sm:p-7"
        >
          <span class="text-base text-muted-foreground">هزینهٔ تو</span>
          <div class="flex items-baseline gap-2">
            <span class="text-4xl font-black tabular-nums">{{
              formatCurrency(math.round(monthly()))
            }}</span>
            <span class="text-muted-foreground">در ماه</span>
          </div>
          <dl class="flex flex-col gap-3 border-t border-border pt-5 text-base">
            <div class="flex justify-between gap-2">
              <dt class="text-muted-foreground">
                پرداختِ {{ yearly() ? "سالانه" : "ماهانه" }}
              </dt>
              <dd class="tabular-nums">
                {{
                  formatCurrency(
                    math.round(yearly() ? monthly() * 12 : monthly())
                  )
                }}
              </dd>
            </div>
            @if (yearly()) {
              <div class="flex justify-between gap-2">
                <dt class="text-muted-foreground">صرفه‌جویی</dt>
                <dd class="text-[var(--dig-green-400)] tabular-nums">
                  {{
                    formatCurrency(math.round(seats()[0] * PER_SEAT * 12 * 0.2))
                  }}
                </dd>
              </div>
            }
          </dl>
          <button digButton type="button" fullWidth class="mt-auto">
            شروعِ ۱۴ روز رایگان
          </button>
        </section>
      </div>
    </main>
  `,
})
export class PricingCalculatorBlock {
  readonly PER_SEAT = PER_SEAT
  readonly INCLUDED = INCLUDED
  readonly formatCurrency = formatCurrency
  readonly toFaDigits = toFaDigits
  readonly math = Math

  readonly seats = signal([8])
  readonly period = signal("yearly")
  readonly yearly = computed(() => this.period() === "yearly")
  readonly monthly = computed(
    () => this.seats()[0] * PER_SEAT * (this.yearly() ? 0.8 : 1)
  )

  onSeats(value: number[] | undefined) {
    if (value?.length) this.seats.set(value)
  }

  onPeriod(value: string | string[] | undefined) {
    if (value === "monthly" || value === "yearly") this.period.set(value)
  }
}

کدِ این بلاک هنوز برای Android نوشته نشده است.

همهٔ کامپوننت‌های لازم برای Android آماده‌اند؛ با MCP می‌توانید همین صفحه را از روی نسخهٔ React بسازید.

کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="android" ایجنت آن را با کامپوننت‌های Android می‌سازد.