المكوّنات · شريط بحث عائم فوق خريطة
شريط بحث عائم فوق خريطة
يطفو فوق الخريطة، ونتائجه تنزلق من أسفله
7 تصاميم من هذه العائلة
<div class="ap apsm"><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="map"><span class="pin p1"></span><span class="pin p2"></span>
<span class="pin p3"></span><span class="me"></span></div>
</div>
<div class="float">
<div class="fld"><span aria-hidden="true">🔍</span>
<input type="search" aria-label="ابحث عن مكان" placeholder="مطعم، صيدلية، محطّة…">
<button class="mic tap" aria-label="بحث صوتي">🎙</button></div>
<ul class="rs" hidden></ul>
</div>
<div class="safe"></div>
</div></div>
/* pt-scoped */
/* appsrch-map — تطبيق خرائط */
.apsm{width:100%;height:100%;display:flex;align-items:center;
justify-content:center;padding:6px;font-size:10px;color:var(--pt-text-secondary);
overflow:hidden}
.apsm .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)}
/* شريط الحالة — ليس تزيينًا: يثبت أعلى الشاشة فلا يبدأ المحتوى عند الحافّة */
.apsm .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}
.apsm .sb .r{display:flex;gap:3px}
.apsm .scr{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.apsm .body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
-webkit-overflow-scrolling:touch}
.apsm .body::-webkit-scrollbar{width:0}
/* المنطقة الآمنة السفلية — شريط الإيماءات يأكل ما تحته */
.apsm .safe{flex:none;height:9px;display:grid;place-items:center}
.apsm .safe::after{content:'';width:52px;height:3px;border-radius:99px;
background:var(--pt-border-strong)}
.apsm h6{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.apsm p{margin:0;font-size:8px;color:var(--pt-text-muted);line-height:1.65}
.apsm .num{font-variant-numeric:tabular-nums}
.apsm 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)}
.apsm button:focus-visible, .apsm a:focus-visible, .apsm input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
/* هدف اللمس: 44 بكسلًا على الشاشات اللمسية، ومساحة نقر ممتدّة على غيرها */
@media(pointer:coarse){.apsm .tap{min-width:44px;min-height:44px}
}
.apsm .tap{position:relative}
.apsm .tap::before{content:'';position:absolute;inset:-6px}
@media(prefers-reduced-motion:reduce){.apsm *{transition:none!important;animation:none!important}
}
.apsm .ph{position:relative}
.apsm .scr{overflow:hidden}
.apsm .map{flex:1;position:relative;
background:
repeating-linear-gradient(0deg,color-mix(in srgb,var(--pt-border-subtle) 60%,transparent) 0 1px,transparent 1px 26px),
repeating-linear-gradient(90deg,color-mix(in srgb,var(--pt-border-subtle) 60%,transparent) 0 1px,transparent 1px 26px),
var(--pt-bg-inset)}
.apsm .pin{position:absolute;width:8px;height:8px;border-radius:50% 50% 50% 0;
background:var(--pt-color-danger-400);transform:rotate(-45deg);
box-shadow:0 1px 3px rgba(0,0,0,.4)}
.apsm .p1{inset-block-start:44%;inset-inline-start:28%}
.apsm .p2{inset-block-start:62%;inset-inline-start:56%}
.apsm .p3{inset-block-start:36%;inset-inline-start:70%}
.apsm .me{position:absolute;inset-block-start:52%;inset-inline-start:46%;width:9px;height:9px;
border-radius:50%;background:var(--pt-accent);border:2px solid var(--pt-bg-base);
box-shadow:0 0 0 5px color-mix(in srgb,var(--pt-accent) 22%,transparent)}
/* سطح مصمت وظلّ: الشفافية فوق ألوان تضاريس لا تُتوقّع تقتل التباين */
.apsm .float{position:absolute;inset-block-start:26px;inset-inline:10px;z-index:5}
.apsm .fld{display:flex;align-items:center;gap:6px;padding:7px 11px;border-radius:99px;
background:var(--pt-bg-overlay);border:1px solid var(--pt-border-default);
box-shadow:var(--pt-shadow-4);color:var(--pt-text-muted);font-size:9px}
.apsm .fld input{flex:1;min-width:0;border:0;background:transparent;font:inherit;
font-size:9.5px;color:var(--pt-text-primary);outline:none}
.apsm .mic{width:18px;height:18px;border:0;border-radius:50%;background:transparent;
color:var(--pt-text-muted);font-size:10px}
.apsm .mic[aria-pressed=true]{color:var(--pt-accent)}
.apsm .rs{list-style:none;margin:5px 0 0;padding:4px;border-radius:var(--pt-radius-md);
background:var(--pt-bg-overlay);border:1px solid var(--pt-border-default);
box-shadow:var(--pt-shadow-4);max-height:112px;overflow-y:auto;
animation:apsmIn var(--pt-motion-duration-normal) var(--pt-motion-easing-emphasized)}
@keyframes apsmIn{from{opacity:0;transform:translateY(-6px)}to{opacity:1;transform:none}}
.apsm .rs li{display:flex;align-items:center;gap:7px;padding:6px 7px;
border-radius:var(--pt-radius-sm);font-size:8.5px;cursor:pointer}
.apsm .rs li:hover{background:var(--pt-surface-hover)}
.apsm .rs .t{flex:1;min-width:0;color:var(--pt-text-primary)}
.apsm .rs .d{color:var(--pt-accent);font-size:7.5px;font-variant-numeric:tabular-nums}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.apsm');
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 PLACES = [
{ t: 'صيدلية النهدي', k: 'صيدلية', d: 0.4 },
{ t: 'محطّة وقود ساسكو', k: 'محطّة', d: 1.2 },
{ t: 'مطعم الطازج', k: 'مطعم', d: 0.8 },
{ t: 'سوبرماركت بندة', k: 'بقالة', d: 2.1 },
{ t: 'مستشفى الملك فهد', k: 'مستشفى', d: 3.6 }
];
var input = root.querySelector('input'), rs = root.querySelector('.rs');
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);
if (!q) { rs.hidden = true; return; }
var found = PLACES.filter(function (p) { return norm(p.t + ' ' + p.k).indexOf(q) !== -1; })
.sort(function (a, b) { return a.d - b.d; }); // الأقرب أوّلًا
rs.hidden = false;
rs.innerHTML = found.length
? found.map(function (p) {
return '<li><span class="t">' + p.t + '</span><span class="d">' +
p.d.toFixed(1) + (ar ? ' كم' : ' km') + '</span></li>';
}).join('')
: '<li style="color:var(--pt-text-muted);cursor:default">' +
(ar ? 'لا مكان مطابق' : 'No matching place') + '</li>';
}
input.addEventListener('input', run);
rs.addEventListener('click', function (e) {
var li = e.target.closest('li');
if (!li || !li.querySelector('.t')) return;
input.value = li.querySelector('.t').textContent;
rs.hidden = true; buzz();
});
var mic = root.querySelector('.mic');
mic.addEventListener('click', function () {
var on = mic.getAttribute('aria-pressed') === 'true';
mic.setAttribute('aria-pressed', String(!on));
if (!on) {
buzz();
setTimeout(function () {
input.value = 'صيدلية';
mic.setAttribute('aria-pressed', 'false');
run();
}, 900);
}
});
}
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(); });
})();
# Floating Search over a Map
**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:** Floating Search over a Map — Floats above the map with results sliding out beneath it
**Why this component matters:** A bar floating over a map needs a solid surface and a shadow: transparency over unpredictable terrain colours destroys contrast in exactly the places you cannot test.
**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.