المكوّنات · بطاقة تُسحب لكشف إجراءات
بطاقة تُسحب لكشف إجراءات
السحب يكشف إجراءين، ويرتدّ إن لم يبلغ العتبة
9 تصاميم من هذه العائلة
<div class="ap apcw"><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="Inbox">الوارد</h6>
<p class="tip" data-ar="اسحب أي رسالة أفقيًّا" data-en="Swipe any message horizontally">اسحب أي رسالة أفقيًّا</p>
<ul class="ml"></ul>
</div></div>
<div class="lg" role="status" aria-live="polite"></div>
<div class="safe"></div>
</div></div>
/* pt-scoped */
/* appcard-swipe — صندوق بريد */
.apcw{width:100%;height:100%;display:flex;align-items:center;
justify-content:center;padding:6px;font-size:10px;color:var(--pt-text-secondary);
overflow:hidden}
.apcw .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)}
/* شريط الحالة — ليس تزيينًا: يثبت أعلى الشاشة فلا يبدأ المحتوى عند الحافّة */
.apcw .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}
.apcw .sb .r{display:flex;gap:3px}
.apcw .scr{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.apcw .body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
-webkit-overflow-scrolling:touch}
.apcw .body::-webkit-scrollbar{width:0}
/* المنطقة الآمنة السفلية — شريط الإيماءات يأكل ما تحته */
.apcw .safe{flex:none;height:9px;display:grid;place-items:center}
.apcw .safe::after{content:'';width:52px;height:3px;border-radius:99px;
background:var(--pt-border-strong)}
.apcw h6{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.apcw p{margin:0;font-size:8px;color:var(--pt-text-muted);line-height:1.65}
.apcw .num{font-variant-numeric:tabular-nums}
.apcw 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)}
.apcw button:focus-visible, .apcw a:focus-visible, .apcw input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
/* هدف اللمس: 44 بكسلًا على الشاشات اللمسية، ومساحة نقر ممتدّة على غيرها */
@media(pointer:coarse){.apcw .tap{min-width:44px;min-height:44px}
}
.apcw .tap{position:relative}
.apcw .tap::before{content:'';position:absolute;inset:-6px}
@media(prefers-reduced-motion:reduce){.apcw *{transition:none!important;animation:none!important}
}
.apcw .ph{position:relative}
.apcw .body{padding:9px 0}
.apcw .body h6, .apcw .tip{padding:0 12px}
.apcw .tip{margin-bottom:7px}
.apcw .ml{list-style:none;margin:0;padding:0}
.apcw .row{position:relative;overflow:hidden;border-bottom:1px solid var(--pt-border-subtle)}
.apcw .acts{position:absolute;inset-block:0;inset-inline-end:0;display:flex}
.apcw .acts button{width:52px;border:0;color:#fff;font-size:8px;font-weight:700;
display:grid;place-items:center;gap:2px}
.apcw .acts .ar{background:var(--pt-color-info-500,#3a6ea5)}
.apcw .acts .dl{background:var(--pt-color-danger-500)}
.apcw .card{position:relative;display:flex;gap:8px;align-items:flex-start;padding:8px 12px;
background:var(--pt-bg-base);touch-action:pan-y;
transition:transform var(--pt-motion-duration-normal) var(--pt-motion-easing-emphasized)}
.apcw .card.free{transition:none}
.apcw .av{flex:none;width:26px;height:26px;border-radius:50%;display:grid;place-items:center;
font-size:10px;font-weight:700;color:var(--pt-color-ink-900)}
.apcw .fr{font-size:8.5px;color:var(--pt-text-primary);font-weight:600}
.apcw .sj{font-size:8px;color:var(--pt-text-secondary)}
.apcw .pv{font-size:7px;color:var(--pt-text-muted);display:block;white-space:nowrap;
overflow:hidden;text-overflow:ellipsis;max-width:118px}
.apcw .mn{flex:none;width:22px;height:22px;border:0;border-radius:50%;background:transparent;
color:var(--pt-text-muted);font-size:11px}
.apcw .lg{position:absolute;inset-block-end:14px;inset-inline:12px;z-index:5;text-align:center;
font-size:8px;color:var(--pt-accent)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.apcw');
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) {} };
var MAIL = [
{ f: 'بوّابة التوظيف', s: 'تحديث على طلبك', p: 'تمّ نقل طلبك إلى مرحلة المقابلة', h: 200 },
{ f: 'فريق المنتج', s: 'مراجعة التصميم', p: 'أرفقت الملاحظات في المستند', h: 300 },
{ f: 'المصرف', s: 'إشعار عملية', p: 'عملية شراء بمبلغ 86 ريالًا', h: 150 },
{ f: 'نورة العتيبي', s: 'اجتماع الأحد', p: 'هل يناسبك التاسعة صباحًا؟', h: 30 }
];
var ul = root.querySelector('.ml'), lg = root.querySelector('.lg');
function say(t) { lg.textContent = t; setTimeout(function () { lg.textContent = ''; }, 1500); }
function draw() {
ul.innerHTML = MAIL.map(function (m, i) {
return '<li class="row"><div class="acts">' +
'<button class="ar tap" data-a="ar" data-i="' + i + '">أرشفة</button>' +
'<button class="dl tap" data-a="dl" data-i="' + i + '">حذف</button></div>' +
'<div class="card"><span class="av" style="background:hsl(' + m.h + ' 58% 66%)">' +
m.f[0] + '</span><span style="flex:1;min-width:0"><span class="fr">' + m.f +
'</span><br><span class="sj">' + m.s + '</span><span class="pv">' + m.p +
'</span></span><button class="mn tap" data-a="menu" data-i="' + i +
'" aria-label="إجراءات ' + m.s + '">⋯</button></div></li>';
}).join('');
bind();
}
var W = 104;
function bind() {
[].slice.call(ul.querySelectorAll('.card')).forEach(function (card) {
var x0 = 0, dx = 0, open = false, drag = false;
var rtl = getComputedStyle(root).direction === 'rtl';
function place(v) { card.style.transform = 'translateX(' + v + 'px)'; }
card.addEventListener('pointerdown', function (e) {
if (e.target.closest('button')) return;
drag = true; x0 = e.clientX; card.classList.add('free');
card.setPointerCapture(e.pointerId);
});
card.addEventListener('pointermove', function (e) {
if (!drag) return;
// الاتجاه يتبع اتجاه المستند: سحب ثابت يعمل عكسيًّا في العربية
var raw = (e.clientX - x0) * (rtl ? 1 : -1);
dx = Math.max(0, Math.min(W, raw + (open ? W : 0)));
place(rtl ? dx : -dx);
});
['pointerup', 'pointercancel'].forEach(function (ev) {
card.addEventListener(ev, function () {
if (!drag) return;
drag = false; card.classList.remove('free');
open = dx > W / 2; // عتبة النصف: أقلّ منها يرتدّ
dx = open ? W : 0;
place(rtl ? dx : -dx);
if (open) buzz();
});
});
});
}
ul.addEventListener('click', function (e) {
var b = e.target.closest('button'); if (!b) return;
var i = +b.dataset.i;
/* الإجراءات نفسها متاحة من زرّ ⋯: الإيماءة وحدها غير مرئية
ولا تُطال بلوحة المفاتيح. */
if (b.dataset.a === 'menu') { say(ar ? 'أرشفة · حذف · تمييز' : 'Archive · Delete · Flag'); return; }
say(b.dataset.a === 'ar' ? (ar ? 'أُرشفت: ' : 'Archived: ') + MAIL[i].s
: (ar ? 'حُذفت: ' : 'Deleted: ') + MAIL[i].s);
MAIL.splice(i, 1); draw(); buzz(14);
});
draw();
}
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(); });
})();
# Swipe-to-Reveal 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:** Swipe-to-Reveal Card — A swipe reveals two actions and springs back below the threshold
**Why this component matters:** Mirror the swipe direction with the document direction and expose the same actions in a menu: gesture-only affordances are invisible and unreachable by keyboard.
**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.