المكوّنات · بطاقة طقس بمنحنى ساعات
بطاقة طقس بمنحنى ساعات
المنحنى مرسوم من القيم، والمقياس من أدناها وأقصاها
9 تصاميم من هذه العائلة
<div class="ap apcwx"><div class="ph">
<div class="sb"><span class="tm num"></span>
<span class="r" aria-hidden="true"><span>▲</span><span>◗</span><span class="bt num"></span></span></div>
<div class="scr"><div class="body">
<article class="wx">
<div class="now"><div><span class="ct" data-ar="الرياض" data-en="Riyadh">الرياض</span>
<b class="tm2 num"></b><span class="ds"></span></div>
<span class="ico" aria-hidden="true">☀</span></div>
<div class="mm"><span class="hi num"></span><span class="lo num"></span></div>
<svg class="spark" viewBox="0 0 160 34" preserveAspectRatio="none" aria-hidden="true">
<path class="fillp"></path><path class="linep"></path></svg>
<ul class="hrs"></ul>
</article>
</div></div>
<div class="safe"></div>
</div></div>
/* pt-scoped */
/* appcard-weather — تطبيق طقس */
.apcwx{width:100%;height:100%;display:flex;align-items:center;
justify-content:center;padding:6px;font-size:10px;color:var(--pt-text-secondary);
overflow:hidden}
.apcwx .ph{position:relative;width:198px;height:100%;max-height:224px;display:flex;
flex-direction:column;overflow:hidden;background:var(--pt-bg-base);
border:1px solid var(--pt-border-default);border-radius:20px;
box-shadow:var(--pt-shadow-3)}
/* شريط الحالة — ليس تزيينًا: يثبت أعلى الشاشة فلا يبدأ المحتوى عند الحافّة */
.apcwx .sb{flex:none;display:flex;align-items:center;justify-content:space-between;
padding:5px 12px 2px;font-size:7px;color:var(--pt-text-muted);
font-variant-numeric:tabular-nums}
.apcwx .sb .r{display:flex;gap:3px}
.apcwx .scr{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden}
.apcwx .body{flex:1;min-height:0;overflow-y:auto;overflow-x:hidden;
-webkit-overflow-scrolling:touch}
.apcwx .body::-webkit-scrollbar{width:0}
/* المنطقة الآمنة السفلية — شريط الإيماءات يأكل ما تحته */
.apcwx .safe{flex:none;height:9px;display:grid;place-items:center}
.apcwx .safe::after{content:'';width:52px;height:3px;border-radius:99px;
background:var(--pt-border-strong)}
.apcwx h6{margin:0;font-size:10px;color:var(--pt-text-primary);font-weight:600;line-height:1.4}
.apcwx p{margin:0;font-size:8px;color:var(--pt-text-muted);line-height:1.65}
.apcwx .num{font-variant-numeric:tabular-nums}
.apcwx button{font:inherit;cursor:pointer;
transition:background var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
color var(--pt-motion-duration-fast) var(--pt-motion-easing-standard),
transform var(--pt-motion-duration-fast) var(--pt-motion-easing-standard)}
.apcwx button:focus-visible, .apcwx a:focus-visible, .apcwx input:focus-visible{
outline:2px solid var(--pt-focus-ring);outline-offset:-1px}
/* هدف اللمس: 44 بكسلًا على الشاشات اللمسية، ومساحة نقر ممتدّة على غيرها */
@media(pointer:coarse){.apcwx .tap{min-width:44px;min-height:44px}
}
.apcwx .tap{position:relative}
.apcwx .tap::before{content:'';position:absolute;inset:-6px}
@media(prefers-reduced-motion:reduce){.apcwx *{transition:none!important;animation:none!important}
}
.apcwx .body{padding:10px 12px;display:flex;align-items:center}
.apcwx .wx{width:100%;display:flex;flex-direction:column;gap:7px;padding:11px;
border-radius:16px;
background:linear-gradient(155deg,
color-mix(in srgb,var(--pt-accent) 20%,var(--pt-surface)),var(--pt-surface));
border:1px solid var(--pt-border-subtle)}
.apcwx .now{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}
.apcwx .ct{font-size:8.5px;color:var(--pt-text-muted)}
.apcwx .tm2{display:block;font-size:26px;line-height:1.1;color:var(--pt-text-primary);
font-weight:700;letter-spacing:-.02em}
.apcwx .ds{font-size:8px;color:var(--pt-text-secondary)}
.apcwx .ico{font-size:26px}
.apcwx .mm{display:flex;gap:9px;font-size:8px;color:var(--pt-text-muted)}
.apcwx .spark{width:100%;height:34px;display:block}
.apcwx .linep{fill:none;stroke:var(--pt-accent);stroke-width:1.4;stroke-linejoin:round;
stroke-linecap:round;vector-effect:non-scaling-stroke}
.apcwx .fillp{fill:color-mix(in srgb,var(--pt-accent) 16%,transparent);stroke:none}
.apcwx .hrs{list-style:none;margin:0;padding:0;display:flex;justify-content:space-between}
.apcwx .hrs li{display:flex;flex-direction:column;align-items:center;gap:1px;font-size:6.5px;
color:var(--pt-text-muted);font-variant-numeric:tabular-nums}
.apcwx .hrs b{font-size:8px;color:var(--pt-text-primary)}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.apcwx');
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 money = function (usd, d) {
return ar ? n(usd * 3.75, d) + ' ر.س' : '$' + n(usd, d);
};
var set = function (sel, txt) {
var el = root.querySelector(sel); if (el) el.textContent = txt; return el;
};
/* الساعة بأرقام لاتينية دائمًا — قرار موحّد في المشروع كلّه */
(function clock() {
var t = root.querySelector('.tm');
if (!t) return;
function tick() {
var d = new Date();
t.textContent = String(d.getHours()).padStart(2, '0') + ':' +
String(d.getMinutes()).padStart(2, '0');
setTimeout(tick, 20000);
}
tick();
})();
var bt = root.querySelector('.bt');
if (bt) bt.textContent = '84%';
/* اهتزاز خفيف حيث يوجد — تأكيد لمسيّ لا يعتمد عليه شيء */
var buzz = function (ms) { try { if (navigator.vibrate) navigator.vibrate(ms || 8); } catch (e) {} };
var HOURS = [
{ h: '13', t: 38, i: '☀' }, { h: '14', t: 39, i: '☀' }, { h: '15', t: 39, i: '☀' },
{ h: '16', t: 37, i: '⛅' }, { h: '17', t: 35, i: '⛅' }, { h: '18', t: 33, i: '☁' },
{ h: '19', t: 31, i: '☁' }
];
var temps = HOURS.map(function (x) { return x.t; });
var hi = Math.max.apply(null, temps), lo = Math.min.apply(null, temps);
set('.tm2', temps[0] + '°');
set('.ds', ar ? 'صحو · يُحسّ كأنّه 41°' : 'Clear · feels like 41°');
set('.hi', (ar ? 'العظمى ' : 'H ') + hi + '°');
set('.lo', (ar ? 'الصغرى ' : 'L ') + lo + '°');
/* المقياس من أدنى القيم وأقصاها لا من الصفر: مدى 33–38 يصير خطًّا مستقيمًا
لحظة تثبيت المحور عند الصفر. */
var W = 160, H = 34, PAD = 4;
var span = Math.max(1, hi - lo);
var pts = temps.map(function (t, i) {
return [i / (temps.length - 1) * W, PAD + (1 - (t - lo) / span) * (H - PAD * 2)];
});
var d = pts.map(function (p, i) {
return (i ? 'L' : 'M') + p[0].toFixed(1) + ' ' + p[1].toFixed(1);
}).join(' ');
root.querySelector('.linep').setAttribute('d', d);
root.querySelector('.fillp').setAttribute('d', d + ' L' + W + ' ' + H + ' L0 ' + H + ' Z');
root.querySelector('.hrs').innerHTML = HOURS.map(function (x) {
return '<li><span>' + x.h + '</span><span>' + x.i + '</span><b>' + x.t + '°</b></li>';
}).join('');
}
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(); });
})();
# Weather Card with Hourly Curve
**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:** Weather Card with Hourly Curve — The curve is generated from the values, scaled to their own min and max
**Why this component matters:** Scale the sparkline to the actual min and max of the series, not to zero: a range of 33–38°C flattens into a straight line the moment you anchor the axis at zero.
**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.