المكوّنات · شريط جانبي متعدّد المستويات
شريط جانبي متعدّد المستويات
مجموعات تُفتح وتُغلق، وواحدة مفتوحة في كل مرّة
13 تصاميم من هذه العائلة
<div class="sb sbn">
<nav aria-label="التنقّل الرئيسي">
<div class="sb-head"><b data-ar="الدفاتر" data-en="Books">الدفاتر</b></div>
<ul>
<li class="grp">
<button class="item gtg" aria-expanded="true" aria-controls="g1">
<span class="ic" aria-hidden="true">◫</span>
<span class="lbl" data-ar="القيود" data-en="Journal">القيود</span>
<span class="arw" aria-hidden="true">⌄</span></button>
<ul id="g1" class="sub">
<li><button class="item" data-nav aria-current="page"><span class="lbl" data-ar="قيد جديد" data-en="New entry">قيد جديد</span></button></li>
<li><button class="item" data-nav><span class="lbl" data-ar="دفتر الأستاذ" data-en="Ledger">دفتر الأستاذ</span></button></li>
<li><button class="item" data-nav><span class="lbl" data-ar="ميزان المراجعة" data-en="Trial balance">ميزان المراجعة</span></button></li>
</ul>
</li>
<li class="grp">
<button class="item gtg" aria-expanded="false" aria-controls="g2">
<span class="ic" aria-hidden="true">◪</span>
<span class="lbl" data-ar="الفواتير" data-en="Invoices">الفواتير</span>
<span class="arw" aria-hidden="true">⌄</span></button>
<ul id="g2" class="sub" hidden>
<li><button class="item" data-nav><span class="lbl" data-ar="فواتير المبيعات" data-en="Sales">فواتير المبيعات</span></button></li>
<li><button class="item" data-nav><span class="lbl" data-ar="فواتير المشتريات" data-en="Purchases">فواتير المشتريات</span></button></li>
<li><button class="item" data-nav><span class="lbl" data-ar="إقرار الضريبة" data-en="VAT return">إقرار الضريبة</span></button></li>
</ul>
</li>
<li><button class="item" data-nav><span class="ic" aria-hidden="true">◩</span>
<span class="lbl" data-ar="التقارير المالية" data-en="Financials">التقارير المالية</span></button></li>
</ul>
</nav>
<div class="body">
<h4 data-ar="نظام محاسبة" data-en="Accounting">نظام محاسبة</h4>
<p data-ar="اضغط أي بند لتراه ينشط. التنقّل بالكيبورد يعمل بالأسهم." data-en="Click any item to activate it. Arrow keys navigate.">اضغط أي بند لتراه ينشط. التنقّل بالكيبورد يعمل بالأسهم.</p>
</div>
</div>
/* pt-scoped */
/* sidebar-nested — نظام محاسبة */
.sbn{display:flex;height:100%;width:100%;font-size:10px;
color:var(--pt-text-secondary);overflow:hidden;position:relative}
.sbn nav{flex:none;display:flex;flex-direction:column;min-width:0}
.sbn ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;
overflow-y:auto;flex:1}
.sbn li{margin:0}
.sbn .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}
.sbn .ic{flex:none;text-align:center;line-height:1}
.sbn .lbl{flex:1;overflow:hidden;text-overflow:ellipsis}
.sbn .body{flex:1;padding:12px;display:flex;flex-direction:column;gap:7px;min-width:0}
.sbn .body h4{margin:0;font-size:11px;color:var(--pt-text-primary)}
.sbn .body p{margin:0;font-size:9px;color:var(--pt-text-muted);line-height:1.8}
.sbn .item:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:-2px}
/* شخصية: ناعمة وفسيحة — انحناء كبير، تلوين خفيف بلا شريط */
.sbn{border:1px solid var(--pt-border-subtle);border-radius:var(--pt-radius-lg);
background:var(--pt-surface)}
.sbn nav{width:210px;background:transparent;padding-bottom:6px;
border-inline-end:1px solid var(--pt-border-subtle)}
.sbn .sb-head{padding:11px 12px 7px}
.sbn .sb-head b{font-size:10.5px;color:var(--pt-text-primary);font-weight:600}
.sbn ul{padding:0 8px;gap:3px}
.sbn .item{gap:8px;padding:7px 10px;border-radius:var(--pt-radius-lg)}
.sbn .ic{width:14px;font-size:11px}
.sbn .item:hover{background:var(--pt-surface-hover);color:var(--pt-text-primary)}
.sbn .item[aria-current="page"]{
background:color-mix(in srgb,var(--pt-accent) 15%,transparent);color:var(--pt-accent)}
.sbn .sub{padding:3px 0;margin-inline-start:16px;gap:2px;overflow:visible}
.sbn .sub .item{font-size:9.5px;padding:5px 10px;border-radius:var(--pt-radius-md)}
.sbn .arw{margin-inline-start:auto;font-size:9px;
transition:transform var(--pt-motion-duration-fast) var(--pt-motion-easing-standard)}
.sbn .gtg[aria-expanded="false"] .arw{transform:rotate(-90deg)}
[dir=ltr] .sbn .gtg[aria-expanded="false"] .arw{transform:rotate(90deg)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.sbn');
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();
});
}
var toggles = [].slice.call(root.querySelectorAll('.gtg'));
toggles.forEach(function (t) {
t.addEventListener('click', function () {
var open = t.getAttribute('aria-expanded') === 'true';
toggles.forEach(function (o) {
o.setAttribute('aria-expanded', 'false');
document.getElementById(o.getAttribute('aria-controls')).hidden = true;
});
if (!open) {
t.setAttribute('aria-expanded', 'true');
document.getElementById(t.getAttribute('aria-controls')).hidden = false;
}
});
});
}
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(); });
})();
# Nested Sidebar
**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:** Nested Sidebar — Groups that expand and collapse — one open at a time
**Why this component matters:** Accounting systems have more sections than fit on a screen. Accordion groups keep the list scannable; opening one closes the others so the user never faces a wall of links.
**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.