المكوّنات · تسجيل بموافقات متدرّجة
تسجيل بموافقات متدرّجة
إلزامي واختياري، ومربّع كلّي بثلاث حالات لا حالتين
12 تصاميم من هذه العائلة
<div class="sg sgk">
<h5 data-ar="الموافقات" data-en="Consents">الموافقات</h5>
<label class="all"><input type="checkbox" class="ck">
<span data-ar="تحديد الكل" data-en="Select all">تحديد الكل</span></label>
<ul class="list">
<li><label><input type="checkbox" data-req="1">
<span><b data-ar="شروط الاستخدام" data-en="Terms of use">شروط الاستخدام</b>
<i data-ar="إلزامي" data-en="Required">إلزامي</i></span></label></li>
<li><label><input type="checkbox" data-req="1">
<span><b data-ar="معالجة البيانات الصحّية" data-en="Health data processing">معالجة البيانات الصحّية</b>
<i data-ar="إلزامي" data-en="Required">إلزامي</i></span></label></li>
<li><label><input type="checkbox">
<span><b data-ar="مشاركة النتائج مع طبيبي" data-en="Share results with my doctor">مشاركة النتائج مع طبيبي</b>
<i class="opt" data-ar="اختياري" data-en="Optional">اختياري</i></span></label></li>
<li><label><input type="checkbox">
<span><b data-ar="رسائل تسويقية" data-en="Marketing messages">رسائل تسويقية</b>
<i class="opt" data-ar="اختياري" data-en="Optional">اختياري</i></span></label></li>
</ul>
<span class="err"></span>
<button class="go" disabled data-ar="متابعة" data-en="Continue">متابعة</button>
</div>
/* pt-scoped */
/* signup-consent — منصّة صحّية */
.sgk{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.sgk h5{margin:0;font-size:11px;color:var(--pt-text-primary);font-weight:600}
.sgk .sub{margin:0;font-size:8.5px;color:var(--pt-text-muted)}
.sgk label{display:flex;flex-direction:column;gap:3px}
.sgk label > span{font-size:8.5px;color:var(--pt-text-muted)}
.sgk input, .sgk select{width:100%;font:inherit;font-size:9.5px;
color:var(--pt-text-primary);outline:none}
.sgk input::placeholder{color:var(--pt-text-muted)}
.sgk .err{font-size:8px;color:var(--pt-color-danger-400);min-height:0}
.sgk .ok{color:var(--pt-accent)}
.sgk button{font:inherit;cursor:pointer}
.sgk button:focus-visible, .sgk input:focus-visible{outline:2px solid var(--pt-focus-ring);
outline-offset:1px}
/* شخصية: قائمة موافقات — انحناء صغير، شارات إلزامي/اختياري */
.sgk{padding:10px;gap:6px;justify-content:center;
border:1px solid var(--pt-border-subtle);border-radius:var(--pt-radius-sm);
background:var(--pt-surface)}
.sgk label{flex-direction:row;align-items:flex-start;gap:6px;cursor:pointer}
.sgk input[type=checkbox]{width:12px;height:12px;flex:none;margin-top:1px;
accent-color:var(--pt-accent);cursor:pointer}
.sgk .all{padding:5px 7px;border-radius:var(--pt-radius-xs);background:var(--pt-bg-inset);
font-size:9px;color:var(--pt-text-primary);font-weight:600}
.sgk .list{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}
.sgk .list span{display:flex;align-items:baseline;gap:5px;flex-wrap:wrap}
.sgk .list b{font-size:9px;font-weight:400;color:var(--pt-text-secondary)}
.sgk .list i{font-style:normal;font-size:7px;padding:1px 5px;border-radius:var(--pt-radius-full);
background:color-mix(in srgb,var(--pt-color-danger-400) 18%,transparent);
color:var(--pt-color-danger-400)}
.sgk .list i.opt{background:var(--pt-bg-inset);color:var(--pt-text-muted)}
.sgk .go{padding:7px;border-radius:var(--pt-radius-xs);border:0;background:var(--pt-accent);
color:var(--pt-color-ink-900);font-size:9.5px;font-weight:600}
.sgk .go:disabled{opacity:.45;cursor:not-allowed}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.sgk');
if (!host) return;
var snapshot = host.innerHTML;
var timers = [];
var ac = null;
/* الجسم كما كتبه المولِّد. يستقبل بدائل مظلَّلة لـ root وdocument
والمؤقّتات، فينظّف نفسه دون أن يعرف أنه قابل لإعادة التركيب. */
function run(root, document, setTimeout, setInterval) {
/* الخطأ يظهر بعد مغادرة الحقل لا مع كل حرف: القراءة أثناء الكتابة
تُشعر المستخدم بالفشل قبل أن ينتهي من الإدخال. */
function bind(input, check, msg) {
var box = input.closest('label') || input.parentElement;
var err = box.querySelector('.err') || box.parentElement.querySelector('.err');
var touched = false;
function paint() {
var good = check(input.value);
input.setAttribute('aria-invalid', String(touched && !good));
if (err) err.textContent = touched && !good ? msg : '';
return good;
}
input.addEventListener('blur', function () { touched = true; paint(); });
input.addEventListener('input', function () { if (touched) paint(); });
return paint;
}
var all = root.querySelector('.ck');
var boxes = [].slice.call(root.querySelectorAll('.list input'));
var req = boxes.filter(function (b) { return b.dataset.req; });
var go = root.querySelector('.go'), err = root.querySelector('.err');
function refresh() {
var on = boxes.filter(function (b) { return b.checked; }).length;
/* ثلاث حالات لا حالتان: محدَّد، وفارغ، وغير محسوم حين يُحدَّد بعضها فقط.
إسقاط الثالثة يجعل المربّع يكذب على المستخدم. */
all.checked = on === boxes.length;
all.indeterminate = on > 0 && on < boxes.length;
var missing = req.filter(function (b) { return !b.checked; }).length;
go.disabled = missing > 0;
err.textContent = missing ? 'يلزم قبول ' + missing + ' من الموافقات الإلزامية' : '';
}
all.addEventListener('change', function () {
boxes.forEach(function (b) { b.checked = all.checked; });
refresh();
});
boxes.forEach(function (b) { b.addEventListener('change', refresh); });
refresh();
}
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(); });
})();
# Sign-up with Layered Consent
**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:** Sign-up with Layered Consent — Required and optional consents, with a genuinely tri-state “select all”
**Why this component matters:** “Select all” has three states, not two: checked, unchecked, and indeterminate. Skipping the third makes the box lie whenever only some children are ticked.
**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.