المكوّنات · شريط بإعلان علوي
شريط بإعلان علوي
شريط عرض فوقه بمؤقّت حقيقي، ويُغلق فلا يعود
12 تصاميم من هذه العائلة
<div class="nb nban">
<div class="promo">
<span data-ar="شحن مجّاني على الطلبات فوق" data-en="Free shipping over">شحن مجّاني على الطلبات فوق</span>
<b class="amt"></b>
<span class="tmr"></span>
<button class="x" aria-label="إغلاق الإعلان">✕</button>
</div>
<header>
<span class="brand"><span class="mk">◇</span><span data-ar="متجر نُدى" data-en="Nada Store">متجر نُدى</span></span>
<nav aria-label="الرئيسية">
<a href="#" aria-current="page" data-ar="الأقسام" data-en="Categories">الأقسام</a><a href="#" data-ar="الجديد" data-en="New">الجديد</a><a href="#" data-ar="العروض" data-en="Deals">العروض</a>
</nav>
<span class="grow"></span>
<button class="ic" aria-label="السلّة">🛍<span class="dot">2</span></button>
</header>
<div class="stage">
<h4 data-ar="إعلان علوي" data-en="Announcement bar">إعلان علوي</h4>
<p data-ar="اضغط أي رابط ليصير الحالي. القوائم تُغلق بالهروب وبالضغط خارجها." data-en="Click any link to make it current. Menus close on Escape and outside click.">اضغط أي رابط ليصير الحالي. القوائم تُغلق بالهروب وبالضغط خارجها.</p>
</div>
</div>
/* pt-scoped */
/* navbar-announce — متجر إلكتروني · 44px */
.nban{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden;position:relative}
.nban header{flex:none;display:flex;align-items:center;gap:9px;width:100%}
.nban .brand{display:flex;align-items:center;gap:6px;font-weight:700;
color:var(--pt-text-primary);white-space:nowrap}
.nban .brand .mk{display:grid;place-items:center;flex:none;font-size:10px}
.nban nav{display:flex;align-items:center;gap:2px;min-width:0}
.nban nav a{padding:5px 8px;color:var(--pt-text-muted);white-space:nowrap;cursor:pointer;
transition:color var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
background var(--pt-motion-duration-fast) var(--pt-motion-easing-standard)}
.nban nav a:hover{color:var(--pt-text-primary)}
.nban .grow{flex:1}
.nban .stage{flex:1;display:flex;flex-direction:column;gap:5px;padding:10px;min-height:0}
.nban .stage h4{margin:0;font-size:10.5px;color:var(--pt-text-primary)}
.nban .stage p{margin:0;font-size:8.5px;color:var(--pt-text-muted);line-height:1.8}
.nban button{font:inherit;cursor:pointer}
.nban a:focus-visible, .nban button:focus-visible, .nban input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
.nban .promo{flex:none;display:flex;align-items:center;justify-content:center;gap:6px;
height:24px;padding:0 8px;font-size:8.5px;
background:linear-gradient(90deg,
color-mix(in srgb,var(--pt-accent) 16%,var(--pt-bg-base)),
color-mix(in srgb,var(--pt-accent) 28%,var(--pt-bg-base)),
color-mix(in srgb,var(--pt-accent) 16%,var(--pt-bg-base)));
color:var(--pt-text-primary);
border-bottom:1px solid color-mix(in srgb,var(--pt-accent) 30%,transparent)}
.nban .promo b{color:var(--pt-accent);font-variant-numeric:tabular-nums}
.nban .tmr{font-size:8px;color:var(--pt-text-muted);font-variant-numeric:tabular-nums}
.nban .promo .x{position:absolute;inset-inline-end:6px;width:16px;height:16px;border:0;
border-radius:var(--pt-radius-full);background:transparent;color:var(--pt-text-muted);font-size:8px}
.nban .promo .x:hover{background:var(--pt-surface-hover);color:var(--pt-text-primary)}
.nban header{height:44px;padding:0 11px;background:var(--pt-surface);
border-bottom:1px solid var(--pt-border-subtle)}
.nban .brand{font-size:10.5px}
.nban .brand .mk{width:19px;height:19px;color:var(--pt-accent);font-size:11px}
.nban nav{margin-inline-start:9px}
.nban nav a{border-radius:var(--pt-radius-full)}
.nban nav a[aria-current=page]{color:var(--pt-accent);background:var(--pt-bg-inset)}
.nban .ic{position:relative;width:27px;height:27px;border:0;border-radius:var(--pt-radius-full);
background:transparent;color:var(--pt-text-muted);font-size:12px}
.nban .dot{position:absolute;inset-block-start:0;inset-inline-end:0;min-width:12px;height:12px;
border-radius:99px;background:var(--pt-accent);color:var(--pt-color-ink-900);
font-size:7px;display:grid;place-items:center}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.nban');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
/* تفعيل الرابط الحالي — سلوك مشترك بين كل الأشرطة */
var links = [].slice.call(root.querySelectorAll('nav a'));
links.forEach(function (a) {
a.addEventListener('click', function (e) {
e.preventDefault();
links.forEach(function (x) { x.removeAttribute('aria-current'); });
a.setAttribute('aria-current', 'page');
});
});
/* إغلاق أي قائمة مفتوحة بالهروب أو بالضغط خارجها */
function autoClose(btn, panel, onToggle) {
function set(v) {
panel.hidden = !v;
btn.setAttribute('aria-expanded', String(v));
if (onToggle) onToggle(v);
}
btn.addEventListener('click', function (e) { e.stopPropagation(); set(panel.hidden); });
panel.addEventListener('click', function (e) { e.stopPropagation(); });
document.addEventListener('click', function () { if (!panel.hidden) set(false); });
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape' && !panel.hidden) { set(false); btn.focus(); }
});
return set;
}
var promo = root.querySelector('.promo');
var KEY = 'nb-promo-off';
try { if (localStorage.getItem(KEY) === '1') promo.remove(); } catch (e) {}
var x = root.querySelector('.x');
if (x) x.addEventListener('click', function () {
promo.remove();
try { localStorage.setItem(KEY, '1'); } catch (e) {}
});
var amt = root.querySelector('.amt');
if (amt) {
var ar = document.documentElement.lang !== 'en';
amt.textContent = ar ? '200 ر.س' : '$53';
}
var tmr = root.querySelector('.tmr');
if (tmr) {
// الهدف تاريخ لا عدّاد يتناقص — الطرح المتتابع ينحرف مع الوقت
var end = Date.now() + 3 * 3600e3 + 42 * 60e3;
(function tick() {
var left = Math.max(0, end - Date.now());
var h = Math.floor(left / 36e5), m = Math.floor(left / 6e4) % 60, s = Math.floor(left / 1e3) % 60;
tmr.textContent = '· ' + h + ':' + String(m).padStart(2, '0') + ':' + String(s).padStart(2, '0');
setTimeout(tick, 1000);
})();
}
}
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(); });
})();
# Navbar with Announcement Bar
**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:** Navbar with Announcement Bar — A promo strip above with a real timer that stays dismissed
**Why this component matters:** A promo bar that returns on every page load is an annoyance; persist the dismissal, and compute the countdown from a target date so it never drifts.
**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.