المكوّنات · شريط جانبي بشارات حيّة
شريط جانبي بشارات حيّة
عدّادات تتغيّر ويُعلَن تغيّرها لقارئ الشاشة
13 تصاميم من هذه العائلة
<div class="sb sbb">
<nav aria-label="التنقّل الرئيسي">
<div class="sb-head"><b data-ar="الدعم الفنّي" data-en="Support">الدعم الفنّي</b></div>
<ul>
<li><button class="item" data-nav aria-current="page">
<span class="ic" aria-hidden="true">◍</span>
<span class="lbl" data-ar="الوارد" data-en="Inbox">الوارد</span><span class="bdg">18</span>
</button></li>
<li><button class="item" data-nav>
<span class="ic" aria-hidden="true">◎</span>
<span class="lbl" data-ar="المسنَدة إليّ" data-en="Assigned">المسنَدة إليّ</span><span class="bdg">5</span>
</button></li>
<li><button class="item" data-nav>
<span class="ic" aria-hidden="true">◌</span>
<span class="lbl" data-ar="قيد المعالجة" data-en="In progress">قيد المعالجة</span><span class="bdg">9</span>
</button></li>
<li><button class="item" data-nav>
<span class="ic" aria-hidden="true">◉</span>
<span class="lbl" data-ar="متأخّرة" data-en="Overdue">متأخّرة</span><span class="bdg">2</span>
</button></li>
<li><button class="item" data-nav>
<span class="ic" aria-hidden="true">◐</span>
<span class="lbl" data-ar="مغلقة" data-en="Closed">مغلقة</span>
</button></li>
<li><button class="item" data-nav>
<span class="ic" aria-hidden="true">⚙</span>
<span class="lbl" data-ar="الإعدادات" data-en="Settings">الإعدادات</span>
</button></li>
</ul>
</nav>
<div class="body">
<h4 data-ar="مركز الدعم" data-en="Support desk">مركز الدعم</h4>
<p data-ar="العدّاد يتغيّر كل ثلاث ثوانٍ، ويُعلَن لقارئ الشاشة بلا مقاطعة." data-en="The counter changes every three seconds and is announced without interrupting.">العدّاد يتغيّر كل ثلاث ثوانٍ، ويُعلَن لقارئ الشاشة بلا مقاطعة.</p>
<button class="bump" data-ar="تذكرة جديدة" data-en="New ticket">تذكرة جديدة</button>
</div>
</div>
/* pt-scoped */
/* sidebar-badges — مركز دعم */
.sbb{display:flex;height:100%;width:100%;font-size:10px;
color:var(--pt-text-secondary);overflow:hidden;position:relative}
.sbb nav{flex:none;display:flex;flex-direction:column;min-width:0}
.sbb ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;
overflow-y:auto;flex:1}
.sbb li{margin:0}
.sbb .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}
.sbb .ic{flex:none;text-align:center;line-height:1}
.sbb .lbl{flex:1;overflow:hidden;text-overflow:ellipsis}
.sbb .body{flex:1;padding:12px;display:flex;flex-direction:column;gap:7px;min-width:0}
.sbb .body h4{margin:0;font-size:11px;color:var(--pt-text-primary)}
.sbb .body p{margin:0;font-size:9px;color:var(--pt-text-muted);line-height:1.8}
.sbb .item:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:-2px}
/* شخصية: حلقات — النشط حلقة لا تعبئة، والشارات كبسولات */
.sbb{border:1px solid var(--pt-border-subtle);border-radius:var(--pt-radius-lg);
background:var(--pt-bg-base)}
.sbb nav{width:205px;background:var(--pt-surface);padding:6px;
border-inline-end:1px solid var(--pt-border-subtle)}
.sbb .sb-head{padding:5px 7px 9px}
.sbb .sb-head b{font-size:10px;color:var(--pt-text-primary)}
.sbb ul{padding:0;gap:4px}
.sbb .item{gap:8px;padding:6px 9px;border-radius:var(--pt-radius-full);
box-shadow:inset 0 0 0 1px transparent;
transition:box-shadow var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
color var(--pt-motion-duration-fast) var(--pt-motion-easing-standard)}
.sbb .ic{width:14px;font-size:11px}
.sbb .item:hover{box-shadow:inset 0 0 0 1px var(--pt-border-strong);color:var(--pt-text-primary)}
.sbb .item[aria-current="page"]{color:var(--pt-accent);box-shadow:inset 0 0 0 1.5px var(--pt-accent)}
.sbb .bdg{flex:none;min-width:16px;height:15px;padding:0 5px;
border-radius:var(--pt-radius-full);display:grid;place-items:center;font-size:8px;
font-weight:600;font-variant-numeric:tabular-nums;
background:var(--pt-accent-muted);color:var(--pt-accent)}
.sbb .item[aria-current="page"] .bdg{background:var(--pt-accent);color:var(--pt-color-ink-900)}
.sbb .bump{align-self:flex-start;padding:6px 11px;border-radius:var(--pt-radius-full);
border:1px solid var(--pt-border-default);background:var(--pt-bg-raised);
color:var(--pt-text-secondary);font:inherit;font-size:9.5px;cursor:pointer}
.sbb .bump:hover{border-color:var(--pt-accent);color:var(--pt-accent)}
.sbb .bump:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:1px}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.sbb');
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 badges = [].slice.call(root.querySelectorAll('.bdg'));
badges.forEach(function (b) {
b.setAttribute('aria-live', 'polite');
b.setAttribute('aria-atomic', 'true');
});
function bump(b, by) {
var v = parseInt(b.textContent, 10) || 0;
b.textContent = String(Math.max(0, v + by));
}
root.querySelector('.bump').addEventListener('click', function () { bump(badges[0], 1); });
setInterval(function () {
bump(badges[Math.floor(Math.random() * badges.length)], Math.random() > 0.5 ? 1 : -1);
}, 3000);
}
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 Live Badges
**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 Live Badges — Counters that change and announce themselves to screen readers
**Why this component matters:** A badge that changes silently is invisible to screen-reader users. aria-live="polite" announces the new count without interrupting — exactly what a notification counter needs.
**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.