المكوّنات · خطأ بإعادة محاولة متباعدة
خطأ بإعادة محاولة متباعدة
المهلة تتضاعف مع كل محاولة، ولها حدّ أعلى
12 تصاميم من هذه العائلة
<div class="fb fbr"><div class="wrap">
<span class="ic" aria-hidden="true">⚠</span>
<h4 data-ar="تعذّر تحميل رصيدك" data-en="Could not load your balance">تعذّر تحميل رصيدك</h4>
<p data-ar="الاتّصال بخوادم المصرف لم ينجح. بياناتك آمنة ولم تتغيّر." data-en="The connection to the bank did not succeed. Your data is safe and unchanged.">الاتّصال بخوادم المصرف لم ينجح. بياناتك آمنة ولم تتغيّر.</p>
<button class="retry" data-ar="أعد المحاولة" data-en="Try again">أعد المحاولة</button>
<p class="state" role="status"></p>
<code class="ref"></code>
</div></div>
/* pt-scoped */
/* feedback-error — تطبيق مصرفي */
.fbr{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.fbr h4{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600;line-height:1.5}
.fbr p{margin:0;font-size:9px;line-height:1.85;color:var(--pt-text-muted)}
.fbr .num{font-variant-numeric:tabular-nums}
.fbr button{font:inherit;cursor:pointer}
.fbr button:focus-visible, .fbr input:focus-visible, .fbr a:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:2px}
.fbr button:disabled{cursor:not-allowed;opacity:.45}
/* كل حالة تُعلَن لقارئ الشاشة: تغيّرٌ لا يُرى ولا يُسمَع لم يحدث */
.fbr [role=status], .fbr [role=alert]{display:block}
@media(pointer:coarse){.fbr button{min-height:44px}
}
/* شخصية: علامة خطر، حدّ محذّر، انحناء صغير */
.fbr{align-items:center;justify-content:center;padding:13px}
.fbr .wrap{display:flex;flex-direction:column;align-items:center;text-align:center;gap:6px;
max-width:270px;padding:13px 15px;border-radius:var(--pt-radius-sm);
background:var(--pt-surface);
border:1px solid color-mix(in srgb,var(--pt-color-danger-400) 40%,transparent)}
.fbr .ic{width:26px;height:26px;display:grid;place-items:center;border-radius:50%;
background:color-mix(in srgb,var(--pt-color-danger-400) 16%,transparent);
color:var(--pt-color-danger-400);font-size:13px}
.fbr .retry{padding:6px 16px;border-radius:var(--pt-radius-sm);border:0;
background:var(--pt-accent);color:var(--pt-color-ink-900);font-size:9px;font-weight:600}
.fbr .state{font-size:8px;min-height:11px;font-variant-numeric:tabular-nums}
.fbr .ref{font-family:var(--pt-font-mono);font-size:7px;color:var(--pt-text-muted);
letter-spacing:.04em}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.fbr');
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 btn = root.querySelector('.retry'), state = root.querySelector('.state');
/* التضاعف مع سقف: طرقُ خادم متعثّر كل ثانية يزيد العطل ويستنزف البطّارية */
var BASE = 2, CAP = 30, attempt = 0, ticking = null;
/* رقم مرجعي ثابت للجلسة — يقوله المستخدم للدعم فيجدون الحادثة */
var ref = 'ERR-' + String(Math.abs(
('' + navigator.userAgent.length * 7919 + document.title.length * 104729) | 0
)).slice(0, 6);
root.querySelector('.ref').textContent = ref;
function wait(a) { return Math.min(CAP, BASE * Math.pow(2, a)); }
function countdown(secs, then) {
clearInterval(ticking);
var left = secs;
btn.disabled = true;
(function tick() {
state.textContent = ar ? 'المحاولة التالية بعد ' + left + ' ثانية'
: 'Next attempt in ' + left + 's';
if (left <= 0) { clearInterval(ticking); btn.disabled = false; then(); return; }
left--;
})();
ticking = setInterval(function () {
state.textContent = ar ? 'المحاولة التالية بعد ' + left + ' ثانية'
: 'Next attempt in ' + left + 's';
if (left-- <= 0) { clearInterval(ticking); btn.disabled = false;
state.textContent = ar ? 'يمكنك المحاولة الآن' : 'You can retry now'; then(); }
}, 1000);
}
btn.addEventListener('click', function () {
attempt++;
btn.disabled = true;
state.textContent = ar ? 'جارٍ المحاولة ' + attempt + '…' : 'Attempt ' + attempt + '…';
setTimeout(function () {
var w = wait(attempt);
state.textContent = ar ? 'فشلت المحاولة ' + attempt : 'Attempt ' + attempt + ' failed';
countdown(w, function () {});
}, 900);
});
}
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(); });
})();
# Error with Backoff Retry
**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:** Error with Backoff Retry — The wait doubles with each attempt, and it is capped
**Why this component matters:** Retry with exponential backoff and a ceiling: hammering a failing server every second makes the outage worse and drains the battery. Show the wait so the user knows the app is not stuck.
**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.