المكوّنات · بطاقة فاتورة
بطاقة فاتورة
المجموع والضريبة والإجمالي محسوبة من البنود
12 تصاميم من هذه العائلة
<div class="cd cdi"><article class="card">
<div class="hd"><h5 data-ar="فاتورة ضريبية مبسّطة" data-en="Simplified tax invoice">فاتورة ضريبية مبسّطة</h5>
<span class="no num">INV-2481</span></div>
<ul class="items"></ul>
<dl class="totals">
<div><dt data-ar="المجموع" data-en="Subtotal">المجموع</dt><dd class="sub num"></dd></div>
<div><dt class="vt"></dt><dd class="vat num"></dd></div>
<div class="grand"><dt data-ar="الإجمالي" data-en="Total">الإجمالي</dt><dd class="tot num"></dd></div>
</dl>
</article></div>
/* pt-scoped */
/* card-invoice — نظام محاسبة */
.cdi{width:100%;height:100%;display:flex;align-items:center;justify-content:center;
padding:8px;font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.cdi .card{display:flex;overflow:hidden;background:var(--pt-surface);
border:1px solid var(--pt-border-subtle)}
.cdi h5{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.cdi p{margin:0;font-size:8.5px;color:var(--pt-text-muted);line-height:1.7}
.cdi .num{font-variant-numeric:tabular-nums;letter-spacing:-.01em}
.cdi .img{flex:none;position:relative;overflow:hidden}
.cdi button{font:inherit;cursor:pointer}
.cdi button:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:1px}
.cdi .bar{height:3px;border-radius:99px;background:var(--pt-border-subtle);overflow:hidden}
.cdi .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){.cdi .bar i{transition:none}
}
/* شكل: مستند رسمي — بلا انحناء تقريبًا، حدود صريحة */
.cdi .card{flex-direction:column;width:216px;gap:7px;padding:10px;
border-radius:var(--pt-radius-xs);border-color:var(--pt-border-default)}
.cdi .hd{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.cdi .no{font-size:8px;color:var(--pt-text-muted);font-family:var(--pt-font-mono)}
.cdi .items{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:3px}
.cdi .items li{display:grid;grid-template-columns:1fr auto auto;gap:8px;align-items:baseline;
font-size:8.5px;padding-bottom:3px;border-bottom:1px dotted var(--pt-border-subtle)}
.cdi .items .q{color:var(--pt-text-muted);font-size:8px}
.cdi .items .a{color:var(--pt-text-secondary);font-variant-numeric:tabular-nums}
.cdi .totals{margin:0;display:flex;flex-direction:column;gap:3px;font-size:8.5px}
.cdi .totals div{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.cdi .totals dt{color:var(--pt-text-muted)}
.cdi .totals dd{margin:0;color:var(--pt-text-secondary)}
.cdi .grand{padding-top:5px;border-top:1px solid var(--pt-border-default)}
.cdi .grand dt{color:var(--pt-text-primary);font-weight:600}
.cdi .grand dd{color:var(--pt-accent);font-weight:700;font-size:11.5px}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.cdi');
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 VAT = 0.15;
var ITEMS = [
{ ar: 'استضافة سنوية', en: 'Annual hosting', q: 1, p: 96 },
{ ar: 'تصميم واجهات', en: 'UI design', q: 3, p: 140 },
{ ar: 'صيانة شهرية', en: 'Monthly upkeep', q: 6, p: 32 }
];
root.querySelector('.items').innerHTML = ITEMS.map(function (it) {
return '<li><span>' + (ar ? it.ar : it.en) + '</span>' +
'<span class="q">×' + it.q + '</span>' +
'<span class="a">' + money(it.q * it.p, 2) + '</span></li>';
}).join('');
// التقريب مرّة واحدة عند الإجمالي: جمع بنود مقرَّبة ينحرف بهللة
var sub = ITEMS.reduce(function (a, it) { return a + it.q * it.p; }, 0);
set('.sub', money(sub, 2));
set('.vat', money(sub * VAT, 2));
set('.tot', money(sub * (1 + VAT), 2));
set('.vt', ar ? 'ضريبة القيمة المضافة 15%' : 'VAT 15%');
}
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(); });
})();
# Invoice 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:** Invoice Card — Subtotal, VAT and total all computed from the line items
**Why this component matters:** Round once at the total, not per line: summing pre-rounded lines drifts by a halala and the printed invoice stops reconciling with the ledger.
**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.