المكوّنات · تقدّم متعدّد الملفّات
تقدّم متعدّد الملفّات
نسبة كلّية موزونة بالحجم لا بعدد الملفّات
12 تصاميم من هذه العائلة
<div class="fb fbp">
<div class="head"><span class="ttl" data-ar="رفع الملفّات" data-en="Uploading files">رفع الملفّات</span>
<span class="all num"></span></div>
<div class="bar"><i></i></div>
<ul class="files"></ul>
<div class="foot"><span class="sum num"></span>
<button class="tog" data-ar="ابدأ" data-en="Start">ابدأ</button></div>
</div>
/* pt-scoped */
/* feedback-progress — رفع ملفّات */
.fbp{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.fbp h4{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600;line-height:1.5}
.fbp p{margin:0;font-size:9px;line-height:1.85;color:var(--pt-text-muted)}
.fbp .num{font-variant-numeric:tabular-nums}
.fbp button{font:inherit;cursor:pointer}
.fbp button:focus-visible, .fbp input:focus-visible, .fbp a:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:2px}
.fbp button:disabled{cursor:not-allowed;opacity:.45}
/* كل حالة تُعلَن لقارئ الشاشة: تغيّرٌ لا يُرى ولا يُسمَع لم يحدث */
.fbp [role=status], .fbp [role=alert]{display:block}
@media(pointer:coarse){.fbp button{min-height:44px}
}
/* شخصية: شريط كلّي فوق قائمة ملفّات، انحناء صغير */
.fbp{gap:6px;padding:10px 12px}
.fbp .head{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.fbp .ttl{font-size:9.5px;color:var(--pt-text-primary);font-weight:600}
.fbp .all{font-size:9.5px;color:var(--pt-accent);font-weight:700}
.fbp .bar{height:4px;border-radius:99px;background:var(--pt-border-subtle);overflow:hidden}
.fbp .bar i{display:block;height:100%;width:0;background:var(--pt-accent);border-radius:inherit;
transition:width var(--pt-motion-duration-fast) linear}
.fbp .files{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px;
flex:1;overflow-y:auto;min-height:0}
.fbp .files li{display:grid;grid-template-columns:1fr auto;gap:3px 8px;font-size:8px}
.fbp .files .nm{color:var(--pt-text-secondary);white-space:nowrap;overflow:hidden;
text-overflow:ellipsis}
.fbp .files .sz{color:var(--pt-text-muted);font-variant-numeric:tabular-nums}
.fbp .files .fb2{grid-column:1 / -1;height:2px;border-radius:99px;
background:var(--pt-border-subtle);overflow:hidden}
.fbp .files .fb2 i{display:block;height:100%;width:0;background:var(--pt-accent);
transition:width var(--pt-motion-duration-fast) linear}
.fbp .files li.done .sz{color:var(--pt-accent)}
.fbp .foot{display:flex;align-items:center;justify-content:space-between;gap:8px}
.fbp .sum{font-size:7.5px;color:var(--pt-text-muted)}
.fbp .tog{padding:5px 14px;border-radius:var(--pt-radius-xs);border:0;
background:var(--pt-accent);color:var(--pt-color-ink-900);font-size:8.5px;font-weight:600}
@media(prefers-reduced-motion:reduce){.fbp .bar i, .fbp .files .fb2 i{transition:none}
}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.fbp');
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 FILES = [
{ n: 'brand-guidelines.pdf', mb: 18.4 },
{ n: 'logo-pack.zip', mb: 2.1 },
{ n: 'hero-render.png', mb: 46.9 },
{ n: 'palette.json', mb: 0.03 }
];
var total = FILES.reduce(function (a, f) { return a + f.mb; }, 0);
var list = root.querySelector('.files'), bar = root.querySelector('.bar i');
var all = root.querySelector('.all'), sum = root.querySelector('.sum');
var tog = root.querySelector('.tog');
list.innerHTML = FILES.map(function (f) {
return '<li><span class="nm" dir="ltr">' + f.n + '</span>' +
'<span class="sz">' + n(f.mb, 1) + ' MB</span>' +
'<span class="fb2"><i></i></span></li>';
}).join('');
var lis = [].slice.call(list.children);
var bars = lis.map(function (li) { return li.querySelector('.fb2 i'); });
var prog = FILES.map(function () { return 0; });
var timer = null;
function paint() {
/* الوزن بالبايت لا بالعدد: ملفّ ضخم وثلاثة صغيرة يجعلان شريط العدد
يقف عند 75% معظم الوقت، فيبدو متجمّدًا. */
var doneMb = FILES.reduce(function (a, f, i) { return a + f.mb * prog[i]; }, 0);
var pct = Math.round(doneMb / total * 100);
bar.style.width = pct + '%';
all.textContent = pct + '%';
sum.textContent = n(doneMb, 1) + ' / ' + n(total, 1) + ' MB';
prog.forEach(function (p, i) {
bars[i].style.width = (p * 100) + '%';
lis[i].classList.toggle('done', p >= 1);
});
}
function run() {
tog.textContent = ar ? 'إيقاف' : 'Pause';
timer = setInterval(function () {
var i = prog.findIndex(function (p) { return p < 1; });
if (i === -1) { stop(); tog.textContent = ar ? 'أعد' : 'Restart'; return; }
/* السرعة ثابتة بالميغابايت — فالملفّ الأكبر يأخذ وقته الحقيقي */
prog[i] = Math.min(1, prog[i] + (2.6 / FILES[i].mb));
paint();
}, 90);
}
function stop() { clearInterval(timer); timer = null; }
tog.addEventListener('click', function () {
if (timer) { stop(); tog.textContent = ar ? 'أكمل' : 'Resume'; return; }
if (prog.every(function (p) { return p >= 1; })) { prog = FILES.map(function () { return 0; }); }
run();
});
paint();
}
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(); });
})();
# Multi-file Progress
**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:** Multi-file Progress — An overall percentage weighted by size, not by file count
**Why this component matters:** Weight the overall bar by bytes, not by file count: three tiny files and one huge one make a count-based bar sit at 75% for most of the upload, which reads as frozen.
**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.