المكوّنات · أشرطة تنبيه بأربعة مستويات
أشرطة تنبيه بأربعة مستويات
اللون لا يحمل المعنى وحده — لكلٍّ رمزه ودوره
12 تصاميم من هذه العائلة
<div class="fb fbb">
<div class="rail"></div>
<div class="ctl"><button class="add" data-ar="أضف تنبيهًا" data-en="Add alert">أضف تنبيهًا</button>
<span class="cnt num"></span></div>
</div>
/* pt-scoped */
/* feedback-banner — منصّة تعليمية */
.fbb{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.fbb h4{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600;line-height:1.5}
.fbb p{margin:0;font-size:9px;line-height:1.85;color:var(--pt-text-muted)}
.fbb .num{font-variant-numeric:tabular-nums}
.fbb button{font:inherit;cursor:pointer}
.fbb button:focus-visible, .fbb input:focus-visible, .fbb a:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:2px}
.fbb button:disabled{cursor:not-allowed;opacity:.45}
/* كل حالة تُعلَن لقارئ الشاشة: تغيّرٌ لا يُرى ولا يُسمَع لم يحدث */
.fbb [role=status], .fbb [role=alert]{display:block}
@media(pointer:coarse){.fbb button{min-height:44px}
}
/* شخصية: أشرطة أفقية بحدّ جانبي ملوّن، انحناء صغير */
.fbb{gap:7px;padding:11px 12px}
.fbb .rail{flex:1;display:flex;flex-direction:column;gap:5px;overflow-y:auto;min-height:0}
.fbb .al{display:flex;align-items:flex-start;gap:7px;padding:7px 9px;
border-radius:var(--pt-radius-sm);border-inline-start:3px solid;font-size:8.5px;
animation:fbslide var(--pt-motion-duration-normal) var(--pt-motion-easing-emphasized)}
@keyframes fbslide{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
@media(prefers-reduced-motion:reduce){.fbb .al{animation:none}
}
.fbb .al i{font-style:normal;font-size:11px;line-height:1.2;flex:none}
.fbb .al .bd{flex:1;display:flex;flex-direction:column;gap:1px;min-width:0}
.fbb .al b{font-weight:600;font-size:8.5px}
.fbb .al span{color:var(--pt-text-muted);font-size:8px;line-height:1.7}
.fbb .al .x{width:15px;height:15px;min-height:0;padding:0;flex:none;border:0;border-radius:50%;
background:transparent;color:var(--pt-text-muted);font-size:8px}
.fbb .al .x:hover{background:var(--pt-surface-hover)}
.fbb .info{background:color-mix(in srgb,var(--pt-color-info-400) 11%,transparent);
border-color:var(--pt-color-info-400)}
.fbb .info b, .fbb .info i{color:var(--pt-color-info-400)}
.fbb .ok{background:color-mix(in srgb,var(--pt-accent) 12%,transparent);border-color:var(--pt-accent)}
.fbb .ok b, .fbb .ok i{color:var(--pt-accent)}
.fbb .warn{background:color-mix(in srgb,var(--pt-color-warn-400) 12%,transparent);
border-color:var(--pt-color-warn-400)}
.fbb .warn b, .fbb .warn i{color:var(--pt-color-warn-400)}
.fbb .err{background:color-mix(in srgb,var(--pt-color-danger-400) 12%,transparent);
border-color:var(--pt-color-danger-400)}
.fbb .err b, .fbb .err i{color:var(--pt-color-danger-400)}
.fbb .ctl{display:flex;align-items:center;justify-content:space-between;gap:8px}
.fbb .add{padding:5px 12px;border-radius:var(--pt-radius-sm);
border:1px solid var(--pt-border-default);background:transparent;
color:var(--pt-text-secondary);font-size:8.5px}
.fbb .add:hover{border-color:var(--pt-accent);color:var(--pt-accent)}
.fbb .cnt{font-size:8px;color:var(--pt-text-muted)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.fbb');
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 LEVELS = [
{ c: 'info', i: 'ⓘ', role: 'status',
t: { ar: 'معلومة', en: 'Info' },
m: { ar: 'أُضيف مسار جديد إلى خطّتك: تحليل البيانات.', en: 'A new track was added to your plan: Data Analysis.' } },
{ c: 'ok', i: '✓', role: 'status',
t: { ar: 'تمّ', en: 'Success' },
m: { ar: 'اجتزتَ اختبار الوحدة الثالثة بنسبة 92%.', en: 'You passed unit 3 with 92%.' } },
{ c: 'warn', i: '△', role: 'status',
t: { ar: 'تحذير', en: 'Warning' },
m: { ar: 'يتبقّى 3 أيّام على انتهاء وصولك للمسار.', en: '3 days left before your track access ends.' } },
{ c: 'err', i: '✕', role: 'alert',
t: { ar: 'خطأ', en: 'Error' },
m: { ar: 'تعذّر حفظ إجابتك — تحقّق من اتّصالك وأعد المحاولة.', en: 'Could not save your answer — check your connection and retry.' } }
];
var rail = root.querySelector('.rail'), cnt = root.querySelector('.cnt');
var k = 0;
function refresh() {
cnt.textContent = rail.children.length +
(ar ? ' من 4 مستويات' : ' of 4 levels');
}
function add(lv) {
var el = document.createElement('div');
el.className = 'al ' + lv.c;
/* role=alert للخطأ وحده: يقاطع القارئ الشاشيّ، فاستعماله للمعلومة إزعاج */
el.setAttribute('role', lv.role);
el.innerHTML = '<i aria-hidden="true">' + lv.i + '</i><span class="bd">' +
'<b>' + (ar ? lv.t.ar : lv.t.en) + '</b>' +
'<span>' + (ar ? lv.m.ar : lv.m.en) + '</span></span>' +
'<button class="x" type="button" aria-label="إغلاق">✕</button>';
rail.appendChild(el);
refresh();
}
rail.addEventListener('click', function (e) {
var x = e.target.closest('.x');
if (x) { x.closest('.al').remove(); refresh(); }
});
root.querySelector('.add').addEventListener('click', function () {
add(LEVELS[k++ % LEVELS.length]);
rail.scrollTop = rail.scrollHeight;
});
LEVELS.forEach(add);
k = 0;
}
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(); });
})();
# Four-level Alert Banners
**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:** Four-level Alert Banners — Colour never carries the meaning alone — each level has an icon and a role
**Why this component matters:** Never encode severity in colour alone: about one in twelve men cannot separate red from green. Pair every level with an icon and a text label, and use role="alert" only for errors.
**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.