المكوّنات · بحث برقاقات مرشّحات
بحث برقاقات مرشّحات
رقاقات أفقية قابلة للتمرير تضيّق النتيجة، وعدّاد يتبعها
7 تصاميم من هذه العائلة
<div class="ap apsf"><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="hdr">
<div class="fld"><span aria-hidden="true">🔍</span>
<input type="search" aria-label="ابحث عن عقار" placeholder="حيّ أو مدينة…"></div>
<div class="chips" role="group" aria-label="المرشّحات"></div>
<div class="cnt num"></div>
</div>
<div class="body"><ul class="rs"></ul>
<p class="empty" hidden data-ar="لا عقار يطابق المرشّحات" data-en="No property matches the filters">لا عقار يطابق المرشّحات</p></div>
<div class="safe"></div>
</div></div>
/* pt-scoped */
/* appsrch-filters — تطبيق عقارات */
.apsf{width:100%;height:100%;display:flex;align-items:center;
justify-content:center;padding:6px;font-size:10px;color:var(--pt-text-secondary);
overflow:hidden}
.apsf .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)}
/* شريط الحالة — ليس تزيينًا: يثبت أعلى الشاشة فلا يبدأ المحتوى عند الحافّة */
.apsf .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}
.apsf .sb .r{display:flex;gap:3px}
.apsf .scr{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.apsf .body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
-webkit-overflow-scrolling:touch}
.apsf .body::-webkit-scrollbar{width:0}
/* المنطقة الآمنة السفلية — شريط الإيماءات يأكل ما تحته */
.apsf .safe{flex:none;height:9px;display:grid;place-items:center}
.apsf .safe::after{content:'';width:52px;height:3px;border-radius:99px;
background:var(--pt-border-strong)}
.apsf h6{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.apsf p{margin:0;font-size:8px;color:var(--pt-text-muted);line-height:1.65}
.apsf .num{font-variant-numeric:tabular-nums}
.apsf 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)}
.apsf button:focus-visible, .apsf a:focus-visible, .apsf input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
/* هدف اللمس: 44 بكسلًا على الشاشات اللمسية، ومساحة نقر ممتدّة على غيرها */
@media(pointer:coarse){.apsf .tap{min-width:44px;min-height:44px}
}
.apsf .tap{position:relative}
.apsf .tap::before{content:'';position:absolute;inset:-6px}
@media(prefers-reduced-motion:reduce){.apsf *{transition:none!important;animation:none!important}
}
.apsf .hdr{flex:none;padding:3px 0 6px;background:var(--pt-surface);
border-bottom:1px solid var(--pt-border-subtle)}
.apsf .fld{display:flex;align-items:center;gap:6px;margin:0 11px;padding:6px 10px;
border-radius:99px;background:var(--pt-bg-inset);color:var(--pt-text-muted);font-size:9px}
.apsf .fld input{flex:1;min-width:0;border:0;background:transparent;font:inherit;
font-size:9.5px;color:var(--pt-text-primary);outline:none}
.apsf .chips{display:flex;gap:4px;overflow-x:auto;padding:6px 11px 0;scrollbar-width:none}
.apsf .chips::-webkit-scrollbar{height:0}
.apsf .chips button{flex:none;padding:4px 10px;border-radius:99px;
border:1px solid var(--pt-border-default);background:transparent;
color:var(--pt-text-muted);font-size:8px;white-space:nowrap}
.apsf .chips button[aria-pressed=true]{background:var(--pt-accent);border-color:var(--pt-accent);
color:var(--pt-color-ink-900);font-weight:700}
.apsf .cnt{padding:5px 11px 0;font-size:7.5px;color:var(--pt-text-muted)}
.apsf .body{padding:7px 11px 8px}
.apsf .rs{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
.apsf .rs li{display:flex;gap:7px;padding:6px;border-radius:var(--pt-radius-md);
background:var(--pt-surface);border:1px solid var(--pt-border-subtle)}
.apsf .rs .im{flex:none;width:38px;height:38px;border-radius:var(--pt-radius-sm)}
.apsf .rs .t{font-size:8.5px;color:var(--pt-text-primary)}
.apsf .rs .m{font-size:7px;color:var(--pt-text-muted)}
.apsf .rs .p{font-size:9px;color:var(--pt-accent);font-weight:700;
font-variant-numeric:tabular-nums}
.apsf .empty{text-align:center;padding:16px 0}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.apsf');
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 HOMES = [
{ t: 'شقّة 3 غرف · الملقا', c: 'الرياض', k: 'شقّة', r: 3, p: 208000, h: 200 },
{ t: 'فيلا دورين · الياسمين', c: 'الرياض', k: 'فيلا', r: 5, p: 493000, h: 150 },
{ t: 'دور أرضي · الشاطئ', c: 'جدّة', k: 'دور', r: 4, p: 298000, h: 30 },
{ t: 'استوديو · الكورنيش', c: 'الخبر', k: 'شقّة', r: 1, p: 112000, h: 260 },
{ t: 'فيلا مستقلّة · النرجس', c: 'الرياض', k: 'فيلا', r: 6, p: 640000, h: 96 },
{ t: 'شقّة مطلّة · السلامة', c: 'جدّة', k: 'شقّة', r: 2, p: 170000, h: 320 }
];
var FILTERS = [
{ l: 'فيلا', f: function (h) { return h.k === 'فيلا'; } },
{ l: 'شقّة', f: function (h) { return h.k === 'شقّة'; } },
{ l: 'الرياض', f: function (h) { return h.c === 'الرياض'; } },
{ l: '4 غرف فأكثر', f: function (h) { return h.r >= 4; } },
{ l: 'أقلّ من 300 ألف', f: function (h) { return h.p < 300000; } }
];
var chips = root.querySelector('.chips'), rs = root.querySelector('.rs');
var input = root.querySelector('input'), cnt = root.querySelector('.cnt');
var empty = root.querySelector('.empty');
chips.innerHTML = FILTERS.map(function (f, i) {
return '<button class="tap" type="button" aria-pressed="false" data-i="' + i + '">' +
f.l + '</button>';
}).join('');
function norm(s) {
return String(s).replace(/[\u064B-\u0652\u0640]/g, '')
.replace(/[\u0622\u0623\u0625]/g, '\u0627').replace(/\u0629/g, '\u0647')
.replace(/\u0649/g, '\u064A').toLowerCase().trim();
}
rs.innerHTML = HOMES.map(function (h) {
return '<li><span class="im" style="background:hsl(' + h.h + ' 34% 38%)"></span>' +
'<span style="flex:1;min-width:0"><span class="t">' + h.t + '</span><br>' +
'<span class="m">' + h.c + ' · ' + h.r + (ar ? ' غرف' : ' rooms') + '</span><br>' +
'<span class="p">' + money(h.p / 3.75) + '</span></span></li>';
}).join('');
var lis = [].slice.call(rs.children);
function run() {
var active = [].slice.call(chips.querySelectorAll('[aria-pressed=true]'))
.map(function (b) { return FILTERS[+b.dataset.i]; });
var q = norm(input.value), shown = 0;
lis.forEach(function (li, i) {
var h = HOMES[i];
var ok = active.every(function (f) { return f.f(h); }) &&
(!q || norm(h.t + ' ' + h.c).indexOf(q) !== -1);
li.hidden = !ok; if (ok) shown++;
});
empty.hidden = shown > 0;
/* عدّ المرشّحات ظاهر في الصفّ نفسه: الرقاقات تخرج من الرؤية بالتمرير،
ومن لا يرى مرشّحاته يلوم البحث على الفراغ. */
cnt.textContent = shown + (ar ? ' عقارًا' : ' properties') +
(active.length ? (ar ? ' · ' + active.length + ' مرشّحًا نشطًا'
: ' · ' + active.length + ' filters on') : '');
}
chips.addEventListener('click', function (e) {
var b = e.target.closest('button'); if (!b) return;
b.setAttribute('aria-pressed', String(b.getAttribute('aria-pressed') !== 'true'));
buzz(); run();
});
input.addEventListener('input', run);
run();
}
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(); });
})();
# Search with Filter Chips
**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:** Search with Filter Chips — Horizontally scrolling chips narrow the result, with a counter that follows
**Why this component matters:** Show the active filter count on the row itself: chips scroll out of view, and a user who cannot see their filters will blame the search for the empty result.
**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.