المكوّنات · هيكل تحميل
هيكل تحميل
يحجز مقاس المحتوى الحقيقي فلا تقفز الصفحة عند وصوله
12 تصاميم من هذه العائلة
<div class="fb fbs">
<div class="bar"><span class="lbl" role="status"></span>
<button class="tog" data-ar="حمّل المحتوى" data-en="Load content">حمّل المحتوى</button></div>
<ul class="list"></ul>
</div>
/* pt-scoped */
/* feedback-skeleton — صحيفة */
.fbs{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.fbs h4{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600;line-height:1.5}
.fbs p{margin:0;font-size:9px;line-height:1.85;color:var(--pt-text-muted)}
.fbs .num{font-variant-numeric:tabular-nums}
.fbs button{font:inherit;cursor:pointer}
.fbs button:focus-visible, .fbs input:focus-visible, .fbs a:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:2px}
.fbs button:disabled{cursor:not-allowed;opacity:.45}
/* كل حالة تُعلَن لقارئ الشاشة: تغيّرٌ لا يُرى ولا يُسمَع لم يحدث */
.fbs [role=status], .fbs [role=alert]{display:block}
@media(pointer:coarse){.fbs button{min-height:44px}
}
/* شخصية: قائمة أخبار، أشرطة رمادية تلمع، انحناء صغير */
.fbs{gap:7px;padding:10px 12px}
.fbs .bar{display:flex;align-items:center;justify-content:space-between;gap:8px}
.fbs .lbl{font-size:8px;color:var(--pt-text-muted)}
.fbs .tog{padding:4px 11px;border-radius:var(--pt-radius-full);
border:1px solid var(--pt-border-default);background:transparent;
color:var(--pt-text-secondary);font-size:8.5px}
.fbs .tog:hover{border-color:var(--pt-accent);color:var(--pt-accent)}
.fbs .list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:7px;
flex:1;min-height:0}
.fbs .list li{display:flex;gap:8px;align-items:flex-start}
/* المقاسات هنا هي مقاسات المحتوى الحقيقي — وإلّا قفزت الصفحة عند الاستبدال */
.fbs .th{width:52px;height:38px;flex:none;border-radius:var(--pt-radius-sm)}
.fbs .txt{flex:1;display:flex;flex-direction:column;gap:4px;min-width:0}
.fbs .l1{height:9px;width:82%;border-radius:3px}
.fbs .l2{height:7px;width:58%;border-radius:3px}
.fbs .sk{background:linear-gradient(90deg,var(--pt-bg-inset) 0%,
var(--pt-surface-hover) 50%,var(--pt-bg-inset) 100%);
background-size:200% 100%;animation:fbshine 1.4s linear infinite}
@keyframes fbshine{from{background-position:200% 0}to{background-position:-200% 0}}
@media(prefers-reduced-motion:reduce){.fbs .sk{animation:none;background:var(--pt-bg-inset)}
}
.fbs .real .t{font-size:9.5px;color:var(--pt-text-primary);line-height:1.5}
.fbs .real .m{font-size:7.5px;color:var(--pt-text-muted)}
.fbs .real .th{background:linear-gradient(135deg,#3a3f6b,#6f5aa8)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.fbs');
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 ITEMS = [
{ t: { ar: 'ارتفاع الصادرات غير النفطية في الربع الثاني', en: 'Non-oil exports rise in Q2' },
m: { ar: 'اقتصاد · قبل ساعتين', en: 'Economy · 2h ago' } },
{ t: { ar: 'افتتاح الخطّ الأزرق لقطار الرياض', en: 'Riyadh Metro blue line opens' },
m: { ar: 'محليات · قبل 4 ساعات', en: 'Local · 4h ago' } },
{ t: { ar: 'الأخضر يتأهّل بعد فوز متأخّر', en: 'Late win seals qualification' },
m: { ar: 'رياضة · أمس', en: 'Sport · yesterday' } }
];
var list = root.querySelector('.list'), lbl = root.querySelector('.lbl');
var tog = root.querySelector('.tog');
var loaded = false;
function skeleton() {
list.className = 'list';
list.innerHTML = ITEMS.map(function () {
return '<li><span class="th sk"></span><span class="txt">' +
'<span class="l1 sk"></span><span class="l2 sk"></span></span></li>';
}).join('');
lbl.textContent = ar ? 'جارٍ التحميل…' : 'Loading…';
tog.textContent = ar ? 'حمّل المحتوى' : 'Load content';
}
function real() {
list.className = 'list real';
list.innerHTML = ITEMS.map(function (it) {
return '<li><span class="th"></span><span class="txt">' +
'<span class="t">' + (ar ? it.t.ar : it.t.en) + '</span>' +
'<span class="m">' + (ar ? it.m.ar : it.m.en) + '</span></span></li>';
}).join('');
lbl.textContent = ar ? n(ITEMS.length) + ' أخبار' : n(ITEMS.length) + ' stories';
tog.textContent = ar ? 'أعرض الهيكل' : 'Show skeleton';
}
tog.addEventListener('click', function () { loaded = !loaded; loaded ? real() : skeleton(); });
skeleton();
}
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(); });
})();
# Loading Skeleton
**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:** Loading Skeleton — Reserves the real content’s box so the page does not jump when it arrives
**Why this component matters:** A skeleton must match the real content’s dimensions, or replacing it shifts the layout — the very jank it exists to prevent. And it must stop animating under prefers-reduced-motion.
**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.