المكوّنات · بطاقة رحلة
بطاقة رحلة
المدّة محسوبة من التوقيتين مع فرق المنطقة
12 تصاميم من هذه العائلة
<div class="cd cdf"><article class="card">
<div class="top"><span class="al" data-ar="الخطوط السعودية · SV 553" data-en="Saudia · SV 553">الخطوط السعودية · SV 553</span>
<span class="cls" data-ar="اقتصادي" data-en="Economy">اقتصادي</span></div>
<div class="leg">
<div class="pt"><b class="num t1"></b><span class="cd3">RUH</span></div>
<div class="path"><span class="dur num"></span><span class="line" aria-hidden="true"></span>
<span class="stop" data-ar="مباشرة" data-en="Direct">مباشرة</span></div>
<div class="pt end"><b class="num t2"></b><span class="cd3">DXB</span></div>
</div>
<div class="notch" aria-hidden="true"></div>
<div class="bot"><span class="seat" data-ar="المقعد 14A" data-en="Seat 14A">المقعد 14A</span>
<b class="fare num"></b></div>
</article></div>
/* pt-scoped */
/* card-flight — شركة طيران */
.cdf{width:100%;height:100%;display:flex;align-items:center;justify-content:center;
padding:8px;font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.cdf .card{display:flex;overflow:hidden;background:var(--pt-surface);
border:1px solid var(--pt-border-subtle)}
.cdf h5{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.cdf p{margin:0;font-size:8.5px;color:var(--pt-text-muted);line-height:1.7}
.cdf .num{font-variant-numeric:tabular-nums;letter-spacing:-.01em}
.cdf .img{flex:none;position:relative;overflow:hidden}
.cdf button{font:inherit;cursor:pointer}
.cdf button:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:1px}
.cdf .bar{height:3px;border-radius:99px;background:var(--pt-border-subtle);overflow:hidden}
.cdf .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){.cdf .bar i{transition:none}
}
/* شكل: تذكرة بشقّين جانبيّين، انحناء متوسّط */
.cdf .card{position:relative;flex-direction:column;width:212px;gap:7px;padding:10px;
border-radius:var(--pt-radius-md);background:var(--pt-bg-inset)}
.cdf .top{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:8.5px}
.cdf .al{color:var(--pt-text-secondary);font-weight:600}
.cdf .cls{padding:2px 6px;border-radius:var(--pt-radius-full);
background:var(--pt-accent-muted);color:var(--pt-accent);font-size:7.5px}
.cdf .leg{display:flex;align-items:center;gap:8px}
.cdf .pt{display:flex;flex-direction:column;gap:1px}
.cdf .pt.end{text-align:end}
.cdf .pt b{font-size:14px;color:var(--pt-text-primary);font-weight:700}
.cdf .cd3{font-size:8px;color:var(--pt-text-muted);letter-spacing:.08em}
.cdf .path{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px}
.cdf .dur{font-size:8px;color:var(--pt-text-secondary)}
.cdf .line{width:100%;height:1px;background:var(--pt-border-strong);position:relative}
.cdf .line::before, .cdf .line::after{content:'';position:absolute;inset-block-start:-2px;
width:5px;height:5px;border-radius:50%;background:var(--pt-accent)}
.cdf .line::before{inset-inline-start:0}
.cdf .line::after{inset-inline-end:0}
.cdf .stop{font-size:7.5px;color:var(--pt-text-muted)}
.cdf .notch{border-top:1px dashed var(--pt-border-strong);margin:0 -10px;position:relative}
.cdf .notch::before, .cdf .notch::after{content:'';position:absolute;inset-block-start:-6px;
width:12px;height:12px;border-radius:50%;background:var(--pt-bg-base)}
.cdf .notch::before{inset-inline-start:-6px}
.cdf .notch::after{inset-inline-end:-6px}
.cdf .bot{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.cdf .seat{font-size:8.5px;color:var(--pt-text-muted)}
.cdf .fare{font-size:12px;color:var(--pt-accent);font-weight:700}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.cdf');
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;
};
/* التوقيت المحلّي في الطرفين مع إزاحته عن UTC — طرح المحلّيين مباشرةً
يعطي مدّة خاطئة، وهذا أكثر خطأ في بطاقات الرحلات. */
var DEP = { hm: '02:15', off: 3 }; // الرياض +3
var ARR = { hm: '05:40', off: 4 }; // دبي +4
var FARE = 168;
function utcMin(t) {
var p = t.hm.split(':');
return (+p[0]) * 60 + (+p[1]) - t.off * 60;
}
var d = utcMin(ARR) - utcMin(DEP);
if (d < 0) d += 1440; // عبور منتصف الليل
set('.t1', DEP.hm);
set('.t2', ARR.hm);
set('.dur', ar ? Math.floor(d / 60) + ' س ' + (d % 60) + ' د'
: Math.floor(d / 60) + 'h ' + (d % 60) + 'm');
set('.fare', money(FARE));
}
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(); });
})();
# Flight 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:** Flight Card — Duration computed from both times including the timezone offset
**Why this component matters:** Subtracting local departure from local arrival gives the wrong duration across timezones. Convert both to UTC first, then format — this is the bug in most flight cards.
**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.