diff --git a/src/pages/Home/sections/RiskSection.tsx b/src/pages/Home/sections/RiskSection.tsx index 64227b8..1b46679 100644 --- a/src/pages/Home/sections/RiskSection.tsx +++ b/src/pages/Home/sections/RiskSection.tsx @@ -161,6 +161,65 @@ const T = { }, } +/* ─── Shared card ───────────────────────────────────────── */ +function RiskCard({ + item, cfg, lang, idx, mobile, +}: { + item: RiskItem + cfg: { dot: string; label: string; bg: string } + lang: 'fa' | 'en' + idx: number + mobile?: boolean +}) { + const text = lang === 'en' && item.quoteEn ? item.quoteEn : item.quote + const name = lang === 'en' && item.nameEn ? item.nameEn : item.name + const date = lang === 'en' && item.dateEn ? item.dateEn : item.date + + return ( +
+
+
+ + {cfg.label} + +
+ +

+ {text} +

+ +
+
+
{name}
+
{date}
+
+
+ {cfg.label} +
+
+
+ ) +} + /* ─── Section ────────────────────────────────────────────── */ export default function RiskSection() { const { lang } = useLang() @@ -252,7 +311,7 @@ export default function RiskSection() { {/* ── Slider ── */}
setPaused(true)} onMouseLeave={() => setPaused(false)} onTouchStart={e => { touchStartX.current = e.touches[0].clientX }} @@ -261,81 +320,50 @@ export default function RiskSection() { if (Math.abs(dx) > 50) go(dx > 0 ? 'next' : 'prev') }} > - {/* Cards row */} -
- {visibleItems.map((item, idx) => { - const cfg = levelCfg[item.level] - return ( -
0 ? 'max-md:hidden' : ''} - style={{ - background: 'var(--paper)', - border: '1px solid var(--rule-thin)', - borderTop: `3px solid ${cfg.dot}`, - padding: '24px 24px 20px', - direction: 'rtl', - display: 'flex', - flexDirection: 'column', - animation: `riskCardIn 320ms ease both`, - animationDelay: `${idx * 60}ms`, - }} - > -
-
- - {cfg.label} - -
- -

- {lang === 'en' && item.quoteEn ? item.quoteEn : item.quote} -

- -
-
-
{lang === 'en' && item.nameEn ? item.nameEn : item.name}
-
{lang === 'en' && item.dateEn ? item.dateEn : item.date}
-
-
- {cfg.label} -
-
-
- ) - })} + {/* Desktop: 3 cards */} +
+ {visibleItems.map((item, idx) => ( + + ))} +
+ {/* Mobile: 1 card */} +
+ {/* Mobile: single card with slide animation */} +
+ +
- {/* Controls */} -
- {/* Dots */} -
+ {/* Progress bar (mobile) + dots (desktop) + arrows */} +
+ {/* Progress bar on mobile, dots on desktop */} +
+
+
+
{riskItems.map((_, i) => ( -
+ {/* Counter on mobile */} + + {(current + 1).toLocaleString('fa-IR')} / {total.toLocaleString('fa-IR')} + + {/* Arrows */} -
-