المكوّنات · شريط سفلي بشارات عدّ
شريط سفلي بشارات عدّ
الشارة تُقصّ عند 99+ والمجموع محسوب من المحادثات
7 تصاميم من هذه العائلة
<div class="ap aptbb"><div class="ph">
<div class="sb"><span class="tm num"></span>
<span class="r" aria-hidden="true"><span>▲</span><span>◗</span><span class="bt num"></span></span></div>
<div class="scr"><div class="body"><ul class="ch"></ul></div></div>
<nav class="tb" role="tablist" aria-label="التنقّل الرئيسي"></nav>
<div class="safe"></div>
</div></div>
/* pt-scoped */
/* apptab-badge — تطبيق محادثة */
.aptbb{width:100%;height:100%;display:flex;align-items:center;
justify-content:center;padding:6px;font-size:10px;color:var(--pt-text-secondary);
overflow:hidden}
.aptbb .ph{position:relative;width:198px;height:100%;max-height:224px;display:flex;
flex-direction:column;overflow:hidden;background:var(--pt-bg-base);
border:1px solid var(--pt-border-default);border-radius:20px;
box-shadow:var(--pt-shadow-3)}
/* شريط الحالة — ليس تزيينًا: يثبت أعلى الشاشة فلا يبدأ المحتوى عند الحافّة */
.aptbb .sb{flex:none;display:flex;align-items:center;justify-content:space-between;
padding:5px 12px 2px;font-size:7px;color:var(--pt-text-muted);
font-variant-numeric:tabular-nums}
.aptbb .sb .r{display:flex;gap:3px}
.aptbb .scr{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.aptbb .body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
-webkit-overflow-scrolling:touch}
.aptbb .body::-webkit-scrollbar{width:0}
/* المنطقة الآمنة السفلية — شريط الإيماءات يأكل ما تحته */
.aptbb .safe{flex:none;height:9px;display:grid;place-items:center}
.aptbb .safe::after{content:'';width:52px;height:3px;border-radius:99px;
background:var(--pt-border-strong)}
.aptbb h6{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.aptbb p{margin:0;font-size:8px;color:var(--pt-text-muted);line-height:1.65}
.aptbb .num{font-variant-numeric:tabular-nums}
.aptbb button{font:inherit;cursor:pointer;
transition:background var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
color var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
transform var(--pt-motion-duration-fast) var(--pt-motion-easing-standard)}
.aptbb button:focus-visible, .aptbb a:focus-visible, .aptbb input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
/* هدف اللمس: 44 بكسلًا على الشاشات اللمسية، ومساحة نقر ممتدّة على غيرها */
@media(pointer:coarse){.aptbb .tap{min-width:44px;min-height:44px}
}
.aptbb .tap{position:relative}
.aptbb .tap::before{content:'';position:absolute;inset:-6px}
@media(prefers-reduced-motion:reduce){.aptbb *{transition:none!important;animation:none!important}
}
.aptbb .body{padding:6px 0}
.aptbb .ch{list-style:none;margin:0;padding:0}
.aptbb .ch li{display:flex;align-items:center;gap:8px;padding:7px 12px;
border-bottom:1px solid var(--pt-border-subtle)}
.aptbb .ch .av{flex:none;width:28px;height:28px;border-radius:50%;display:grid;
place-items:center;font-size:11px;font-weight:700;color:var(--pt-color-ink-900)}
.aptbb .ch .t{font-size:9px;color:var(--pt-text-primary)}
.aptbb .ch .m{font-size:7.5px;color:var(--pt-text-muted);white-space:nowrap;
overflow:hidden;text-overflow:ellipsis;display:block;max-width:96px}
.aptbb .ch .u{flex:none;min-width:16px;height:16px;padding:0 4px;border-radius:99px;
background:var(--pt-accent);color:var(--pt-color-ink-900);font-size:7.5px;font-weight:700;
display:grid;place-items:center;font-variant-numeric:tabular-nums}
.aptbb .tb{flex:none;display:flex;padding:5px 6px 3px;background:var(--pt-surface);
border-top:1px solid var(--pt-border-subtle)}
.aptbb .tb button{position:relative;flex:1;display:flex;flex-direction:column;
align-items:center;gap:2px;padding:4px 0;border:0;background:transparent;
color:var(--pt-text-muted);font-size:6.5px}
.aptbb .tb button i{font-style:normal;font-size:13px;line-height:1}
.aptbb .tb button[aria-selected=true]{color:var(--pt-accent)}
.aptbb .bd{position:absolute;inset-block-start:0;inset-inline-end:calc(50% - 16px);
min-width:13px;height:13px;padding:0 3px;border-radius:99px;
background:var(--pt-color-danger-400);color:#fff;font-size:7px;font-weight:700;
display:grid;place-items:center;font-variant-numeric:tabular-nums}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.aptbb');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
var ar = document.documentElement.lang !== 'en';
var n = function (v, d) { return Number(v).toLocaleString('en-US', {
minimumFractionDigits: d || 0, maximumFractionDigits: d || 0 }); };
var money = function (usd, d) {
return ar ? n(usd * 3.75, d) + ' ر.س' : '$' + n(usd, d);
};
var set = function (sel, txt) {
var el = root.querySelector(sel); if (el) el.textContent = txt; return el;
};
/* الساعة بأرقام لاتينية دائمًا — قرار موحّد في المشروع كلّه */
(function clock() {
var t = root.querySelector('.tm');
if (!t) return;
function tick() {
var d = new Date();
t.textContent = String(d.getHours()).padStart(2, '0') + ':' +
String(d.getMinutes()).padStart(2, '0');
setTimeout(tick, 20000);
}
tick();
})();
var bt = root.querySelector('.bt');
if (bt) bt.textContent = '84%';
/* اهتزاز خفيف حيث يوجد — تأكيد لمسيّ لا يعتمد عليه شيء */
var buzz = function (ms) { try { if (navigator.vibrate) navigator.vibrate(ms || 8); } catch (e) {} };
var CHATS = [
{ t: 'مجموعة العمل', m: 'راجعوا الملفّ قبل الاجتماع', u: 12, h: 200 },
{ t: 'خالد المطيري', m: 'تمام، أرسل لي التفاصيل', u: 3, h: 30 },
{ t: 'الدعم الفنّي', m: 'تمّ حلّ التذكرة #4821', u: 0, h: 150 },
{ t: 'العائلة', m: 'الغداء الجمعة إن شاء الله', u: 128, h: 280 },
{ t: 'نورة', m: 'شكرًا لك 🌸', u: 0, h: 340 }
];
var ITEMS = [
{ i: '💬', ar: 'المحادثات', en: 'Chats', b: 0 },
{ i: '◉', ar: 'الحالات', en: 'Status', b: 4 },
{ i: '☎', ar: 'المكالمات', en: 'Calls', b: 0 },
{ i: '◔', ar: 'حسابي', en: 'Profile', b: 0 }
];
// مجموع غير المقروء محسوب من المحادثات لا مكتوب
ITEMS[0].b = CHATS.reduce(function (a, c) { return a + c.u; }, 0);
/* القصّ في النصّ والرقم الحقيقي في aria-label: «+99» تسع الشارة
والإعلان المسموع يبقى دقيقًا. */
function cap(v) { return v > 99 ? '99+' : String(v); }
root.querySelector('.ch').innerHTML = CHATS.map(function (c) {
return '<li><span class="av" style="background:hsl(' + c.h + ' 58% 66%)">' + c.t[0] +
'</span><span style="flex:1;min-width:0"><span class="t">' + c.t + '</span><br>' +
'<span class="m">' + c.m + '</span></span>' +
(c.u ? '<span class="u" aria-label="' + c.u + ' رسالة غير مقروءة">' + cap(c.u) + '</span>' : '') +
'</li>';
}).join('');
var tb = root.querySelector('.tb');
tb.innerHTML = ITEMS.map(function (x, k) {
return '<button class="tap" role="tab" aria-selected="' + (k === 0) + '">' +
'<i aria-hidden="true">' + x.i + '</i>' + (ar ? x.ar : x.en) +
(x.b ? '<span class="bd" aria-label="' + x.b + ' غير مقروءة">' + cap(x.b) + '</span>' : '') +
'</button>';
}).join('');
var btns = [].slice.call(tb.querySelectorAll('button'));
btns.forEach(function (b) {
b.addEventListener('click', function () {
btns.forEach(function (x) { x.setAttribute('aria-selected', String(x === b)); });
var bd = b.querySelector('.bd');
if (bd) bd.remove(); // فتح التبويب يصفّر شارته
buzz();
});
});
}
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(); });
})();
# Tab Bar with Count 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:** Tab Bar with Count Badges — The badge caps at 99+ and the total is summed from the conversations
**Why this component matters:** Cap the badge and keep the real number in aria-label: “99+” fits the pill while the assistive announcement stays exact.
**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.