المكوّنات · زرّ عائم بحلقة تقدّم
زرّ عائم بحلقة تقدّم
حلقة SVG تُحسب من محيطها لا من عرض ثابت
7 تصاميم من هذه العائلة
<div class="ap apfp"><div class="ph">
<div class="sb"><span class="tm num"></span>
<span class="r" aria-hidden="true"><span>▲</span><span>◗</span><span class="bt num"></span></span></div>
<div class="scr"><div class="body">
<h6 data-ar="مكتبة الوسائط" data-en="Media library">مكتبة الوسائط</h6>
<div class="grid"></div>
</div></div>
<div class="pf">
<svg class="ring" viewBox="0 0 44 44" aria-hidden="true">
<circle class="bg" cx="22" cy="22" r="19"></circle>
<circle class="fg" cx="22" cy="22" r="19"></circle></svg>
<button class="pfab tap" aria-label="ارفع ملفًّا">↑</button>
</div>
<div class="lg" role="status" aria-live="polite"></div>
<div class="safe"></div>
</div></div>
/* pt-scoped */
/* appfab-progress — رفع وسائط */
.apfp{width:100%;height:100%;display:flex;align-items:center;
justify-content:center;padding:6px;font-size:10px;color:var(--pt-text-secondary);
overflow:hidden}
.apfp .ph{position:relative;width:198px;height:100%;max-height:224px;display:flex;
flex-direction:column;overflow:hidden;background:var(--pt-bg-base);
border:1px solid var(--pt-border-default);border-radius:20px;
box-shadow:var(--pt-shadow-3)}
/* شريط الحالة — ليس تزيينًا: يثبت أعلى الشاشة فلا يبدأ المحتوى عند الحافّة */
.apfp .sb{flex:none;display:flex;align-items:center;justify-content:space-between;
padding:5px 12px 2px;font-size:7px;color:var(--pt-text-muted);
font-variant-numeric:tabular-nums}
.apfp .sb .r{display:flex;gap:3px}
.apfp .scr{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.apfp .body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
-webkit-overflow-scrolling:touch}
.apfp .body::-webkit-scrollbar{width:0}
/* المنطقة الآمنة السفلية — شريط الإيماءات يأكل ما تحته */
.apfp .safe{flex:none;height:9px;display:grid;place-items:center}
.apfp .safe::after{content:'';width:52px;height:3px;border-radius:99px;
background:var(--pt-border-strong)}
.apfp h6{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.apfp p{margin:0;font-size:8px;color:var(--pt-text-muted);line-height:1.65}
.apfp .num{font-variant-numeric:tabular-nums}
.apfp button{font:inherit;cursor:pointer;
transition:background var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
color var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
transform var(--pt-motion-duration-fast) var(--pt-motion-easing-standard)}
.apfp button:focus-visible, .apfp a:focus-visible, .apfp input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
/* هدف اللمس: 44 بكسلًا على الشاشات اللمسية، ومساحة نقر ممتدّة على غيرها */
@media(pointer:coarse){.apfp .tap{min-width:44px;min-height:44px}
}
.apfp .tap{position:relative}
.apfp .tap::before{content:'';position:absolute;inset:-6px}
@media(prefers-reduced-motion:reduce){.apfp *{transition:none!important;animation:none!important}
}
.apfp .ph{position:relative}
.apfp .body{padding:9px 13px 46px}
.apfp .grid{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;margin-top:7px}
.apfp .grid span{aspect-ratio:1;border-radius:var(--pt-radius-sm)}
.apfp .pf{position:absolute;inset-block-end:13px;inset-inline-end:11px;z-index:5;
width:44px;height:44px;display:grid;place-items:center}
.apfp .ring{position:absolute;inset:0;transform:rotate(-90deg)}
.apfp .ring circle{fill:none;stroke-width:3;stroke-linecap:round}
.apfp .ring .bg{stroke:var(--pt-border-subtle)}
.apfp .ring .fg{stroke:var(--pt-accent);
transition:stroke-dashoffset var(--pt-motion-duration-normal) linear}
.apfp .pfab{width:34px;height:34px;border-radius:50%;border:0;background:var(--pt-accent);
color:var(--pt-color-ink-900);font-size:15px;display:grid;place-items:center;
box-shadow:var(--pt-shadow-3)}
.apfp .pfab.busy{background:var(--pt-bg-overlay);color:var(--pt-accent);
font-size:8px;font-weight:700}
.apfp .lg{position:absolute;inset-block-end:16px;inset-inline-start:12px;z-index:4;
font-size:7.5px;color:var(--pt-text-muted)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.apfp');
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 money = function (usd, d) {
return ar ? n(usd * 3.75, d) + ' ر.س' : '$' + n(usd, d);
};
var set = function (sel, txt) {
var el = root.querySelector(sel); if (el) el.textContent = txt; return el;
};
/* الساعة بأرقام لاتينية دائمًا — قرار موحّد في المشروع كلّه */
(function clock() {
var t = root.querySelector('.tm');
if (!t) return;
function tick() {
var d = new Date();
t.textContent = String(d.getHours()).padStart(2, '0') + ':' +
String(d.getMinutes()).padStart(2, '0');
setTimeout(tick, 20000);
}
tick();
})();
var bt = root.querySelector('.bt');
if (bt) bt.textContent = '84%';
/* اهتزاز خفيف حيث يوجد — تأكيد لمسيّ لا يعتمد عليه شيء */
var buzz = function (ms) { try { if (navigator.vibrate) navigator.vibrate(ms || 8); } catch (e) {} };
var HUES = [200, 32, 150, 280, 96, 340, 18, 258, 120];
root.querySelector('.grid').innerHTML = HUES.map(function (h) {
return '<span style="background:hsl(' + h + ' 38% 34%)"></span>';
}).join('');
var fg = root.querySelector('.fg'), fab = root.querySelector('.pfab');
var lg = root.querySelector('.lg');
/* المحيط محسوب من نصف القطر: تثبيت الطول يدويًّا ينكسر بأوّل تغيير
في r فتتوقّف الحلقة عن بلوغ المئة بصمت. */
var r = fg.r.baseVal.value, C = 2 * Math.PI * r;
fg.style.strokeDasharray = C;
function paint(p) { fg.style.strokeDashoffset = C * (1 - p / 100); }
paint(0);
var timer = null, p = 0;
fab.addEventListener('click', function () {
if (timer) return;
buzz(); p = 0; fab.classList.add('busy');
timer = setInterval(function () {
p = Math.min(100, p + 5);
paint(p);
fab.textContent = p + '%';
lg.textContent = (ar ? 'يُرفع ' : 'Uploading ') + '3 ' + (ar ? 'ملفّات' : 'files');
if (p >= 100) {
clearInterval(timer); timer = null;
fab.classList.remove('busy'); fab.textContent = '✓';
lg.textContent = ar ? 'اكتمل الرفع' : 'Upload complete';
setTimeout(function () { fab.textContent = '↑'; paint(0); lg.textContent = ''; }, 1500);
}
}, 130);
});
}
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(); });
})();
# FAB with Progress Ring
**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:** FAB with Progress Ring — An SVG ring computed from its own circumference, not a fixed width
**Why this component matters:** Derive stroke-dasharray from 2πr in code: hard-coding the dash length breaks the moment anyone changes the radius, and the ring silently stops reaching 100%.
**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.