المكوّنات · بطاقة شحنة
بطاقة شحنة
الأيام المتبقّية والتأخّر محسوبان من التواريخ
12 تصاميم من هذه العائلة
<div class="cd cds"><article class="card">
<div class="hd"><span class="awb num">SA-77410-3</span>
<span class="st"></span></div>
<div class="route">
<div class="p"><b data-ar="جدّة" data-en="Jeddah">جدّة</b><span class="d1 num"></span></div>
<div class="mid"><div class="bar"><i></i></div><span class="pctl num"></span></div>
<div class="p end"><b data-ar="الدمّام" data-en="Dammam">الدمّام</b><span class="d2 num"></span></div>
</div>
<div class="ft"><span class="wt num"></span><span class="left num"></span></div>
</article></div>
/* pt-scoped */
/* card-shipment — شحن ولوجستيات */
.cds{width:100%;height:100%;display:flex;align-items:center;justify-content:center;
padding:8px;font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.cds .card{display:flex;overflow:hidden;background:var(--pt-surface);
border:1px solid var(--pt-border-subtle)}
.cds h5{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.cds p{margin:0;font-size:8.5px;color:var(--pt-text-muted);line-height:1.7}
.cds .num{font-variant-numeric:tabular-nums;letter-spacing:-.01em}
.cds .img{flex:none;position:relative;overflow:hidden}
.cds button{font:inherit;cursor:pointer}
.cds button:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:1px}
.cds .bar{height:3px;border-radius:99px;background:var(--pt-border-subtle);overflow:hidden}
.cds .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){.cds .bar i{transition:none}
}
/* شكل: أفقية المسار، حدّ سميك أعلى، انحناء متوسّط */
.cds .card{flex-direction:column;width:228px;gap:8px;padding:10px;
border-radius:var(--pt-radius-md);border-block-start:3px solid var(--pt-accent)}
.cds .hd{display:flex;align-items:center;justify-content:space-between;gap:8px}
.cds .awb{font-size:8.5px;color:var(--pt-text-secondary);font-family:var(--pt-font-mono)}
.cds .st{padding:2px 7px;border-radius:var(--pt-radius-xs);font-size:7.5px;font-weight:700}
.cds .st.ok{background:var(--pt-accent-muted);color:var(--pt-accent)}
.cds .st.late{background:color-mix(in srgb,var(--pt-color-danger-400) 20%,transparent);
color:var(--pt-color-danger-400)}
.cds .route{display:flex;align-items:center;gap:9px}
.cds .p{display:flex;flex-direction:column;gap:1px}
.cds .p.end{text-align:end}
.cds .p b{font-size:10px;color:var(--pt-text-primary)}
.cds .p span{font-size:7.5px;color:var(--pt-text-muted)}
.cds .mid{flex:1;display:flex;flex-direction:column;align-items:center;gap:3px}
.cds .mid .bar{width:100%}
.cds .pctl{font-size:7.5px;color:var(--pt-accent);font-weight:700}
.cds .ft{display:flex;align-items:baseline;justify-content:space-between;gap:8px;
padding-top:6px;border-top:1px solid var(--pt-border-subtle);font-size:8px;
color:var(--pt-text-muted)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.cds');
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 SHIPPED = -4, DUE = 2; /* بالأيام من اليوم */
var WEIGHT = 18.4, PROGRESS_KM = 780, TOTAL_KM = 1340;
function dayShift(k) {
var d = new Date(); d.setHours(0, 0, 0, 0); d.setDate(d.getDate() + k); return d;
}
function fmt(d) {
return d.toLocaleDateString(ar ? 'ar-SA-u-nu-latn' : 'en-GB',
{ day: 'numeric', month: 'short' });
}
var today = dayShift(0), due = dayShift(DUE);
set('.d1', fmt(dayShift(SHIPPED)));
set('.d2', fmt(due));
// المقارنة على مستوى اليوم لا بالملّي ثانية — وإلّا انقلب «اليوم» إلى «غدًا»
var left = Math.round((due - today) / 864e5);
var st = root.querySelector('.st');
st.className = 'st ' + (left < 0 ? 'late' : 'ok');
st.textContent = left < 0 ? (ar ? 'متأخّرة' : 'Delayed') : (ar ? 'في الموعد' : 'On time');
set('.left', left === 0 ? (ar ? 'تصل اليوم' : 'Arrives today')
: left > 0 ? (ar ? 'تصل خلال ' + left + ' يومًا' : 'Arrives in ' + left + ' days')
: (ar ? 'متأخّرة ' + (-left) + ' يومًا' : (-left) + ' days late'));
set('.wt', n(WEIGHT, 1) + (ar ? ' كجم' : ' kg'));
var pct = Math.round(PROGRESS_KM / TOTAL_KM * 100);
set('.pctl', pct + '%');
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(); });
})();
# Shipment 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:** Shipment Card — Days left and delay computed from the dates themselves
**Why this component matters:** Compare dates at day granularity, not by millisecond subtraction: two timestamps hours apart can land on different days and flip “arrives today” to “arrives tomorrow”.
**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.