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

فوتر با خبرنامه

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

بخشِ فوتر با ردیفِ بزرگِ عضویت در خبرنامه، چهار ستونِ لینک و کپی‌رایت با شبکه‌های اجتماعی، روی سطحِ subtle.

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

این بلاک از ۶ آیتم دیگ استفاده می‌کند: buttoncontrol-sizefootericonspersiantext-field

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

۲. کد صفحه

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

footer-newsletter.tsx
"use client"

import * as React from "react"

import { InstagramLogo, LinkedInLogo, TelegramLogo } from "@/components/icons"
import { Button } from "@/components/ui/button"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { Footer, FooterBottom, FooterColumn, FooterColumns, FooterColumnTitle, FooterLink, FooterLinkList, FooterSocialLink, FooterSocialLinks } from "@/components/ui/footer"
import { TextField } from "@/components/ui/text-field"
import { isValidEmail, toFaDigits } from "@/lib/persian"

const COLUMNS = [
  { title: "محصول", links: ["امکانات", "قیمت‌ها", "تازه‌ها"] },
  { title: "شرکت", links: ["درباره ما", "فرصت‌های شغلی", "تماس"] },
  { title: "منابع", links: ["مجله", "راهنما", "وضعیتِ سرویس"] },
  { title: "حقوقی", links: ["حریمِ خصوصی", "شرایطِ استفاده"] },
]

/**
 * فوتر با خبرنامهٔ بزرگ: ردیفِ بالا دعوت به عضویت با تیتر و فرمِ ایمیل، زیرش چهار ستونِ
 * لینک، و پایین کپی‌رایت با شبکه‌های اجتماعی. روی سطحِ subtle، جدا از محتوای صفحه.
 */
export default function FooterNewsletterBlock() {
  const [done, setDone] = React.useState(false)

  React.useEffect(() => {
    if (!done) return
    const timer = window.setTimeout(() => setDone(false), 4000)
    return () => window.clearTimeout(timer)
  }, [done])

  return (
    <ControlSizeProvider size="xl" asChild>
      <Footer className="bg-subtle">
        <div className="mx-auto flex w-full max-w-6xl flex-col gap-12 px-4 py-16 sm:px-6">
          <div className="grid grid-cols-1 items-end gap-8 border-b border-border pb-12 lg:grid-cols-2">
            <div className="flex flex-col gap-3">
              <h2 className="text-3xl font-black text-balance">هر پنجشنبه، یک نامهٔ کوتاه</h2>
              <p className="leading-8 text-muted-foreground">تازه‌های محصول و یک نکتهٔ مالی؛ بدونِ تبلیغ.</p>
            </div>
            {done ? (
              <p role="status" className="rounded-lg bg-success-subtle p-4 font-medium text-success-subtle-foreground">
                عضو شدی؛ پنجشنبه می‌بینیمت.
              </p>
            ) : (
              <form
                className="flex flex-col gap-3 sm:flex-row sm:items-start"
                onSubmit={(event) => {
                  event.preventDefault()
                  setDone(true)
                }}
              >
                <TextField aria-label="ایمیل" name="email" type="email" dir="ltr" placeholder="name@example.com" required validate={(value) => (isValidEmail(value) ? undefined : "ایمیل معتبر نیست.")} className="flex-1" />
                <Button type="submit">عضویت</Button>
              </form>
            )}
          </div>
          <FooterColumns className="grid-cols-2 sm:grid-cols-4">
            {COLUMNS.map((column) => (
              <FooterColumn key={column.title}>
                <FooterColumnTitle>{column.title}</FooterColumnTitle>
                <FooterLinkList>
                  {column.links.map((link) => (
                    <FooterLink key={link} href="#">
                      {link}
                    </FooterLink>
                  ))}
                </FooterLinkList>
              </FooterColumn>
            ))}
          </FooterColumns>
        </div>
        <FooterBottom>
          <span>© {toFaDigits(1405)} آوند</span>
          <FooterSocialLinks>
            <FooterSocialLink href="#" aria-label="اینستاگرام">
              <InstagramLogo />
            </FooterSocialLink>
            <FooterSocialLink href="#" aria-label="تلگرام">
              <TelegramLogo />
            </FooterSocialLink>
            <FooterSocialLink href="#" aria-label="لینکدین">
              <LinkedInLogo />
            </FooterSocialLink>
          </FooterSocialLinks>
        </FooterBottom>
      </Footer>
    </ControlSizeProvider>
  )
}
footer-newsletter.vue
<script setup lang="ts">
import { onBeforeUnmount, ref, watch } from "vue"

import Button from "@/components/ui/Button.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import Footer from "@/components/ui/Footer.vue"
import FooterBottom from "@/components/ui/FooterBottom.vue"
import FooterColumn from "@/components/ui/FooterColumn.vue"
import FooterColumnTitle from "@/components/ui/FooterColumnTitle.vue"
import FooterColumns from "@/components/ui/FooterColumns.vue"
import FooterLink from "@/components/ui/FooterLink.vue"
import FooterLinkList from "@/components/ui/FooterLinkList.vue"
import FooterSocialLink from "@/components/ui/FooterSocialLink.vue"
import FooterSocialLinks from "@/components/ui/FooterSocialLinks.vue"
import TextField from "@/components/ui/TextField.vue"
import { DigIcon } from "@/lib/icons"
import { isValidEmail, toFaDigits } from "@/lib/persian"

const COLUMNS = [
  { title: "محصول", links: ["امکانات", "قیمت‌ها", "تازه‌ها"] },
  { title: "شرکت", links: ["درباره ما", "فرصت‌های شغلی", "تماس"] },
  { title: "منابع", links: ["مجله", "راهنما", "وضعیتِ سرویس"] },
  { title: "حقوقی", links: ["حریمِ خصوصی", "شرایطِ استفاده"] },
]

/**
 * فوتر با خبرنامهٔ بزرگ: ردیفِ بالا دعوت به عضویت با تیتر و فرمِ ایمیل، زیرش چهار ستونِ
 * لینک، و پایین کپی‌رایت با شبکه‌های اجتماعی. روی سطحِ subtle، جدا از محتوای صفحه.
 * همان صفحهٔ `footer-newsletter` نسخهٔ React.
 */
const done = ref(false)

let timer: ReturnType<typeof setTimeout> | undefined
watch(done, (value) => {
  if (timer) clearTimeout(timer)
  timer = undefined
  if (value) timer = setTimeout(() => (done.value = false), 4000)
})
onBeforeUnmount(() => timer && clearTimeout(timer))

const validateEmail = (value: string) => (isValidEmail(value) ? undefined : "ایمیل معتبر نیست.")
</script>

<template>
  <ControlSize size="xl" as-child>
    <Footer class="bg-subtle">
      <div class="mx-auto flex w-full max-w-6xl flex-col gap-12 px-4 py-16 sm:px-6">
        <div class="grid grid-cols-1 items-end gap-8 border-b border-border pb-12 lg:grid-cols-2">
          <div class="flex flex-col gap-3">
            <h2 class="text-3xl font-black text-balance">هر پنجشنبه، یک نامهٔ کوتاه</h2>
            <p class="leading-8 text-muted-foreground">تازه‌های محصول و یک نکتهٔ مالی؛ بدونِ تبلیغ.</p>
          </div>
          <p v-if="done" role="status" class="rounded-lg bg-success-subtle p-4 font-medium text-success-subtle-foreground">عضو شدی؛ پنجشنبه می‌بینیمت.</p>
          <form v-else class="flex flex-col gap-3 sm:flex-row sm:items-start" @submit.prevent="done = true">
            <TextField aria-label="ایمیل" name="email" type="email" dir="ltr" placeholder="name@example.com" required :validate="validateEmail" class="flex-1" />
            <Button type="submit">عضویت</Button>
          </form>
        </div>
        <FooterColumns class="grid-cols-2 sm:grid-cols-4">
          <FooterColumn v-for="column in COLUMNS" :key="column.title">
            <FooterColumnTitle>{{ column.title }}</FooterColumnTitle>
            <FooterLinkList>
              <FooterLink v-for="link in column.links" :key="link" href="#">{{ link }}</FooterLink>
            </FooterLinkList>
          </FooterColumn>
        </FooterColumns>
      </div>
      <FooterBottom>
        <span>© {{ toFaDigits(1405) }} آوند</span>
        <FooterSocialLinks>
          <FooterSocialLink href="#" aria-label="اینستاگرام"><DigIcon name="instagram-logo" /></FooterSocialLink>
          <FooterSocialLink href="#" aria-label="تلگرام"><DigIcon name="telegram-logo" /></FooterSocialLink>
          <FooterSocialLink href="#" aria-label="لینکدین"><DigIcon name="linked-in-logo" /></FooterSocialLink>
        </FooterSocialLinks>
      </FooterBottom>
    </Footer>
  </ControlSize>
</template>

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

این موارد هنوز برای Svelte آماده نیستند: control-sizefooterpersiantext-fieldآیکون instagram-logoآیکون linked-in-logoآیکون telegram-logo

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

footer-newsletter.ts
import {
  ChangeDetectionStrategy,
  Component,
  DestroyRef,
  inject,
  signal,
} from "@angular/core"

import { DigButton } from "@/components/ui/button"
import { DigControlSize } from "@/components/ui/control-size"
import {
  DigFooter,
  DigFooterBottom,
  DigFooterColumn,
  DigFooterColumnTitle,
  DigFooterColumns,
  DigFooterLink,
  DigFooterLinkList,
  DigFooterSocialLink,
  DigFooterSocialLinks,
} from "@/components/ui/footer"
import { DigIcon } from "@/lib/icons"
import { DigInput, DigInputField } from "@/components/ui/input"
import { DigTextField } from "@/components/ui/text-field"
import { isValidEmail, toFaDigits } from "@/lib/persian"

const COLUMNS = [
  { title: "محصول", links: ["امکانات", "قیمت‌ها", "تازه‌ها"] },
  { title: "شرکت", links: ["درباره ما", "فرصت‌های شغلی", "تماس"] },
  { title: "منابع", links: ["مجله", "راهنما", "وضعیتِ سرویس"] },
  { title: "حقوقی", links: ["حریمِ خصوصی", "شرایطِ استفاده"] },
]

@Component({
  selector: "dig-block-footer-newsletter",
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [
    DigButton,
    DigControlSize,
    DigFooter,
    DigFooterBottom,
    DigFooterColumn,
    DigFooterColumnTitle,
    DigFooterColumns,
    DigFooterLink,
    DigFooterLinkList,
    DigFooterSocialLink,
    DigFooterSocialLinks,
    DigIcon,
    DigInput,
    DigInputField,
    DigTextField,
  ],
  template: `
    <footer digFooter digControlSize="xl" class="bg-subtle">
      <div
        class="mx-auto flex w-full max-w-6xl flex-col gap-12 px-4 py-16 sm:px-6"
      >
        <div
          class="grid grid-cols-1 items-end gap-8 border-b border-border pb-12 lg:grid-cols-2"
        >
          <div class="flex flex-col gap-3">
            <h2 class="text-3xl font-black text-balance">
              هر پنجشنبه، یک نامهٔ کوتاه
            </h2>
            <p class="leading-8 text-muted-foreground">
              تازه‌های محصول و یک نکتهٔ مالی؛ بدونِ تبلیغ.
            </p>
          </div>
          @if (done()) {
            <p
              role="status"
              class="rounded-lg bg-success-subtle p-4 font-medium text-success-subtle-foreground"
            >
              عضو شدی؛ پنجشنبه می‌بینیمت.
            </p>
          } @else {
            <form
              class="flex flex-col gap-3 sm:flex-row sm:items-start"
              (submit)="$event.preventDefault(); onSubmit()"
            >
              <div
                digTextField
                required
                [validate]="validateEmail"
                class="flex-1"
              >
                <dig-input
                  ><input
                    digInput
                    aria-label="ایمیل"
                    name="email"
                    type="email"
                    dir="ltr"
                    placeholder="name@example.com"
                    [value]="email()"
                    (valueChange)="email.set($event)"
                /></dig-input>
              </div>
              <button digButton type="submit">عضویت</button>
            </form>
          }
        </div>
        <div digFooterColumns class="grid-cols-2 sm:grid-cols-4">
          @for (column of COLUMNS; track column.title) {
            <div digFooterColumn>
              <h3 digFooterColumnTitle>{{ column.title }}</h3>
              <ul digFooterLinkList>
                @for (link of column.links; track link) {
                  <li digFooterLink href="#">{{ link }}</li>
                }
              </ul>
            </div>
          }
        </div>
      </div>
      <div digFooterBottom>
        <span>© {{ toFaDigits(1405) }} آوند</span>
        <div digFooterSocialLinks>
          <a digFooterSocialLink href="#" aria-label="اینستاگرام"
            ><svg digIcon="instagram-logo"></svg
          ></a>
          <a digFooterSocialLink href="#" aria-label="تلگرام"
            ><svg digIcon="telegram-logo"></svg
          ></a>
          <a digFooterSocialLink href="#" aria-label="لینکدین"
            ><svg digIcon="linked-in-logo"></svg
          ></a>
        </div>
      </div>
    </footer>
  `,
})
export class FooterNewsletterBlock {
  readonly COLUMNS = COLUMNS
  readonly toFaDigits = toFaDigits

  readonly email = signal("")
  readonly done = signal(false)

  private resetTimer?: ReturnType<typeof setTimeout>

  constructor() {
    inject(DestroyRef).onDestroy(() => clearTimeout(this.resetTimer))
  }

  validateEmail(value: string) {
    return isValidEmail(value)
      ? undefined
      : "ایمیل معتبر نیست؛ مثل name@example.com"
  }

  onSubmit() {
    if (this.validateEmail(this.email())) return
    this.done.set(true)
    clearTimeout(this.resetTimer)
    this.resetTimer = setTimeout(() => this.done.set(false), 4000)
  }
}

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

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

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