المكوّنات · لوحة مرشّحات
لوحة مرشّحات
التغييرات مؤقّتة حتى «تطبيق»، و«إعادة ضبط» تُرجعها
7 تصاميم من هذه العائلة
<div class="ap apsl"><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">
<div class="hd"><h6 data-ar="الأزياء" data-en="Fashion">الأزياء</h6>
<button class="fb tap" aria-expanded="false"><span data-ar="تصفية" data-en="Filter">تصفية</span>
<b class="fc num"></b></button></div>
<div class="cnt num"></div>
<div class="grid"></div>
<p class="empty" hidden data-ar="لا منتج يطابق" data-en="Nothing matches">لا منتج يطابق</p>
</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="Filter">تصفية</b>
<button class="rs" data-ar="إعادة ضبط" data-en="Reset">إعادة ضبط</button></div>
<div class="cn">
<div class="fg"><span data-ar="الفئة" data-en="Category">الفئة</span><div class="ck cat"></div></div>
<div class="fg"><span data-ar="المقاس" data-en="Size">المقاس</span><div class="ck sz"></div></div>
<div class="fg"><span data-ar="السعر الأقصى" data-en="Max price">السعر الأقصى</span>
<input class="pr" type="range" min="40" max="400" step="20" value="400" aria-label="السعر الأقصى">
<b class="pv num"></b></div>
</div>
<button class="ap-btn" data-ar="تطبيق" data-en="Apply">تطبيق</button>
</section>
<div class="safe"></div>
</div></div>
/* pt-scoped */
/* appsheet-filter — متجر أزياء */
.apsl{width:100%;height:100%;display:flex;align-items:center;
justify-content:center;padding:6px;font-size:10px;color:var(--pt-text-secondary);
overflow:hidden}
.apsl .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)}
/* شريط الحالة — ليس تزيينًا: يثبت أعلى الشاشة فلا يبدأ المحتوى عند الحافّة */
.apsl .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}
.apsl .sb .r{display:flex;gap:3px}
.apsl .scr{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.apsl .body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
-webkit-overflow-scrolling:touch}
.apsl .body::-webkit-scrollbar{width:0}
/* المنطقة الآمنة السفلية — شريط الإيماءات يأكل ما تحته */
.apsl .safe{flex:none;height:9px;display:grid;place-items:center}
.apsl .safe::after{content:'';width:52px;height:3px;border-radius:99px;
background:var(--pt-border-strong)}
.apsl h6{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.apsl p{margin:0;font-size:8px;color:var(--pt-text-muted);line-height:1.65}
.apsl .num{font-variant-numeric:tabular-nums}
.apsl 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)}
.apsl button:focus-visible, .apsl a:focus-visible, .apsl input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
/* هدف اللمس: 44 بكسلًا على الشاشات اللمسية، ومساحة نقر ممتدّة على غيرها */
@media(pointer:coarse){.apsl .tap{min-width:44px;min-height:44px}
}
.apsl .tap{position:relative}
.apsl .tap::before{content:'';position:absolute;inset:-6px}
@media(prefers-reduced-motion:reduce){.apsl *{transition:none!important;animation:none!important}
}
.apsl .ph{position:relative}
.apsl .body{padding:8px 12px}
.apsl .hd{display:flex;align-items:center;justify-content:space-between;gap:8px}
.apsl .fb{display:flex;align-items:center;gap:5px;padding:5px 11px;border-radius:99px;
border:1px solid var(--pt-border-default);background:transparent;
color:var(--pt-text-secondary);font-size:8.5px}
.apsl .fc{min-width:14px;height:14px;border-radius:99px;background:var(--pt-accent);
color:var(--pt-color-ink-900);font-size:7px;display:none;place-items:center}
.apsl .fc.on{display:grid}
.apsl .cnt{font-size:7.5px;color:var(--pt-text-muted);padding:6px 0 5px}
.apsl .grid{display:grid;grid-template-columns:repeat(3,1fr);gap:5px}
.apsl .grid figure{margin:0;border-radius:8px;overflow:hidden;border:1px solid var(--pt-border-subtle)}
.apsl .grid .im{height:38px}
.apsl .grid figcaption{padding:3px 4px;font-size:6.5px;color:var(--pt-text-secondary);
background:var(--pt-surface);text-align:center}
.apsl .empty{text-align:center;padding:14px 0}
.apsl .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)}
.apsl .grab{flex:none;padding:7px 0 3px;display:grid;place-items:center;cursor:grab;
touch-action:none}
.apsl .grab::after{content:'';width:34px;height:4px;border-radius:99px;background:var(--pt-border-strong)}
.apsl .scrim{position:absolute;inset:0;z-index:5;background:rgba(5,9,26,.55)}
.apsl .sheet{max-height:82%}
.apsl .sh{flex:none;display:flex;align-items:center;justify-content:space-between;gap:8px;
padding:2px 13px 8px;border-bottom:1px solid var(--pt-border-subtle)}
.apsl .sh b{font-size:10px;color:var(--pt-text-primary)}
.apsl .rs{border:0;background:transparent;color:var(--pt-accent);font-size:8.5px;padding:2px}
.apsl .cn{flex:1;min-height:0;overflow-y:auto;padding:9px 13px;display:flex;
flex-direction:column;gap:10px}
.apsl .fg{display:flex;flex-direction:column;gap:5px}
.apsl .fg > span{font-size:8px;color:var(--pt-text-muted)}
.apsl .ck{display:flex;flex-wrap:wrap;gap:4px}
.apsl .ck button{padding:4px 10px;border-radius:99px;border:1px solid var(--pt-border-default);
background:transparent;color:var(--pt-text-secondary);font-size:8px}
.apsl .ck button[aria-pressed=true]{background:var(--pt-accent);border-color:var(--pt-accent);
color:var(--pt-color-ink-900);font-weight:700}
.apsl .pr{width:100%;accent-color:var(--pt-accent);height:3px}
.apsl .pv{font-size:9px;color:var(--pt-accent);font-variant-numeric:tabular-nums}
.apsl .ap-btn{flex:none;margin:0 13px 12px;padding:9px;border:0;border-radius:10px;
background:var(--pt-accent);color:var(--pt-color-ink-900);font-size:9.5px;font-weight:700}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.apsl');
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 ITEMS = [
{ t: 'عباية سادة', c: 'نسائي', s: 'M', p: 120, h: 260 },
{ t: 'ثوب صيفي', c: 'رجالي', s: 'L', p: 90, h: 42 },
{ t: 'قميص كتّان', c: 'رجالي', s: 'M', p: 70, h: 200 },
{ t: 'فستان سهرة', c: 'نسائي', s: 'S', p: 340, h: 320 },
{ t: 'حذاء أطفال', c: 'أطفال', s: 'S', p: 55, h: 96 },
{ t: 'جاكيت شتوي', c: 'رجالي', s: 'XL', p: 260, h: 150 }
];
var CATS = ['نسائي', 'رجالي', 'أطفال'], SIZES = ['S', 'M', 'L', 'XL'];
var grid = root.querySelector('.grid'), cnt = root.querySelector('.cnt');
var empty = root.querySelector('.empty'), fc = root.querySelector('.fc');
grid.innerHTML = ITEMS.map(function (x) {
return '<figure><div class="im" style="background:hsl(' + x.h + ' 34% 38%)"></div>' +
'<figcaption>' + x.t + '</figcaption></figure>';
}).join('');
var figs = [].slice.call(grid.children);
/* الحالة المطبَّقة والمسوّدة منفصلتان: التصفية الحيّة خلف لوحة مفتوحة
تُعيد رسم قائمة لا يراها المستخدم، ثم لا يجد «إلغاء» ما يتراجع عنه. */
var applied = { cat: [], sz: [], max: 400 };
var draft = JSON.parse(JSON.stringify(applied));
root.querySelector('.cat').innerHTML = CATS.map(function (c) {
return '<button class="tap" type="button" aria-pressed="false">' + c + '</button>';
}).join('');
root.querySelector('.sz').innerHTML = SIZES.map(function (s) {
return '<button class="tap" type="button" aria-pressed="false">' + s + '</button>';
}).join('');
var pr = root.querySelector('.pr'), pv = root.querySelector('.pv');
function paintDraft() {
root.querySelectorAll('.cat button').forEach(function (b) {
b.setAttribute('aria-pressed', String(draft.cat.indexOf(b.textContent) !== -1));
});
root.querySelectorAll('.sz button').forEach(function (b) {
b.setAttribute('aria-pressed', String(draft.sz.indexOf(b.textContent) !== -1));
});
pr.value = draft.max;
pv.textContent = money(draft.max / 3.75);
}
function apply() {
var shown = 0;
figs.forEach(function (f, i) {
var x = ITEMS[i];
var ok = (!applied.cat.length || applied.cat.indexOf(x.c) !== -1) &&
(!applied.sz.length || applied.sz.indexOf(x.s) !== -1) &&
x.p <= applied.max;
f.hidden = !ok; if (ok) shown++;
});
empty.hidden = shown > 0;
cnt.textContent = shown + (ar ? ' منتجًا' : ' items');
var count = applied.cat.length + applied.sz.length + (applied.max < 400 ? 1 : 0);
fc.textContent = count; fc.classList.toggle('on', count > 0);
}
function toggle(arr, v) {
var i = arr.indexOf(v);
if (i === -1) arr.push(v); else arr.splice(i, 1);
}
root.querySelector('.cn').addEventListener('click', function (e) {
var b = e.target.closest('.ck button'); if (!b) return;
toggle(b.closest('.cat') ? draft.cat : draft.sz, b.textContent);
paintDraft();
});
pr.addEventListener('input', function () { draft.max = +pr.value; paintDraft(); });
var sheet = root.querySelector('.sheet'), scrim = root.querySelector('.scrim');
var fb = root.querySelector('.fb');
var set = mountSheet(sheet, scrim, fb);
fb.addEventListener('click', function () {
draft = JSON.parse(JSON.stringify(applied)); // تُفتح على آخر ما طُبّق
paintDraft(); set(true);
});
root.querySelector('.rs').addEventListener('click', function () {
draft = { cat: [], sz: [], max: 400 }; paintDraft();
});
root.querySelector('.ap-btn').addEventListener('click', function () {
applied = JSON.parse(JSON.stringify(draft));
apply(); set(false); buzz();
});
paintDraft(); apply();
}
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(); });
})();
# Filter 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:** Filter Sheet — Changes stay pending until Apply — Reset restores the last applied state
**Why this component matters:** Keep filter edits in a draft and commit only on Apply. Filtering live behind an open sheet re-renders a list the user cannot see, and Cancel then has nothing to undo.
**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.