المكوّنات · شريط تطبيق مصغّر
شريط تطبيق مصغّر
أنحف مقاس، بمبدّل مشروع ومفتاح أوامر
12 تصاميم من هذه العائلة
<div class="nb nbap">
<header>
<span class="brand"><span class="mk">▸</span></span>
<button class="proj" aria-expanded="false" aria-controls="pjp" aria-haspopup="listbox">
<span class="pn">منصّة الرصد</span>⌄</button>
<span class="sep" aria-hidden="true">/</span>
<nav aria-label="الرئيسية">
<a href="#" aria-current="page" data-ar="النظرة العامة" data-en="Overview">النظرة العامة</a><a href="#" data-ar="السجلّات" data-en="Logs">السجلّات</a><a href="#" data-ar="التنبيهات" data-en="Alerts">التنبيهات</a>
</nav>
<span class="grow"></span>
<kbd class="kb">Ctrl K</kbd>
<span class="av">م</span>
</header>
<ul id="pjp" class="pjl" role="listbox" hidden>
<li role="option" aria-selected="true">منصّة الرصد</li>
<li role="option" aria-selected="false">بوّابة العملاء</li>
<li role="option" aria-selected="false">واجهة الشركاء</li>
</ul>
<div class="stage">
<h4 data-ar="شريط تطبيق" data-en="App bar">شريط تطبيق</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-app — منصّة تقنية · 34px */
.nbap{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden;position:relative}
.nbap header{flex:none;display:flex;align-items:center;gap:9px;width:100%}
.nbap .brand{display:flex;align-items:center;gap:6px;font-weight:700;
color:var(--pt-text-primary);white-space:nowrap}
.nbap .brand .mk{display:grid;place-items:center;flex:none;font-size:10px}
.nbap nav{display:flex;align-items:center;gap:2px;min-width:0}
.nbap 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)}
.nbap nav a:hover{color:var(--pt-text-primary)}
.nbap .grow{flex:1}
.nbap .stage{flex:1;display:flex;flex-direction:column;gap:5px;padding:10px;min-height:0}
.nbap .stage h4{margin:0;font-size:10.5px;color:var(--pt-text-primary)}
.nbap .stage p{margin:0;font-size:8.5px;color:var(--pt-text-muted);line-height:1.8}
.nbap button{font:inherit;cursor:pointer}
.nbap a:focus-visible, .nbap button:focus-visible, .nbap input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
.nbap header{height:34px;padding:0 8px;background:var(--pt-bg-base);
border-bottom:1px solid var(--pt-border-default);gap:6px}
.nbap .brand .mk{width:16px;height:16px;border-radius:var(--pt-radius-xs);
background:var(--pt-accent);color:var(--pt-color-ink-900);font-size:8px}
.nbap .proj{display:flex;align-items:center;gap:4px;padding:3px 7px;
border-radius:var(--pt-radius-xs);border:1px solid var(--pt-border-subtle);
background:transparent;color:var(--pt-text-secondary);font-size:9px}
.nbap .proj:hover, .nbap .proj[aria-expanded=true]{border-color:var(--pt-accent);color:var(--pt-accent)}
.nbap .sep{color:var(--pt-border-strong);font-size:10px}
.nbap nav a{padding:3px 6px;font-size:9px;border-radius:var(--pt-radius-xs)}
.nbap nav a[aria-current=page]{color:var(--pt-accent);background:var(--pt-bg-inset)}
.nbap .kb{font-family:var(--pt-font-mono);font-size:7px;padding:2px 5px;
border-radius:var(--pt-radius-xs);border:1px solid var(--pt-border-subtle);
color:var(--pt-text-muted)}
.nbap .av{width:19px;height:19px;border-radius:var(--pt-radius-xs);display:grid;
place-items:center;background:var(--pt-accent-muted);color:var(--pt-accent);font-size:8.5px}
.nbap .pjl{position:absolute;inset-block-start:34px;inset-inline-start:30px;z-index:7;
margin:0;padding:4px;list-style:none;display:flex;flex-direction:column;gap:1px;min-width:130px;
border-radius:var(--pt-radius-sm);background:var(--pt-bg-overlay);
border:1px solid var(--pt-border-default);box-shadow:var(--pt-shadow-4)}
.nbap .pjl li{padding:5px 8px;border-radius:var(--pt-radius-xs);font-size:9px;
cursor:pointer;color:var(--pt-text-secondary)}
.nbap .pjl li:hover{background:var(--pt-surface-hover);color:var(--pt-text-primary)}
.nbap .pjl li[aria-selected=true]{color:var(--pt-accent)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.nbap');
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 proj = root.querySelector('.proj'), list = root.querySelector('.pjl');
var nm = root.querySelector('.pn');
var set = autoClose(proj, list);
list.addEventListener('click', function (e) {
var li = e.target.closest('li');
if (!li) return;
list.querySelectorAll('li').forEach(function (x) {
x.setAttribute('aria-selected', String(x === li));
});
nm.textContent = li.textContent;
set(false);
});
document.addEventListener('keydown', function (e) {
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'k') { e.preventDefault(); set(true); }
});
}
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(); });
})();
# Compact App Bar
**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:** Compact App Bar — The slimmest size, with a project switcher and a command key
**Why this component matters:** At 34px every pixel counts: use a single row, icon-sized controls, and expose the keyboard shortcut visually so the bar stays usable without growing.
**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.