المكوّنات · قمع تحويل
قمع تحويل
كل مرحلة نسبتان: من سابقتها ومن الأولى
12 تصاميم من هذه العائلة
<div class="gg ggf">
<span class="k" data-ar="مسار التحويل — الحملة الربيعية" data-en="Conversion path — Spring campaign">مسار التحويل — الحملة الربيعية</span>
<ul class="steps"></ul>
</div>
/* pt-scoped */
/* gauge-funnel — حملة تسويقية */
.ggf{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.ggf .k{font-size:8.5px;color:var(--pt-text-muted)}
.ggf .v{font-variant-numeric:tabular-nums;color:var(--pt-text-primary);line-height:1.15}
.ggf .up{color:var(--pt-accent)}
.ggf .dn{color:var(--pt-color-danger-400)}
/* شخصية: أشرطة متدرّجة العرض، انحناء متوسّط، نسبتان لكل صفّ */
.ggf{padding:9px;gap:7px}
.ggf .steps{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:5px}
.ggf li{display:flex;flex-direction:column;gap:3px}
.ggf .row{display:flex;align-items:baseline;gap:7px;font-size:9px}
.ggf .nm{flex:1;color:var(--pt-text-secondary)}
.ggf .n{font-variant-numeric:tabular-nums;color:var(--pt-text-primary)}
.ggf .step{font-size:8px;font-variant-numeric:tabular-nums;min-width:34px;text-align:end}
.ggf .bar{height:9px;border-radius:var(--pt-radius-md);background:var(--pt-accent);
width:0;transition:width var(--pt-motion-duration-slow) var(--pt-motion-easing-decelerate)}
.ggf li:nth-child(n+2) .bar{background:color-mix(in srgb,var(--pt-accent) 70%,transparent)}
.ggf li:nth-child(n+4) .bar{background:color-mix(in srgb,var(--pt-accent) 45%,transparent)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.ggf');
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 STEPS = [
{ ar: 'مشاهدة الإعلان', en: 'Impressions', v: 48200 },
{ ar: 'زيارة الصفحة', en: 'Visits', v: 9640 },
{ ar: 'إضافة للسلّة', en: 'Add to cart', v: 2410 },
{ ar: 'بدء الدفع', en: 'Checkout', v: 1180 },
{ ar: 'طلب مكتمل', en: 'Purchase', v: 742 }
];
var ul = root.querySelector('.steps');
var first = STEPS[0].v;
STEPS.forEach(function (s, i) {
var li = document.createElement('li');
var prev = i === 0 ? s.v : STEPS[i - 1].v;
// نسبتان معًا: أين يقع التسرّب، وكم بقي من الأصل
var stepPct = (s.v / prev) * 100;
var totalPct = (s.v / first) * 100;
li.innerHTML =
'<div class="row"><span class="nm">' + s.ar + '</span>' +
'<span class="n">' + nf(s.v) + '</span>' +
'<span class="step ' + (stepPct >= 50 ? 'up' : 'dn') + '">' +
(i === 0 ? '—' : nf(stepPct, 1) + '%') + '</span></div>' +
'<span class="bar" role="meter" aria-valuemin="0" aria-valuemax="100" ' +
'aria-valuenow="' + Math.round(totalPct) + '" aria-label="' + s.ar + '"></span>';
ul.appendChild(li);
requestAnimationFrame(function () {
li.querySelector('.bar').style.width = Math.max(6, totalPct) + '%';
});
});
}
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(); });
})();
# Conversion Funnel
**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:** Conversion Funnel — Each stage carries two ratios: from the previous stage and from the first
**Why this component matters:** A funnel showing only the overall rate hides where the drop happens. Showing step-over-step beside total conversion is what turns the chart into a decision.
**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.