المكوّنات · بطاقة دورة بتقدّم
بطاقة دورة بتقدّم
النسبة والوقت المتبقّي محسوبان من الدروس
12 تصاميم من هذه العائلة
<div class="cd cdc"><article class="card">
<div class="head"><span class="ico" aria-hidden="true">◐</span>
<div><h5 data-ar="أساسيّات تحليل البيانات" data-en="Data Analysis Fundamentals">أساسيّات تحليل البيانات</h5>
<p data-ar="المسار المهني · المستوى الثاني" data-en="Career track · Level 2">المسار المهني · المستوى الثاني</p></div></div>
<div class="prog"><div class="pl"><span class="pct num"></span>
<span class="lc num"></span></div><div class="bar"><i></i></div></div>
<div class="foot"><span class="left num"></span>
<button class="go" data-ar="متابعة" data-en="Continue">متابعة</button></div>
</article></div>
/* pt-scoped */
/* card-course — منصّة تعليمية */
.cdc{width:100%;height:100%;display:flex;align-items:center;justify-content:center;
padding:8px;font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.cdc .card{display:flex;overflow:hidden;background:var(--pt-surface);
border:1px solid var(--pt-border-subtle)}
.cdc h5{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.cdc p{margin:0;font-size:8.5px;color:var(--pt-text-muted);line-height:1.7}
.cdc .num{font-variant-numeric:tabular-nums;letter-spacing:-.01em}
.cdc .img{flex:none;position:relative;overflow:hidden}
.cdc button{font:inherit;cursor:pointer}
.cdc button:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:1px}
.cdc .bar{height:3px;border-radius:99px;background:var(--pt-border-subtle);overflow:hidden}
.cdc .bar i{display:block;height:100%;background:var(--pt-accent);border-radius:inherit;
transition:width var(--pt-motion-duration-slow) var(--pt-motion-easing-standard)}
@media(prefers-reduced-motion:reduce){.cdc .bar i{transition:none}
}
/* شكل: أفقية الرأس، حدّ جانبي ملوّن، انحناء صغير */
.cdc .card{flex-direction:column;width:206px;gap:8px;padding:10px;
border-radius:var(--pt-radius-sm);border-inline-start:3px solid var(--pt-accent)}
.cdc .head{display:flex;gap:8px;align-items:flex-start}
.cdc .ico{flex:none;width:26px;height:26px;display:grid;place-items:center;
border-radius:var(--pt-radius-sm);background:var(--pt-accent-muted);
color:var(--pt-accent);font-size:13px}
.cdc .prog{display:flex;flex-direction:column;gap:4px}
.cdc .pl{display:flex;align-items:baseline;justify-content:space-between;font-size:8px}
.cdc .pct{font-size:11px;font-weight:700;color:var(--pt-text-primary)}
.cdc .lc{color:var(--pt-text-muted)}
.cdc .foot{display:flex;align-items:center;justify-content:space-between;gap:8px}
.cdc .left{font-size:8px;color:var(--pt-text-muted)}
.cdc .go{padding:5px 12px;border-radius:var(--pt-radius-sm);border:0;
background:var(--pt-accent);color:var(--pt-color-ink-900);font-size:9px;font-weight:600}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.cdc');
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 PEG = 3.75; /* الريال مربوط بالدولار */
var n = function (v, d) { return Number(v).toLocaleString('en-US', {
minimumFractionDigits: d || 0, maximumFractionDigits: d || 0 }); };
/* العملة: ر.س بعد الرقم عربيًّا، $ قبله إنجليزيًّا */
var money = function (usd, d) {
return ar ? n(usd * PEG, d) + ' ر.س' : '$' + n(usd, d);
};
var set = function (sel, txt) {
var el = root.querySelector(sel); if (el) el.textContent = txt; return el;
};
/* الدروس هي المصدر — النسبة والوقت مشتقّان منها لا مخزَّنان */
var LESSONS = [
{ m: 12, done: true }, { m: 18, done: true }, { m: 9, done: true },
{ m: 22, done: true }, { m: 15, done: true }, { m: 20, done: false },
{ m: 14, done: false }, { m: 25, done: false }
];
var done = LESSONS.filter(function (l) { return l.done; });
var pct = Math.round(done.length / LESSONS.length * 100);
var mins = LESSONS.filter(function (l) { return !l.done; })
.reduce(function (a, l) { return a + l.m; }, 0);
set('.pct', pct + '%');
set('.lc', done.length + ' / ' + LESSONS.length + (ar ? ' درسًا' : ' lessons'));
set('.left', ar ? 'يتبقّى ' + Math.floor(mins / 60) + ' س ' + (mins % 60) + ' د'
: Math.floor(mins / 60) + 'h ' + (mins % 60) + 'm left');
requestAnimationFrame(function () { root.querySelector('.bar i').style.width = pct + '%'; });
}
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(); });
})();
# Course Card with Progress
**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:** Course Card with Progress — Percentage and time left derived from the lesson list
**Why this component matters:** Progress must come from the lesson data, not a stored percentage — and the remaining time should be the sum of unfinished lessons, not an estimate.
**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.