المكوّنات · بحث يفتح شاشة كاملة
بحث يفتح شاشة كاملة
الضغط على الشريط يفتح شاشة بحث بسجلّ ورائج
7 تصاميم من هذه العائلة
<div class="ap apss"><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="stub" role="button" tabindex="0" aria-label="افتح البحث">
<span aria-hidden="true">🔍</span>
<span data-ar="ابحث عن منتج" data-en="Search products">ابحث عن منتج</span></div>
<div class="grid"></div>
</div></div>
<section class="sheet" hidden aria-label="البحث">
<div class="top"><button class="bk tap" aria-label="رجوع">‹</button>
<input type="search" aria-label="ابحث" placeholder="اكتب للبحث…"></div>
<div class="pn">
<div class="sec hist"><b data-ar="بحثك السابق" data-en="Recent">بحثك السابق</b><div class="ch"></div></div>
<div class="sec trend"><b data-ar="الأكثر بحثًا" data-en="Trending">الأكثر بحثًا</b><ol class="tr"></ol></div>
<ul class="rs" hidden></ul>
</div>
</section>
<div class="safe"></div>
</div></div>
/* pt-scoped */
/* appsrch-sheet — متجر إلكتروني */
.apss{width:100%;height:100%;display:flex;align-items:center;
justify-content:center;padding:6px;font-size:10px;color:var(--pt-text-secondary);
overflow:hidden}
.apss .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)}
/* شريط الحالة — ليس تزيينًا: يثبت أعلى الشاشة فلا يبدأ المحتوى عند الحافّة */
.apss .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}
.apss .sb .r{display:flex;gap:3px}
.apss .scr{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.apss .body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
-webkit-overflow-scrolling:touch}
.apss .body::-webkit-scrollbar{width:0}
/* المنطقة الآمنة السفلية — شريط الإيماءات يأكل ما تحته */
.apss .safe{flex:none;height:9px;display:grid;place-items:center}
.apss .safe::after{content:'';width:52px;height:3px;border-radius:99px;
background:var(--pt-border-strong)}
.apss h6{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.apss p{margin:0;font-size:8px;color:var(--pt-text-muted);line-height:1.65}
.apss .num{font-variant-numeric:tabular-nums}
.apss 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)}
.apss button:focus-visible, .apss a:focus-visible, .apss input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
/* هدف اللمس: 44 بكسلًا على الشاشات اللمسية، ومساحة نقر ممتدّة على غيرها */
@media(pointer:coarse){.apss .tap{min-width:44px;min-height:44px}
}
.apss .tap{position:relative}
.apss .tap::before{content:'';position:absolute;inset:-6px}
@media(prefers-reduced-motion:reduce){.apss *{transition:none!important;animation:none!important}
}
.apss .ph{position:relative}
.apss .body{padding:8px 12px}
.apss .stub{display:flex;align-items:center;gap:6px;padding:8px 11px;border-radius:99px;
background:var(--pt-bg-inset);color:var(--pt-text-muted);font-size:9px;cursor:pointer;
border:1px solid var(--pt-border-subtle)}
.apss .grid{display:grid;grid-template-columns:repeat(2,1fr);gap:6px;margin-top:8px}
.apss .grid div{height:52px;border-radius:var(--pt-radius-md)}
/* شاشة كاملة لأن لوحة المفاتيح تلتهم نصف الشاشة — القائمة المنسدلة بلا مكان */
.apss .sheet{position:absolute;inset:0;z-index:6;display:flex;flex-direction:column;
background:var(--pt-bg-base);
animation:apssIn var(--pt-motion-duration-normal) var(--pt-motion-easing-emphasized)}
@keyframes apssIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}
.apss .top{flex:none;display:flex;align-items:center;gap:7px;padding:24px 10px 8px;
border-bottom:1px solid var(--pt-border-subtle)}
.apss .bk{width:24px;height:24px;border:0;border-radius:50%;background:var(--pt-bg-inset);
color:var(--pt-text-secondary);font-size:13px;display:grid;place-items:center;flex:none}
[dir=rtl] .apss .bk{transform:scaleX(-1)}
.apss .top input{flex:1;min-width:0;padding:6px 10px;border-radius:99px;
border:1px solid var(--pt-border-default);background:var(--pt-bg-inset);font:inherit;
font-size:9.5px;color:var(--pt-text-primary);outline:none}
.apss .pn{flex:1;min-height:0;overflow-y:auto;padding:9px 12px}
.apss .sec{margin-bottom:10px}
.apss .sec b{display:block;font-size:8px;color:var(--pt-text-muted);margin-bottom:5px}
.apss .ch{display:flex;flex-wrap:wrap;gap:4px}
.apss .ch button{padding:4px 9px;border-radius:99px;border:1px solid var(--pt-border-default);
background:transparent;color:var(--pt-text-secondary);font-size:8px}
.apss .tr{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:5px}
.apss .tr li{display:flex;align-items:center;gap:7px;font-size:8.5px;cursor:pointer;
color:var(--pt-text-secondary)}
.apss .tr .k{width:14px;font-weight:700;color:var(--pt-accent);
font-variant-numeric:tabular-nums}
.apss .rs{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
.apss .rs li{display:flex;align-items:center;gap:7px;font-size:8.5px}
.apss .rs .im{flex:none;width:26px;height:26px;border-radius:var(--pt-radius-sm)}
.apss .rs .p{color:var(--pt-accent);font-weight:700;font-variant-numeric:tabular-nums;
font-size:8px}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.apss');
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 PRODUCTS = [
{ t: 'سمّاعة لاسلكية', p: 89, h: 260 }, { t: 'ساعة رياضية', p: 145, h: 200 },
{ t: 'حقيبة ظهر', p: 62, h: 30 }, { t: 'لوحة مفاتيح ميكانيكية', p: 118, h: 150 },
{ t: 'مصباح مكتب', p: 38, h: 42 }, { t: 'شاحن سريع', p: 24, h: 320 }
];
var TREND = ['سمّاعة', 'ساعة', 'شاحن', 'حقيبة'];
var HIST = ['لوحة مفاتيح', 'مصباح'];
root.querySelector('.grid').innerHTML = PRODUCTS.slice(0, 4).map(function (p) {
return '<div style="background:hsl(' + p.h + ' 36% 34%)"></div>';
}).join('');
var stub = root.querySelector('.stub'), sheet = root.querySelector('.sheet');
var bk = root.querySelector('.bk'), input = root.querySelector('.top input');
var hist = root.querySelector('.hist'), trend = root.querySelector('.trend');
var rs = root.querySelector('.rs');
root.querySelector('.ch').innerHTML = HIST.map(function (h) {
return '<button class="tap" type="button">↺ ' + h + '</button>';
}).join('');
root.querySelector('.tr').innerHTML = TREND.map(function (t, i) {
return '<li><span class="k">' + (i + 1) + '</span><span>' + t + '</span></li>';
}).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();
}
function run() {
var q = norm(input.value);
var has = q.length > 0;
hist.hidden = has; trend.hidden = has; rs.hidden = !has;
if (!has) return;
var found = PRODUCTS.filter(function (p) { return norm(p.t).indexOf(q) !== -1; });
rs.innerHTML = found.length ? found.map(function (p) {
return '<li><span class="im" style="background:hsl(' + p.h + ' 36% 34%)"></span>' +
'<span style="flex:1">' + p.t + '</span><span class="p">' + money(p.p) + '</span></li>';
}).join('') : '<li style="color:var(--pt-text-muted)">' +
(ar ? 'لا منتج مطابق' : 'No matching product') + '</li>';
}
function open(v) {
sheet.hidden = !v;
if (v) input.focus(); else { input.value = ''; run(); stub.focus(); }
}
stub.addEventListener('click', function () { open(true); });
stub.addEventListener('keydown', function (e) {
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); open(true); }
});
bk.addEventListener('click', function () { open(false); });
input.addEventListener('input', run);
input.addEventListener('keydown', function (e) { if (e.key === 'Escape') open(false); });
root.querySelector('.pn').addEventListener('click', function (e) {
var b = e.target.closest('.ch button') || e.target.closest('.tr li');
if (!b) return;
input.value = b.textContent.replace('↺ ', '').replace(/^\d+/, '').trim();
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(); });
})();
# Full-screen Search 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:** Full-screen Search Sheet — Tapping the bar opens a search screen with history and trending
**Why this component matters:** The full-screen sheet is the mobile pattern for search because the keyboard eats half the viewport — an inline dropdown would have nowhere left to render.
**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.