صفحهٔ اصلیِ داروخانه
پیشنمایش تمامصفحهصفحهٔ اصلیِ اپِ داروخانه: نشانیِ ارسال و سبد، جستوجوی دارو، بنرِ سفارش با عکسِ نسخه، دستهها، پیشنهادهای ویژه با افزودن به سبد و داروخانههای نزدیک روی نقشه.
۱. نصب کامپوننتها
این بلاک از ۱۰ آیتم دیگ استفاده میکند: add-to-cartbadgebottom-navigationbuttoncontrol-sizeiconsmap-viewpersianproduct-cardsearch-field
npx digdesign@latest add https://docs.digdesign.ir/r/add-to-cart.json https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/bottom-navigation.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/map-view.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/product-card.json https://docs.digdesign.ir/r/search-field.jsonpnpm dlx digdesign@latest add https://docs.digdesign.ir/r/add-to-cart.json https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/bottom-navigation.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/map-view.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/product-card.json https://docs.digdesign.ir/r/search-field.jsonyarn dlx digdesign@latest add https://docs.digdesign.ir/r/add-to-cart.json https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/bottom-navigation.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/map-view.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/product-card.json https://docs.digdesign.ir/r/search-field.jsonbunx --bun digdesign@latest add https://docs.digdesign.ir/r/add-to-cart.json https://docs.digdesign.ir/r/badge.json https://docs.digdesign.ir/r/bottom-navigation.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/map-view.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/product-card.json https://docs.digdesign.ir/r/search-field.jsonnpx digdesign@latest add add-to-cart badge bottom-navigation button control-size map-view persian product-card search-field --framework vuepnpm dlx digdesign@latest add add-to-cart badge bottom-navigation button control-size map-view persian product-card search-field --framework vueyarn dlx digdesign@latest add add-to-cart badge bottom-navigation button control-size map-view persian product-card search-field --framework vuebunx --bun digdesign@latest add add-to-cart badge bottom-navigation button control-size map-view persian product-card search-field --framework vuenpx digdesign@latest add button --framework sveltepnpm dlx digdesign@latest add button --framework svelteyarn dlx digdesign@latest add button --framework sveltebunx --bun digdesign@latest add button --framework sveltenpx digdesign@latest add add-to-cart badge bottom-navigation button control-size icons map-view persian product-card search-field --framework angularpnpm dlx digdesign@latest add add-to-cart badge bottom-navigation button control-size icons map-view persian product-card search-field --framework angularyarn dlx digdesign@latest add add-to-cart badge bottom-navigation button control-size icons map-view persian product-card search-field --framework angularbunx --bun digdesign@latest add add-to-cart badge bottom-navigation button control-size icons map-view persian product-card search-field --framework angularnpx digdesign@latest add add-to-cart badge bottom-navigation button control-size map-view persian product-card search-field --framework androidpnpm dlx digdesign@latest add add-to-cart badge bottom-navigation button control-size map-view persian product-card search-field --framework androidyarn dlx digdesign@latest add add-to-cart badge bottom-navigation button control-size map-view persian product-card search-field --framework androidbunx --bun digdesign@latest add add-to-cart badge bottom-navigation button control-size map-view persian product-card search-field --framework android۲. کد صفحه
کد را در صفحهٔ پروژهتان بگذارید (React: app/<route>/page.tsx) و متنها، داده و هندلرها را با محصول خودتان عوض کنید. با سوییچر فریمورک کدِ همین صفحه در فریمورک دیگر را ببینید.
"use client"
import * as React from "react"
import {
BandageIcon,
ChevronDownIcon,
ChevronLeftIcon,
CloudUploadIcon,
DashboardIcon,
FaceMaskIcon,
FirstAidKitIcon,
GridIcon,
HandSoapIcon,
HeartIcon,
LocationIcon,
PillIcon,
ShoppingCartIcon,
StethoscopeIcon,
TestTubeIcon,
UserIcon,
} from "@/components/icons"
import { AddToCart } from "@/components/ui/add-to-cart"
import { Badge } from "@/components/ui/badge"
import { BottomNavigation, BottomNavigationItem } from "@/components/ui/bottom-navigation"
import { Button } from "@/components/ui/button"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { MapMarker, MapView } from "@/components/ui/map-view"
import { ProductCard, ProductCardBody, ProductCardCategory, ProductCardFooter, ProductCardMedia, ProductCardPrice, ProductCardTitle } from "@/components/ui/product-card"
import { SearchField } from "@/components/ui/search-field"
import { formatCurrency, toFaDigits } from "@/lib/persian"
import { stockImages, type StockImageName } from "@/lib/stock-images"
/** مرکزِ نقشه (حوالیِ میدانِ ونک، تهران) و تبدیلِ جای نمونهها به مختصات؛ در محصول lat و lng را از داده بگیرید. */
const MAP_CENTER = { lat: 35.7575, lng: 51.4135 }
const at = (x: number, y: number) => ({ lat: MAP_CENTER.lat + (50 - y) * 0.00012, lng: MAP_CENTER.lng + (x - 50) * 0.00024 })
/** هر دسته یک رنگِ ملایم از خانوادهٔ خودش؛ کاشی و آیکون همرنگ، بیopacity. */
const CATEGORIES = [
{ id: "otc", label: "داروی بدونِ نسخه", icon: <PillIcon />, hue: "--dig-blue-500" },
{ id: "supplement", label: "مکمل و ویتامین", icon: <TestTubeIcon />, hue: "--dig-amber-500" },
{ id: "beauty", label: "آرایشی و بهداشتی", icon: <HandSoapIcon />, hue: "--dig-pink-500" },
{ id: "devices", label: "تجهیزاتِ پزشکی", icon: <StethoscopeIcon />, hue: "--dig-violet-500" },
{ id: "firstaid", label: "کمکهای اولیه", icon: <BandageIcon />, hue: "--dig-red-500" },
{ id: "hygiene", label: "ماسک و ضدعفونی", icon: <FaceMaskIcon />, hue: "--dig-green-500" },
]
type Product = { id: string; title: string; brand: string; price: number; oldPrice?: number; rx?: boolean; image: StockImageName }
const OFFERS: Product[] = [
{ id: "1", title: "قرصِ جوشانِ ویتامین C هزار، ۲۰ عدد", brand: "هانسال", price: 186_000, oldPrice: 248_000, image: "vitaminCEffervescent" },
{ id: "2", title: "ژلِ ضدعفونیِ دست ۵۰۰ میلیلیتر", brand: "درمانگستر", price: 94_000, image: "handSanitizer" },
{ id: "3", title: "قطرهٔ چشمیِ لاتانوپروست ۲٫۵ میلیلیتر", brand: "سینا دارو", price: 412_000, rx: true, image: "eyeDrops" },
{ id: "4", title: "چسبِ زخمِ ضدآب، ۲۰ عدد", brand: "پارسطب", price: 58_000, oldPrice: 72_000, image: "bandAid" },
]
const NEARBY = [
{ id: "1", name: "داروخانهٔ شبانهروزیِ آزادی", distance: "۰٫۸ کیلومتر", open: true, hours: "شبانهروزی", x: 34, y: 46 },
{ id: "2", name: "داروخانهٔ دکتر صالحی", distance: "۱٫۴ کیلومتر", open: true, hours: "تا ۲۳", x: 66, y: 34 },
{ id: "3", name: "داروخانهٔ سینا", distance: "۲٫۱ کیلومتر", open: false, hours: "از ۸ صبح", x: 78, y: 70 },
]
const tint = (hue: string) => ({ background: `color-mix(in oklab, var(${hue}) 14%, var(--card))`, color: `color-mix(in oklab, var(${hue}) 75%, var(--foreground))` })
/** عنوانِ هر بخش با «همه» در انتهای ردیف؛ یک الگو برای همهٔ بخشها. */
function SectionHeader({ id, title, href = "#" }: { id: string; title: string; href?: string }) {
return (
<div className="flex items-center justify-between gap-3">
<h2 id={id} className="text-lg leading-snug font-bold">
{title}
</h2>
<a href={href} className="flex items-center gap-0.5 text-sm font-medium text-brand-secondary hover:underline">
همه
<ChevronLeftIcon aria-hidden className="size-4" />
</a>
</div>
)
}
/**
* صفحهٔ اصلیِ اپِ داروخانه: نشانیِ ارسال و سبد در سرصفحه، جستوجوی دارو، بنرِ «سفارش با عکسِ نسخه» (راهِ اصلیِ
* خریدِ داروی نسخهای)، دستهها، پیشنهادهای ویژه با AddToCart (داروی نسخهای بهجای افزودن «ثبت با نسخه»
* دارد) و داروخانههای نزدیک روی نقشه با وضعیتِ باز یا بسته. در موبایل نوارِ پایین، در دسکتاپ گریدِ پهن.
*/
export default function PharmacyHomeBlock() {
const [cart, setCart] = React.useState<Record<string, number>>({})
const [tab, setTab] = React.useState("home")
const [active, setActive] = React.useState("1")
const cartCount = Object.values(cart).reduce((sum, qty) => sum + qty, 0)
return (
<ControlSizeProvider size="xl" asChild>
<div className="mx-auto flex min-h-svh w-full max-w-6xl flex-col bg-background">
<main className="flex flex-1 flex-col gap-8 p-4 sm:p-6">
<header className="flex flex-col gap-3">
<div className="flex items-center justify-between gap-3">
<Button variant="ghost" aria-label="نشانیِ ارسال: خانه، خیابانِ آزادی؛ تغییر" className="-ms-1 h-auto min-w-0 justify-start gap-2 px-1 py-1 text-start font-normal">
<span aria-hidden className="flex size-10 shrink-0 items-center justify-center rounded-lg bg-primary-subtle text-primary-subtle-foreground [&>svg]:size-5">
<LocationIcon />
</span>
<span className="flex min-w-0 flex-col">
<span className="text-xs text-muted-foreground">ارسال به</span>
<span className="flex items-center gap-1 truncate text-sm font-semibold">
خانه، خیابانِ آزادی
<ChevronDownIcon aria-hidden className="size-4 shrink-0" />
</span>
</span>
</Button>
<ControlSizeProvider size="lg" mobileSize="default" asChild>
<Button variant="outline" size="icon" aria-label={cartCount ? `سبدِ خرید، ${toFaDigits(cartCount)} کالا` : "سبدِ خرید"} className="relative shrink-0">
<ShoppingCartIcon />
{cartCount > 0 && (
<Badge color="destructive" className="absolute -end-1.5 -top-1.5 min-w-5 justify-center px-1 tabular-nums">
{toFaDigits(cartCount)}
</Badge>
)}
</Button>
</ControlSizeProvider>
</div>
<SearchField aria-label="جستوجوی دارو" placeholder="نامِ دارو، برند یا علامت" />
</header>
{/* بنرِ طراحیشده: گرادیانِ همخانواده، الگوی نقطهای و کاشیِ کج بهعنوانِ عنصرِ تزئینی. */}
<section aria-labelledby="rx-title" className="relative isolate overflow-hidden rounded-xl bg-[linear-gradient(135deg,var(--dig-green-600),var(--dig-green-800))] p-5 text-[var(--dig-white)] sm:p-8">
<span
aria-hidden
className="absolute inset-0 -z-10 bg-[radial-gradient(color-mix(in_oklab,var(--dig-white)_30%,var(--dig-green-800))_1.2px,transparent_1.3px)] [background-size:18px_18px] [mask-image:linear-gradient(to_left,black,transparent_70%)]"
/>
<span
aria-hidden
className="absolute -end-6 -bottom-8 flex size-36 rotate-[-12deg] items-center justify-center rounded-3xl bg-[color-mix(in_oklab,var(--dig-white)_16%,var(--dig-green-700))] text-[var(--dig-white)] sm:-end-2 sm:size-48 [&>svg]:size-16 sm:[&>svg]:size-24"
>
<FirstAidKitIcon />
</span>
<div className="flex max-w-sm flex-col items-start gap-3 pe-24 sm:pe-0">
<h1 id="rx-title" className="text-xl leading-snug font-black sm:text-3xl">
عکسِ نسخه را بفرست، داروخانه آماده میکند
</h1>
<p className="text-sm leading-6 text-[color-mix(in_oklab,var(--dig-white)_85%,var(--dig-green-800))]">قیمت در ۱۵ دقیقه اعلام میشود؛ بعد از تأییدِ تو پیک میآورد.</p>
<ControlSizeProvider size="lg" asChild>
<Button className="mt-1 bg-[var(--dig-white)] text-[var(--dig-green-900)] hover:bg-[color-mix(in_oklab,var(--dig-white)_90%,var(--dig-green-800))]">
<CloudUploadIcon />
بارگذاریِ نسخه
</Button>
</ControlSizeProvider>
</div>
</section>
<section aria-labelledby="cat-title" className="flex flex-col gap-4">
<SectionHeader id="cat-title" title="دستهها" />
<ul className="grid grid-cols-3 gap-2 sm:grid-cols-6 sm:gap-3">
{CATEGORIES.map((item) => (
<li key={item.id}>
<a
href="#"
className="flex h-full flex-col items-center gap-2 rounded-xl border border-border bg-card px-2 py-3 text-center text-xs leading-5 font-medium outline-none hover:border-[color-mix(in_oklab,var(--foreground)_30%,var(--border))] focus-visible:ring-[3px] focus-visible:ring-ring/50 sm:text-sm"
>
<span aria-hidden className="flex size-11 items-center justify-center rounded-lg [&>svg]:size-6" style={tint(item.hue)}>
{item.icon}
</span>
{item.label}
</a>
</li>
))}
</ul>
</section>
<section aria-labelledby="offers-title" className="flex flex-col gap-4">
<SectionHeader id="offers-title" title="پیشنهادهای ویژه" />
{/* موبایل: ردیفِ پیمایشی با کارتِ ۱۶۰ پیکسلی؛ دسکتاپ: گریدِ چهارستونه. */}
<ul className="-mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1 [scrollbar-width:none] sm:mx-0 sm:grid sm:grid-cols-4 sm:overflow-visible sm:px-0">
{OFFERS.map((item) => (
<li key={item.id} className="w-40 shrink-0 snap-start sm:w-auto">
<ProductCard size="sm" className="h-full w-full">
<ProductCardMedia>
{/* eslint-disable-next-line @next/next/no-img-element -- عکس از کتابخانهٔ تصویرِ دیگ */}
<img src={stockImages[item.image].src} alt={stockImages[item.image].alt} loading="lazy" />
</ProductCardMedia>
<ProductCardBody>
<ProductCardCategory>{item.brand}</ProductCardCategory>
<ProductCardTitle>{item.title}</ProductCardTitle>
{item.rx && (
<Badge variant="soft" color="warning" className="w-fit">
نیاز به نسخه
</Badge>
)}
<ProductCardPrice
amount={formatCurrency(item.price)}
originalAmount={item.oldPrice ? formatCurrency(item.oldPrice) : undefined}
discount={item.oldPrice ? `٪${toFaDigits(Math.round((1 - item.price / item.oldPrice) * 100))}` : undefined}
/>
</ProductCardBody>
<ProductCardFooter>
{item.rx ? (
<Button variant="outline" fullWidth>
ثبت با نسخه
</Button>
) : (
<AddToCart
fullWidth
label="افزودن"
itemName={item.title}
quantity={cart[item.id] ?? 0}
onQuantityChange={(quantity) => setCart((current) => ({ ...current, [item.id]: quantity }))}
/>
)}
</ProductCardFooter>
</ProductCard>
</li>
))}
</ul>
</section>
<section aria-labelledby="near-title" className="flex flex-col gap-4">
<SectionHeader id="near-title" title="داروخانههای نزدیک" />
<div className="grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
<MapView center={MAP_CENTER} zoom={15} label="نقشهٔ داروخانههای نزدیک" className="aspect-[2/1] lg:aspect-auto lg:h-full">
<MapMarker variant="you" {...at(50, 60)} label="موقعیتِ شما" />
{NEARBY.map((item) => (
<MapMarker key={item.id} {...at(item.x, item.y)} label={item.name} active={active === item.id} onClick={() => setActive(item.id)} />
))}
</MapView>
<ul className="flex flex-col divide-y divide-border rounded-xl border border-border bg-card">
{NEARBY.map((item) => (
<li key={item.id}>
<a
href="#"
aria-current={active === item.id ? "true" : undefined}
onFocus={() => setActive(item.id)}
onMouseEnter={() => setActive(item.id)}
className="flex items-center gap-3 p-4 outline-none hover:bg-subtle focus-visible:bg-subtle aria-[current=true]:bg-primary-subtle"
>
<span className="flex min-w-0 flex-1 flex-col gap-0.5">
<span className="truncate font-semibold">{item.name}</span>
<span className="flex flex-wrap items-center gap-x-2 text-sm text-muted-foreground">
{item.distance}
<span aria-hidden>·</span>
<span className={item.open ? "font-medium text-success-subtle-foreground" : "font-medium text-destructive"}>{item.open ? "باز" : "بسته"}</span>
<span>{item.hours}</span>
</span>
</span>
<ChevronLeftIcon aria-hidden className="size-5 shrink-0 text-muted-foreground" />
</a>
</li>
))}
</ul>
</div>
</section>
</main>
<BottomNavigation value={tab} onValueChange={setTab} indicator="pill" fixed={false} className="sticky bottom-0 sm:hidden">
<BottomNavigationItem value="home" icon={<DashboardIcon />} label="خانه" />
<BottomNavigationItem value="catalog" icon={<GridIcon />} label="دستهها" />
<BottomNavigationItem
value="cart"
icon={<ShoppingCartIcon />}
label="سبد"
badge={cartCount ? <Badge color="destructive">{toFaDigits(cartCount)}</Badge> : undefined}
/>
<BottomNavigationItem value="saved" icon={<HeartIcon />} label="ذخیرهها" />
<BottomNavigationItem value="profile" icon={<UserIcon />} label="حساب" />
</BottomNavigation>
</div>
</ControlSizeProvider>
)
}
<script setup lang="ts">
import { computed, ref } from "vue"
import AddToCart from "@/components/ui/AddToCart.vue"
import Badge from "@/components/ui/Badge.vue"
import BottomNavigation from "@/components/ui/BottomNavigation.vue"
import BottomNavigationItem from "@/components/ui/BottomNavigationItem.vue"
import Button from "@/components/ui/Button.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import MapMarker from "@/components/ui/MapMarker.vue"
import MapView from "@/components/ui/MapView.vue"
import ProductCard from "@/components/ui/ProductCard.vue"
import ProductCardBody from "@/components/ui/ProductCardBody.vue"
import ProductCardCategory from "@/components/ui/ProductCardCategory.vue"
import ProductCardFooter from "@/components/ui/ProductCardFooter.vue"
import ProductCardMedia from "@/components/ui/ProductCardMedia.vue"
import ProductCardPrice from "@/components/ui/ProductCardPrice.vue"
import ProductCardTitle from "@/components/ui/ProductCardTitle.vue"
import SearchField from "@/components/ui/SearchField.vue"
import { DigIcon } from "@/lib/icons"
import { formatCurrency, toFaDigits } from "@/lib/persian"
// stock-images:begin
/** تصویرهای کتابخانهٔ دیگ (همان آدرسهای `stockImages` نسخهٔ React). */
const stockImages = {
vitaminCEffervescent: { src: "https://docs.digdesign.ir/images/vitamin-c-effervescent.webp", alt: "قرصِ جوشانِ ویتامین C هزار میلیگرمی در لولهٔ نارنجی" },
handSanitizer: { src: "https://docs.digdesign.ir/images/hand-sanitizer.webp", alt: "شیشهٔ ژلِ ضدعفونیِ دست روی زمینهٔ روشن" },
eyeDrops: { src: "https://docs.digdesign.ir/images/eye-drops.webp", alt: "قطرهچشمیِ سفید کنارِ عینک" },
bandAid: { src: "https://docs.digdesign.ir/images/band-aid.webp", alt: "چسبِ زخم روی پوست" },
}
// stock-images:end
type StockImageName = keyof typeof stockImages
/** مرکزِ نقشه (حوالیِ میدانِ ونک، تهران) و تبدیلِ جای نمونهها به مختصات؛ در محصول lat و lng را از داده بگیرید. */
const MAP_CENTER = { lat: 35.7575, lng: 51.4135 }
const at = (x: number, y: number) => ({ lat: MAP_CENTER.lat + (50 - y) * 0.00012, lng: MAP_CENTER.lng + (x - 50) * 0.00024 })
/** هر دسته یک رنگِ ملایم از خانوادهٔ خودش؛ کاشی و آیکون همرنگ، بیopacity. */
const CATEGORIES = [
{ id: "otc", label: "داروی بدونِ نسخه", icon: "pill", hue: "--dig-blue-500" },
{ id: "supplement", label: "مکمل و ویتامین", icon: "test-tube", hue: "--dig-amber-500" },
{ id: "beauty", label: "آرایشی و بهداشتی", icon: "hand-soap", hue: "--dig-pink-500" },
{ id: "devices", label: "تجهیزاتِ پزشکی", icon: "stethoscope", hue: "--dig-violet-500" },
{ id: "firstaid", label: "کمکهای اولیه", icon: "bandage", hue: "--dig-red-500" },
{ id: "hygiene", label: "ماسک و ضدعفونی", icon: "face-mask", hue: "--dig-green-500" },
]
type Product = { id: string; title: string; brand: string; price: number; oldPrice?: number; rx?: boolean; image: StockImageName }
const OFFERS: Product[] = [
{ id: "1", title: "قرصِ جوشانِ ویتامین C هزار، ۲۰ عدد", brand: "هانسال", price: 186_000, oldPrice: 248_000, image: "vitaminCEffervescent" },
{ id: "2", title: "ژلِ ضدعفونیِ دست ۵۰۰ میلیلیتر", brand: "درمانگستر", price: 94_000, image: "handSanitizer" },
{ id: "3", title: "قطرهٔ چشمیِ لاتانوپروست ۲٫۵ میلیلیتر", brand: "سینا دارو", price: 412_000, rx: true, image: "eyeDrops" },
{ id: "4", title: "چسبِ زخمِ ضدآب، ۲۰ عدد", brand: "پارسطب", price: 58_000, oldPrice: 72_000, image: "bandAid" },
]
const NEARBY = [
{ id: "1", name: "داروخانهٔ شبانهروزیِ آزادی", distance: "۰٫۸ کیلومتر", open: true, hours: "شبانهروزی", x: 34, y: 46 },
{ id: "2", name: "داروخانهٔ دکتر صالحی", distance: "۱٫۴ کیلومتر", open: true, hours: "تا ۲۳", x: 66, y: 34 },
{ id: "3", name: "داروخانهٔ سینا", distance: "۲٫۱ کیلومتر", open: false, hours: "از ۸ صبح", x: 78, y: 70 },
]
const tint = (hue: string) => ({ background: `color-mix(in oklab, var(${hue}) 14%, var(--card))`, color: `color-mix(in oklab, var(${hue}) 75%, var(--foreground))` })
/**
* صفحهٔ اصلیِ اپِ داروخانه: نشانیِ ارسال و سبد در سرصفحه، جستوجوی دارو، بنرِ «سفارش با عکسِ نسخه» (راهِ اصلیِ
* خریدِ داروی نسخهای)، دستهها، پیشنهادهای ویژه با AddToCart (داروی نسخهای بهجای افزودن «ثبت با نسخه»
* دارد) و داروخانههای نزدیک روی نقشه با وضعیتِ باز یا بسته. در موبایل نوارِ پایین، در دسکتاپ گریدِ پهن.
*/
const cart = ref<Record<string, number>>({})
const tab = ref("home")
const active = ref("1")
const cartCount = computed(() => Object.values(cart.value).reduce((sum, qty) => sum + qty, 0))
</script>
<template>
<ControlSize size="xl" as-child>
<div class="mx-auto flex min-h-svh w-full max-w-6xl flex-col bg-background">
<main class="flex flex-1 flex-col gap-8 p-4 sm:p-6">
<header class="flex flex-col gap-3">
<div class="flex items-center justify-between gap-3">
<Button variant="ghost" aria-label="نشانیِ ارسال: خانه، خیابانِ آزادی؛ تغییر" class="-ms-1 h-auto min-w-0 justify-start gap-2 px-1 py-1 text-start font-normal">
<span aria-hidden="true" class="flex size-10 shrink-0 items-center justify-center rounded-lg bg-primary-subtle text-primary-subtle-foreground [&>svg]:size-5">
<DigIcon name="location" />
</span>
<span class="flex min-w-0 flex-col">
<span class="text-xs text-muted-foreground">ارسال به</span>
<span class="flex items-center gap-1 truncate text-sm font-semibold">
خانه، خیابانِ آزادی
<DigIcon name="chevron-down" aria-hidden="true" class="size-4 shrink-0" />
</span>
</span>
</Button>
<ControlSize size="lg" mobile-size="default" as-child>
<Button variant="outline" size="icon" :aria-label="cartCount ? `سبدِ خرید، ${toFaDigits(cartCount)} کالا` : 'سبدِ خرید'" class="relative shrink-0">
<DigIcon name="shopping-cart" />
<Badge v-if="cartCount > 0" color="destructive" class="absolute -end-1.5 -top-1.5 min-w-5 justify-center px-1 tabular-nums">{{ toFaDigits(cartCount) }}</Badge>
</Button>
</ControlSize>
</div>
<SearchField aria-label="جستوجوی دارو" placeholder="نامِ دارو، برند یا علامت" />
</header>
<!-- بنرِ طراحیشده: گرادیانِ همخانواده، الگوی نقطهای و کاشیِ کج بهعنوانِ عنصرِ تزئینی. -->
<section aria-labelledby="rx-title" class="relative isolate overflow-hidden rounded-xl bg-[linear-gradient(135deg,var(--dig-green-600),var(--dig-green-800))] p-5 text-[var(--dig-white)] sm:p-8">
<span
aria-hidden="true"
class="absolute inset-0 -z-10 bg-[radial-gradient(color-mix(in_oklab,var(--dig-white)_30%,var(--dig-green-800))_1.2px,transparent_1.3px)] [background-size:18px_18px] [mask-image:linear-gradient(to_left,black,transparent_70%)]"
/>
<span
aria-hidden="true"
class="absolute -end-6 -bottom-8 flex size-36 rotate-[-12deg] items-center justify-center rounded-3xl bg-[color-mix(in_oklab,var(--dig-white)_16%,var(--dig-green-700))] text-[var(--dig-white)] sm:-end-2 sm:size-48 [&>svg]:size-16 sm:[&>svg]:size-24"
>
<DigIcon name="first-aid-kit" />
</span>
<div class="flex max-w-sm flex-col items-start gap-3 pe-24 sm:pe-0">
<h1 id="rx-title" class="text-xl leading-snug font-black sm:text-3xl">عکسِ نسخه را بفرست، داروخانه آماده میکند</h1>
<p class="text-sm leading-6 text-[color-mix(in_oklab,var(--dig-white)_85%,var(--dig-green-800))]">قیمت در ۱۵ دقیقه اعلام میشود؛ بعد از تأییدِ تو پیک میآورد.</p>
<ControlSize size="lg" as-child>
<Button class="mt-1 bg-[var(--dig-white)] text-[var(--dig-green-900)] hover:bg-[color-mix(in_oklab,var(--dig-white)_90%,var(--dig-green-800))]">
<DigIcon name="cloud-upload" />
بارگذاریِ نسخه
</Button>
</ControlSize>
</div>
</section>
<section aria-labelledby="cat-title" class="flex flex-col gap-4">
<div class="flex items-center justify-between gap-3">
<h2 id="cat-title" class="text-lg leading-snug font-bold">دستهها</h2>
<a href="#" class="flex items-center gap-0.5 text-sm font-medium text-brand-secondary hover:underline">
همه
<DigIcon name="chevron-left" aria-hidden="true" class="size-4" />
</a>
</div>
<ul class="grid grid-cols-3 gap-2 sm:grid-cols-6 sm:gap-3">
<li v-for="item in CATEGORIES" :key="item.id">
<a
href="#"
class="flex h-full flex-col items-center gap-2 rounded-xl border border-border bg-card px-2 py-3 text-center text-xs leading-5 font-medium outline-none hover:border-[color-mix(in_oklab,var(--foreground)_30%,var(--border))] focus-visible:ring-[3px] focus-visible:ring-ring/50 sm:text-sm"
>
<span aria-hidden="true" class="flex size-11 items-center justify-center rounded-lg [&>svg]:size-6" :style="tint(item.hue)">
<DigIcon :name="item.icon" />
</span>
{{ item.label }}
</a>
</li>
</ul>
</section>
<section aria-labelledby="offers-title" class="flex flex-col gap-4">
<div class="flex items-center justify-between gap-3">
<h2 id="offers-title" class="text-lg leading-snug font-bold">پیشنهادهای ویژه</h2>
<a href="#" class="flex items-center gap-0.5 text-sm font-medium text-brand-secondary hover:underline">
همه
<DigIcon name="chevron-left" aria-hidden="true" class="size-4" />
</a>
</div>
<!-- موبایل: ردیفِ پیمایشی با کارتِ ۱۶۰ پیکسلی؛ دسکتاپ: گریدِ چهارستونه. -->
<ul class="-mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1 [scrollbar-width:none] sm:mx-0 sm:grid sm:grid-cols-4 sm:overflow-visible sm:px-0">
<li v-for="item in OFFERS" :key="item.id" class="w-40 shrink-0 snap-start sm:w-auto">
<ProductCard size="sm" class="h-full w-full">
<ProductCardMedia>
<img :src="stockImages[item.image].src" :alt="stockImages[item.image].alt" loading="lazy" />
</ProductCardMedia>
<ProductCardBody>
<ProductCardCategory>{{ item.brand }}</ProductCardCategory>
<ProductCardTitle>{{ item.title }}</ProductCardTitle>
<Badge v-if="item.rx" variant="soft" color="warning" class="w-fit">نیاز به نسخه</Badge>
<ProductCardPrice
:amount="formatCurrency(item.price)"
:original-amount="item.oldPrice ? formatCurrency(item.oldPrice) : undefined"
:discount="item.oldPrice ? `٪${toFaDigits(Math.round((1 - item.price / item.oldPrice) * 100))}` : undefined"
/>
</ProductCardBody>
<ProductCardFooter>
<Button v-if="item.rx" variant="outline" full-width>ثبت با نسخه</Button>
<AddToCart
v-else
full-width
label="افزودن"
:item-name="item.title"
:quantity="cart[item.id] ?? 0"
@update:quantity="(quantity) => (cart = { ...cart, [item.id]: quantity })"
/>
</ProductCardFooter>
</ProductCard>
</li>
</ul>
</section>
<section aria-labelledby="near-title" class="flex flex-col gap-4">
<div class="flex items-center justify-between gap-3">
<h2 id="near-title" class="text-lg leading-snug font-bold">داروخانههای نزدیک</h2>
<a href="#" class="flex items-center gap-0.5 text-sm font-medium text-brand-secondary hover:underline">
همه
<DigIcon name="chevron-left" aria-hidden="true" class="size-4" />
</a>
</div>
<div class="grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
<MapView :center="MAP_CENTER" :zoom="15" label="نقشهٔ داروخانههای نزدیک" class="aspect-[2/1] lg:aspect-auto lg:h-full">
<MapMarker variant="you" v-bind="at(50, 60)" label="موقعیتِ شما" />
<MapMarker v-for="item in NEARBY" :key="item.id" v-bind="at(item.x, item.y)" :label="item.name" :active="active === item.id" @click="active = item.id" />
</MapView>
<ul class="flex flex-col divide-y divide-border rounded-xl border border-border bg-card">
<li v-for="item in NEARBY" :key="item.id">
<a
href="#"
:aria-current="active === item.id ? 'true' : undefined"
class="flex items-center gap-3 p-4 outline-none hover:bg-subtle focus-visible:bg-subtle aria-[current=true]:bg-primary-subtle"
@focus="active = item.id"
@mouseenter="active = item.id"
>
<span class="flex min-w-0 flex-1 flex-col gap-0.5">
<span class="truncate font-semibold">{{ item.name }}</span>
<span class="flex flex-wrap items-center gap-x-2 text-sm text-muted-foreground">
{{ item.distance }}
<span aria-hidden="true">·</span>
<span :class="item.open ? 'font-medium text-success-subtle-foreground' : 'font-medium text-destructive'">{{ item.open ? "باز" : "بسته" }}</span>
<span>{{ item.hours }}</span>
</span>
</span>
<DigIcon name="chevron-left" aria-hidden="true" class="size-5 shrink-0 text-muted-foreground" />
</a>
</li>
</ul>
</div>
</section>
</main>
<BottomNavigation v-model:value="tab" indicator="pill" :fixed="false" class="sticky bottom-0 sm:hidden">
<BottomNavigationItem value="home" label="خانه">
<template #icon><DigIcon name="dashboard" /></template>
</BottomNavigationItem>
<BottomNavigationItem value="catalog" label="دستهها">
<template #icon><DigIcon name="grid" /></template>
</BottomNavigationItem>
<BottomNavigationItem value="cart" label="سبد">
<template #icon><DigIcon name="shopping-cart" /></template>
<template v-if="cartCount" #badge><Badge color="destructive">{{ toFaDigits(cartCount) }}</Badge></template>
</BottomNavigationItem>
<BottomNavigationItem value="saved" label="ذخیرهها">
<template #icon><DigIcon name="heart" /></template>
</BottomNavigationItem>
<BottomNavigationItem value="profile" label="حساب">
<template #icon><DigIcon name="user" /></template>
</BottomNavigationItem>
</BottomNavigation>
</div>
</ControlSize>
</template>
کدِ این بلاک هنوز برای Svelte نوشته نشده است.
این موارد هنوز برای Svelte آماده نیستند: add-to-cartbadgebottom-navigationcontrol-sizemap-viewpersianproduct-cardsearch-fieldآیکون bandageآیکون chevron-downآیکون chevron-leftآیکون cloud-uploadآیکون dashboardآیکون face-maskآیکون first-aid-kitآیکون gridآیکون hand-soapآیکون heartآیکون locationآیکون pillآیکون shopping-cartآیکون stethoscopeآیکون test-tubeآیکون user
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="svelte" ایجنت آن را با کامپوننتهای Svelte میسازد.
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 { DigBadge } from "@/components/ui/badge"
import { DigSearchField } from "@/components/ui/search-field"
import {
DigProductCard,
DigProductCardMedia,
DigProductCardBody,
DigProductCardCategory,
DigProductCardTitle,
DigProductCardPrice,
DigProductCardFooter,
} from "@/components/ui/product-card"
import { DigAddToCart } from "@/components/ui/add-to-cart"
import { DigMapView, DigMapMarkerYou, DigMapMarker } from "@/components/ui/map-view"
import {
DigBottomNavigation,
DigBottomNavigationItem,
DigBottomNavigationActiveIcon,
DigBottomNavigationBadge,
} from "@/components/ui/bottom-navigation"
import { formatCurrency, toFaDigits } from "@/lib/persian"
const stockImages = {
vitaminCEffervescent: {
src: "https://docs.digdesign.ir/images/vitamin-c-effervescent.webp",
alt: "قرصِ جوشانِ ویتامین C هزار میلیگرمی در لولهٔ نارنجی",
},
handSanitizer: {
src: "https://docs.digdesign.ir/images/hand-sanitizer.webp",
alt: "شیشهٔ ژلِ ضدعفونیِ دست روی زمینهٔ روشن",
},
eyeDrops: { src: "https://docs.digdesign.ir/images/eye-drops.webp", alt: "قطرهچشمیِ سفید کنارِ عینک" },
bandAid: { src: "https://docs.digdesign.ir/images/band-aid.webp", alt: "چسبِ زخم روی پوست" },
}
type StockImageName = keyof typeof stockImages
const MAP_CENTER = { lat: 35.7575, lng: 51.4135 }
const at = (x: number, y: number) => ({
lat: MAP_CENTER.lat + (50 - y) * 0.00012,
lng: MAP_CENTER.lng + (x - 50) * 0.00024,
})
const CATEGORIES = [
{ id: "otc", label: "داروی بدونِ نسخه", icon: "pill" as const, hue: "--dig-blue-500" },
{ id: "supplement", label: "مکمل و ویتامین", icon: "test-tube" as const, hue: "--dig-amber-500" },
{ id: "beauty", label: "آرایشی و بهداشتی", icon: "hand-soap" as const, hue: "--dig-pink-500" },
{ id: "devices", label: "تجهیزاتِ پزشکی", icon: "stethoscope" as const, hue: "--dig-violet-500" },
{ id: "firstaid", label: "کمکهای اولیه", icon: "bandage" as const, hue: "--dig-red-500" },
{ id: "hygiene", label: "ماسک و ضدعفونی", icon: "face-mask" as const, hue: "--dig-green-500" },
]
type Product = {
id: string
title: string
brand: string
price: number
oldPrice?: number
rx?: boolean
image: StockImageName
}
const OFFERS: Product[] = [
{
id: "1",
title: "قرصِ جوشانِ ویتامین C هزار، ۲۰ عدد",
brand: "هانسال",
price: 186_000,
oldPrice: 248_000,
image: "vitaminCEffervescent",
},
{ id: "2", title: "ژلِ ضدعفونیِ دست ۵۰۰ میلیلیتر", brand: "درمانگستر", price: 94_000, image: "handSanitizer" },
{
id: "3",
title: "قطرهٔ چشمیِ لاتانوپروست ۲٫۵ میلیلیتر",
brand: "سینا دارو",
price: 412_000,
rx: true,
image: "eyeDrops",
},
{ id: "4", title: "چسبِ زخمِ ضدآب، ۲۰ عدد", brand: "پارسطب", price: 58_000, oldPrice: 72_000, image: "bandAid" },
]
const NEARBY = [
{
id: "1",
name: "داروخانهٔ شبانهروزیِ آزادی",
distance: "۰٫۸ کیلومتر",
open: true,
hours: "شبانهروزی",
x: 34,
y: 46,
},
{ id: "2", name: "داروخانهٔ دکتر صالحی", distance: "۱٫۴ کیلومتر", open: true, hours: "تا ۲۳", x: 66, y: 34 },
{ id: "3", name: "داروخانهٔ سینا", distance: "۲٫۱ کیلومتر", open: false, hours: "از ۸ صبح", x: 78, y: 70 },
]
const tint = (hue: string) => ({
background: `color-mix(in oklab, var(${hue}) 14%, var(--card))`,
color: `color-mix(in oklab, var(${hue}) 75%, var(--foreground))`,
})
@Component({
selector: "dig-block-pharmacy-home",
imports: [
DigControlSize,
DigButton,
DigIcon,
DigBadge,
DigSearchField,
DigProductCard,
DigProductCardMedia,
DigProductCardBody,
DigProductCardCategory,
DigProductCardTitle,
DigProductCardPrice,
DigProductCardFooter,
DigAddToCart,
DigMapView,
DigMapMarkerYou,
DigMapMarker,
DigBottomNavigation,
DigBottomNavigationItem,
DigBottomNavigationActiveIcon,
DigBottomNavigationBadge,
],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<div digControlSize="xl" class="mx-auto flex min-h-svh w-full max-w-6xl flex-col bg-background">
<main class="flex flex-1 flex-col gap-8 p-4 sm:p-6">
<header class="flex flex-col gap-3">
<div class="flex items-center justify-between gap-3">
<button
digButton
type="button"
variant="ghost"
aria-label="نشانیِ ارسال: خانه، خیابانِ آزادی؛ تغییر"
class="-ms-1 h-auto min-w-0 justify-start gap-2 px-1 py-1 text-start font-normal"
>
<span
aria-hidden="true"
class="flex size-10 shrink-0 items-center justify-center rounded-lg bg-primary-subtle text-primary-subtle-foreground [&>svg]:size-5"
><svg digIcon="location"></svg
></span>
<span class="flex min-w-0 flex-col"
><span class="text-xs text-muted-foreground">ارسال به</span>
<span class="flex items-center gap-1 truncate text-sm font-semibold">
خانه، خیابانِ آزادی
<svg digIcon="chevron-down" aria-hidden="true" class="size-4 shrink-0"></svg></span
></span>
</button>
<button
digControlSize="lg"
mobileSize="default"
digButton
type="button"
variant="outline"
size="icon"
[attr.aria-label]="cartCount() ? \`سبدِ خرید، \${toFaDigits(cartCount())} کالا\` : 'سبدِ خرید'"
class="relative shrink-0"
>
<svg digIcon="shopping-cart"></svg>
@if (cartCount() > 0) {
<span
digBadge
color="destructive"
class="absolute -end-1.5 -top-1.5 min-w-5 justify-center px-1 tabular-nums"
>{{ toFaDigits(cartCount()) }}</span
>
}
</button>
</div>
<div digSearchField aria-label="جستوجوی دارو" placeholder="نامِ دارو، برند یا علامت"></div>
</header>
<!-- بنرِ طراحیشده: گرادیانِ همخانواده، الگوی نقطهای و کاشیِ کج بهعنوانِ عنصرِ تزئینی. -->
<section
aria-labelledby="rx-title"
class="relative isolate overflow-hidden rounded-xl bg-[linear-gradient(135deg,var(--dig-green-600),var(--dig-green-800))] p-5 text-[var(--dig-white)] sm:p-8"
>
<span
aria-hidden="true"
class="absolute inset-0 -z-10 bg-[radial-gradient(color-mix(in_oklab,var(--dig-white)_30%,var(--dig-green-800))_1.2px,transparent_1.3px)] [background-size:18px_18px] [mask-image:linear-gradient(to_left,black,transparent_70%)]"
></span>
<span
aria-hidden="true"
class="absolute -end-6 -bottom-8 flex size-36 rotate-[-12deg] items-center justify-center rounded-3xl bg-[color-mix(in_oklab,var(--dig-white)_16%,var(--dig-green-700))] text-[var(--dig-white)] sm:-end-2 sm:size-48 [&>svg]:size-16 sm:[&>svg]:size-24"
><svg digIcon="first-aid-kit"></svg
></span>
<div class="flex max-w-sm flex-col items-start gap-3 pe-24 sm:pe-0">
<h1 id="rx-title" class="text-xl leading-snug font-black sm:text-3xl">
عکسِ نسخه را بفرست، داروخانه آماده میکند
</h1>
<p class="text-sm leading-6 text-[color-mix(in_oklab,var(--dig-white)_85%,var(--dig-green-800))]">
قیمت در ۱۵ دقیقه اعلام میشود؛ بعد از تأییدِ تو پیک میآورد.
</p>
<button
digControlSize="lg"
digButton
type="button"
class="mt-1 bg-[var(--dig-white)] text-[var(--dig-green-900)] hover:bg-[color-mix(in_oklab,var(--dig-white)_90%,var(--dig-green-800))]"
>
<svg digIcon="cloud-upload"></svg>
بارگذاریِ نسخه
</button>
</div>
</section>
<section aria-labelledby="cat-title" class="flex flex-col gap-4">
<div class="flex items-center justify-between gap-3">
<h2 id="cat-title" class="text-lg leading-snug font-bold">دستهها</h2>
<a href="#" class="flex items-center gap-0.5 text-sm font-medium text-brand-secondary hover:underline">
همه
<svg digIcon="chevron-left" aria-hidden="true" class="size-4"></svg
></a>
</div>
<ul class="grid grid-cols-3 gap-2 sm:grid-cols-6 sm:gap-3">
@for (item of CATEGORIES; track item.id) {
<li>
<a
href="#"
class="flex h-full flex-col items-center gap-2 rounded-xl border border-border bg-card px-2 py-3 text-center text-xs leading-5 font-medium outline-none hover:border-[color-mix(in_oklab,var(--foreground)_30%,var(--border))] focus-visible:ring-[3px] focus-visible:ring-ring/50 sm:text-sm"
><span
aria-hidden="true"
class="flex size-11 items-center justify-center rounded-lg [&>svg]:size-6"
[style]="tint(item.hue)"
><svg [digIcon]="item.icon"></svg
></span>
{{ item.label }}</a
>
</li>
}
</ul>
</section>
<section aria-labelledby="offers-title" class="flex flex-col gap-4">
<div class="flex items-center justify-between gap-3">
<h2 id="offers-title" class="text-lg leading-snug font-bold">پیشنهادهای ویژه</h2>
<a href="#" class="flex items-center gap-0.5 text-sm font-medium text-brand-secondary hover:underline">
همه
<svg digIcon="chevron-left" aria-hidden="true" class="size-4"></svg
></a>
</div>
<!-- موبایل: ردیفِ پیمایشی با کارتِ ۱۶۰ پیکسلی؛ دسکتاپ: گریدِ چهارستونه. -->
<ul
class="-mx-4 flex snap-x gap-3 overflow-x-auto px-4 pb-1 [scrollbar-width:none] sm:mx-0 sm:grid sm:grid-cols-4 sm:overflow-visible sm:px-0"
>
@for (item of OFFERS; track item.id) {
<li class="w-40 shrink-0 snap-start sm:w-auto">
<article digProductCard size="sm" class="h-full w-full">
<div digProductCardMedia>
<img [src]="stockImages[item.image].src" [alt]="stockImages[item.image].alt" loading="lazy" />
</div>
<div digProductCardBody>
<span digProductCardCategory>{{ item.brand }}</span>
<h3 digProductCardTitle>{{ item.title }}</h3>
@if (item.rx) {
<span digBadge variant="soft" color="warning" class="w-fit">نیاز به نسخه</span>
}
<div
digProductCardPrice
[amount]="formatCurrency(item.price)"
[originalAmount]="item.oldPrice ? formatCurrency(item.oldPrice) : undefined"
[discount]="
item.oldPrice
? \`٪\${toFaDigits(math.round((1 - item.price / item.oldPrice) * 100))}\`
: undefined
"
></div>
</div>
<div digProductCardFooter>
@if (item.rx) {
<button digButton type="button" variant="outline" fullWidth>ثبت با نسخه</button>
} @else {
<div
digAddToCart
fullWidth
label="افزودن"
[itemName]="item.title"
[quantity]="cart()[item.id] ?? 0"
(quantityChange)="setQuantity(item.id, $event)"
></div>
}
</div>
</article>
</li>
}
</ul>
</section>
<section aria-labelledby="near-title" class="flex flex-col gap-4">
<div class="flex items-center justify-between gap-3">
<h2 id="near-title" class="text-lg leading-snug font-bold">داروخانههای نزدیک</h2>
<a href="#" class="flex items-center gap-0.5 text-sm font-medium text-brand-secondary hover:underline">
همه
<svg digIcon="chevron-left" aria-hidden="true" class="size-4"></svg
></a>
</div>
<div class="grid grid-cols-1 gap-3 lg:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]">
<div
digMapView
[center]="MAP_CENTER"
[zoom]="15"
label="نقشهٔ داروخانههای نزدیک"
class="aspect-[2/1] lg:aspect-auto lg:h-full"
>
<span digMapMarkerYou [lat]="at(50, 60).lat" [lng]="at(50, 60).lng" label="موقعیتِ شما"></span>
@for (item of NEARBY; track item.id) {
<button
digMapMarker
[lat]="at(item.x, item.y).lat"
[lng]="at(item.x, item.y).lng"
[label]="item.name"
[active]="active() === item.id"
(click)="active.set(item.id)"
></button>
}
</div>
<ul class="flex flex-col divide-y divide-border rounded-xl border border-border bg-card">
@for (item of NEARBY; track item.id) {
<li>
<a
href="#"
[attr.aria-current]="active() === item.id ? 'true' : undefined"
class="flex items-center gap-3 p-4 outline-none hover:bg-subtle focus-visible:bg-subtle aria-[current=true]:bg-primary-subtle"
(focus)="active.set(item.id)"
(mouseenter)="active.set(item.id)"
><span class="flex min-w-0 flex-1 flex-col gap-0.5"
><span class="truncate font-semibold">{{ item.name }}</span>
<span class="flex flex-wrap items-center gap-x-2 text-sm text-muted-foreground"
>{{ item.distance }}
<span aria-hidden="true">·</span>
<span
[class]="
item.open ? 'font-medium text-success-subtle-foreground' : 'font-medium text-destructive'
"
>{{ item.open ? "باز" : "بسته" }}</span
>
<span>{{ item.hours }}</span></span
></span
>
<svg digIcon="chevron-left" aria-hidden="true" class="size-5 shrink-0 text-muted-foreground"></svg
></a>
</li>
}
</ul>
</div>
</section>
</main>
<nav
digBottomNavigation
[value]="tab()"
(valueChange)="typeof $event === 'string' && tab.set($event)"
indicator="pill"
[fixed]="false"
class="sticky bottom-0 sm:hidden"
>
<button digBottomNavigationItem value="home" label="خانه"><svg digIcon="dashboard"></svg></button>
<button digBottomNavigationItem value="catalog" label="دستهها"><svg digIcon="grid"></svg></button>
<button digBottomNavigationItem value="cart" label="سبد">
<svg digIcon="shopping-cart"></svg
><span digBottomNavigationBadge
><span digBadge color="destructive">{{ toFaDigits(cartCount()) }}</span></span
>
</button>
<button digBottomNavigationItem value="saved" label="ذخیرهها"><svg digIcon="heart"></svg></button>
<button digBottomNavigationItem value="profile" label="حساب"><svg digIcon="user"></svg></button>
</nav>
</div>
`,
})
export class PharmacyHomeBlock {
readonly math = Math
readonly toFaDigits = toFaDigits
readonly formatCurrency = formatCurrency
readonly tint = tint
readonly NEARBY = NEARBY
readonly OFFERS = OFFERS
readonly CATEGORIES = CATEGORIES
readonly at = at
readonly MAP_CENTER = MAP_CENTER
readonly stockImages = stockImages
readonly cart = signal<Record<string, number>>({})
readonly tab = signal("home")
readonly active = signal("1")
readonly cartCount = computed(() => Object.values(this.cart()).reduce((sum, qty) => sum + qty, 0))
setQuantity(id: string, quantity: number | undefined) {
if (quantity !== undefined) this.cart.update((cart) => ({ ...cart, [id]: quantity }))
}
}
کدِ این بلاک هنوز برای Android نوشته نشده است.
همهٔ کامپوننتهای لازم برای Android آمادهاند؛ با MCP میتوانید همین صفحه را از روی نسخهٔ React بسازید.
کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="android" ایجنت آن را با کامپوننتهای Android میسازد.