المكوّنات · عدّاد نصف دائري
عدّاد نصف دائري
قوس تُحسب زاويته من النسبة وطوله من نصف القطر
12 تصاميم من هذه العائلة
<div class="gg gga" data-now="1840" data-max="2400">
<span class="k" data-ar="إنتاج الوردية" data-en="Shift output">إنتاج الوردية</span>
<svg viewBox="0 0 100 56" aria-hidden="true">
<path class="trk" d="M8 50 A42 42 0 0 1 92 50"></path>
<path class="bar" d="M8 50 A42 42 0 0 1 92 50"></path>
</svg>
<div class="mid"><b class="v"></b><span class="pc"></span></div>
<div class="ends"><span class="e0">0</span><span class="e1"></span></div>
</div>
/* pt-scoped */
/* gauge-arc — خطّ إنتاج مصنع */
.gga{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.gga .k{font-size:8.5px;color:var(--pt-text-muted)}
.gga .v{font-variant-numeric:tabular-nums;color:var(--pt-text-primary);line-height:1.15}
.gga .up{color:var(--pt-accent)}
.gga .dn{color:var(--pt-color-danger-400)}
/* شخصية: متمركزة، بلا حدود، الرقم داخل القوس */
.gga{padding:10px;align-items:center;justify-content:center;gap:2px;
background:var(--pt-bg-inset);border-radius:var(--pt-radius-2xl)}
.gga svg{width:100%;max-width:150px;height:auto;overflow:visible}
.gga .trk{fill:none;stroke:var(--pt-border-default);stroke-width:7;stroke-linecap:round}
.gga .bar{fill:none;stroke:var(--pt-accent);stroke-width:7;stroke-linecap:round;
transition:stroke-dashoffset var(--pt-motion-duration-slow) var(--pt-motion-easing-decelerate)}
.gga .mid{display:flex;align-items:baseline;gap:6px;margin-top:-14px}
.gga .v{font-size:19px;font-weight:700}
.gga .pc{font-size:9px;color:var(--pt-accent);font-variant-numeric:tabular-nums}
.gga .ends{display:flex;justify-content:space-between;width:100%;max-width:150px;
font-size:8px;color:var(--pt-text-muted);font-variant-numeric:tabular-nums}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.gga');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
function nf(x, d) {
return Number(x).toLocaleString('en-US',
{ minimumFractionDigits: d || 0, maximumFractionDigits: d || 0 });
}
function money(x) {
var ar = document.documentElement.lang !== 'en';
return ar ? nf(Math.round(x * 3.75)) + ' ر.س' : '$' + nf(x);
}
var now = +root.dataset.now, max = +root.dataset.max;
var bar = root.querySelector('.bar');
// نصف دورة = π·r — لا رقم مضبوط يدويًّا على مقاس واحد
var r = 42, L = Math.PI * r;
var share = Math.max(0, Math.min(1, now / max));
bar.style.strokeDasharray = L.toFixed(2);
bar.style.strokeDashoffset = L.toFixed(2);
root.querySelector('.v').textContent = nf(now);
root.querySelector('.pc').textContent = nf(share * 100, 1) + '%';
root.querySelector('.e1').textContent = nf(max);
requestAnimationFrame(function () {
bar.style.strokeDashoffset = (L * (1 - share)).toFixed(2);
});
}
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(); });
})();
# Semicircular Gauge
**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:** Semicircular Gauge — An arc whose angle comes from the ratio and whose length comes from the radius
**Why this component matters:** Semicircular gauges are usually faked with a hardcoded dasharray tuned to one size. Deriving the arc length from the radius (π·r for a half turn) keeps the fill exact at any dimension.
**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.