المكوّنات · قسم تواصل بنموذج
قسم تواصل بنموذج
نموذج متعدّد الحقول بتحقّق بعد المغادرة وملخّص أخطاء
12 تصاميم من هذه العائلة
<div class="bk bkct"><section>
<div class="side">
<h3 data-ar="نبحث لك عن العقار المناسب" data-en="We find the right property for you">نبحث لك عن العقار المناسب</h3>
<p data-ar="أخبرنا بما تريد ونرسل خيارات مطابقة خلال 24 ساعة." data-en="Tell us what you want and we send matching options within 24 hours.">أخبرنا بما تريد ونرسل خيارات مطابقة خلال 24 ساعة.</p>
<ul class="meta">
<li><span aria-hidden="true">◷</span><span data-ar="ردّ خلال يوم عمل" data-en="Reply within a working day">ردّ خلال يوم عمل</span></li>
<li><span aria-hidden="true">◎</span><span data-ar="الرياض · جدّة · الخبر" data-en="Riyadh · Jeddah · Khobar">الرياض · جدّة · الخبر</span></li>
</ul>
</div>
<form class="frm" novalidate>
<div class="err-sum" tabindex="-1" hidden role="alert"></div>
<div class="row">
<label><span data-ar="الاسم" data-en="Name">الاسم</span>
<input name="nm" type="text" required></label>
<label><span data-ar="الجوّال" data-en="Mobile">الجوّال</span>
<input name="ph" type="tel" inputmode="numeric" dir="ltr" required></label>
</div>
<label><span data-ar="ما الذي تبحث عنه؟" data-en="What are you looking for?">ما الذي تبحث عنه؟</span>
<select name="tp" required><option value="">اختر…</option>
<option>شقّة</option><option>فيلا</option><option>أرض</option><option>مكتب</option></select></label>
<button type="submit" data-ar="أرسل الطلب" data-en="Send request">أرسل الطلب</button>
</form>
</section></div>
/* pt-scoped */
/* block-contact — منصّة عقارية */
.bkct{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.bkct h2{margin:0;font-size:19px;line-height:1.35;color:var(--pt-text-primary);
font-weight:700;letter-spacing:-.01em}
.bkct h3{margin:0;font-size:12px;line-height:1.4;color:var(--pt-text-primary);font-weight:600}
.bkct h4{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600}
.bkct p{margin:0;font-size:9.5px;line-height:1.85;color:var(--pt-text-muted)}
.bkct .eyebrow{font-size:8px;letter-spacing:.14em;color:var(--pt-accent);font-weight:700}
.bkct .num{font-variant-numeric:tabular-nums;letter-spacing:-.01em}
.bkct button, .bkct a{font:inherit;cursor:pointer;text-decoration:none}
.bkct button:focus-visible, .bkct a:focus-visible, .bkct input:focus-visible, .bkct summary:focus-visible{outline:2px solid var(--pt-focus-ring);outline-offset:2px}
/* الأقسام تمتدّ من حافّة إلى حافّة — هذا ما يميّزها عن المكوّنات */
.bkct > section{flex:1;display:flex;flex-direction:column;justify-content:center;min-height:0}
@media(pointer:coarse){.bkct button, .bkct a{min-height:44px;display:inline-flex;
align-items:center;justify-content:center}
}
/* شخصية: عمودان، نموذج على سطح مرفوع، انحناء صغير */
.bkct > section{flex-direction:row;align-items:center;gap:20px;padding:14px 24px;
background:var(--pt-bg-inset)}
.bkct .side{flex:1;display:flex;flex-direction:column;gap:5px;min-width:0}
.bkct .meta{list-style:none;margin:2px 0 0;padding:0;display:flex;flex-direction:column;gap:3px}
.bkct .meta li{display:flex;align-items:center;gap:5px;font-size:8px;color:var(--pt-text-muted)}
.bkct .meta span:first-child{color:var(--pt-accent);font-size:9px}
.bkct .frm{flex:1.15;display:flex;flex-direction:column;gap:6px;padding:11px;
border-radius:var(--pt-radius-sm);background:var(--pt-surface);
border:1px solid var(--pt-border-subtle)}
.bkct .row{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.bkct label{display:flex;flex-direction:column;gap:2px}
.bkct label > span{font-size:7.5px;color:var(--pt-text-muted)}
.bkct input, .bkct select{width:100%;padding:5px 7px;border-radius:var(--pt-radius-xs);
border:1px solid var(--pt-border-default);background:var(--pt-bg-inset);
font:inherit;font-size:9px;color:var(--pt-text-primary);outline:none}
.bkct [aria-invalid=true]{border-color:var(--pt-color-danger-400)}
.bkct .err-sum{padding:5px 7px;border-radius:var(--pt-radius-xs);font-size:8px;
background:color-mix(in srgb,var(--pt-color-danger-400) 14%,transparent);
color:var(--pt-color-danger-400);outline-offset:2px}
.bkct .err-sum.ok{background:var(--pt-accent-muted);color:var(--pt-accent)}
.bkct button{margin-top:1px;padding:6px;border-radius:var(--pt-radius-xs);border:0;
background:var(--pt-accent);color:var(--pt-color-ink-900);font-size:9px;font-weight:700}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.bkct');
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 frm = root.querySelector('.frm'), sum = root.querySelector('.err-sum');
var F = {
nm: { el: frm.nm, ok: function (v) { return v.trim().length >= 3; },
ar: 'الاسم قصير جدًّا', en: 'Name is too short' },
ph: { el: frm.ph, ok: function (v) { return /^0?5\d{8}$/.test(v.replace(/\D/g, '')); },
ar: 'رقم جوّال غير صحيح', en: 'Invalid mobile number' },
tp: { el: frm.tp, ok: function (v) { return !!v; },
ar: 'اختر نوع العقار', en: 'Pick a property type' }
};
Object.keys(F).forEach(function (k) {
var f = F[k], touched = false;
function paint() { f.el.setAttribute('aria-invalid', String(touched && !f.ok(f.el.value))); }
f.el.addEventListener('blur', function () { touched = true; paint(); });
f.el.addEventListener('input', function () { if (touched) paint(); });
f.el.addEventListener('change', function () { touched = true; paint(); });
});
frm.addEventListener('submit', function (e) {
e.preventDefault();
var bad = Object.keys(F).filter(function (k) { return !F[k].ok(F[k].el.value); });
/* تُكتب الحالة على كل الحقول لا على الخاطئة وحدها: الإضافة بلا رفع
تُبقي حقلًا صُحّح مُعلَّمًا بالأحمر، فيبحث المستخدم عن خطأ لا وجود له. */
Object.keys(F).forEach(function (k) {
F[k].el.setAttribute('aria-invalid', String(bad.indexOf(k) !== -1));
});
if (bad.length) {
/* ملخّص الأخطاء يتلقّى التركيز: بدونه لا يعرف مستخدم القارئ الشاشيّ
ما الذي فشل ولا أين هو. */
sum.hidden = false;
sum.className = 'err-sum';
sum.textContent = (ar ? 'صحّح ' + bad.length + ': ' : 'Fix ' + bad.length + ': ') +
bad.map(function (k) { return ar ? F[k].ar : F[k].en; }).join(' · ');
sum.focus();
return;
}
sum.hidden = false;
sum.className = 'err-sum ok';
sum.textContent = ar ? '✓ وصلنا طلبك — نراسلك خلال 24 ساعة' : '✓ Received — we reply within 24 hours';
frm.reset();
Object.keys(F).forEach(function (k) { F[k].el.removeAttribute('aria-invalid'); });
});
}
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(); });
})();
# Contact Section
**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:** Contact Section — A multi-field form validating on blur, with an error summary
**Why this component matters:** On failed submit, move focus to an error summary listing every invalid field — a screen-reader user otherwise has no way to discover what went wrong.
**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.