المكوّنات · لوحة اختيار وسيلة الدفع
لوحة اختيار وسيلة الدفع
كل وسيلة برسومها، والإجمالي يُعاد حسابه عند التبديل
7 تصاميم من هذه العائلة
<div class="ap apsy"><div class="ph">
<div class="sb"><span class="tm num"></span>
<span class="r" aria-hidden="true"><span>▲</span><span>◗</span><span class="bt num"></span></span></div>
<div class="scr"><div class="body">
<h6 data-ar="إتمام الطلب" data-en="Checkout">إتمام الطلب</h6>
<ul class="cart"></ul>
<div class="tt"><span data-ar="الإجمالي" data-en="Total">الإجمالي</span><b class="grand num"></b></div>
<button class="op" aria-expanded="false"><span class="mth"></span><span aria-hidden="true">⌄</span></button>
<button class="pay" data-ar="ادفع الآن" data-en="Pay now">ادفع الآن</button>
</div></div>
<div class="scrim" hidden></div>
<section class="sheet" hidden aria-label="وسائل الدفع">
<div class="grab" role="separator" aria-label="مقبض اللوحة"></div>
<div class="sh"><b data-ar="اختر وسيلة الدفع" data-en="Choose payment method">اختر وسيلة الدفع</b></div>
<ul class="mm" role="radiogroup" aria-label="وسائل الدفع"></ul>
</section>
<div class="safe"></div>
</div></div>
/* pt-scoped */
/* appsheet-payment — بوّابة دفع */
.apsy{width:100%;height:100%;display:flex;align-items:center;
justify-content:center;padding:6px;font-size:10px;color:var(--pt-text-secondary);
overflow:hidden}
.apsy .ph{position:relative;width:198px;height:100%;max-height:224px;display:flex;
flex-direction:column;overflow:hidden;background:var(--pt-bg-base);
border:1px solid var(--pt-border-default);border-radius:20px;
box-shadow:var(--pt-shadow-3)}
/* شريط الحالة — ليس تزيينًا: يثبت أعلى الشاشة فلا يبدأ المحتوى عند الحافّة */
.apsy .sb{flex:none;display:flex;align-items:center;justify-content:space-between;
padding:5px 12px 2px;font-size:7px;color:var(--pt-text-muted);
font-variant-numeric:tabular-nums}
.apsy .sb .r{display:flex;gap:3px}
.apsy .scr{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.apsy .body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
-webkit-overflow-scrolling:touch}
.apsy .body::-webkit-scrollbar{width:0}
/* المنطقة الآمنة السفلية — شريط الإيماءات يأكل ما تحته */
.apsy .safe{flex:none;height:9px;display:grid;place-items:center}
.apsy .safe::after{content:'';width:52px;height:3px;border-radius:99px;
background:var(--pt-border-strong)}
.apsy h6{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.apsy p{margin:0;font-size:8px;color:var(--pt-text-muted);line-height:1.65}
.apsy .num{font-variant-numeric:tabular-nums}
.apsy button{font:inherit;cursor:pointer;
transition:background var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
color var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
transform var(--pt-motion-duration-fast) var(--pt-motion-easing-standard)}
.apsy button:focus-visible, .apsy a:focus-visible, .apsy input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
/* هدف اللمس: 44 بكسلًا على الشاشات اللمسية، ومساحة نقر ممتدّة على غيرها */
@media(pointer:coarse){.apsy .tap{min-width:44px;min-height:44px}
}
.apsy .tap{position:relative}
.apsy .tap::before{content:'';position:absolute;inset:-6px}
@media(prefers-reduced-motion:reduce){.apsy *{transition:none!important;animation:none!important}
}
.apsy .ph{position:relative}
.apsy .body{padding:9px 12px;display:flex;flex-direction:column;gap:6px}
.apsy .cart{list-style:none;margin:4px 0 0;padding:0;display:flex;flex-direction:column;gap:4px}
.apsy .cart li{display:flex;align-items:baseline;justify-content:space-between;gap:8px;
font-size:8.5px;color:var(--pt-text-secondary)}
.apsy .cart .v{font-variant-numeric:tabular-nums}
.apsy .tt{display:flex;align-items:baseline;justify-content:space-between;gap:8px;
padding-top:6px;border-top:1px solid var(--pt-border-default);font-size:8.5px;
color:var(--pt-text-muted)}
.apsy .grand{font-size:14px;color:var(--pt-accent);font-weight:700}
.apsy .op{display:flex;align-items:center;justify-content:space-between;gap:8px;
padding:8px 11px;border-radius:10px;border:1px solid var(--pt-border-default);
background:var(--pt-bg-inset);color:var(--pt-text-primary);font-size:9px;margin-top:3px}
.apsy .pay{padding:10px;border-radius:10px;border:0;background:var(--pt-accent);
color:var(--pt-color-ink-900);font-size:10px;font-weight:700}
.apsy .sheet{position:absolute;inset-inline:0;inset-block-end:0;z-index:6;
display:flex;flex-direction:column;background:var(--pt-bg-overlay);
border-start-start-radius:16px;border-start-end-radius:16px;
border:1px solid var(--pt-border-default);border-bottom:0;box-shadow:var(--pt-shadow-5);
transition:transform var(--pt-motion-duration-normal) var(--pt-motion-easing-emphasized)}
.apsy .grab{flex:none;padding:7px 0 3px;display:grid;place-items:center;cursor:grab;
touch-action:none}
.apsy .grab::after{content:'';width:34px;height:4px;border-radius:99px;background:var(--pt-border-strong)}
.apsy .scrim{position:absolute;inset:0;z-index:5;background:rgba(5,9,26,.55)}
.apsy .sh{flex:none;padding:2px 13px 8px;border-bottom:1px solid var(--pt-border-subtle)}
.apsy .sh b{font-size:10px;color:var(--pt-text-primary)}
.apsy .mm{list-style:none;margin:0;padding:6px 9px 12px;display:flex;flex-direction:column;gap:4px}
.apsy .mm li{display:flex;align-items:center;gap:9px;padding:9px 10px;border-radius:10px;
border:1px solid var(--pt-border-default);background:transparent;cursor:pointer}
.apsy .mm li[aria-checked=true]{border-color:var(--pt-accent);background:var(--pt-accent-muted)}
.apsy .mm .e{font-size:15px}
.apsy .mm .t{font-size:9px;color:var(--pt-text-primary)}
.apsy .mm .f{font-size:7.5px;color:var(--pt-text-muted)}
.apsy .mm .rd{width:14px;height:14px;border-radius:50%;flex:none;
border:1.5px solid var(--pt-border-strong);display:grid;place-items:center}
.apsy .mm li[aria-checked=true] .rd{border-color:var(--pt-accent)}
.apsy .mm li[aria-checked=true] .rd::after{content:'';width:7px;height:7px;border-radius:50%;
background:var(--pt-accent)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.apsy');
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 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 * 3.75, d) + ' ر.س' : '$' + n(usd, d);
};
var set = function (sel, txt) {
var el = root.querySelector(sel); if (el) el.textContent = txt; return el;
};
/* الساعة بأرقام لاتينية دائمًا — قرار موحّد في المشروع كلّه */
(function clock() {
var t = root.querySelector('.tm');
if (!t) return;
function tick() {
var d = new Date();
t.textContent = String(d.getHours()).padStart(2, '0') + ':' +
String(d.getMinutes()).padStart(2, '0');
setTimeout(tick, 20000);
}
tick();
})();
var bt = root.querySelector('.bt');
if (bt) bt.textContent = '84%';
/* اهتزاز خفيف حيث يوجد — تأكيد لمسيّ لا يعتمد عليه شيء */
var buzz = function (ms) { try { if (navigator.vibrate) navigator.vibrate(ms || 8); } catch (e) {} };
/* اللوحة السفلية تُغلق بالسحب لا بالبحث عن ✕ في زاوية بعيدة عن الإبهام */
function mountSheet(sheet, scrim, opener) {
var last = null;
function set(v) {
sheet.hidden = !v; scrim.hidden = !v;
sheet.style.transform = '';
if (opener) opener.setAttribute('aria-expanded', String(v));
if (v) {
last = document.activeElement;
var f = sheet.querySelector('button, input, [tabindex]');
if (f) f.focus();
} else if (last) last.focus();
}
scrim.addEventListener('click', function () { set(false); });
document.addEventListener('keydown', function (e) {
if (sheet.hidden) return;
if (e.key === 'Escape') { set(false); return; }
if (e.key !== 'Tab') return;
var f = sheet.querySelectorAll('button:not(:disabled), input, [tabindex="0"]');
if (!f.length) return;
var first = f[0], lastEl = f[f.length - 1];
if (e.shiftKey && document.activeElement === first) { e.preventDefault(); lastEl.focus(); }
else if (!e.shiftKey && document.activeElement === lastEl) { e.preventDefault(); first.focus(); }
});
var grab = sheet.querySelector('.grab');
if (grab) {
var y0 = 0, dragging = false;
grab.addEventListener('pointerdown', function (e) {
dragging = true; y0 = e.clientY; grab.setPointerCapture(e.pointerId);
sheet.style.transition = 'none';
});
grab.addEventListener('pointermove', function (e) {
if (!dragging) return;
sheet.style.transform = 'translateY(' + Math.max(0, e.clientY - y0) + 'px)';
});
['pointerup', 'pointercancel'].forEach(function (ev) {
grab.addEventListener(ev, function (e) {
if (!dragging) return;
dragging = false;
sheet.style.transition = '';
// عتبة إغلاق: أقلّ منها يعود، وأكثر يُغلق — بلا عتبة يُغلق بأي لمسة
if (e.clientY - y0 > 46) set(false); else sheet.style.transform = '';
});
});
}
return set;
}
var CART = [['سمّاعة لاسلكية', 89], ['شاحن سريع', 24], ['حافظة', 12]];
/* رسوم كل وسيلة تُعرض لحظة الاختيار لا في الإيصال: الوسيلة الأغلى تقول
ذلك قبل أن تُختار، وإلّا شعر الدافع بالخديعة. */
var METHODS = [
{ e: '💳', t: 'بطاقة مدى', fee: 0, note: 'بلا رسوم' },
{ e: '', t: 'Apple Pay', fee: 0, note: 'بلا رسوم' },
{ e: '🏦', t: 'تحويل بنكي', fee: 2, note: 'رسوم ثابتة' },
{ e: '📦', t: 'الدفع عند الاستلام', fee: 5, note: 'رسوم خدمة' }
];
var at = 0;
root.querySelector('.cart').innerHTML = CART.map(function (c) {
return '<li><span>' + c[0] + '</span><span class="v">' + money(c[1]) + '</span></li>';
}).join('');
var sub = CART.reduce(function (a, c) { return a + c[1]; }, 0);
var grand = root.querySelector('.grand'), mth = root.querySelector('.mth');
function paint() {
var m = METHODS[at];
grand.textContent = money(sub + m.fee);
mth.textContent = m.t + (m.fee ? ' · +' + money(m.fee) : '');
}
var mm = root.querySelector('.mm');
mm.innerHTML = METHODS.map(function (m, i) {
return '<li role="radio" tabindex="0" aria-checked="' + (i === at) + '" data-i="' + i + '">' +
'<span class="e">' + m.e + '</span><span style="flex:1"><span class="t">' + m.t +
'</span><br><span class="f">' + (m.fee ? m.note + ' ' + money(m.fee) : m.note) +
'</span></span><span class="rd" aria-hidden="true"></span></li>';
}).join('');
var sheet = root.querySelector('.sheet'), scrim = root.querySelector('.scrim');
var op = root.querySelector('.op');
var set = mountSheet(sheet, scrim, op);
op.addEventListener('click', function () { set(true); });
function pick(li) {
at = +li.dataset.i;
mm.querySelectorAll('li').forEach(function (x) {
x.setAttribute('aria-checked', String(x === li));
});
paint(); buzz(); set(false);
}
mm.addEventListener('click', function (e) {
var li = e.target.closest('li'); if (li) pick(li);
});
mm.addEventListener('keydown', function (e) {
var li = e.target.closest('li'); if (!li) return;
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); pick(li); }
});
var pay = root.querySelector('.pay');
pay.addEventListener('click', function () {
buzz(16);
pay.textContent = (ar ? '✓ دُفع عبر ' : '✓ Paid with ') + METHODS[at].t;
pay.disabled = true; pay.style.opacity = '.7';
});
paint();
}
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(); });
})();
# Payment Method Sheet
**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:** Payment Method Sheet — Each method carries its fee, and the total recomputes on switch
**Why this component matters:** Show the fee difference at the moment of choice, not on the receipt: a method that costs more must say so before it is picked, or the charge feels like a trick.
**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.