المكوّنات · شريط بحساب وإشعارات
شريط بحساب وإشعارات
قائمتان منفصلتان، فتح إحداهما يغلق الأخرى
12 تصاميم من هذه العائلة
<div class="nb nba">
<header>
<span class="brand"><span class="mk">◫</span><span data-ar="مصرف الوفاء" data-en="Wafa Bank">مصرف الوفاء</span></span>
<nav aria-label="الرئيسية">
<a href="#" aria-current="page" data-ar="الحسابات" data-en="Accounts">الحسابات</a><a href="#" data-ar="التحويلات" data-en="Transfers">التحويلات</a><a href="#" data-ar="البطاقات" data-en="Cards">البطاقات</a>
</nav>
<span class="grow"></span>
<button class="ic bell" aria-expanded="false" aria-controls="alp" aria-label="الإشعارات">
🔔<span class="dot">4</span></button>
<button class="usr" aria-expanded="false" aria-controls="usp" aria-haspopup="menu">
<span class="av">ع</span><span class="nm" data-ar="عبدالله" data-en="Abdullah">عبدالله</span>⌄</button>
</header>
<ul id="alp" class="pop alerts" hidden>
<li><b data-ar="حوالة واردة" data-en="Incoming transfer">حوالة واردة</b><span class="am"></span></li>
<li><b data-ar="فاتورة مستحقّة" data-en="Bill due">فاتورة مستحقّة</b><span class="am"></span></li>
<li><b data-ar="تنبيه أمني" data-en="Security alert">تنبيه أمني</b><span class="tm" data-ar="أمس" data-en="Yesterday">أمس</span></li>
</ul>
<ul id="usp" class="pop menu" role="menu" hidden>
<li role="none"><button role="menuitem" data-ar="ملفّي" data-en="Profile">ملفّي</button></li>
<li role="none"><button role="menuitem" data-ar="الإعدادات" data-en="Settings">الإعدادات</button></li>
<li role="none"><button role="menuitem" class="out" data-ar="خروج" data-en="Sign out">خروج</button></li>
</ul>
<div class="stage">
<h4 data-ar="حساب وإشعارات" data-en="Account and alerts">حساب وإشعارات</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-account — مصرف · 50px */
.nba{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden;position:relative}
.nba header{flex:none;display:flex;align-items:center;gap:9px;width:100%}
.nba .brand{display:flex;align-items:center;gap:6px;font-weight:700;
color:var(--pt-text-primary);white-space:nowrap}
.nba .brand .mk{display:grid;place-items:center;flex:none;font-size:10px}
.nba nav{display:flex;align-items:center;gap:2px;min-width:0}
.nba 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)}
.nba nav a:hover{color:var(--pt-text-primary)}
.nba .grow{flex:1}
.nba .stage{flex:1;display:flex;flex-direction:column;gap:5px;padding:10px;min-height:0}
.nba .stage h4{margin:0;font-size:10.5px;color:var(--pt-text-primary)}
.nba .stage p{margin:0;font-size:8.5px;color:var(--pt-text-muted);line-height:1.8}
.nba button{font:inherit;cursor:pointer}
.nba a:focus-visible, .nba button:focus-visible, .nba input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
.nba header{height:50px;padding:0 11px;background:var(--pt-surface);
border-bottom:1px solid var(--pt-border-subtle)}
.nba .brand{font-size:10.5px}
.nba .brand .mk{width:20px;height:20px;border-radius:var(--pt-radius-xs);
background:var(--pt-accent-muted);color:var(--pt-accent)}
.nba nav{margin-inline-start:9px}
.nba nav a{border-radius:var(--pt-radius-xs)}
.nba nav a[aria-current=page]{color:var(--pt-accent);background:var(--pt-bg-inset)}
.nba .ic{position:relative;width:28px;height:28px;border:0;border-radius:var(--pt-radius-full);
background:transparent;color:var(--pt-text-muted);font-size:12px}
.nba .ic[aria-expanded=true], .nba .ic:hover{background:var(--pt-surface-hover)}
.nba .dot{position:absolute;inset-block-start:1px;inset-inline-end:1px;min-width:12px;height:12px;
border-radius:99px;background:var(--pt-color-danger-400);color:#fff;font-size:7px;
display:grid;place-items:center}
.nba .usr{display:flex;align-items:center;gap:5px;padding:4px 8px 4px 4px;
border-radius:var(--pt-radius-full);border:1px solid var(--pt-border-subtle);
background:transparent;color:var(--pt-text-secondary);font-size:9px}
.nba .usr:hover, .nba .usr[aria-expanded=true]{border-color:var(--pt-accent);color:var(--pt-accent)}
.nba .av{width:19px;height:19px;border-radius:50%;display:grid;place-items:center;
background:var(--pt-accent-muted);color:var(--pt-accent);font-size:8.5px}
.nba .pop{position:absolute;inset-block-start:50px;z-index:7;margin:0;padding:5px;
list-style:none;display:flex;flex-direction:column;gap:2px;min-width:150px;
border-radius:var(--pt-radius-md);background:var(--pt-bg-overlay);
border:1px solid var(--pt-border-default);box-shadow:var(--pt-shadow-4)}
.nba .alerts{inset-inline-end:56px}
.nba .menu{inset-inline-end:8px}
.nba .alerts li{display:flex;align-items:baseline;justify-content:space-between;gap:8px;
padding:5px 7px;border-radius:var(--pt-radius-sm);font-size:9px}
.nba .alerts b{font-weight:500;color:var(--pt-text-secondary)}
.nba .alerts .am{color:var(--pt-accent);font-variant-numeric:tabular-nums;font-size:8.5px}
.nba .alerts .tm{color:var(--pt-text-muted);font-size:8px}
.nba .menu button{width:100%;padding:5px 8px;border:0;border-radius:var(--pt-radius-sm);
background:transparent;color:var(--pt-text-secondary);font-size:9px;text-align:start}
.nba .menu button:hover{background:var(--pt-surface-hover);color:var(--pt-text-primary)}
.nba .menu .out{color:var(--pt-color-danger-400)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.nba');
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 bell = root.querySelector('.bell'), alerts = root.querySelector('#alp');
var usr = root.querySelector('.usr'), menu = root.querySelector('#usp');
// فتح إحداهما يغلق الأخرى — وإلّا تراكمت اللوحات وعلق التركيز بينهما
var setAlerts = autoClose(bell, alerts, function (v) { if (v) setMenu(false); });
var setMenu = autoClose(usr, menu, function (v) { if (v) setAlerts(false); });
var amounts = [2400, 860];
root.querySelectorAll('.am').forEach(function (el, i) {
var ar = document.documentElement.lang !== 'en';
var v = amounts[i];
el.textContent = ar ? Math.round(v * 3.75).toLocaleString('en-US') + ' ر.س'
: '$' + v.toLocaleString('en-US');
});
}
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(); });
})();
# Navbar with Account and Alerts
**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:** Navbar with Account and Alerts — Two separate menus — opening one closes the other
**Why this component matters:** Two independent dropdowns in one bar must be mutually exclusive; leaving both open stacks panels over each other and traps keyboard focus between them.
**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.