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

اعلان‌های دسته‌بندی‌شده

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

هر منبع یک کارت با تازه‌ترین اعلان و «چند اعلانِ دیگر» بازشونده؛ برای کاهشِ شلوغیِ اعلان‌ها.

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

این بلاک از ۴ آیتم دیگ استفاده می‌کند: buttoncontrol-sizeiconspersian

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

۲. کد صفحه

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

notifications-grouped.tsx
"use client"

import * as React from "react"

import { ChevronDownIcon, ReceiptIcon, TruckIcon, UsersIcon } from "@/components/icons"
import { Button } from "@/components/ui/button"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { toFaDigits } from "@/lib/persian"

const GROUPS = [
  { key: "orders", title: "سفارش‌ها", icon: <TruckIcon />, items: ["سفارشِ ۸۸۲۱۰۴۲ ارسال شد", "سفارشِ ۸۸۲۱۰۴۱ تحویل شد", "سفارشِ ۸۸۲۱۰۴۰ آماده‌سازی شد", "سفارشِ ۸۸۲۱۰۳۹ مرجوع شد"], time: "۱۰ دقیقه پیش" },
  { key: "team", title: "تیم", icon: <UsersIcon />, items: ["سارا محمدی به تیمِ فروش پیوست", "امیر رضایی نقشِ مدیر گرفت"], time: "۲ ساعت پیش" },
  { key: "finance", title: "مالی", icon: <ReceiptIcon />, items: ["پرداختِ فاکتورِ ۱۴۰۵-۰۲۳۱ انجام شد"], time: "دیروز" },
]

/**
 * اعلان‌های دسته‌بندی‌شده برای کاهشِ شلوغی: هر منبع یک کارت با تازه‌ترین اعلان و «۳ اعلانِ
 * دیگر» که باز و بسته می‌شود (aria-expanded)؛ کاربر به‌جای ده ردیف، سه خبرِ اصلی می‌بیند.
 */
export default function NotificationsGroupedBlock() {
  const [open, setOpen] = React.useState<string[]>([])

  return (
    <ControlSizeProvider size="xl" asChild>
      <main className="mx-auto flex w-full max-w-2xl flex-col gap-8 p-4 sm:p-6">
        <header className="flex flex-col gap-1">
          <h1 className="text-2xl font-bold">اعلان‌ها</h1>
          <p className="text-muted-foreground">{toFaDigits(GROUPS.reduce((sum, group) => sum + group.items.length, 0))} اعلان از {toFaDigits(GROUPS.length)} بخش</p>
        </header>
        <ul className="flex flex-col gap-3">
          {GROUPS.map((group) => {
            const expanded = open.includes(group.key)
            const rest = group.items.length - 1
            return (
              <li key={group.key} className="flex flex-col rounded-xl border border-border bg-card">
                <div className="flex items-start gap-3 p-4">
                  <span aria-hidden className="flex size-10 shrink-0 items-center justify-center rounded-full bg-subtle text-brand-secondary [&>svg]:size-5">
                    {group.icon}
                  </span>
                  <div className="flex flex-1 flex-col gap-1">
                    <span className="flex items-center justify-between gap-2">
                      <span className="text-sm font-semibold text-muted-foreground">{group.title}</span>
                      <span className="text-xs text-muted-foreground">{group.time}</span>
                    </span>
                    <span className="font-medium">{group.items[0]}</span>
                  </div>
                </div>
                {rest > 0 && (
                  <>
                    {expanded && (
                      <ul id={`ng-${group.key}`} className="flex flex-col gap-2 border-t border-border px-4 py-3 ps-[4.25rem]">
                        {group.items.slice(1).map((item) => (
                          <li key={item} className="text-sm text-muted-foreground">
                            {item}
                          </li>
                        ))}
                      </ul>
                    )}
                    <Button
                      variant="ghost"
                      aria-expanded={expanded}
                      aria-controls={`ng-${group.key}`}
                      onClick={() => setOpen((list) => (expanded ? list.filter((key) => key !== group.key) : [...list, group.key]))}
                      className="justify-center gap-2 rounded-t-none border-t border-border"
                    >
                      {expanded ? "بستن" : `${toFaDigits(rest)} اعلانِ دیگر`}
                      <ChevronDownIcon className={expanded ? "rotate-180" : ""} />
                    </Button>
                  </>
                )}
              </li>
            )
          })}
        </ul>
      </main>
    </ControlSizeProvider>
  )
}
notifications-grouped.vue
<script setup lang="ts">
import { ref } from "vue"

import Button from "@/components/ui/Button.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import { DigIcon } from "@/lib/icons"
import { toFaDigits } from "@/lib/persian"

const GROUPS = [
  { key: "orders", title: "سفارش‌ها", icon: "truck", items: ["سفارشِ ۸۸۲۱۰۴۲ ارسال شد", "سفارشِ ۸۸۲۱۰۴۱ تحویل شد", "سفارشِ ۸۸۲۱۰۴۰ آماده‌سازی شد", "سفارشِ ۸۸۲۱۰۳۹ مرجوع شد"], time: "۱۰ دقیقه پیش" },
  { key: "team", title: "تیم", icon: "users", items: ["سارا محمدی به تیمِ فروش پیوست", "امیر رضایی نقشِ مدیر گرفت"], time: "۲ ساعت پیش" },
  { key: "finance", title: "مالی", icon: "receipt", items: ["پرداختِ فاکتورِ ۱۴۰۵-۰۲۳۱ انجام شد"], time: "دیروز" },
]

/**
 * اعلان‌های دسته‌بندی‌شده برای کاهشِ شلوغی: هر منبع یک کارت با تازه‌ترین اعلان و «۳ اعلانِ
 * دیگر» که باز و بسته می‌شود (aria-expanded)؛ کاربر به‌جای ده ردیف، سه خبرِ اصلی می‌بیند.
 */
const open = ref<string[]>([])

function toggle(key: string) {
  open.value = open.value.includes(key) ? open.value.filter((entry) => entry !== key) : [...open.value, key]
}
</script>

<template>
  <ControlSize size="xl" as-child>
    <main class="mx-auto flex w-full max-w-2xl flex-col gap-8 p-4 sm:p-6">
      <header class="flex flex-col gap-1">
        <h1 class="text-2xl font-bold">اعلان‌ها</h1>
        <p class="text-muted-foreground">{{ toFaDigits(GROUPS.reduce((sum, group) => sum + group.items.length, 0)) }} اعلان از {{ toFaDigits(GROUPS.length) }} بخش</p>
      </header>
      <ul class="flex flex-col gap-3">
        <li v-for="group in GROUPS" :key="group.key" class="flex flex-col rounded-xl border border-border bg-card">
          <div class="flex items-start gap-3 p-4">
            <span aria-hidden="true" class="flex size-10 shrink-0 items-center justify-center rounded-full bg-subtle text-brand-secondary [&>svg]:size-5">
              <DigIcon :name="group.icon" />
            </span>
            <div class="flex flex-1 flex-col gap-1">
              <span class="flex items-center justify-between gap-2">
                <span class="text-sm font-semibold text-muted-foreground">{{ group.title }}</span>
                <span class="text-xs text-muted-foreground">{{ group.time }}</span>
              </span>
              <span class="font-medium">{{ group.items[0] }}</span>
            </div>
          </div>
          <template v-if="group.items.length - 1 > 0">
            <ul v-if="open.includes(group.key)" :id="`ng-${group.key}`" class="flex flex-col gap-2 border-t border-border px-4 py-3 ps-[4.25rem]">
              <li v-for="item in group.items.slice(1)" :key="item" class="text-sm text-muted-foreground">{{ item }}</li>
            </ul>
            <Button variant="ghost" :aria-expanded="open.includes(group.key)" :aria-controls="`ng-${group.key}`" class="justify-center gap-2 rounded-t-none border-t border-border" @click="toggle(group.key)">
              {{ open.includes(group.key) ? "بستن" : `${toFaDigits(group.items.length - 1)} اعلانِ دیگر` }}
              <DigIcon name="chevron-down" :class="open.includes(group.key) ? 'rotate-180' : ''" />
            </Button>
          </template>
        </li>
      </ul>
    </main>
  </ControlSize>
</template>

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

این موارد هنوز برای Svelte آماده نیستند: control-sizepersianآیکون chevron-downآیکون receiptآیکون truckآیکون users

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

notifications-grouped.ts
import { Component, ChangeDetectionStrategy, signal } from "@angular/core"

import { DigControlSize } from "@/components/ui/control-size"
import { DigIcon } from "@/lib/icons"
import { DigButton } from "@/components/ui/button"
import { toFaDigits } from "@/lib/persian"

const GROUPS = [
  {
    key: "orders",
    title: "سفارش‌ها",
    icon: "truck" as const,
    items: [
      "سفارشِ ۸۸۲۱۰۴۲ ارسال شد",
      "سفارشِ ۸۸۲۱۰۴۱ تحویل شد",
      "سفارشِ ۸۸۲۱۰۴۰ آماده‌سازی شد",
      "سفارشِ ۸۸۲۱۰۳۹ مرجوع شد",
    ],
    time: "۱۰ دقیقه پیش",
  },
  {
    key: "team",
    title: "تیم",
    icon: "users" as const,
    items: ["سارا محمدی به تیمِ فروش پیوست", "امیر رضایی نقشِ مدیر گرفت"],
    time: "۲ ساعت پیش",
  },
  {
    key: "finance",
    title: "مالی",
    icon: "receipt" as const,
    items: ["پرداختِ فاکتورِ ۱۴۰۵-۰۲۳۱ انجام شد"],
    time: "دیروز",
  },
]

@Component({
  selector: "dig-block-notifications-grouped",
  imports: [DigControlSize, DigIcon, DigButton],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <main digControlSize="xl" class="mx-auto flex w-full max-w-2xl flex-col gap-8 p-4 sm:p-6">
      <header class="flex flex-col gap-1">
        <h1 class="text-2xl font-bold">اعلان‌ها</h1>
        <p class="text-muted-foreground">
          {{ toFaDigits(GROUPS.reduce((sum, group) => sum + group.items.length, 0)) }} اعلان از
          {{ toFaDigits(GROUPS.length) }} بخش
        </p>
      </header>
      <ul class="flex flex-col gap-3">
        @for (group of GROUPS; track group.key) {
          <li class="flex flex-col rounded-xl border border-border bg-card">
            <div class="flex items-start gap-3 p-4">
              <span
                aria-hidden="true"
                class="flex size-10 shrink-0 items-center justify-center rounded-full bg-subtle text-brand-secondary [&>svg]:size-5"
                ><svg [digIcon]="group.icon"></svg
              ></span>
              <div class="flex flex-1 flex-col gap-1">
                <span class="flex items-center justify-between gap-2"
                  ><span class="text-sm font-semibold text-muted-foreground">{{ group.title }}</span>
                  <span class="text-xs text-muted-foreground">{{ group.time }}</span></span
                >
                <span class="font-medium">{{ group.items[0] }}</span>
              </div>
            </div>
            @if (group.items.length - 1 > 0) {
              @if (open().includes(group.key)) {
                <ul
                  [id]="\`ng-\${group.key}\`"
                  class="flex flex-col gap-2 border-t border-border px-4 py-3 ps-[4.25rem]"
                >
                  @for (item of group.items.slice(1); track item) {
                    <li class="text-sm text-muted-foreground">{{ item }}</li>
                  }
                </ul>
              }
              <button
                digButton
                type="button"
                variant="ghost"
                [attr.aria-expanded]="open().includes(group.key)"
                [attr.aria-controls]="\`ng-\${group.key}\`"
                class="justify-center gap-2 rounded-t-none border-t border-border"
                (click)="toggle(group.key)"
              >
                {{ open().includes(group.key) ? "بستن" : \`\${toFaDigits(group.items.length - 1)} اعلانِ دیگر\` }}
                <svg digIcon="chevron-down" [class]="open().includes(group.key) ? 'rotate-180' : ''"></svg>
              </button>
            }
          </li>
        }
      </ul>
    </main>
  `,
})
export class NotificationsGroupedBlock {
  readonly toFaDigits = toFaDigits

  readonly GROUPS = GROUPS

  readonly open = signal<string[]>([])

  toggle(key: string) {
    this.open.set(this.open().includes(key) ? this.open().filter((entry) => entry !== key) : [...this.open(), key])
  }
}

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

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

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