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

ورود با چیدمانِ دوستونه و عکسِ واقعیِ تمام‌قد با جملهٔ برند روی آن؛ فرمِ ایمیل یا موبایل و رمز، خطای ورود، مرا به خاطر بسپار و فراموشی رمز.

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

این بلاک از ۱۱ آیتم دیگ استفاده می‌کند: alertbuttoncheckboxcontrol-sizeiconslabellinkpassword-fieldpersiansocial-auth-buttonstext-field

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

۲. کد صفحه

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

login-image.tsx
"use client"

import * as React from "react"

import { SparklesIcon } from "@/components/icons"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { Label } from "@/components/ui/label"
import { Link } from "@/components/ui/link"
import { PasswordField } from "@/components/ui/password-field"
import { SocialAuthButtons } from "@/components/ui/social-auth-buttons"
import { TextField } from "@/components/ui/text-field"
import { isValidEmail, isValidMobile } from "@/lib/persian"
import { stockImages } from "@/lib/stock-images"

/**
 * ورود با عکسِ تمام‌قد: فرم در ستونِ شروع، عکسِ واقعی در ستونِ پایان با یک جملهٔ
 * برند روی پایینِ عکس. در صفحهٔ باریک عکس به نواری کوتاه بالای فرم تبدیل می‌شود.
 */
export default function LoginImageBlock() {
  const [error, setError] = React.useState(false)
  const [signing, setSigning] = React.useState(false)

  async function onSubmit(event: React.FormEvent<HTMLFormElement>) {
    event.preventDefault()
    setSigning(true)
    setError(false)
    // جای درخواستِ واقعی ورود؛ این نمونه همیشه «اطلاعات نادرست» برمی‌گرداند.
    await new Promise((resolve) => setTimeout(resolve, 800))
    setSigning(false)
    setError(true)
  }

  return (
    <ControlSizeProvider size="xl" asChild>
      <main className="grid grid-cols-1 min-h-svh gap-4 bg-background p-4 lg:grid-cols-2">
        <div className="flex flex-col px-4 py-10 sm:px-10">
          <span className="flex items-center gap-2 font-black">
            <span aria-hidden className="flex size-9 items-center justify-center rounded-lg bg-foreground text-background [&>svg]:size-4">
              <SparklesIcon />
            </span>
            حساب‌یار
          </span>
          <div className="mx-auto flex w-full max-w-sm flex-1 flex-col justify-center gap-8 py-10">
            <header className="flex flex-col gap-2">
              <h1 className="text-3xl font-bold">خوش برگشتی</h1>
              <p className="text-muted-foreground">برای ادامه وارد حسابت شو.</p>
            </header>
            <form onSubmit={onSubmit} className="flex flex-col gap-4">
              {error && (
                <Alert color="destructive">
                  <AlertTitle>ورود ناموفق بود</AlertTitle>
                  <AlertDescription>ایمیل، شماره یا رمز عبور درست نیست.</AlertDescription>
                </Alert>
              )}
              <TextField
                label="ایمیل یا شمارهٔ موبایل"
                name="identifier"
                dir="ltr"
                autoComplete="username"
                required
                validate={(value) => (isValidEmail(value) || isValidMobile(value) ? undefined : "یک ایمیل یا شماره موبایلِ معتبر وارد کنید.")}
                disabled={signing}
              />
              <PasswordField label="رمز عبور" name="password" autoComplete="current-password" required disabled={signing} />
              <div className="flex items-center justify-between gap-2">
                <div className="flex items-center gap-2">
                  <Checkbox id="login-image-remember" name="remember" />
                  <Label htmlFor="login-image-remember">مرا به خاطر بسپار</Label>
                </div>
                <Link href="/forgot-password" size="sm">
                  فراموشی رمز
                </Link>
              </div>
              <Button type="submit" fullWidth loading={signing} className="mt-4">
                ورود
              </Button>
            </form>
            <SocialAuthButtons />
            <p className="text-sm text-muted-foreground">
              حساب ندارید؟ <Link href="/signup">ثبت‌نام کنید</Link>
            </p>
          </div>
        </div>

        {/* عکسِ واقعی با جملهٔ برند روی سایه‌روشنِ پایین. */}
        <aside className="relative order-first min-h-56 overflow-hidden rounded-xl bg-muted lg:order-none">
          {/* eslint-disable-next-line @next/next/no-img-element -- عکس از کتابخانهٔ تصویرِ دیگ */}
          <img src={stockImages.authWorkspace.src} alt="" className="absolute inset-0 size-full object-cover" />
          <div className="absolute inset-x-0 bottom-0 flex flex-col gap-2 bg-linear-to-t from-[var(--dig-graphite-950)] to-transparent p-8 pt-24 text-[var(--dig-white)] sm:p-12 sm:pt-32">
            <p className="max-w-md text-2xl leading-relaxed font-bold sm:text-3xl sm:leading-relaxed">حساب‌وکتاب، آرام و بی‌دردسر.</p>
            <p className="text-sm text-[var(--dig-neutral-300)]">بیش از ۱۲ هزار کسب‌وکار هر روز با حساب‌یار کار می‌کنند.</p>
          </div>
        </aside>
      </main>
    </ControlSizeProvider>
  )
}
login-image.vue
<script setup lang="ts">
import { ref } from "vue"

import Alert from "@/components/ui/Alert.vue"
import AlertDescription from "@/components/ui/AlertDescription.vue"
import AlertTitle from "@/components/ui/AlertTitle.vue"
import Button from "@/components/ui/Button.vue"
import Checkbox from "@/components/ui/Checkbox.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import Label from "@/components/ui/Label.vue"
import Link from "@/components/ui/Link.vue"
import PasswordField from "@/components/ui/PasswordField.vue"
import SocialAuthButtons from "@/components/ui/SocialAuthButtons.vue"
import TextField from "@/components/ui/TextField.vue"
import { DigIcon } from "@/lib/icons"
import { isValidEmail, isValidMobile } from "@/lib/persian"

/**
 * ورود با عکسِ تمام‌قد: فرم در ستونِ شروع، عکسِ واقعی در ستونِ پایان با یک جملهٔ
 * برند روی پایینِ عکس. در صفحهٔ باریک عکس به نواری کوتاه بالای فرم تبدیل می‌شود.
 */
const authWorkspaceSrc = "https://docs.digdesign.ir/images/auth-workspace.webp"
const error = ref(false)
const signing = ref(false)

async function onSubmit() {
  signing.value = true
  error.value = false
  // جای درخواستِ واقعی ورود؛ این نمونه همیشه «اطلاعات نادرست» برمی‌گرداند.
  await new Promise((resolve) => setTimeout(resolve, 800))
  signing.value = false
  error.value = true
}

function validateIdentifier(value: string) {
  return isValidEmail(value) || isValidMobile(value) ? undefined : "یک ایمیل یا شماره موبایلِ معتبر وارد کنید."
}
</script>

<template>
  <ControlSize size="xl" as-child>
    <main class="grid grid-cols-1 min-h-svh gap-4 bg-background p-4 lg:grid-cols-2">
      <div class="flex flex-col px-4 py-10 sm:px-10">
        <span class="flex items-center gap-2 font-black">
          <span aria-hidden="true" class="flex size-9 items-center justify-center rounded-lg bg-foreground text-background [&>svg]:size-4">
            <DigIcon name="sparkles" />
          </span>
          حساب‌یار
        </span>
        <div class="mx-auto flex w-full max-w-sm flex-1 flex-col justify-center gap-8 py-10">
          <header class="flex flex-col gap-2">
            <h1 class="text-3xl font-bold">خوش برگشتی</h1>
            <p class="text-muted-foreground">برای ادامه وارد حسابت شو.</p>
          </header>
          <form class="flex flex-col gap-4" @submit.prevent="onSubmit">
            <Alert v-if="error" color="destructive">
              <AlertTitle>ورود ناموفق بود</AlertTitle>
              <AlertDescription>ایمیل، شماره یا رمز عبور درست نیست.</AlertDescription>
            </Alert>
            <TextField
              label="ایمیل یا شمارهٔ موبایل"
              name="identifier"
              dir="ltr"
              autocomplete="username"
              required
              :validate="validateIdentifier"
              :disabled="signing"
            />
            <PasswordField label="رمز عبور" name="password" autocomplete="current-password" required :disabled="signing" />
            <div class="flex items-center justify-between gap-2">
              <div class="flex items-center gap-2">
                <Checkbox id="login-image-remember" name="remember" />
                <Label for="login-image-remember">مرا به خاطر بسپار</Label>
              </div>
              <Link href="/forgot-password" size="sm">فراموشی رمز</Link>
            </div>
            <Button type="submit" full-width :loading="signing" class="mt-4">ورود</Button>
          </form>
          <SocialAuthButtons />
          <p class="text-sm text-muted-foreground">
            حساب ندارید؟ <Link href="/signup">ثبت‌نام کنید</Link>
          </p>
        </div>
      </div>

      <!-- عکسِ واقعی با جملهٔ برند روی سایه‌روشنِ پایین. -->
      <aside class="relative order-first min-h-56 overflow-hidden rounded-xl bg-muted lg:order-none">
        <img :src="authWorkspaceSrc" alt="" class="absolute inset-0 size-full object-cover" />
        <div class="absolute inset-x-0 bottom-0 flex flex-col gap-2 bg-linear-to-t from-[var(--dig-graphite-950)] to-transparent p-8 pt-24 text-[var(--dig-white)] sm:p-12 sm:pt-32">
          <p class="max-w-md text-2xl leading-relaxed font-bold sm:text-3xl sm:leading-relaxed">حساب‌وکتاب، آرام و بی‌دردسر.</p>
          <p class="text-sm text-[var(--dig-neutral-300)]">بیش از ۱۲ هزار کسب‌وکار هر روز با حساب‌یار کار می‌کنند.</p>
        </div>
      </aside>
    </main>
  </ControlSize>
</template>

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

این موارد هنوز برای Svelte آماده نیستند: alertcheckboxcontrol-sizelabellinkpassword-fieldpersiansocial-auth-buttonstext-fieldآیکون sparkles

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

login-image.ts
import {
  ChangeDetectionStrategy,
  ChangeDetectorRef,
  Component,
  inject,
} from "@angular/core"

import {
  DigAlert,
  DigAlertDescription,
  DigAlertTitle,
} from "@/components/ui/alert"
import { DigButton } from "@/components/ui/button"
import { DigCheckbox } from "@/components/ui/checkbox"
import { DigControlSize } from "@/components/ui/control-size"
import { DigIcon } from "@/lib/icons"
import { DigInput, DigInputField } from "@/components/ui/input"
import { DigLabel } from "@/components/ui/label"
import { DigLink } from "@/components/ui/link"
import { DigPasswordField } from "@/components/ui/password-field"
import { DigSocialAuthButtons } from "@/components/ui/social-auth-buttons"
import { DigTextField } from "@/components/ui/text-field"
import { isValidEmail, isValidMobile } from "@/lib/persian"

let nextFieldId = 0

@Component({
  selector: "dig-block-login-image",
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [
    DigAlert,
    DigAlertDescription,
    DigAlertTitle,
    DigButton,
    DigCheckbox,
    DigControlSize,
    DigIcon,
    DigInput,
    DigInputField,
    DigLabel,
    DigLink,
    DigPasswordField,
    DigSocialAuthButtons,
    DigTextField,
  ],
  template: `
    <main
      digControlSize="xl"
      class="grid grid-cols-1 min-h-svh gap-4 bg-background p-4 lg:grid-cols-2"
    >
      <div class="flex flex-col px-4 py-10 sm:px-10">
        <span class="flex items-center gap-2 font-black">
          <span
            aria-hidden="true"
            class="flex size-9 items-center justify-center rounded-lg bg-foreground text-background [&>svg]:size-4"
          >
            <svg digIcon="sparkles"></svg>
          </span>
          حساب‌یار
        </span>
        <div
          class="mx-auto flex w-full max-w-sm flex-1 flex-col justify-center gap-8 py-10"
        >
          <header class="flex flex-col gap-2">
            <h1 class="text-3xl font-bold">خوش برگشتی</h1>
            <p class="text-muted-foreground">برای ادامه وارد حسابت شو.</p>
          </header>
          <form
            class="flex flex-col gap-4"
            (submit)="$event.preventDefault(); onSubmit()"
          >
            @if (error) {
              <div digAlert color="destructive">
                <h2 digAlertTitle>ورود ناموفق بود</h2>
                <div digAlertDescription>
                  ایمیل، شماره یا رمز عبور درست نیست.
                </div>
              </div>
            }
            <div
              digTextField
              label="ایمیل یا شمارهٔ موبایل"
              required
              [validate]="validateIdentifier"
              [disabled]="signing"
            >
              <dig-input>
                <input
                  digInput
                  name="identifier"
                  [value]="identifier"
                  (valueChange)="identifier = $event"
                  dir="ltr"
                  autocomplete="username"
                />
              </dig-input>
            </div>
            <div
              digPasswordField
              label="رمز عبور"
              name="password"
              autocomplete="current-password"
              required
              [disabled]="signing"
            ></div>
            <div class="flex items-center justify-between gap-2">
              <div class="flex items-center gap-2">
                <button digCheckbox type="button" [attr.id]="fieldId"></button>
                <label digLabel [attr.for]="fieldId">مرا به خاطر بسپار</label>
              </div>
              <a digLink href="/forgot-password" size="sm">فراموشی رمز</a>
            </div>
            <button
              digButton
              type="submit"
              fullWidth
              [loading]="signing"
              class="mt-4"
            >
              ورود
            </button>
          </form>
          <dig-social-auth-buttons></dig-social-auth-buttons>
          <p class="text-sm text-muted-foreground">
            حساب ندارید؟ <a digLink href="/signup">ثبت‌نام کنید</a>
          </p>
        </div>
      </div>

      <!-- عکسِ واقعی با جملهٔ برند روی سایه‌روشنِ پایین. -->
      <aside
        class="relative order-first min-h-56 overflow-hidden rounded-xl bg-muted lg:order-none"
      >
        <img
          [src]="authWorkspaceSrc"
          alt=""
          class="absolute inset-0 size-full object-cover"
        />
        <div
          class="absolute inset-x-0 bottom-0 flex flex-col gap-2 bg-linear-to-t from-[var(--dig-graphite-950)] to-transparent p-8 pt-24 text-[var(--dig-white)] sm:p-12 sm:pt-32"
        >
          <p
            class="max-w-md text-2xl leading-relaxed font-bold sm:text-3xl sm:leading-relaxed"
          >
            حساب‌وکتاب، آرام و بی‌دردسر.
          </p>
          <p class="text-sm text-[var(--dig-neutral-300)]">
            بیش از ۱۲ هزار کسب‌وکار هر روز با حساب‌یار کار می‌کنند.
          </p>
        </div>
      </aside>
    </main>
  `,
})
export class LoginImageBlock {
  private readonly changeDetector = inject(ChangeDetectorRef)
  readonly fieldId = `login-image-${++nextFieldId}`

  /**
   * ورود با عکسِ تمام‌قد: فرم در ستونِ شروع، عکسِ واقعی در ستونِ پایان با یک جملهٔ
   * برند روی پایینِ عکس. در صفحهٔ باریک عکس به نواری کوتاه بالای فرم تبدیل می‌شود.
   */
  readonly authWorkspaceSrc =
    "https://docs.digdesign.ir/images/auth-workspace.webp"
  error = false
  signing = false
  identifier = ""

  async onSubmit() {
    if (this.signing || this.validateIdentifier(this.identifier)) return
    this.signing = true
    this.error = false
    // جای درخواستِ واقعی ورود؛ این نمونه همیشه «اطلاعات نادرست» برمی‌گرداند.
    await new Promise((resolve) => setTimeout(resolve, 800))
    this.signing = false
    this.error = true
    this.changeDetector.markForCheck()
  }

  validateIdentifier(value: string) {
    return isValidEmail(value) || isValidMobile(value)
      ? undefined
      : "یک ایمیل یا شماره موبایلِ معتبر وارد کنید."
  }
}

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

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

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