المكوّنات · شريط جانبي بلوحة أوامر
شريط جانبي بلوحة أوامر
Ctrl+K تفتح بحثًا يقفز إلى أي قسم بالكيبورد وحده
13 تصاميم من هذه العائلة
<div class="sb sbcm">
<nav aria-label="التنقّل الرئيسي">
<div class="sb-head">
<b data-ar="مشاريع نُهى" data-en="Nuha Projects">مشاريع نُهى</b>
<kbd class="hint">Ctrl K</kbd>
</div>
<ul>
<li data-k="اللوحة Board"><button class="item" data-nav aria-current="page">
<span class="ic" aria-hidden="true">◰</span>
<span class="lbl" data-ar="اللوحة" data-en="Board">اللوحة</span>
</button></li>
<li data-k="المهامّ Tasks"><button class="item" data-nav>
<span class="ic" aria-hidden="true">◱</span>
<span class="lbl" data-ar="المهامّ" data-en="Tasks">المهامّ</span>
</button></li>
<li data-k="المراحل Milestones"><button class="item" data-nav>
<span class="ic" aria-hidden="true">◲</span>
<span class="lbl" data-ar="المراحل" data-en="Milestones">المراحل</span>
</button></li>
<li data-k="الفريق Team"><button class="item" data-nav>
<span class="ic" aria-hidden="true">◳</span>
<span class="lbl" data-ar="الفريق" data-en="Team">الفريق</span>
</button></li>
<li data-k="الوقت Time"><button class="item" data-nav>
<span class="ic" aria-hidden="true">◴</span>
<span class="lbl" data-ar="الوقت" data-en="Time">الوقت</span>
</button></li>
<li data-k="الملفات Files"><button class="item" data-nav>
<span class="ic" aria-hidden="true">◵</span>
<span class="lbl" data-ar="الملفات" data-en="Files">الملفات</span>
</button></li>
</ul>
</nav>
<div class="body">
<h4 data-ar="إدارة مشاريع" data-en="Project management">إدارة مشاريع</h4>
<p data-ar="اضغط أي بند لتراه ينشط. التنقّل بالكيبورد يعمل بالأسهم." data-en="Click any item to activate it. Arrow keys navigate.">اضغط أي بند لتراه ينشط. التنقّل بالكيبورد يعمل بالأسهم.</p>
<button class="openp" data-ar="افتح لوحة الأوامر" data-en="Open command palette">افتح لوحة الأوامر</button>
</div>
<div class="pal" hidden role="dialog" aria-modal="true" aria-label="لوحة الأوامر">
<input class="pq" type="text" aria-label="اكتب للبحث"
placeholder="اكتب للانتقال…" data-ar-ph="اكتب للانتقال…" data-en-ph="Type to jump…">
<ul class="pres" role="listbox"></ul>
<p class="pempty" hidden data-ar="لا نتائج" data-en="No results">لا نتائج</p>
</div>
</div>
/* pt-scoped */
/* sidebar-command — إدارة مشاريع */
.sbcm{display:flex;height:100%;width:100%;font-size:10px;
color:var(--pt-text-secondary);overflow:hidden;position:relative}
.sbcm nav{flex:none;display:flex;flex-direction:column;min-width:0}
.sbcm ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;
overflow-y:auto;flex:1}
.sbcm li{margin:0}
.sbcm .item{display:flex;align-items:center;width:100%;border:0;background:transparent;
color:inherit;font:inherit;font-size:10px;cursor:pointer;text-align:start;
white-space:nowrap;overflow:hidden;position:relative}
.sbcm .ic{flex:none;text-align:center;line-height:1}
.sbcm .lbl{flex:1;overflow:hidden;text-overflow:ellipsis}
.sbcm .body{flex:1;padding:12px;display:flex;flex-direction:column;gap:7px;min-width:0}
.sbcm .body h4{margin:0;font-size:11px;color:var(--pt-text-primary)}
.sbcm .body p{margin:0;font-size:9px;color:var(--pt-text-muted);line-height:1.8}
.sbcm .item:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:-2px}
/* شخصية: تقنية — حدود مربّعة، لوحة عائمة، مفتاح ظاهر */
.sbcm{border:1px solid var(--pt-border-default);border-radius:var(--pt-radius-sm);
background:var(--pt-bg-base)}
.sbcm nav{width:200px;background:var(--pt-surface);
border-inline-end:1px solid var(--pt-border-default)}
.sbcm .sb-head{display:flex;align-items:center;gap:6px;padding:8px 10px;
border-bottom:1px solid var(--pt-border-subtle)}
.sbcm .sb-head b{flex:1;font-size:10px;color:var(--pt-text-primary)}
.sbcm .hint{font-family:var(--pt-font-mono);font-size:7.5px;padding:2px 5px;
border-radius:var(--pt-radius-xs);border:1px solid var(--pt-border-default);
color:var(--pt-text-muted);white-space:nowrap}
.sbcm ul{padding:5px;gap:1px}
.sbcm .item{gap:7px;padding:5px 8px;border-radius:var(--pt-radius-xs)}
.sbcm .ic{width:13px;font-size:10px}
.sbcm .item:hover{background:var(--pt-surface-hover);color:var(--pt-text-primary)}
.sbcm .item[aria-current="page"]{background:var(--pt-bg-inset);color:var(--pt-accent)}
.sbcm .openp{align-self:flex-start;padding:5px 10px;border-radius:var(--pt-radius-xs);
border:1px solid var(--pt-border-default);background:var(--pt-bg-raised);
color:var(--pt-text-secondary);font:inherit;font-size:9px;cursor:pointer}
.sbcm .openp:hover{border-color:var(--pt-accent);color:var(--pt-accent)}
.sbcm .openp:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:1px}
.sbcm .pal{position:absolute;inset-block-start:14%;inset-inline:14%;z-index:8;padding:6px;
border-radius:var(--pt-radius-md);background:var(--pt-bg-overlay);
border:1px solid var(--pt-border-strong);box-shadow:var(--pt-shadow-5)}
.sbcm .pq{width:100%;border:0;border-bottom:1px solid var(--pt-border-subtle);
background:transparent;color:var(--pt-text-primary);font:inherit;font-size:10px;
padding:5px 6px 7px;outline:none}
.sbcm .pres{list-style:none;margin:6px 0 0;padding:0;display:flex;flex-direction:column;
gap:1px;max-height:96px;overflow-y:auto}
.sbcm .pres li{padding:5px 7px;border-radius:var(--pt-radius-xs);font-size:9.5px;
cursor:pointer;color:var(--pt-text-secondary)}
.sbcm .pres li[aria-selected="true"]{background:var(--pt-accent);color:var(--pt-color-ink-900)}
.sbcm .pempty{margin:8px 0 4px;text-align:center;font-size:9px;color:var(--pt-text-muted)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.sbcm');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
var nav = root.querySelector('nav ul');
if (nav) {
var items = [].slice.call(nav.querySelectorAll('[data-nav]'));
items.forEach(function (b) {
b.tabIndex = b.getAttribute('aria-current') === 'page' ? 0 : -1;
b.addEventListener('click', function () { activate(b); });
});
function activate(b) {
items.forEach(function (x) {
var on = x === b;
if (on) x.setAttribute('aria-current', 'page'); else x.removeAttribute('aria-current');
x.tabIndex = on ? 0 : -1;
});
b.focus();
}
nav.addEventListener('keydown', function (e) {
var i = items.indexOf(document.activeElement);
if (i === -1) return;
var j = null;
if (e.key === 'ArrowDown') j = (i + 1) % items.length;
else if (e.key === 'ArrowUp') j = (i - 1 + items.length) % items.length;
else if (e.key === 'Home') j = 0;
else if (e.key === 'End') j = items.length - 1;
if (j === null) return;
e.preventDefault();
items[j].focus();
});
}
function norm(s) {
return String(s).replace(/[\u064B-\u0652\u0670\u0640]/g, '')
.replace(/[\u0622\u0623\u0625\u0671]/g, '\u0627')
.replace(/\u0629/g, '\u0647').replace(/\u0649/g, '\u064A')
.toLowerCase().trim();
}
function stripAl(w) { return w.length > 4 && w.indexOf('\u0627\u0644') === 0 ? w.slice(2) : w; }
var pal = root.querySelector('.pal');
var q = root.querySelector('.pq');
var res = root.querySelector('.pres');
var empty = root.querySelector('.pempty');
var navItems = [].slice.call(root.querySelectorAll('nav [data-nav]'));
var sel = 0, shown = [];
function render() {
var t = norm(q.value);
shown = navItems.filter(function (b) {
return !t || norm(b.closest('li').dataset.k).indexOf(t) !== -1
|| norm(b.closest('li').dataset.k).indexOf(stripAl(t)) !== -1;
});
res.innerHTML = '';
shown.forEach(function (b, i) {
var li = document.createElement('li');
li.textContent = b.querySelector('.lbl').textContent;
li.setAttribute('role', 'option');
li.setAttribute('aria-selected', String(i === sel));
li.addEventListener('click', function () { go(i); });
res.appendChild(li);
});
empty.hidden = shown.length > 0;
}
function go(i) { if (shown[i]) { shown[i].click(); open(false); } }
function open(v) {
pal.hidden = !v;
if (v) { q.value = ''; sel = 0; render(); q.focus(); }
}
root.querySelector('.openp').addEventListener('click', function () { open(true); });
q.addEventListener('input', function () { sel = 0; render(); });
document.addEventListener('keydown', function (e) {
// مفتاح الخبراء: يُلغى الافتراضي حتى لا يفتح بحث المتصفّح
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'k') { e.preventDefault(); open(true); return; }
if (pal.hidden) return;
if (e.key === 'Escape') { open(false); return; }
if (e.key === 'ArrowDown') { e.preventDefault(); sel = (sel + 1) % shown.length; render(); }
else if (e.key === 'ArrowUp') { e.preventDefault(); sel = (sel - 1 + shown.length) % shown.length; render(); }
else if (e.key === 'Enter') { e.preventDefault(); go(sel); }
});
}
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(); });
})();
# Sidebar with Command Palette
**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:** Sidebar with Command Palette — Ctrl+K opens a search that jumps anywhere by keyboard alone
**Why this component matters:** Power users navigate by typing, not clicking. A palette needs a visible keyboard hint, arrow-key selection, Enter to confirm and Escape to dismiss — a search box without those is just a filter.
**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.