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

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

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

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

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

۲. کد صفحه

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

gallery-masonry.tsx
"use client";

import * as React from "react";

import { ChevronLeftIcon, ChevronRightIcon } from "@/components/icons";
import { Button } from "@/components/ui/button";
import { ControlSizeProvider } from "@/components/ui/control-size";
import {
  Dialog,
  DialogContent,
  DialogDescription,
  DialogTitle,
  DialogTrigger,
} from "@/components/ui/dialog";
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 Shot = {
  photo: StockImageName;
  title: string;
  tag: "space" | "food" | "people";
  tall?: boolean;
};

const SHOTS: Shot[] = [
  {
    photo: "restaurant",
    title: "سالنِ اصلی، عصرِ پنجشنبه",
    tag: "space",
    tall: true,
  },
  { photo: "foodDish", title: "خورشِ فصل با برنجِ دم‌پخت", tag: "food" },
  { photo: "personWoman2", title: "سرآشپز، پیش از سرویس", tag: "people" },
  { photo: "studioSunlit", title: "نورِ صبح روی میزِ کار", tag: "space" },
  {
    photo: "productVase",
    title: "ظرف‌های سفالیِ دست‌ساز",
    tag: "food",
    tall: true,
  },
  { photo: "personMan2", title: "میزبانِ شب", tag: "people", tall: true },
  { photo: "coverMinimalRoom", title: "گوشهٔ آرامِ طبقهٔ دوم", tag: "space" },
  { photo: "projectCafeBrand", title: "منوی تازهٔ پاییز", tag: "food" },
];
const FILTERS = [
  { value: "all", label: "همه" },
  { value: "space", label: "فضا" },
  { value: "food", label: "غذا" },
  { value: "people", label: "آدم‌ها" },
];

/**
 * گالریِ آجری با فیلترِ سگمنت: عکس‌ها با ارتفاعِ متفاوت در ستون‌ها می‌نشینند و با کلیک در
 * نمای بزرگ باز می‌شوند؛ قبلی/بعدی با دکمه یا کلیدهای جهت، و شمارهٔ عکس.
 */
export default function GalleryMasonryBlock() {
  const [filter, setFilter] = React.useState("all");
  const [open, setOpen] = React.useState<number | null>(null);
  const shots = SHOTS.filter((shot) => filter === "all" || shot.tag === filter);
  const current = open === null ? null : shots[open];
  const step = (delta: number) =>
    setOpen((index) =>
      index === null ? index : (index + delta + shots.length) % shots.length,
    );

  return (
    <ControlSizeProvider size="xl" asChild>
      <section
        aria-labelledby="masonry-title"
        className="mx-auto flex w-full max-w-6xl flex-col gap-10 px-4 py-24 sm:px-6"
      >
        <div className="flex flex-col items-start justify-between gap-6 md:flex-row md:items-end">
          <div className="flex flex-col gap-3">
            <span className="text-sm font-semibold text-brand-secondary">
              گالری
            </span>
            <h2 id="masonry-title" className="text-3xl font-black sm:text-4xl">
              یک شب در حیاط
            </h2>
          </div>
          <ControlSizeProvider size="lg" mobileSize="default" asChild>
            <ToggleGroup
              type="single"
              variant="segmented"
              value={filter}
              onValueChange={(value) => value && setFilter(value as string)}
              aria-label="دستهٔ عکس"
            >
              {FILTERS.map((item) => (
                <ToggleGroupItem key={item.value} value={item.value}>
                  {item.label}
                </ToggleGroupItem>
              ))}
            </ToggleGroup>
          </ControlSizeProvider>
        </div>

        <Dialog
          open={current !== null}
          onOpenChange={(value) => !value && setOpen(null)}
        >
          <ul className="columns-1 gap-4 sm:columns-2 lg:columns-3">
            {shots.map((shot, index) => (
              <Reveal asChild key={shot.photo} delay={(index % 3) * 80}>
                <li className="mb-4 break-inside-avoid">
                  <DialogTrigger asChild>
                    <button
                      type="button"
                      onClick={() => setOpen(index)}
                      className="group relative block w-full overflow-hidden rounded-xl outline-none focus-visible:ring-4 focus-visible:ring-ring"
                    >
                      {/* eslint-disable-next-line @next/next/no-img-element -- عکس از کتابخانهٔ تصویرِ دیگ */}
                      <img
                        src={stockImages[shot.photo].src}
                        alt={shot.title}
                        className={`w-full object-cover transition-transform duration-500 group-hover:scale-105 ${shot.tall ? "aspect-[3/4]" : "aspect-[4/3]"}`}
                      />
                      <span
                        aria-hidden
                        className="absolute inset-0 flex items-end bg-[linear-gradient(to_top,var(--dig-graphite-950)_0%,color-mix(in_oklab,var(--dig-graphite-950)_68%,transparent)_32%,color-mix(in_oklab,var(--dig-graphite-950)_22%,transparent)_64%,transparent_100%)] p-4 pt-20 text-start text-sm font-semibold text-[var(--dig-white)] invisible group-hover:visible group-focus-visible:visible"
                      >
                        {shot.title}
                      </span>
                    </button>
                  </DialogTrigger>
                </li>
              </Reveal>
            ))}
          </ul>

          <DialogContent
            className="max-w-4xl gap-4 p-3 sm:p-4"
            onKeyDown={(event) => {
              if (event.key === "ArrowLeft") step(1);
              if (event.key === "ArrowRight") step(-1);
            }}
          >
            {current && (
              <>
                {/* eslint-disable-next-line @next/next/no-img-element -- عکس از کتابخانهٔ تصویرِ دیگ */}
                <img
                  src={stockImages[current.photo].src}
                  alt={current.title}
                  className="max-h-[70vh] w-full rounded-lg object-cover"
                />
                <div className="flex items-center justify-between gap-4 px-1">
                  <div className="flex flex-col gap-0.5">
                    <DialogTitle className="text-base">
                      {current.title}
                    </DialogTitle>
                    <DialogDescription>
                      عکسِ {toFaDigits((open ?? 0) + 1)} از{" "}
                      {toFaDigits(shots.length)}
                    </DialogDescription>
                  </div>
                  <div className="flex gap-2">
                    <Button
                      variant="outline"
                      size="icon"
                      aria-label="عکسِ قبلی"
                      onClick={() => step(-1)}
                    >
                      <ChevronRightIcon />
                    </Button>
                    <Button
                      variant="outline"
                      size="icon"
                      aria-label="عکسِ بعدی"
                      onClick={() => step(1)}
                    >
                      <ChevronLeftIcon />
                    </Button>
                  </div>
                </div>
              </>
            )}
          </DialogContent>
        </Dialog>
      </section>
    </ControlSizeProvider>
  );
}
gallery-masonry.vue
<script setup lang="ts">
import { computed, ref } from "vue"

import Button from "@/components/ui/Button.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import Dialog from "@/components/ui/Dialog.vue"
import DialogContent from "@/components/ui/DialogContent.vue"
import DialogDescription from "@/components/ui/DialogDescription.vue"
import DialogTitle from "@/components/ui/DialogTitle.vue"
import DialogTrigger from "@/components/ui/DialogTrigger.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"

// تصویرها از کتابخانهٔ تصویرِ دیگ (همان آدرس‌های نسخهٔ React)
const stockImages = {
  restaurant: { src: "https://docs.digdesign.ir/images/restaurant.webp", alt: "فضای داخلیِ رستوران با میز و صندلی" },
  foodDish: { src: "https://docs.digdesign.ir/images/food-dish.webp", alt: "بشقابِ غذا با ماهی، کینوا و سبزیجات" },
  personWoman2: { src: "https://docs.digdesign.ir/images/person-woman-2.webp", alt: "پرترهٔ زنی با کتِ طوسی" },
  studioSunlit: { src: "https://docs.digdesign.ir/images/studio-sunlit.webp", alt: "استودیوی آفتاب‌گیر با میزِ چوبی و چهارپایه" },
  productVase: { src: "https://docs.digdesign.ir/images/product-vase.webp", alt: "دو گلدانِ سرامیکیِ سفید کنارِ پارچهٔ کرم" },
  personMan2: { src: "https://docs.digdesign.ir/images/person-man-2.webp", alt: "پرترهٔ مردی با تیشرتِ سفید" },
  coverMinimalRoom: { src: "https://docs.digdesign.ir/images/cover-minimal-room.webp", alt: "میز و صندلیِ ساده در اتاقِ سفید" },
  projectCafeBrand: { src: "https://docs.digdesign.ir/images/project-cafe-brand.webp", alt: "لیوان‌های کاغذیِ قهوه با درِ سیاه و سفید" },
}

type Shot = {
  photo: keyof typeof stockImages
  title: string
  tag: "space" | "food" | "people"
  tall?: boolean
}

const SHOTS: Shot[] = [
  { photo: "restaurant", title: "سالنِ اصلی، عصرِ پنجشنبه", tag: "space", tall: true },
  { photo: "foodDish", title: "خورشِ فصل با برنجِ دم‌پخت", tag: "food" },
  { photo: "personWoman2", title: "سرآشپز، پیش از سرویس", tag: "people" },
  { photo: "studioSunlit", title: "نورِ صبح روی میزِ کار", tag: "space" },
  { photo: "productVase", title: "ظرف‌های سفالیِ دست‌ساز", tag: "food", tall: true },
  { photo: "personMan2", title: "میزبانِ شب", tag: "people", tall: true },
  { photo: "coverMinimalRoom", title: "گوشهٔ آرامِ طبقهٔ دوم", tag: "space" },
  { photo: "projectCafeBrand", title: "منوی تازهٔ پاییز", tag: "food" },
]
const FILTERS = [
  { value: "all", label: "همه" },
  { value: "space", label: "فضا" },
  { value: "food", label: "غذا" },
  { value: "people", label: "آدم‌ها" },
]

/**
 * گالریِ آجری با فیلترِ سگمنت: عکس‌ها با ارتفاعِ متفاوت در ستون‌ها می‌نشینند و با کلیک در
 * نمای بزرگ باز می‌شوند؛ قبلی/بعدی با دکمه یا کلیدهای جهت، و شمارهٔ عکس.
 * همان صفحهٔ `gallery-masonry` نسخهٔ React.
 */
const filter = ref("all")
const open = ref<number | null>(null)
const shots = computed(() => SHOTS.filter((shot) => filter.value === "all" || shot.tag === filter.value))
const current = computed(() => (open.value === null ? null : shots.value[open.value]))

function step(delta: number) {
  if (open.value === null) return
  open.value = (open.value + delta + shots.value.length) % shots.value.length
}

function onFilter(value: string | string[] | undefined) {
  if (typeof value === "string" && value) filter.value = value
}

function onKeyDown(event: KeyboardEvent) {
  if (event.key === "ArrowLeft") step(1)
  if (event.key === "ArrowRight") step(-1)
}
</script>

<template>
  <ControlSize size="xl" as-child>
    <section aria-labelledby="masonry-title" class="mx-auto flex w-full max-w-6xl flex-col gap-10 px-4 py-24 sm:px-6">
      <div class="flex flex-col items-start justify-between gap-6 md:flex-row md:items-end">
        <div class="flex flex-col gap-3">
          <span class="text-sm font-semibold text-brand-secondary">گالری</span>
          <h2 id="masonry-title" class="text-3xl font-black sm:text-4xl">یک شب در حیاط</h2>
        </div>
        <ControlSize size="lg" mobile-size="default" as-child>
          <ToggleGroup type="single" variant="segmented" :value="filter" aria-label="دستهٔ عکس" @update:value="onFilter">
            <ToggleGroupItem v-for="item in FILTERS" :key="item.value" :value="item.value">{{ item.label }}</ToggleGroupItem>
          </ToggleGroup>
        </ControlSize>
      </div>

      <Dialog :open="current !== null" @update:open="(value: boolean) => !value && (open = null)">
        <ul class="columns-1 gap-4 sm:columns-2 lg:columns-3">
          <Reveal v-for="(shot, index) in shots" :key="shot.photo" as-child :delay="(index % 3) * 80">
            <li class="mb-4 break-inside-avoid">
              <DialogTrigger as-child>
                <button type="button" class="group relative block w-full overflow-hidden rounded-xl outline-none focus-visible:ring-4 focus-visible:ring-ring" @click="open = index">
                  <img
                    :src="stockImages[shot.photo].src"
                    :alt="shot.title"
                    :class="`w-full object-cover transition-transform duration-500 group-hover:scale-105 ${shot.tall ? 'aspect-[3/4]' : 'aspect-[4/3]'}`"
                  />
                  <span
                    aria-hidden="true"
                    class="absolute inset-0 flex items-end bg-[linear-gradient(to_top,var(--dig-graphite-950)_0%,color-mix(in_oklab,var(--dig-graphite-950)_68%,transparent)_32%,color-mix(in_oklab,var(--dig-graphite-950)_22%,transparent)_64%,transparent_100%)] p-4 pt-20 text-start text-sm font-semibold text-[var(--dig-white)] invisible group-hover:visible group-focus-visible:visible"
                  >
                    {{ shot.title }}
                  </span>
                </button>
              </DialogTrigger>
            </li>
          </Reveal>
        </ul>

        <DialogContent class="max-w-4xl gap-4 p-3 sm:p-4" @keydown="onKeyDown">
          <template v-if="current">
            <img :src="stockImages[current.photo].src" :alt="current.title" class="max-h-[70vh] w-full rounded-lg object-cover" />
            <div class="flex items-center justify-between gap-4 px-1">
              <div class="flex flex-col gap-0.5">
                <DialogTitle class="text-base">{{ current.title }}</DialogTitle>
                <DialogDescription>عکسِ {{ toFaDigits((open ?? 0) + 1) }} از {{ toFaDigits(shots.length) }}</DialogDescription>
              </div>
              <div class="flex gap-2">
                <Button variant="outline" size="icon" aria-label="عکسِ قبلی" @click="step(-1)">
                  <DigIcon name="chevron-right" />
                </Button>
                <Button variant="outline" size="icon" aria-label="عکسِ بعدی" @click="step(1)">
                  <DigIcon name="chevron-left" />
                </Button>
              </div>
            </div>
          </template>
        </DialogContent>
      </Dialog>
    </section>
  </ControlSize>
</template>

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

این موارد هنوز برای Svelte آماده نیستند: control-sizedialogpersianrevealtoggle-groupآیکون chevron-leftآیکون chevron-right

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

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

import { DigIcon } from "@/lib/icons"
import { toFaDigits } from "@/lib/persian"
import { DigButton } from "@/components/ui/button"
import { DigControlSize } from "@/components/ui/control-size"
import {
  DigDialog,
  DigDialogContent,
  DigDialogDescription,
  DigDialogTitle,
  DigDialogTrigger,
} from "@/components/ui/dialog"
import { DigReveal } from "@/components/ui/reveal"
import {
  DigToggleGroup,
  DigToggleGroupItem,
} from "@/components/ui/toggle-group"

const stockImages = {
  restaurant: {
    src: "https://docs.digdesign.ir/images/restaurant.webp",
    alt: "فضای داخلیِ رستوران با میز و صندلی",
  },
  foodDish: {
    src: "https://docs.digdesign.ir/images/food-dish.webp",
    alt: "بشقابِ غذا با ماهی، کینوا و سبزیجات",
  },
  personWoman2: {
    src: "https://docs.digdesign.ir/images/person-woman-2.webp",
    alt: "پرترهٔ زنی با کتِ طوسی",
  },
  studioSunlit: {
    src: "https://docs.digdesign.ir/images/studio-sunlit.webp",
    alt: "استودیوی آفتاب‌گیر با میزِ چوبی و چهارپایه",
  },
  productVase: {
    src: "https://docs.digdesign.ir/images/product-vase.webp",
    alt: "دو گلدانِ سرامیکیِ سفید کنارِ پارچهٔ کرم",
  },
  personMan2: {
    src: "https://docs.digdesign.ir/images/person-man-2.webp",
    alt: "پرترهٔ مردی با تیشرتِ سفید",
  },
  coverMinimalRoom: {
    src: "https://docs.digdesign.ir/images/cover-minimal-room.webp",
    alt: "میز و صندلیِ ساده در اتاقِ سفید",
  },
  projectCafeBrand: {
    src: "https://docs.digdesign.ir/images/project-cafe-brand.webp",
    alt: "لیوان‌های کاغذیِ قهوه با درِ سیاه و سفید",
  },
}

type Shot = {
  photo: keyof typeof stockImages
  title: string
  tag: "space" | "food" | "people"
  tall?: boolean
}

const SHOTS: Shot[] = [
  {
    photo: "restaurant",
    title: "سالنِ اصلی، عصرِ پنجشنبه",
    tag: "space",
    tall: true,
  },
  { photo: "foodDish", title: "خورشِ فصل با برنجِ دم‌پخت", tag: "food" },
  { photo: "personWoman2", title: "سرآشپز، پیش از سرویس", tag: "people" },
  { photo: "studioSunlit", title: "نورِ صبح روی میزِ کار", tag: "space" },
  {
    photo: "productVase",
    title: "ظرف‌های سفالیِ دست‌ساز",
    tag: "food",
    tall: true,
  },
  { photo: "personMan2", title: "میزبانِ شب", tag: "people", tall: true },
  { photo: "coverMinimalRoom", title: "گوشهٔ آرامِ طبقهٔ دوم", tag: "space" },
  { photo: "projectCafeBrand", title: "منوی تازهٔ پاییز", tag: "food" },
]
const FILTERS = [
  { value: "all", label: "همه" },
  { value: "space", label: "فضا" },
  { value: "food", label: "غذا" },
  { value: "people", label: "آدم‌ها" },
]

@Component({
  selector: "dig-block-gallery-masonry",
  imports: [
    DigButton,
    DigControlSize,
    DigDialog,
    DigDialogContent,
    DigDialogDescription,
    DigDialogTitle,
    DigDialogTrigger,
    DigIcon,
    DigReveal,
    DigToggleGroup,
    DigToggleGroupItem,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <section
      digControlSize="xl"
      aria-labelledby="masonry-title"
      class="mx-auto flex w-full max-w-6xl flex-col gap-10 px-4 py-24 sm:px-6"
    >
      <div
        class="flex flex-col items-start justify-between gap-6 md:flex-row md:items-end"
      >
        <div class="flex flex-col gap-3">
          <span class="text-sm font-semibold text-brand-secondary">گالری</span>
          <h2 id="masonry-title" class="text-3xl font-black sm:text-4xl">
            یک شب در حیاط
          </h2>
        </div>
        <div digControlSize="lg" mobileSize="default">
          <div
            digToggleGroup
            type="single"
            variant="segmented"
            [value]="filter()"
            aria-label="دستهٔ عکس"
            (valueChange)="onFilter($event)"
          >
            @for (item of FILTERS; track item.value) {
              <button digToggleGroupItem type="button" [value]="item.value">
                {{ item.label }}
              </button>
            }
          </div>
        </div>
      </div>

      <ng-container
        digDialog
        [open]="current() !== null"
        (openChange)="onOpenChange($event)"
      >
        <ul class="columns-1 gap-4 sm:columns-2 lg:columns-3">
          @for (shot of shots(); track shot.photo; let index = $index) {
            <li
              [delay]="(index % 3) * 80"
              digReveal
              class="mb-4 break-inside-avoid"
            >
              <button
                digDialogTrigger
                type="button"
                class="group relative block w-full overflow-hidden rounded-xl outline-none focus-visible:ring-4 focus-visible:ring-ring"
                (click)="open.set(index)"
              >
                <img
                  [src]="stockImages[shot.photo].src"
                  [alt]="shot.title"
                  [class]="
                    'w-full object-cover transition-transform duration-500 group-hover:scale-105 ' +
                    (shot.tall ? 'aspect-[3/4]' : 'aspect-[4/3]')
                  "
                />
                <span
                  aria-hidden="true"
                  class="absolute inset-0 flex items-end bg-[linear-gradient(to_top,var(--dig-graphite-950)_0%,color-mix(in_oklab,var(--dig-graphite-950)_68%,transparent)_32%,color-mix(in_oklab,var(--dig-graphite-950)_22%,transparent)_64%,transparent_100%)] p-4 pt-20 text-start text-sm font-semibold text-[var(--dig-white)] invisible group-hover:visible group-focus-visible:visible"
                >
                  {{ shot.title }}
                </span>
              </button>
            </li>
          }
        </ul>

        <div
          digDialogContent
          class="max-w-4xl gap-4 p-3 sm:p-4"
          (keydown)="onKeyDown($event)"
        >
          @if (current(); as shot) {
            <img
              [src]="stockImages[shot.photo].src"
              [alt]="shot.title"
              class="max-h-[70vh] w-full rounded-lg object-cover"
            />
            <div class="flex items-center justify-between gap-4 px-1">
              <div class="flex flex-col gap-0.5">
                <h2 digDialogTitle class="text-base">{{ shot.title }}</h2>
                <p digDialogDescription>
                  عکسِ {{ toFaDigits((open() ?? 0) + 1) }} از
                  {{ toFaDigits(shots().length) }}
                </p>
              </div>
              <div class="flex gap-2">
                <button
                  digButton
                  type="button"
                  variant="outline"
                  size="icon"
                  aria-label="عکسِ قبلی"
                  (click)="step(-1)"
                >
                  <svg digIcon="chevron-right"></svg>
                </button>
                <button
                  digButton
                  type="button"
                  variant="outline"
                  size="icon"
                  aria-label="عکسِ بعدی"
                  (click)="step(1)"
                >
                  <svg digIcon="chevron-left"></svg>
                </button>
              </div>
            </div>
          }
        </div>
      </ng-container>
    </section>
  `,
})
export class GalleryMasonryBlock {
  readonly stockImages = stockImages
  readonly FILTERS = FILTERS
  readonly toFaDigits = toFaDigits

  readonly filter = signal("all")
  readonly open = signal<number | null>(null)
  readonly shots = computed(() =>
    SHOTS.filter(
      (shot) => this.filter() === "all" || shot.tag === this.filter()
    )
  )
  readonly current = computed(() => {
    const index = this.open()
    return index === null ? null : (this.shots()[index] ?? null)
  })

  step(delta: number) {
    const index = this.open()
    const count = this.shots().length
    if (index !== null && count > 0)
      this.open.set((index + delta + count) % count)
  }

  onFilter(value: string | string[] | undefined) {
    if (typeof value === "string" && value) this.filter.set(value)
  }

  onOpenChange(value: boolean) {
    if (!value) this.open.set(null)
  }

  onKeyDown(event: KeyboardEvent) {
    if (event.key === "ArrowLeft") {
      event.preventDefault()
      this.step(1)
    } else if (event.key === "ArrowRight") {
      event.preventDefault()
      this.step(-1)
    }
  }
}

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

این موارد هنوز برای Android آماده نیستند: reveal

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