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

پنلِ حسابِ مشتری: طلا یا نقره، قیمتِ لحظه‌ای، خرید و فروش با مبلغ یا مقدار، کارمزد و جمع، پیشنهادِ وام با وثیقهٔ طلا، کارتِ دارایی با پنهان‌کردنِ موجودی و نمودارِ ۲۴ ساعت.

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

این بلاک از ۱۱ آیتم دیگ استفاده می‌کند: buttonchart-presetscontrol-sizeiconsmasked-valuepersianradio-cardradio-grouptext-fieldtoasttoggle-group

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

۲. کد صفحه

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

account-gold.tsx
"use client"

import * as React from "react"

import { ChatIcon, ChevronLeftIcon, ClockIcon, DashboardIcon, EditIcon, EyeIcon, EyeOffIcon, HeartIcon, InfoIcon, LocationIcon, LogoutIcon, ShopIcon, TrendingUpIcon, UserIcon, WalletIcon } from "@/components/icons"
import { Button } from "@/components/ui/button"
import { MaskedValue } from "@/components/ui/masked-value"
import { AreaChart } from "@/components/ui/chart-presets"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { RadioCard } from "@/components/ui/radio-card"
import { RadioGroup } from "@/components/ui/radio-group"
import { TextField } from "@/components/ui/text-field"
import { toast } from "@/components/ui/toast"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
import { formatCurrency, formatNumber, toFaDigits } from "@/lib/persian"

const NAV = [
  { id: "overview", label: "خلاصهٔ فعالیت‌ها", icon: <DashboardIcon /> },
  { id: "orders", label: "سفارش‌ها", icon: <ShopIcon /> },
  { id: "gold", label: "طلای دیجیتال", icon: <TrendingUpIcon /> },
  { id: "lists", label: "لیست‌های من", icon: <HeartIcon /> },
  { id: "reviews", label: "دیدگاه‌ها و پرسش‌ها", icon: <ChatIcon /> },
  { id: "addresses", label: "نشانی‌ها", icon: <LocationIcon /> },
  { id: "account", label: "اطلاعاتِ حساب", icon: <UserIcon /> },
]

/** ستونِ کنارِ پنلِ حساب: نام و موبایل، کیف پول با افزایشِ موجودی، و منوی بخش‌ها. */
function AccountNav({ active }: { active: string }) {
  return (
    <aside className="flex flex-col gap-2 rounded-xl border border-border bg-card p-4 lg:sticky lg:top-6">
      <div className="flex items-start justify-between gap-2 px-2 pt-1 pb-4">
        <span className="flex flex-col gap-0.5">
          <span className="font-bold">آرمیتا رستگار</span>
          <bdi dir="ltr" className="text-sm text-muted-foreground tabular-nums">
            {toFaDigits("0912 345 6789")}
          </bdi>
        </span>
        <Button variant="ghost" size="icon" aria-label="ویرایشِ اطلاعات" className="-me-2 -mt-2">
          <EditIcon />
        </Button>
      </div>
      <div className="flex items-center justify-between gap-2 rounded-lg bg-subtle p-3">
        <span className="flex items-center gap-2 text-sm [&>svg]:size-4 [&>svg]:text-muted-foreground">
          <WalletIcon aria-hidden />
          کیف پول
        </span>
        <span className="font-bold tabular-nums">{formatCurrency(150_129)}</span>
      </div>
      <a href="#" className="flex items-center gap-1 self-end px-2 pb-2 text-sm font-medium text-brand-secondary hover:underline">
        افزایشِ موجودی
        <ChevronLeftIcon aria-hidden className="size-4" />
      </a>
      <nav aria-label="حسابِ کاربری" className="flex flex-col border-t border-border pt-2">
        {NAV.map((item) => (
          <a
            key={item.id}
            href="#"
            aria-current={item.id === active ? "page" : undefined}
            className={`flex min-h-12 items-center gap-3 rounded-lg px-3 text-sm [&>svg]:size-5 ${item.id === active ? "bg-primary-subtle font-bold" : "text-muted-foreground hover:bg-subtle hover:text-foreground"}`}
          >
            {item.icon}
            {item.label}
          </a>
        ))}
        <a href="#" className="flex min-h-12 items-center gap-3 rounded-lg px-3 text-sm text-destructive hover:bg-destructive-subtle [&>svg]:size-5">
          <LogoutIcon aria-hidden />
          خروج از حساب
        </a>
      </nav>
    </aside>
  )
}

const PRICE = { gold: 262_430, silver: 5_108 } // ریال برای هر میلی‌گرم
const FEE = 0.005
const CHART = [
  { label: "۱۲:۰۰", value: 255_088 },
  { label: "۱۵:۰۰", value: 256_120 },
  { label: "۱۸:۰۰", value: 257_064 },
  { label: "۲۱:۰۰", value: 258_900 },
  { label: "۰۰:۰۰", value: 259_041 },
  { label: "۰۳:۰۰", value: 259_800 },
  { label: "۰۶:۰۰", value: 261_018 },
  { label: "۰۹:۰۰", value: 262_430 },
]

/**
 * خرید و فروشِ طلای دیجیتال در پنلِ حساب: انتخابِ طلا/نقره، قیمتِ لحظه‌ایِ هر میلی‌گرم با نقطهٔ زنده،
 * خرید/فروش با سگمنت، مقدار به میلی‌گرم یا مبلغ به ریال (هر کدام را بنویسی دیگری حساب می‌شود)، کارمزد
 * و جمع، پیشنهادِ «وام با وثیقهٔ طلا» به‌جای فروش، و ستونِ دارایی با پنهان‌کردنِ موجودی و نمودارِ ۲۴ ساعت.
 */
export default function AccountGoldBlock() {
  const [metal, setMetal] = React.useState<"gold" | "silver">("gold")
  const [side, setSide] = React.useState("buy")
  const [rial, setRial] = React.useState("")
  const [mg, setMg] = React.useState("")
  const [hidden, setHidden] = React.useState(false)
  const [loanDismissed, setLoanDismissed] = React.useState(false)
  const price = PRICE[metal]
  const amount = Number(rial) || 0
  const fee = Math.round(amount * FEE)
  const name = metal === "gold" ? "طلا" : "نقره"

  return (
    <ControlSizeProvider size="xl" asChild>
      <main className="mx-auto grid w-full max-w-6xl grid-cols-1 items-start gap-6 p-4 sm:p-6 lg:grid-cols-[17rem_minmax(0,1fr)]">
        <div className="hidden lg:block">
          <AccountNav active="gold" />
        </div>

        <div className="grid min-w-0 grid-cols-1 items-start gap-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
          <section aria-labelledby="trade-title" className="flex flex-col gap-5 rounded-xl border border-border bg-card p-5">
            <h1 id="trade-title" className="text-xl font-black">
              خرید و فروشِ طلای دیجیتال
            </h1>
            {/* انتخابِ فلز: دو کارتِ بزرگ با رنگِ هر فلز. */}
            <RadioGroup value={metal} onValueChange={(value) => setMetal(value as "gold" | "silver")} aria-label="فلز" className="grid grid-cols-2 gap-3">
              {(["gold", "silver"] as const).map((item) => (
                <RadioCard
                  key={item}
                  value={item}
                  media={<span aria-hidden className={`size-6 rotate-12 rounded-md ${item === "gold" ? "bg-[linear-gradient(135deg,var(--dig-amber-300),var(--dig-amber-600))]" : "bg-[linear-gradient(135deg,var(--dig-slate-200),var(--dig-slate-500))]"}`} />}
                  title={item === "gold" ? "طلا" : "نقره"}
                />
              ))}
            </RadioGroup>

            <div className="flex flex-col gap-4 rounded-xl border border-border p-4">
              <div className="flex items-center justify-between gap-3">
                <span className="flex min-w-0 items-center gap-2 text-sm">
                  <span aria-hidden className="relative flex size-2.5">
                    <span className="absolute inset-0 animate-ping rounded-full bg-destructive motion-reduce:hidden" />
                    <span className="relative size-2.5 rounded-full bg-destructive" />
                  </span>
                  <span className="truncate">قیمتِ هر میلی‌گرم {name}</span>
                </span>
                <span className="shrink-0 font-bold whitespace-nowrap tabular-nums">{formatNumber(price)} ریال</span>
              </div>
              <ToggleGroup type="single" variant="segmented" size="lg" value={side} onValueChange={(value) => value && setSide(value as string)} aria-label="خرید یا فروش" className="w-full">
                <ToggleGroupItem value="buy" className="flex-1">
                  خرید
                </ToggleGroupItem>
                <ToggleGroupItem value="sell" className="flex-1">
                  فروش
                </ToggleGroupItem>
              </ToggleGroup>
              <TextField
                label={`مقدارِ ${name}`}
                inputMode="numeric"
                dir="rtl"
                groupDigits
                endContent="میلی‌گرم"
                value={mg}
                onValueChange={(value) => {
                  setMg(value)
                  setRial(value ? String(Number(value) * price) : "")
                }}
              />
              <TextField
                label={side === "buy" ? "مبلغِ پرداختی" : "مبلغِ دریافتی"}
                inputMode="numeric"
                dir="rtl"
                groupDigits
                endContent="ریال"
                value={rial}
                onValueChange={(value) => {
                  setRial(value)
                  setMg(value ? String(Math.floor(Number(value) / price)) : "")
                }}
                description="مقدار یا مبلغ را بنویس؛ دیگری خودش حساب می‌شود."
              />
            </div>

            {side === "sell" && !loanDismissed && (
              <div className="flex flex-col gap-3 rounded-xl bg-subtle p-4">
                <span className="flex items-center gap-2 font-bold [&>svg]:size-5 [&>svg]:text-brand-secondary">
                  <InfoIcon aria-hidden />
                  پول نقد بدونِ فروشِ {name}
                </span>
                <p className="text-sm leading-6 text-muted-foreground">با وثیقه‌کردنِ {name}ِ دیجیتالت وام بگیر و دارایی‌ات را نگه دار؛ بازپرداخت در ۴ قسط.</p>
                <div className="flex gap-2">
                  <ControlSizeProvider size="lg" asChild>
                    <Button variant="outline" className="bg-card">
                      درخواستِ وام
                    </Button>
                  </ControlSizeProvider>
                  <ControlSizeProvider size="lg" asChild>
                    <Button variant="ghost" onClick={() => setLoanDismissed(true)}>
                      بعداً
                    </Button>
                  </ControlSizeProvider>
                </div>
              </div>
            )}

            <dl className="flex flex-col gap-2 text-sm">
              <div className="flex justify-between">
                <dt className="text-muted-foreground">کارمزدِ {side === "buy" ? "خرید" : "فروش"} (٪۰٫۵)</dt>
                <dd className="tabular-nums">{formatNumber(fee)} ریال</dd>
              </div>
              <div className="flex justify-between border-t border-border pt-2 text-base">
                <dt className="font-bold">{side === "buy" ? "جمعِ پرداخت" : "واریز به کیف پول"}</dt>
                <dd className="font-bold tabular-nums">{formatNumber(side === "buy" ? amount + fee : Math.max(0, amount - fee))} ریال</dd>
              </div>
            </dl>
            <Button disabled={!amount} onClick={() => toast.success(side === "buy" ? `${toFaDigits(mg)} میلی‌گرم ${name} خریده شد.` : `${toFaDigits(mg)} میلی‌گرم ${name} فروخته شد.`)}>
              {amount ? `${side === "buy" ? "خرید" : "فروش"}ِ ${toFaDigits(formatNumber(Number(mg)))} میلی‌گرم ${name}` : "مقدار یا مبلغ را بنویس"}
            </Button>
          </section>

          <div className="flex flex-col gap-6">
            {/* داراییِ من: کارتِ رنگیِ طلایی با پنهان‌کردنِ موجودی. */}
            <section aria-labelledby="assets-title" className="relative isolate flex flex-col gap-4 overflow-hidden rounded-xl bg-[linear-gradient(135deg,var(--dig-amber-700),var(--dig-orange-700))] p-5 text-[var(--dig-white)]">
              <span aria-hidden className="pointer-events-none absolute -end-12 -top-12 -z-10 size-44 rounded-full border-[18px] border-[color-mix(in_oklab,var(--dig-white)_16%,transparent)]" />
              <div className="flex items-center justify-between">
                <h2 id="assets-title" className="font-bold">
                  داراییِ من
                </h2>
                <Button
                  variant="ghost"
                  size="icon"
                  aria-pressed={hidden}
                  aria-label={hidden ? "نمایشِ موجودی" : "پنهان‌کردنِ موجودی"}
                  onClick={() => setHidden((value) => !value)}
                  className="-me-2 text-[var(--dig-white)] hover:bg-[color-mix(in_oklab,var(--dig-white)_18%,var(--dig-orange-700))] hover:text-[var(--dig-white)]"
                >
                  {hidden ? <EyeIcon /> : <EyeOffIcon />}
                </Button>
              </div>
              <dl className="grid grid-cols-2 gap-3">
                {[
                  ["طلا", "۲٬۴۶۰ میلی‌گرم", formatCurrency(Math.round((2460 * PRICE.gold) / 10))],
                  ["نقره", "۱۸٬۰۰۰ میلی‌گرم", formatCurrency(Math.round((18000 * PRICE.silver) / 10))],
                ].map(([label, mgText, toman]) => (
                  <div key={label} className="flex flex-col gap-1 rounded-lg bg-[color-mix(in_oklab,var(--dig-black)_12%,var(--dig-orange-700))] p-3">
                    <dt className="text-sm">{label}</dt>
                    <dd className="flex flex-col">
                      <MaskedValue hidden={hidden} value={mgText} mask="••••" className="text-lg font-black" />
                      <MaskedValue hidden={hidden} value={`≈ ${toman}`} mask="••••" className="text-xs" />
                    </dd>
                  </div>
                ))}
              </dl>
            </section>

            <section aria-labelledby="chart-title" className="flex flex-col gap-4 rounded-xl border border-border bg-card p-5">
              <div className="flex items-center justify-between gap-3">
                <h2 id="chart-title" className="font-bold">
                  قیمتِ ۱ میلی‌گرم {name} در ۲۴ ساعت
                </h2>
                <span className="flex items-center gap-1 text-sm font-semibold text-success-subtle-foreground [&>svg]:size-4">
                  <TrendingUpIcon aria-hidden />
                  <bdi dir="ltr">+٪۲٫۹</bdi>
                </span>
              </div>
              <AreaChart className="h-48" data={CHART} categoryKey="label" smooth showPoints={false} valueAxisFromData series={[{ key: "value", label: "ریال", color: "var(--dig-amber-500)" }]} valueFormatter={(value) => formatNumber(value)} />
              <Button variant="outline">
                <ClockIcon />
                تاریخچهٔ خرید و فروش
              </Button>
            </section>
          </div>
        </div>
      </main>
    </ControlSizeProvider>
  )
}
account-gold.vue
<script setup lang="ts">
import { computed, ref } from "vue"

import AreaChart from "@/components/ui/AreaChart.vue"
import Button from "@/components/ui/Button.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import MaskedValue from "@/components/ui/MaskedValue.vue"
import RadioCard from "@/components/ui/RadioCard.vue"
import RadioGroup from "@/components/ui/RadioGroup.vue"
import TextField from "@/components/ui/TextField.vue"
import { toast } from "@/components/ui/Toast.vue"
import ToggleGroup from "@/components/ui/ToggleGroup.vue"
import ToggleGroupItem from "@/components/ui/ToggleGroupItem.vue"
import { DigIcon } from "@/lib/icons"
import { formatCurrency, formatNumber, toFaDigits } from "@/lib/persian"

const NAV = [
  { id: "overview", label: "خلاصهٔ فعالیت‌ها", icon: "dashboard" },
  { id: "orders", label: "سفارش‌ها", icon: "shop" },
  { id: "gold", label: "طلای دیجیتال", icon: "trending-up" },
  { id: "lists", label: "لیست‌های من", icon: "heart" },
  { id: "reviews", label: "دیدگاه‌ها و پرسش‌ها", icon: "chat" },
  { id: "addresses", label: "نشانی‌ها", icon: "location" },
  { id: "account", label: "اطلاعاتِ حساب", icon: "user" },
] as const

const PRICE = { gold: 262_430, silver: 5_108 } // ریال برای هر میلی‌گرم
const FEE = 0.005
const CHART = [
  { label: "۱۲:۰۰", value: 255_088 },
  { label: "۱۵:۰۰", value: 256_120 },
  { label: "۱۸:۰۰", value: 257_064 },
  { label: "۲۱:۰۰", value: 258_900 },
  { label: "۰۰:۰۰", value: 259_041 },
  { label: "۰۳:۰۰", value: 259_800 },
  { label: "۰۶:۰۰", value: 261_018 },
  { label: "۰۹:۰۰", value: 262_430 },
]
const CHART_SERIES = [{ key: "value", label: "ریال", color: "var(--dig-amber-500)" }]
const ASSETS = [
  ["طلا", "۲٬۴۶۰ میلی‌گرم", formatCurrency(Math.round((2460 * PRICE.gold) / 10))],
  ["نقره", "۱۸٬۰۰۰ میلی‌گرم", formatCurrency(Math.round((18000 * PRICE.silver) / 10))],
]

/**
 * خرید و فروشِ طلای دیجیتال در پنلِ حساب: انتخابِ طلا/نقره، قیمتِ لحظه‌ایِ هر میلی‌گرم با نقطهٔ زنده،
 * خرید/فروش با سگمنت، مقدار به میلی‌گرم یا مبلغ به ریال (هر کدام را بنویسی دیگری حساب می‌شود)، کارمزد
 * و جمع، پیشنهادِ «وام با وثیقهٔ طلا» به‌جای فروش، و ستونِ دارایی با پنهان‌کردنِ موجودی و نمودارِ ۲۴ ساعت.
 */
const metal = ref<"gold" | "silver">("gold")
const side = ref("buy")
const rial = ref("")
const mg = ref("")
const hidden = ref(false)
const loanDismissed = ref(false)
const price = computed(() => PRICE[metal.value])
const amount = computed(() => Number(rial.value) || 0)
const fee = computed(() => Math.round(amount.value * FEE))
const name = computed(() => (metal.value === "gold" ? "طلا" : "نقره"))

function onSideChange(value: string | string[] | undefined) {
  if (value) side.value = value as string
}

function onMgChange(value: string | number) {
  const next = String(value)
  mg.value = next
  rial.value = next ? String(Number(next) * price.value) : ""
}

function onRialChange(value: string | number) {
  const next = String(value)
  rial.value = next
  mg.value = next ? String(Math.floor(Number(next) / price.value)) : ""
}

function trade() {
  toast.success(side.value === "buy" ? `${toFaDigits(mg.value)} میلی‌گرم ${name.value} خریده شد.` : `${toFaDigits(mg.value)} میلی‌گرم ${name.value} فروخته شد.`)
}
</script>

<template>
  <ControlSize size="xl" as-child>
    <main class="mx-auto grid w-full max-w-6xl grid-cols-1 items-start gap-6 p-4 sm:p-6 lg:grid-cols-[17rem_minmax(0,1fr)]">
      <div class="hidden lg:block">
        <!-- ستونِ کنارِ پنلِ حساب: نام و موبایل، کیف پول با افزایشِ موجودی، و منوی بخش‌ها. -->
        <aside class="flex flex-col gap-2 rounded-xl border border-border bg-card p-4 lg:sticky lg:top-6">
          <div class="flex items-start justify-between gap-2 px-2 pt-1 pb-4">
            <span class="flex flex-col gap-0.5">
              <span class="font-bold">آرمیتا رستگار</span>
              <bdi dir="ltr" class="text-sm text-muted-foreground tabular-nums">{{ toFaDigits("0912 345 6789") }}</bdi>
            </span>
            <Button variant="ghost" size="icon" aria-label="ویرایشِ اطلاعات" class="-me-2 -mt-2">
              <DigIcon name="edit" />
            </Button>
          </div>
          <div class="flex items-center justify-between gap-2 rounded-lg bg-subtle p-3">
            <span class="flex items-center gap-2 text-sm [&>svg]:size-4 [&>svg]:text-muted-foreground">
              <DigIcon name="wallet" aria-hidden="true" />
              کیف پول
            </span>
            <span class="font-bold tabular-nums">{{ formatCurrency(150_129) }}</span>
          </div>
          <a href="#" class="flex items-center gap-1 self-end px-2 pb-2 text-sm font-medium text-brand-secondary hover:underline">
            افزایشِ موجودی
            <DigIcon name="chevron-left" aria-hidden="true" class="size-4" />
          </a>
          <nav aria-label="حسابِ کاربری" class="flex flex-col border-t border-border pt-2">
            <a
              v-for="item in NAV"
              :key="item.id"
              href="#"
              :aria-current="item.id === 'gold' ? 'page' : undefined"
              :class="`flex min-h-12 items-center gap-3 rounded-lg px-3 text-sm [&>svg]:size-5 ${item.id === 'gold' ? 'bg-primary-subtle font-bold' : 'text-muted-foreground hover:bg-subtle hover:text-foreground'}`"
            >
              <DigIcon :name="item.icon" />
              {{ item.label }}
            </a>
            <a href="#" class="flex min-h-12 items-center gap-3 rounded-lg px-3 text-sm text-destructive hover:bg-destructive-subtle [&>svg]:size-5">
              <DigIcon name="logout" aria-hidden="true" />
              خروج از حساب
            </a>
          </nav>
        </aside>
      </div>

      <div class="grid min-w-0 grid-cols-1 items-start gap-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
        <section aria-labelledby="trade-title" class="flex flex-col gap-5 rounded-xl border border-border bg-card p-5">
          <h1 id="trade-title" class="text-xl font-black">خرید و فروشِ طلای دیجیتال</h1>
          <!-- انتخابِ فلز: دو کارتِ بزرگ با رنگِ هر فلز. -->
          <RadioGroup :value="metal" aria-label="فلز" class="grid grid-cols-2 gap-3" @update:value="(value) => (metal = value as 'gold' | 'silver')">
            <RadioCard v-for="item in (['gold', 'silver'] as const)" :key="item" :value="item" :title="item === 'gold' ? 'طلا' : 'نقره'">
              <template #media>
                <span aria-hidden="true" :class="`size-6 rotate-12 rounded-md ${item === 'gold' ? 'bg-[linear-gradient(135deg,var(--dig-amber-300),var(--dig-amber-600))]' : 'bg-[linear-gradient(135deg,var(--dig-slate-200),var(--dig-slate-500))]'}`" />
              </template>
            </RadioCard>
          </RadioGroup>

          <div class="flex flex-col gap-4 rounded-xl border border-border p-4">
            <div class="flex items-center justify-between gap-3">
              <span class="flex min-w-0 items-center gap-2 text-sm">
                <span aria-hidden="true" class="relative flex size-2.5">
                  <span class="absolute inset-0 animate-ping rounded-full bg-destructive motion-reduce:hidden" />
                  <span class="relative size-2.5 rounded-full bg-destructive" />
                </span>
                <span class="truncate">قیمتِ هر میلی‌گرم {{ name }}</span>
              </span>
              <span class="shrink-0 font-bold whitespace-nowrap tabular-nums">{{ formatNumber(price) }} ریال</span>
            </div>
            <ToggleGroup type="single" variant="segmented" size="lg" :value="side" aria-label="خرید یا فروش" class="w-full" @update:value="onSideChange">
              <ToggleGroupItem value="buy" class="flex-1">خرید</ToggleGroupItem>
              <ToggleGroupItem value="sell" class="flex-1">فروش</ToggleGroupItem>
            </ToggleGroup>
            <TextField :label="`مقدارِ ${name}`" inputmode="numeric" dir="rtl" group-digits :model-value="mg" @update:model-value="onMgChange">
              <template #endContent>میلی‌گرم</template>
            </TextField>
            <TextField
              :label="side === 'buy' ? 'مبلغِ پرداختی' : 'مبلغِ دریافتی'"
              inputmode="numeric"
              dir="rtl"
              group-digits
              :model-value="rial"
              description="مقدار یا مبلغ را بنویس؛ دیگری خودش حساب می‌شود."
              @update:model-value="onRialChange"
            >
              <template #endContent>ریال</template>
            </TextField>
          </div>

          <div v-if="side === 'sell' && !loanDismissed" class="flex flex-col gap-3 rounded-xl bg-subtle p-4">
            <span class="flex items-center gap-2 font-bold [&>svg]:size-5 [&>svg]:text-brand-secondary">
              <DigIcon name="info" aria-hidden="true" />
              پول نقد بدونِ فروشِ {{ name }}
            </span>
            <p class="text-sm leading-6 text-muted-foreground">با وثیقه‌کردنِ {{ name }}ِ دیجیتالت وام بگیر و دارایی‌ات را نگه دار؛ بازپرداخت در ۴ قسط.</p>
            <div class="flex gap-2">
              <ControlSize size="lg" as-child>
                <Button variant="outline" class="bg-card">درخواستِ وام</Button>
              </ControlSize>
              <ControlSize size="lg" as-child>
                <Button variant="ghost" @click="loanDismissed = true">بعداً</Button>
              </ControlSize>
            </div>
          </div>

          <dl class="flex flex-col gap-2 text-sm">
            <div class="flex justify-between">
              <dt class="text-muted-foreground">کارمزدِ {{ side === "buy" ? "خرید" : "فروش" }} (٪۰٫۵)</dt>
              <dd class="tabular-nums">{{ formatNumber(fee) }} ریال</dd>
            </div>
            <div class="flex justify-between border-t border-border pt-2 text-base">
              <dt class="font-bold">{{ side === "buy" ? "جمعِ پرداخت" : "واریز به کیف پول" }}</dt>
              <dd class="font-bold tabular-nums">{{ formatNumber(side === "buy" ? amount + fee : Math.max(0, amount - fee)) }} ریال</dd>
            </div>
          </dl>
          <Button :disabled="!amount" @click="trade">
            {{ amount ? `${side === "buy" ? "خرید" : "فروش"}ِ ${toFaDigits(formatNumber(Number(mg)))} میلی‌گرم ${name}` : "مقدار یا مبلغ را بنویس" }}
          </Button>
        </section>

        <div class="flex flex-col gap-6">
          <!-- داراییِ من: کارتِ رنگیِ طلایی با پنهان‌کردنِ موجودی. -->
          <section aria-labelledby="assets-title" class="relative isolate flex flex-col gap-4 overflow-hidden rounded-xl bg-[linear-gradient(135deg,var(--dig-amber-700),var(--dig-orange-700))] p-5 text-[var(--dig-white)]">
            <span aria-hidden="true" class="pointer-events-none absolute -end-12 -top-12 -z-10 size-44 rounded-full border-[18px] border-[color-mix(in_oklab,var(--dig-white)_16%,transparent)]" />
            <div class="flex items-center justify-between">
              <h2 id="assets-title" class="font-bold">داراییِ من</h2>
              <Button
                variant="ghost"
                size="icon"
                :aria-pressed="hidden"
                :aria-label="hidden ? 'نمایشِ موجودی' : 'پنهان‌کردنِ موجودی'"
                class="-me-2 text-[var(--dig-white)] hover:bg-[color-mix(in_oklab,var(--dig-white)_18%,var(--dig-orange-700))] hover:text-[var(--dig-white)]"
                @click="hidden = !hidden"
              >
                <DigIcon :name="hidden ? 'eye' : 'eye-off'" />
              </Button>
            </div>
            <dl class="grid grid-cols-2 gap-3">
              <div v-for="[label, mgText, toman] in ASSETS" :key="label" class="flex flex-col gap-1 rounded-lg bg-[color-mix(in_oklab,var(--dig-black)_12%,var(--dig-orange-700))] p-3">
                <dt class="text-sm">{{ label }}</dt>
                <dd class="flex flex-col">
                  <MaskedValue :hidden="hidden" :value="mgText" mask="••••" class="text-lg font-black" />
                  <MaskedValue :hidden="hidden" :value="`≈ ${toman}`" mask="••••" class="text-xs" />
                </dd>
              </div>
            </dl>
          </section>

          <section aria-labelledby="chart-title" class="flex flex-col gap-4 rounded-xl border border-border bg-card p-5">
            <div class="flex items-center justify-between gap-3">
              <h2 id="chart-title" class="font-bold">قیمتِ ۱ میلی‌گرم {{ name }} در ۲۴ ساعت</h2>
              <span class="flex items-center gap-1 text-sm font-semibold text-success-subtle-foreground [&>svg]:size-4">
                <DigIcon name="trending-up" aria-hidden="true" />
                <bdi dir="ltr">+٪۲٫۹</bdi>
              </span>
            </div>
            <AreaChart class="h-48" :data="CHART" category-key="label" curve="smooth" :show-points="false" value-axis-from-data :series="CHART_SERIES" :value-formatter="(value) => formatNumber(value)" />
            <Button variant="outline">
              <DigIcon name="clock" />
              تاریخچهٔ خرید و فروش
            </Button>
          </section>
        </div>
      </div>
    </main>
  </ControlSize>
</template>

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

این موارد هنوز برای Svelte آماده نیستند: chart-presetscontrol-sizemasked-valuepersianradio-cardradio-grouptext-fieldtoasttoggle-groupآیکون chatآیکون chevron-leftآیکون clockآیکون dashboardآیکون editآیکون eyeآیکون eye-offآیکون heartآیکون infoآیکون locationآیکون logoutآیکون shopآیکون trending-upآیکون userآیکون wallet

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

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

import { DigControlSize } from "@/components/ui/control-size"
import { DigButton } from "@/components/ui/button"
import { DigIcon } from "@/lib/icons"
import { DigRadioGroup } from "@/components/ui/radio-group"
import { DigRadioCard, DigRadioCardMedia } from "@/components/ui/radio-card"
import { DigToggleGroup, DigToggleGroupItem } from "@/components/ui/toggle-group"
import { DigTextField } from "@/components/ui/text-field"
import { DigInputEnd, DigInput, DigInputField } from "@/components/ui/input"
import { DigMaskedValue } from "@/components/ui/masked-value"
import { DigAreaChart } from "@/components/ui/chart-presets"
import { toast } from "@/components/ui/toast"
import { formatCurrency, formatNumber, toFaDigits } from "@/lib/persian"

const NAV = [
  { id: "overview", label: "خلاصهٔ فعالیت‌ها", icon: "dashboard" },
  { id: "orders", label: "سفارش‌ها", icon: "shop" },
  { id: "gold", label: "طلای دیجیتال", icon: "trending-up" },
  { id: "lists", label: "لیست‌های من", icon: "heart" },
  { id: "reviews", label: "دیدگاه‌ها و پرسش‌ها", icon: "chat" },
  { id: "addresses", label: "نشانی‌ها", icon: "location" },
  { id: "account", label: "اطلاعاتِ حساب", icon: "user" },
] as const

const PRICE = { gold: 262_430, silver: 5_108 }

const FEE = 0.005

const CHART = [
  { label: "۱۲:۰۰", value: 255_088 },
  { label: "۱۵:۰۰", value: 256_120 },
  { label: "۱۸:۰۰", value: 257_064 },
  { label: "۲۱:۰۰", value: 258_900 },
  { label: "۰۰:۰۰", value: 259_041 },
  { label: "۰۳:۰۰", value: 259_800 },
  { label: "۰۶:۰۰", value: 261_018 },
  { label: "۰۹:۰۰", value: 262_430 },
]

const CHART_SERIES = [{ key: "value", label: "ریال", color: "var(--dig-amber-500)" }]

const ASSETS = [
  ["طلا", "۲٬۴۶۰ میلی‌گرم", formatCurrency(Math.round((2460 * PRICE.gold) / 10))],
  ["نقره", "۱۸٬۰۰۰ میلی‌گرم", formatCurrency(Math.round((18000 * PRICE.silver) / 10))],
]

@Component({
  selector: "dig-block-account-gold",
  imports: [
    DigControlSize,
    DigButton,
    DigIcon,
    DigRadioGroup,
    DigRadioCard,
    DigRadioCardMedia,
    DigToggleGroup,
    DigToggleGroupItem,
    DigTextField,
    DigInputEnd,
    DigInput,
    DigInputField,
    DigMaskedValue,
    DigAreaChart,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <main
      digControlSize="xl"
      class="mx-auto grid w-full max-w-6xl grid-cols-1 items-start gap-6 p-4 sm:p-6 lg:grid-cols-[17rem_minmax(0,1fr)]"
    >
      <div class="hidden lg:block">
        <!-- ستونِ کنارِ پنلِ حساب: نام و موبایل، کیف پول با افزایشِ موجودی، و منوی بخش‌ها. -->
        <aside class="flex flex-col gap-2 rounded-xl border border-border bg-card p-4 lg:sticky lg:top-6">
          <div class="flex items-start justify-between gap-2 px-2 pt-1 pb-4">
            <span class="flex flex-col gap-0.5"
              ><span class="font-bold">آرمیتا رستگار</span>
              <bdi dir="ltr" class="text-sm text-muted-foreground tabular-nums">{{
                toFaDigits("0912 345 6789")
              }}</bdi></span
            >
            <button digButton type="button" variant="ghost" size="icon" aria-label="ویرایشِ اطلاعات" class="-me-2 -mt-2">
              <svg digIcon="edit"></svg>
            </button>
          </div>
          <div class="flex items-center justify-between gap-2 rounded-lg bg-subtle p-3">
            <span class="flex items-center gap-2 text-sm [&>svg]:size-4 [&>svg]:text-muted-foreground"
              ><svg digIcon="wallet" aria-hidden="true"></svg>
              کیف پول
            </span>
            <span class="font-bold tabular-nums">{{ formatCurrency(150_129) }}</span>
          </div>
          <a
            href="#"
            class="flex items-center gap-1 self-end px-2 pb-2 text-sm font-medium text-brand-secondary hover:underline"
          >
            افزایشِ موجودی
            <svg digIcon="chevron-left" aria-hidden="true" class="size-4"></svg
          ></a>
          <nav aria-label="حسابِ کاربری" class="flex flex-col border-t border-border pt-2">
            @for (item of NAV; track item.id) {
              <a
                href="#"
                [attr.aria-current]="item.id === 'gold' ? 'page' : undefined"
                [class]="\`flex min-h-12 items-center gap-3 rounded-lg px-3 text-sm [&>svg]:size-5 \${item.id === 'gold' ? 'bg-primary-subtle font-bold' : 'text-muted-foreground hover:bg-subtle hover:text-foreground'}\`"
                ><svg [digIcon]="item.icon"></svg> {{ item.label }}</a
              >
            }
            <a
              href="#"
              class="flex min-h-12 items-center gap-3 rounded-lg px-3 text-sm text-destructive hover:bg-destructive-subtle [&>svg]:size-5"
              ><svg digIcon="logout" aria-hidden="true"></svg>
              خروج از حساب
            </a>
          </nav>
        </aside>
      </div>

      <div class="grid min-w-0 grid-cols-1 items-start gap-6 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
        <section aria-labelledby="trade-title" class="flex flex-col gap-5 rounded-xl border border-border bg-card p-5">
          <h1 id="trade-title" class="text-xl font-black">خرید و فروشِ طلای دیجیتال</h1>
          <!-- انتخابِ فلز: دو کارتِ بزرگ با رنگِ هر فلز. -->
          <div
            digRadioGroup
            [value]="metal()"
            aria-label="فلز"
            class="grid grid-cols-2 gap-3"
            (valueChange)="setMetal($event)"
          >
            @for (item of ["gold", "silver"]; track item) {
              <label digRadioCard [value]="item" [title]="item === 'gold' ? 'طلا' : 'نقره'"
                ><span digRadioCardMedia
                  ><span
                    aria-hidden="true"
                    [class]="\`size-6 rotate-12 rounded-md \${item === 'gold' ? 'bg-[linear-gradient(135deg,var(--dig-amber-300),var(--dig-amber-600))]' : 'bg-[linear-gradient(135deg,var(--dig-slate-200),var(--dig-slate-500))]'}\`"
                  ></span></span
              ></label>
            }
          </div>

          <div class="flex flex-col gap-4 rounded-xl border border-border p-4">
            <div class="flex items-center justify-between gap-3">
              <span class="flex min-w-0 items-center gap-2 text-sm"
                ><span aria-hidden="true" class="relative flex size-2.5"
                  ><span class="absolute inset-0 animate-ping rounded-full bg-destructive motion-reduce:hidden"></span>
                  <span class="relative size-2.5 rounded-full bg-destructive"></span
                ></span>
                <span class="truncate">قیمتِ هر میلی‌گرم {{ name() }}</span></span
              >
              <span class="shrink-0 font-bold whitespace-nowrap tabular-nums">{{ formatNumber(price()) }} ریال</span>
            </div>
            <div
              digToggleGroup
              type="single"
              variant="segmented"
              size="lg"
              [value]="side()"
              aria-label="خرید یا فروش"
              class="w-full"
              (valueChange)="onSideChange($event)"
            >
              <button digToggleGroupItem value="buy" class="flex-1">خرید</button>
              <button digToggleGroupItem value="sell" class="flex-1">فروش</button>
            </div>
            <div digTextField [label]="\`مقدارِ \${name()}\`">
              <dig-input
                ><input
                  digInput
                  inputmode="numeric"
                  dir="rtl"
                  groupDigits
                  [value]="mg()"
                  (valueChange)="onMgChange($event)"
                /><span digInputEnd>میلی‌گرم</span></dig-input
              >
            </div>
            <div
              digTextField
              [label]="side() === 'buy' ? 'مبلغِ پرداختی' : 'مبلغِ دریافتی'"
              description="مقدار یا مبلغ را بنویس؛ دیگری خودش حساب می‌شود."
            >
              <dig-input
                ><input
                  digInput
                  inputmode="numeric"
                  dir="rtl"
                  groupDigits
                  [value]="rial()"
                  (valueChange)="onRialChange($event)"
                /><span digInputEnd>ریال</span></dig-input
              >
            </div>
          </div>

          @if (side() === "sell" && !loanDismissed()) {
            <div class="flex flex-col gap-3 rounded-xl bg-subtle p-4">
              <span class="flex items-center gap-2 font-bold [&>svg]:size-5 [&>svg]:text-brand-secondary"
                ><svg digIcon="info" aria-hidden="true"></svg> پول نقد بدونِ فروشِ {{ name() }}</span
              >
              <p class="text-sm leading-6 text-muted-foreground">
                با وثیقه‌کردنِ {{ name() }}ِ دیجیتالت وام بگیر و دارایی‌ات را نگه دار؛ بازپرداخت در ۴ قسط.
              </p>
              <div class="flex gap-2">
                <button digControlSize="lg" digButton type="button" variant="outline" class="bg-card">
                  درخواستِ وام
                </button>
                <button digControlSize="lg" digButton type="button" variant="ghost" (click)="loanDismissed.set(true)">
                  بعداً
                </button>
              </div>
            </div>
          }

          <dl class="flex flex-col gap-2 text-sm">
            <div class="flex justify-between">
              <dt class="text-muted-foreground">کارمزدِ {{ side() === "buy" ? "خرید" : "فروش" }} (٪۰٫۵)</dt>
              <dd class="tabular-nums">{{ formatNumber(fee()) }} ریال</dd>
            </div>
            <div class="flex justify-between border-t border-border pt-2 text-base">
              <dt class="font-bold">
                {{ side() === "buy" ? "جمعِ پرداخت" : "واریز به کیف پول" }}
              </dt>
              <dd class="font-bold tabular-nums">
                {{ formatNumber(side() === "buy" ? amount() + fee() : math.max(0, amount() - fee())) }}
                ریال
              </dd>
            </div>
          </dl>
          <button digButton type="button" [disabled]="!amount()" (click)="trade()">
            {{
              amount()
                ? \`\${side() === "buy" ? "خرید" : "فروش"}ِ \${toFaDigits(formatNumber(numeric(mg())))} میلی‌گرم \${name()}\`
                : "مقدار یا مبلغ را بنویس"
            }}
          </button>
        </section>

        <div class="flex flex-col gap-6">
          <!-- داراییِ من: کارتِ رنگیِ طلایی با پنهان‌کردنِ موجودی. -->
          <section
            aria-labelledby="assets-title"
            class="relative isolate flex flex-col gap-4 overflow-hidden rounded-xl bg-[linear-gradient(135deg,var(--dig-amber-700),var(--dig-orange-700))] p-5 text-[var(--dig-white)]"
          >
            <span
              aria-hidden="true"
              class="pointer-events-none absolute -end-12 -top-12 -z-10 size-44 rounded-full border-[18px] border-[color-mix(in_oklab,var(--dig-white)_16%,transparent)]"
            ></span>
            <div class="flex items-center justify-between">
              <h2 id="assets-title" class="font-bold">داراییِ من</h2>
              <button
                digButton
                type="button"
                variant="ghost"
                size="icon"
                [attr.aria-pressed]="hidden()"
                [attr.aria-label]="hidden() ? 'نمایشِ موجودی' : 'پنهان‌کردنِ موجودی'"
                class="-me-2 text-[var(--dig-white)] hover:bg-[color-mix(in_oklab,var(--dig-white)_18%,var(--dig-orange-700))] hover:text-[var(--dig-white)]"
                (click)="hidden.set(!hidden())"
              >
                <svg [digIcon]="hidden() ? 'eye' : 'eye-off'"></svg>
              </button>
            </div>
            <dl class="grid grid-cols-2 gap-3">
              @for (entry of ASSETS; track entry[0]) {
                @let label = entry[0];
                @let mgText = entry[1];
                @let toman = entry[2];
                <div
                  class="flex flex-col gap-1 rounded-lg bg-[color-mix(in_oklab,var(--dig-black)_12%,var(--dig-orange-700))] p-3"
                >
                  <dt class="text-sm">{{ label }}</dt>
                  <dd class="flex flex-col">
                    <span digMaskedValue [hidden]="hidden()" mask="••••" class="text-lg font-black">{{ mgText }}</span>
                    <span digMaskedValue [hidden]="hidden()" mask="••••" class="text-xs">{{ \`≈ \${toman}\` }}</span>
                  </dd>
                </div>
              }
            </dl>
          </section>

          <section
            aria-labelledby="chart-title"
            class="flex flex-col gap-4 rounded-xl border border-border bg-card p-5"
          >
            <div class="flex items-center justify-between gap-3">
              <h2 id="chart-title" class="font-bold">قیمتِ ۱ میلی‌گرم {{ name() }} در ۲۴ ساعت</h2>
              <span class="flex items-center gap-1 text-sm font-semibold text-success-subtle-foreground [&>svg]:size-4"
                ><svg digIcon="trending-up" aria-hidden="true"></svg> <bdi dir="ltr">+٪۲٫۹</bdi></span
              >
            </div>
            <div
              digAreaChart
              class="h-48"
              [data]="CHART"
              categoryKey="label"
              curve="smooth"
              [showPoints]="false"
              valueAxisFromData
              [series]="CHART_SERIES"
              [valueFormatter]="(value) => formatNumber(value)"
            ></div>
            <button digButton type="button" variant="outline">
              <svg digIcon="clock"></svg>
              تاریخچهٔ خرید و فروش
            </button>
          </section>
        </div>
      </div>
    </main>
  `,
})
export class AccountGoldBlock {
  readonly numeric = Number

  readonly math = Math

  readonly toFaDigits = toFaDigits

  readonly formatNumber = formatNumber

  readonly formatCurrency = formatCurrency

  readonly ASSETS = ASSETS

  readonly CHART_SERIES = CHART_SERIES

  readonly CHART = CHART

  readonly NAV = NAV

  readonly metal = signal<"gold" | "silver">("gold")

  readonly side = signal("buy")

  readonly rial = signal("")

  readonly mg = signal("")

  readonly hidden = signal(false)

  readonly loanDismissed = signal(false)

  readonly price = computed(() => PRICE[this.metal()])

  readonly amount = computed(() => Number(this.rial()) || 0)

  readonly fee = computed(() => Math.round(this.amount() * FEE))

  readonly name = computed(() => (this.metal() === "gold" ? "طلا" : "نقره"))

  onSideChange(value: string | string[] | undefined) {
    if (value) this.side.set(value as string)
  }

  onMgChange(value: string | number) {
    const next = String(value)
    this.mg.set(next)
    this.rial.set(next ? String(Number(next) * this.price()) : "")
  }

  onRialChange(value: string | number) {
    const next = String(value)
    this.rial.set(next)
    this.mg.set(next ? String(Math.floor(Number(next) / this.price())) : "")
  }

  trade() {
    toast.success(
      this.side() === "buy"
        ? `${toFaDigits(this.mg())} میلی‌گرم ${this.name()} خریده شد.`
        : `${toFaDigits(this.mg())} میلی‌گرم ${this.name()} فروخته شد.`
    )
  }

  setMetal(value: string | undefined) {
    if (value === "gold" || value === "silver") this.metal.set(value)
  }
}

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

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

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