المكوّنات · بطاقة وسائط
بطاقة وسائط
نسبة الأبعاد محفوظة والمدّة منسّقة من الثواني
12 تصاميم من هذه العائلة
<div class="cd cdm"><article class="card">
<div class="img"><span class="dur num"></span>
<button class="play" aria-label="تشغيل">▶</button></div>
<div class="body">
<h5 data-ar="هوية بصرية لعلامة قهوة" data-en="Coffee brand identity">هوية بصرية لعلامة قهوة</h5>
<div class="meta"><span class="ratio num"></span><span aria-hidden="true">·</span>
<span class="size num"></span><span aria-hidden="true">·</span>
<span class="views num"></span></div>
</div>
</article></div>
/* pt-scoped */
/* card-media — استوديو تصميم */
.cdm{width:100%;height:100%;display:flex;align-items:center;justify-content:center;
padding:8px;font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.cdm .card{display:flex;overflow:hidden;background:var(--pt-surface);
border:1px solid var(--pt-border-subtle)}
.cdm h5{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.cdm p{margin:0;font-size:8.5px;color:var(--pt-text-muted);line-height:1.7}
.cdm .num{font-variant-numeric:tabular-nums;letter-spacing:-.01em}
.cdm .img{flex:none;position:relative;overflow:hidden}
.cdm button{font:inherit;cursor:pointer}
.cdm button:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:1px}
.cdm .bar{height:3px;border-radius:99px;background:var(--pt-border-subtle);overflow:hidden}
.cdm .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){.cdm .bar i{transition:none}
}
/* شكل: غطاء بنسبة أبعاد محفوظة، زجاجية أسفل، بلا انحناء علوي */
.cdm .card{flex-direction:column;width:196px;border-radius:var(--pt-radius-xs)}
.cdm .img{width:100%;aspect-ratio:16/9;
background:linear-gradient(115deg,#5a3a2e,#8a5c3c 45%,#c99a6b);display:grid;place-items:center}
.cdm .dur{position:absolute;inset-block-end:5px;inset-inline-end:5px;padding:1px 5px;
border-radius:var(--pt-radius-xs);background:rgba(6,10,24,.78);color:#fff;font-size:7.5px}
.cdm .play{width:30px;height:30px;border-radius:50%;border:1px solid rgba(255,255,255,.6);
background:rgba(255,255,255,.18);color:#fff;font-size:10px;backdrop-filter:blur(4px);
display:grid;place-items:center;padding-inline-start:2px;
transition:transform var(--pt-motion-duration-fast) var(--pt-motion-easing-standard)}
.cdm .play:hover{transform:scale(1.08)}
.cdm .play[aria-pressed=true]{padding-inline-start:0}
.cdm .body{display:flex;flex-direction:column;gap:4px;padding:8px 9px 9px}
.cdm .meta{display:flex;align-items:center;gap:5px;font-size:7.5px;color:var(--pt-text-muted)}
@media(prefers-reduced-motion:reduce){.cdm .play{transition:none}
}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.cdm');
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 SECS = 227, W = 1920, H = 1080, BYTES = 48.6e6, VIEWS = 12840;
// التنسيق من الثواني الخام — والساعة تظهر فقط إن وُجدت
var h = Math.floor(SECS / 3600), m = Math.floor(SECS / 60) % 60, s = SECS % 60;
set('.dur', (h ? h + ':' + String(m).padStart(2, '0') : m) + ':' + String(s).padStart(2, '0'));
// النسبة مختصرة بالقاسم المشترك الأكبر لا مكتوبة يدويًّا
var gcd = function (a, b) { return b ? gcd(b, a % b) : a; };
var g = gcd(W, H);
set('.ratio', (W / g) + ':' + (H / g));
set('.size', n(BYTES / 1e6, 1) + ' MB');
set('.views', n(VIEWS) + (ar ? ' مشاهدة' : ' views'));
var play = root.querySelector('.play');
play.addEventListener('click', function () {
var on = play.getAttribute('aria-pressed') === 'true';
play.setAttribute('aria-pressed', String(!on));
play.textContent = on ? '▶' : '❚❚';
play.setAttribute('aria-label', on ? 'تشغيل' : 'إيقاف مؤقّت');
});
}
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(); });
})();
# Media Card
**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:** Media Card — Aspect ratio preserved, duration formatted from raw seconds
**Why this component matters:** Use aspect-ratio so the thumbnail reserves its box before paint — a media card without it shifts the whole grid when the image finally loads.
**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.