المكوّنات · رأس وعمود ثابتان
رأس وعمود ثابتان
الرأس يثبت رأسيًّا والعمود الأوّل أفقيًّا، والزاوية فوقهما
12 تصاميم من هذه العائلة
<div class="tb tbk">
<div class="head"><h4 data-ar="أسعار الشحن حسب الوزن" data-en="Shipping rates by weight">أسعار الشحن حسب الوزن</h4>
<span class="cnt" data-ar="مرّر أفقيًّا ورأسيًّا" data-en="Scroll both ways">مرّر أفقيًّا ورأسيًّا</span></div>
<div class="wrap"><table><thead><tr></tr></thead><tbody></tbody></table></div>
</div>
/* pt-scoped */
/* table-sticky — جدول أسعار */
.tbk{width:100%;height:100%;display:flex;flex-direction:column;gap:6px;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden;padding:9px 10px}
.tbk .wrap{flex:1;min-height:0;overflow:auto;border-radius:var(--pt-radius-sm);
border:1px solid var(--pt-border-subtle)}
.tbk table{width:100%;border-collapse:collapse;font-size:8.5px}
.tbk th, .tbk td{padding:5px 7px;text-align:start;white-space:nowrap}
.tbk thead th{position:sticky;inset-block-start:0;z-index:2;background:var(--pt-bg-inset);
color:var(--pt-text-muted);font-weight:500;font-size:8px;
border-bottom:1px solid var(--pt-border-default)}
.tbk tbody tr{border-bottom:1px solid var(--pt-border-subtle)}
.tbk tbody tr:last-child{border-bottom:0}
.tbk tbody tr:hover{background:var(--pt-surface-hover)}
.tbk tbody td{color:var(--pt-text-secondary)}
.tbk .e{text-align:end;font-variant-numeric:tabular-nums}
.tbk .head{display:flex;align-items:center;gap:7px;flex-wrap:wrap}
.tbk .head h4{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600}
.tbk .cnt{font-size:8px;color:var(--pt-text-muted);font-variant-numeric:tabular-nums;
margin-inline-start:auto}
.tbk button{font:inherit;cursor:pointer}
.tbk button:focus-visible, .tbk input:focus-visible, .tbk select:focus-visible, .tbk th:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:-2px}
.tbk .empty{padding:12px;text-align:center;font-size:9px;color:var(--pt-text-muted)}
/* شخصية: تثبيت مزدوج، زاوية فوق الاثنين، انحناء صغير */
.tbk .wrap{overflow:auto}
.tbk table{min-width:420px}
.tbk thead th{position:sticky;inset-block-start:0;z-index:2}
/* العمود الأوّل: تثبيت أفقي بـinset-inline-start فيتبع الاتجاه */
.tbk tbody th{position:sticky;inset-inline-start:0;z-index:1;
background:var(--pt-bg-inset);color:var(--pt-text-primary);font-weight:600;
font-size:8.5px;border-inline-end:1px solid var(--pt-border-default)}
/* الزاوية فوق الاثنين — بلا ذلك تنزلق تحت الرأس فيختفي عنوانها */
.tbk thead th:first-child{inset-inline-start:0;z-index:3;
border-inline-end:1px solid var(--pt-border-default)}
.tbk td{font-variant-numeric:tabular-nums;text-align:end}
.tbk td.cheap{color:var(--pt-accent);font-weight:600}
.tbk .cnt{font-size:7.5px}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.tbk');
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';
/* العملة: د.أ (JOD) — سوق الأردن.
الأرقام مخزَّنة بـالريال وتُحوَّل، فتبقى
المبالغ معقولة في كل سوق. والتحويل لا التبديل: «18,500» راتبًا بالريال
معقول، وبالدينار الأردني ثروة.
وثلاث خانات عشرية — الدينار يُقسَّم إلى ألف فلس. */
var money = (function () {
var RATE = 0.709, DEC = 3;
return function (v, d) {
var out = (Number(v) / 3.75) * RATE;
var places = d === undefined ? DEC : d;
var s = out.toLocaleString('en-US', {
minimumFractionDigits: places, maximumFractionDigits: places });
return ar ? s + ' د.أ' : 'JOD ' + s;
};
})();
/* المدن: متنوّعة عبر العرب — وجهات أو أسماء لا ترتبط بعملة المكوّن */
var ANYTOWN = ar ? ['الدار البيضاء', 'العقبة', 'الدوحة', 'الفروانية', 'صحار', 'القاهرة']
: ['Casablanca', 'Aqaba', 'Doha', 'Farwaniya', 'Sohar', 'Cairo'];
/* وجهات عابرة للحدود: التعرفة بعملة البائع والوجهة في بلد آخر —
وهو الحال الشائع في الشحن، لا استثناء فيه. */
var ZONES = ANYTOWN;
var WEIGHTS = [1, 3, 5, 10, 20];
var BASE = [18, 24, 26, 34, 38, 42]; /* أساس لكل وجهة */
/* السعر مشتقّ: أساس الوجهة + معامل الوزن. جدول مكتوب يدويًّا بثلاثين
خلية يتقادم مع أوّل تعديل تعرفة. */
function price(zi, w) { return Math.round(BASE[zi] + w * 4.5 + (w > 10 ? 12 : 0)); }
var hd = root.querySelector('thead tr');
hd.innerHTML = '<th scope="col">' + (ar ? 'الوجهة' : 'Destination') + '</th>' +
WEIGHTS.map(function (w) {
return '<th scope="col">' + w + (ar ? ' كجم' : ' kg') + '</th>';
}).join('');
root.querySelector('tbody').innerHTML = ZONES.map(function (z, zi) {
var row = WEIGHTS.map(function (w) { return price(zi, w); });
var min = Math.min.apply(null, row);
return '<tr><th scope="row">' + z + '</th>' +
row.map(function (p) {
return '<td class="' + (p === min ? 'cheap' : '') + '">' + money(p, 0) + '</td>';
}).join('') + '</tr>';
}).join('');
}
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(); });
})();
# Sticky Header and First Column
**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:** Sticky Header and First Column — Header sticks vertically, first column horizontally, and the corner above both
**Why this component matters:** Sticky rows and columns need explicit z-index layering: the corner cell must sit above both, or it slides under the header and the label disappears exactly when it is needed.
**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.