المكوّنات · قسم أسعار بمبدّل دوري
قسم أسعار بمبدّل دوري
التوفير السنوي محسوب من السعرين لا مكتوبًا
12 تصاميم من هذه العائلة
<div class="bk bkp"><section>
<div class="head">
<h3 data-ar="اختر ما يناسب فريقك" data-en="Pick what fits your team">اختر ما يناسب فريقك</h3>
<div class="tog" role="radiogroup" aria-label="دورة الفوترة">
<button role="radio" aria-checked="true" data-cycle="m" data-ar="شهري" data-en="Monthly">شهري</button>
<button role="radio" aria-checked="false" data-cycle="y" data-ar="سنوي" data-en="Yearly">سنوي</button>
<span class="save num"></span>
</div>
</div>
<ul class="tiers"></ul>
</section></div>
/* pt-scoped */
/* block-pricing — منصّة تعليمية */
.bkp{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.bkp h2{margin:0;font-size:19px;line-height:1.35;color:var(--pt-text-primary);
font-weight:700;letter-spacing:-.01em}
.bkp h3{margin:0;font-size:12px;line-height:1.4;color:var(--pt-text-primary);font-weight:600}
.bkp h4{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600}
.bkp p{margin:0;font-size:9.5px;line-height:1.85;color:var(--pt-text-muted)}
.bkp .eyebrow{font-size:8px;letter-spacing:.14em;color:var(--pt-accent);font-weight:700}
.bkp .num{font-variant-numeric:tabular-nums;letter-spacing:-.01em}
.bkp button, .bkp a{font:inherit;cursor:pointer;text-decoration:none}
.bkp button:focus-visible, .bkp a:focus-visible, .bkp input:focus-visible, .bkp summary:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:2px}
/* الأقسام تمتدّ من حافّة إلى حافّة — هذا ما يميّزها عن المكوّنات */
.bkp > section{flex:1;display:flex;flex-direction:column;justify-content:center;min-height:0}
@media(pointer:coarse){.bkp button, .bkp a{min-height:44px;display:inline-flex;
align-items:center;justify-content:center}
}
/* شخصية: ثلاث باقات، الوسطى مرفوعة، انحناء كبير */
.bkp > section{gap:10px;padding:13px 20px;background:var(--pt-bg-base)}
.bkp .head{display:flex;flex-direction:column;align-items:center;gap:6px}
.bkp .tog{display:flex;align-items:center;gap:6px}
.bkp .tog button{padding:4px 13px;border:0;border-radius:var(--pt-radius-full);
background:var(--pt-bg-inset);color:var(--pt-text-muted);font-size:8.5px;font-weight:600}
.bkp .tog button[aria-checked=true]{background:var(--pt-accent);color:var(--pt-color-ink-900)}
.bkp .save{font-size:7.5px;color:var(--pt-accent);font-weight:700}
.bkp .tiers{list-style:none;margin:0;padding:0;display:grid;
grid-template-columns:repeat(3,1fr);gap:8px;align-items:stretch}
.bkp .tiers li{display:flex;flex-direction:column;gap:5px;padding:10px 11px;
border-radius:var(--pt-radius-xl);background:var(--pt-surface);
border:1px solid var(--pt-border-subtle)}
.bkp .tiers li.best{border-color:var(--pt-accent);transform:translateY(-4px);
box-shadow:var(--pt-shadow-3)}
.bkp .tag{font-size:7px;padding:1px 7px;border-radius:var(--pt-radius-full);
background:var(--pt-accent);color:var(--pt-color-ink-900);font-weight:700;
align-self:flex-start}
.bkp .nm{font-size:9.5px;color:var(--pt-text-primary);font-weight:600}
.bkp .pr{display:flex;align-items:baseline;gap:3px}
.bkp .pr b{font-size:17px;color:var(--pt-text-primary);font-weight:700}
.bkp .pr span{font-size:7.5px;color:var(--pt-text-muted)}
.bkp .fe{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px;
font-size:7.5px;color:var(--pt-text-muted)}
.bkp .fe li::before{content:'✓ ';color:var(--pt-accent)}
.bkp .cta{margin-top:auto;padding:6px;border-radius:var(--pt-radius-lg);border:0;
background:var(--pt-bg-inset);color:var(--pt-text-secondary);font-size:8.5px;font-weight:600}
.bkp li.best .cta{background:var(--pt-accent);color:var(--pt-color-ink-900)}
@media(prefers-reduced-motion:reduce){.bkp .tiers li.best{transform:none}
}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.bkp');
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 TIERS = [
{ ar: 'فردي', en: 'Solo', m: 0, y: 0,
f: { ar: ['3 مسارات', 'شهادة إتمام'], en: ['3 tracks', 'Certificate'] } },
{ ar: 'فريق', en: 'Team', m: 19, y: 182, best: true,
f: { ar: ['كل المسارات', 'تقارير تقدّم', 'حتى 10 أعضاء'],
en: ['All tracks', 'Progress reports', 'Up to 10 seats'] } },
{ ar: 'منشأة', en: 'Enterprise', m: 49, y: 470,
f: { ar: ['مقاعد بلا حدّ', 'مسارات مخصّصة', 'مدير حساب'],
en: ['Unlimited seats', 'Custom tracks', 'Account manager'] } }
];
var cycle = 'm';
var list = root.querySelector('.tiers');
var money = function (usd) {
return ar ? n(Math.round(usd * 3.75)) + ' ر.س' : '$' + n(usd);
};
/* أكبر توفير بين الباقات المدفوعة — لا رقم مكتوب في الشارة */
var paid = TIERS.filter(function (t) { return t.m > 0; });
var best = Math.max.apply(null, paid.map(function (t) {
return Math.round((1 - t.y / (t.m * 12)) * 100);
}));
function draw() {
list.innerHTML = TIERS.map(function (t) {
var price = cycle === 'm' ? t.m : Math.round(t.y / 12);
var per = cycle === 'm' ? (ar ? '/شهريًّا' : '/mo') : (ar ? '/شهريًّا · يُدفع سنويًّا' : '/mo billed yearly');
return '<li class="' + (t.best ? 'best' : '') + '">' +
(t.best ? '<span class="tag">' + (ar ? 'الأكثر اختيارًا' : 'Most picked') + '</span>' : '') +
'<span class="nm">' + (ar ? t.ar : t.en) + '</span>' +
'<span class="pr"><b class="num">' + (price ? money(price) : (ar ? 'مجّانًا' : 'Free')) +
'</b>' + (price ? '<span>' + per + '</span>' : '') + '</span>' +
'<ul class="fe">' + (ar ? t.f.ar : t.f.en).map(function (x) {
return '<li>' + x + '</li>'; }).join('') + '</ul>' +
'<button class="cta">' + (price ? (ar ? 'ابدأ' : 'Start') : (ar ? 'جرّب' : 'Try')) + '</button></li>';
}).join('');
root.querySelector('.save').textContent = cycle === 'y'
? (ar ? 'وفّر حتى ' + best + '%' : 'save up to ' + best + '%') : '';
}
root.querySelectorAll('.tog button').forEach(function (b) {
b.addEventListener('click', function () {
root.querySelectorAll('.tog button').forEach(function (x) {
x.setAttribute('aria-checked', String(x === b));
});
cycle = b.dataset.cycle; draw();
});
});
draw();
}
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(); });
})();
# Pricing with Billing Toggle
**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:** Pricing with Billing Toggle — The annual saving is computed from both prices, never hand-written
**Why this component matters:** Compute the annual discount from the two prices. A hard-coded “save 20%” badge silently becomes a lie the first time either price changes.
**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.