المكوّنات · قسم أرقام متصاعدة
قسم أرقام متصاعدة
الأرقام تتصاعد عند ظهورها، وتظهر كاملةً مع تقليل الحركة
12 تصاميم من هذه العائلة
<div class="bk bkn"><section>
<ul class="row"></ul>
</section></div>
/* pt-scoped */
/* block-stats — شركة مقاولات */
.bkn{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.bkn h2{margin:0;font-size:19px;line-height:1.35;color:var(--pt-text-primary);
font-weight:700;letter-spacing:-.01em}
.bkn h3{margin:0;font-size:12px;line-height:1.4;color:var(--pt-text-primary);font-weight:600}
.bkn h4{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600}
.bkn p{margin:0;font-size:9.5px;line-height:1.85;color:var(--pt-text-muted)}
.bkn .eyebrow{font-size:8px;letter-spacing:.14em;color:var(--pt-accent);font-weight:700}
.bkn .num{font-variant-numeric:tabular-nums;letter-spacing:-.01em}
.bkn button, .bkn a{font:inherit;cursor:pointer;text-decoration:none}
.bkn button:focus-visible, .bkn a:focus-visible, .bkn input:focus-visible, .bkn summary:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:2px}
/* الأقسام تمتدّ من حافّة إلى حافّة — هذا ما يميّزها عن المكوّنات */
.bkn > section{flex:1;display:flex;flex-direction:column;justify-content:center;min-height:0}
@media(pointer:coarse){.bkn button, .bkn a{min-height:44px;display:inline-flex;
align-items:center;justify-content:center}
}
/* شخصية: شريط داكن ممتدّ، أرقام ضخمة، بلا حدود */
.bkn > section{padding:16px 26px;
background:linear-gradient(120deg,var(--pt-color-ink-900),var(--pt-color-ink-800))}
.bkn .row{list-style:none;margin:0;padding:0;display:grid;
grid-template-columns:repeat(4,1fr);gap:10px}
.bkn .row li{display:flex;flex-direction:column;align-items:center;gap:2px;text-align:center;
position:relative}
.bkn .row li + li::before{content:'';position:absolute;inset-inline-start:-5px;
inset-block:14%;width:1px;background:rgba(255,255,255,.13)}
.bkn .v{font-size:24px;line-height:1;font-weight:700;color:#fff;
font-variant-numeric:tabular-nums}
.bkn .v .u{font-size:13px;color:var(--pt-accent);margin-inline-start:1px}
.bkn .k{font-size:8px;color:rgba(255,255,255,.62)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.bkn');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
var ar = document.documentElement.lang !== 'en';
var n = function (v, d) { return Number(v).toLocaleString('en-US', {
minimumFractionDigits: d || 0, maximumFractionDigits: d || 0 }); };
var STATS = [
{ v: 312, u: '', ar: 'مشروعًا مسلَّمًا', en: 'projects delivered' },
{ v: 18, u: '', ar: 'سنة خبرة', en: 'years of practice' },
{ v: 96, u: '%', ar: 'تسليم في الموعد', en: 'on-time delivery' },
{ v: 1.4, u: 'M', ar: 'متر مربّع مبنيّ', en: 'sqm built' }
];
var row = root.querySelector('.row');
row.innerHTML = STATS.map(function (s) {
return '<li><span class="v num">0<i class="u">' + s.u + '</i></span>' +
'<span class="k">' + (ar ? s.ar : s.en) + '</span></li>';
}).join('');
var vals = [].slice.call(row.querySelectorAll('.v'));
var reduce = matchMedia('(prefers-reduced-motion: reduce)').matches;
function paint(el, s, v) {
var dec = s.v % 1 !== 0 ? 1 : 0;
el.firstChild.nodeValue = n(v, dec);
}
function run() {
STATS.forEach(function (s, i) {
if (reduce) return paint(vals[i], s, s.v); /* اقفز إلى النهاية */
var t0 = performance.now(), DUR = 1100;
(function step(t) {
var p = Math.min(1, (t - t0) / DUR);
/* تباطؤ في النهاية: الرقم يستقرّ بدل أن يتوقّف فجأةً */
var e = 1 - Math.pow(1 - p, 3);
paint(vals[i], s, s.v * e);
if (p < 1) requestAnimationFrame(step);
})(t0);
});
}
var started = false;
function start(animate) {
if (started) return;
started = true;
if (animate) run();
else STATS.forEach(function (s, i) { paint(vals[i], s, s.v); });
}
/* لا تبدأ قبل الظهور — حركة لا يراها أحد عمل ضائع */
if ('IntersectionObserver' in window) {
var io = new IntersectionObserver(function (es) {
es.forEach(function (e) { if (e.isIntersecting) { io.disconnect(); start(true); } });
}, { threshold: 0.35 });
io.observe(row);
/* شبكة أمان لا غنى عنها: في تبويب مخفيّ لا يُطلق المراقب إطلاقًا، فتبقى
الأرقام أصفارًا. وصفرٌ معروض أسوأ من رقم بلا حركة — فهو يقرأ كخطأ في
البيانات لا كتأثير لم يبدأ. بعد مهلة نعرض القيم كاملةً بلا تحريك. */
setTimeout(function () { start(false); }, 2500);
} else start(false);
}
function mount() {
ac = new AbortController();
var real = window.document;
/* وسيط يمرّر كل شيء إلى المستند الحقيقي، ويعلّق كل مستمع بإشارة
تُقطع عند إعادة التركيب — فلا يبقى مستمع من نسخة ماتت. */
var doc = new Proxy(real, {
get: function (t, k) {
if (k === 'addEventListener') {
return function (type, fn, opts) {
var o = (opts && typeof opts === 'object') ? Object.assign({}, opts)
: { capture: !!opts };
o.signal = ac.signal;
return t.addEventListener(type, fn, o);
};
}
var v = t[k];
return typeof v === 'function' ? v.bind(t) : v;
}
});
function track(fn) {
return function (f, ms) { var id = fn(f, ms); timers.push(id); return id; };
}
run(host, doc, track(window.setTimeout.bind(window)),
track(window.setInterval.bind(window)));
}
function unmount() {
if (ac) ac.abort();
// المعرّفان يتشاركان فضاءً واحدًا في المتصفّح، فالإلغاء المزدوج آمن
timers.forEach(function (id) { window.clearTimeout(id); window.clearInterval(id); });
timers = [];
host.innerHTML = snapshot;
}
mount();
addEventListener('pt-lang', function () { unmount(); mount(); });
})();
# Animated Stats Band
**Role:** You are an Arabic-first UI designer and front-end engineer. Read the whole
specification before writing a single line, then follow it literally. If two requirements
conflict, favour usability over visual effect.
**Goal:** Animated Stats Band — Numbers count up on entry — and appear complete when motion is reduced
**Why this component matters:** Start the count only when the band enters the viewport, and skip straight to the final value under prefers-reduced-motion — an animation nobody sees is wasted work, and one that cannot be stopped is an accessibility failure.
**Direction:** Genuine RTL — not a mirrored Latin layout. Use logical properties
(`margin-inline-start`, `padding-inline`, `inset-inline-start`, `text-align: start`),
never physical ones (`margin-left`, `left`). The layout must flip with `dir` on its own,
with no duplicated rules.
**Typography:** Cairo for Arabic, IBM Plex Sans for Latin. Arabic line-height must be
`0.18` higher than the Latin equivalent — dots, hamzas and maddas need more vertical room.
Arabic font-size runs `1.06×` the Latin size at the same optical weight.
**Numerals:** Western digits in both languages (`1,234.50`). Only the currency changes:
`ر.س` **after** the number in Arabic, `$` **before** it in English. Jordanian dinar
uses **three** decimal places, not two.
**Colors:** Dark mode — background `#0D142B` · surfaces `#211F54` · borders `#545C91` · text `#918FC2`.
Accent `#ADA9E8` must never exceed 8% of the screen area.
**Language:** Bilingual — every string carries both Arabic and English, and the layout
flips with `dir` automatically.
**States:** `default` · `hover` · `focus` · `active` · `disabled` · `loading` · `error`.
Do not design the resting state alone.
**Accessibility:** Contrast ratio at least `4.5:1`, complete keyboard navigation,
visible focus rings, and honour `prefers-reduced-motion`.
**Output:** Clean HTML and CSS in two separate files. No frameworks, no libraries,
no external dependencies.