المكوّنات · شريط جوّال بقائمة منسدلة
شريط جوّال بقائمة منسدلة
همبرغر يفتح لوحة كاملة تحبس التركيز
12 تصاميم من هذه العائلة
<div class="nb nbmb">
<header>
<button class="bg" aria-expanded="false" aria-controls="sh" aria-label="القائمة">☰</button>
<span class="brand"><span class="mk">⬤</span><span data-ar="نادي الصقور" data-en="Falcons Club">نادي الصقور</span></span>
<span class="grow"></span>
<button class="ic" aria-label="حسابي">◔</button>
</header>
<div class="scrim" hidden></div>
<nav id="sh" class="sheet" aria-label="الرئيسية" hidden>
<a href="#" aria-current="page" data-ar="الأخبار" data-en="News">الأخبار</a><a href="#" data-ar="الفريق" data-en="Team">الفريق</a><a href="#" data-ar="المباريات" data-en="Fixtures">المباريات</a><a href="#" data-ar="العضوية" data-en="Membership">العضوية</a><a href="#" data-ar="المتجر" data-en="Store">المتجر</a>
<button class="close" data-ar="إغلاق" data-en="Close">إغلاق</button>
</nav>
<div class="stage">
<h4 data-ar="قائمة الجوّال" data-en="Mobile sheet">قائمة الجوّال</h4>
<p data-ar="اضغط أي رابط ليصير الحالي. القوائم تُغلق بالهروب وبالضغط خارجها." data-en="Click any link to make it current. Menus close on Escape and outside click.">اضغط أي رابط ليصير الحالي. القوائم تُغلق بالهروب وبالضغط خارجها.</p>
</div>
</div>
/* pt-scoped */
/* navbar-mobile — نادٍ رياضي · 46px */
.nbmb{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden;position:relative}
.nbmb header{flex:none;display:flex;align-items:center;gap:9px;width:100%}
.nbmb .brand{display:flex;align-items:center;gap:6px;font-weight:700;
color:var(--pt-text-primary);white-space:nowrap}
.nbmb .brand .mk{display:grid;place-items:center;flex:none;font-size:10px}
.nbmb nav{display:flex;align-items:center;gap:2px;min-width:0}
.nbmb nav a{padding:5px 8px;color:var(--pt-text-muted);white-space:nowrap;cursor:pointer;
transition:color var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
background var(--pt-motion-duration-fast) var(--pt-motion-easing-standard)}
.nbmb nav a:hover{color:var(--pt-text-primary)}
.nbmb .grow{flex:1}
.nbmb .stage{flex:1;display:flex;flex-direction:column;gap:5px;padding:10px;min-height:0}
.nbmb .stage h4{margin:0;font-size:10.5px;color:var(--pt-text-primary)}
.nbmb .stage p{margin:0;font-size:8.5px;color:var(--pt-text-muted);line-height:1.8}
.nbmb button{font:inherit;cursor:pointer}
.nbmb a:focus-visible, .nbmb button:focus-visible, .nbmb input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
.nbmb header{height:46px;padding:0 10px;background:var(--pt-bg-inset);
border-bottom:1px solid var(--pt-border-subtle)}
.nbmb .bg{width:28px;height:28px;border:0;border-radius:var(--pt-radius-sm);
background:transparent;color:var(--pt-text-secondary);font-size:13px}
.nbmb .bg:hover{background:var(--pt-surface-hover)}
.nbmb .brand{font-size:10.5px}
.nbmb .brand .mk{width:18px;height:18px;color:var(--pt-accent);font-size:9px}
.nbmb .ic{width:26px;height:26px;border:0;border-radius:var(--pt-radius-full);
background:transparent;color:var(--pt-text-muted);font-size:11px}
.nbmb .scrim{position:absolute;inset:0;z-index:5;background:rgba(5,9,26,.6)}
.nbmb .sheet{position:absolute;inset-block-start:46px;inset-inline:0;z-index:6;
flex-direction:column;align-items:stretch;gap:2px;padding:8px;
background:var(--pt-bg-overlay);border-bottom:1px solid var(--pt-border-default);
box-shadow:var(--pt-shadow-5);
border-end-start-radius:var(--pt-radius-xl);border-end-end-radius:var(--pt-radius-xl)}
.nbmb .sheet a{padding:8px 10px;border-radius:var(--pt-radius-md);font-size:10px}
.nbmb .sheet a:hover{background:var(--pt-surface-hover)}
.nbmb .sheet a[aria-current=page]{color:var(--pt-accent);background:var(--pt-bg-inset)}
.nbmb .close{margin-top:4px;padding:7px;border-radius:var(--pt-radius-md);
border:1px solid var(--pt-border-default);background:transparent;
color:var(--pt-text-muted);font-size:9px}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.nbmb');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
/* تفعيل الرابط الحالي — سلوك مشترك بين كل الأشرطة */
var links = [].slice.call(root.querySelectorAll('nav a'));
links.forEach(function (a) {
a.addEventListener('click', function (e) {
e.preventDefault();
links.forEach(function (x) { x.removeAttribute('aria-current'); });
a.setAttribute('aria-current', 'page');
});
});
/* إغلاق أي قائمة مفتوحة بالهروب أو بالضغط خارجها */
function autoClose(btn, panel, onToggle) {
function set(v) {
panel.hidden = !v;
btn.setAttribute('aria-expanded', String(v));
if (onToggle) onToggle(v);
}
btn.addEventListener('click', function (e) { e.stopPropagation(); set(panel.hidden); });
panel.addEventListener('click', function (e) { e.stopPropagation(); });
document.addEventListener('click', function () { if (!panel.hidden) set(false); });
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape' && !panel.hidden) { set(false); btn.focus(); }
});
return set;
}
var bg = root.querySelector('.bg'), sheet = root.querySelector('.sheet');
var scrim = root.querySelector('.scrim'), close = root.querySelector('.close');
var last = null;
function set(v) {
sheet.hidden = !v; scrim.hidden = !v;
bg.setAttribute('aria-expanded', String(v));
if (v) { last = document.activeElement; sheet.querySelector('a').focus(); }
else if (last) last.focus();
}
bg.addEventListener('click', function (e) { e.stopPropagation(); set(sheet.hidden); });
close.addEventListener('click', function () { set(false); });
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('a, button');
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(); }
});
}
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(); });
})();
# Mobile Navbar with 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:** Mobile Navbar with Sheet — A hamburger that opens a full sheet and traps focus
**Why this component matters:** A mobile sheet must trap focus and restore it to the trigger on close, or keyboard users tab straight into the page hidden behind it.
**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.