المكوّنات · شمعدان مصغّر
شمعدان مصغّر
أعلى وأدنى وفتح وإغلاق على مقياس واحد محسوب
12 تصاميم من هذه العائلة
<div class="gg ggc">
<div class="top"><span class="k" data-ar="أداء المحفظة — 10 جلسات" data-en="Portfolio — 10 sessions">أداء المحفظة — 10 جلسات</span>
<b class="last"></b></div>
<div class="chart" role="img" aria-label="مخطّط شمعدان"></div>
<div class="foot"><span class="lo"></span><span class="chg"></span><span class="hi"></span></div>
</div>
/* pt-scoped */
/* gauge-candles — محفظة استثمارية */
.ggc{width:100%;height:100%;display:flex;flex-direction:column;
font-size:10px;color:var(--pt-text-secondary);overflow:hidden}
.ggc .k{font-size:8.5px;color:var(--pt-text-muted)}
.ggc .v{font-variant-numeric:tabular-nums;color:var(--pt-text-primary);line-height:1.15}
.ggc .up{color:var(--pt-accent)}
.ggc .dn{color:var(--pt-color-danger-400)}
/* شخصية: مخطّط مالي داكن، حدود رفيعة، أرقام صغيرة أسفل */
.ggc{padding:9px;gap:5px;border:1px solid var(--pt-border-subtle);
border-radius:var(--pt-radius-sm);background:var(--pt-surface)}
.ggc .top{display:flex;align-items:baseline;justify-content:space-between;gap:8px}
.ggc .last{font-size:13px;font-weight:700;font-variant-numeric:tabular-nums;
color:var(--pt-text-primary)}
.ggc .chart{flex:1;display:flex;align-items:stretch;gap:4px;min-height:52px;padding:2px 0}
.ggc .cd{flex:1;position:relative}
.ggc .wick{position:absolute;inset-inline-start:50%;width:1px;transform:translateX(-50%);
background:var(--pt-border-strong)}
.ggc .bd{position:absolute;inset-inline:1px;border-radius:1px;min-height:2px}
.ggc .cd.u .bd{background:var(--pt-accent)}
.ggc .cd.d .bd{background:var(--pt-color-danger-400)}
.ggc .foot{display:flex;justify-content:space-between;font-size:8px;
color:var(--pt-text-muted);font-variant-numeric:tabular-nums}
/* يعمل داخل إطار معزول — لا يعتمد على شيء خارجه */
/* pt-remount — يعاد التركيب عند تبديل اللغة */
(function () {
var host = document.querySelector('.ggc');
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 S = [
[104, 109, 103, 108], [108, 112, 106, 107], [107, 111, 105, 110],
[110, 116, 109, 115], [115, 117, 111, 112], [112, 114, 108, 109],
[109, 118, 108, 117], [117, 122, 115, 121], [121, 123, 117, 118],
[118, 126, 117, 125]
];
var his = S.map(function (c) { return c[1]; });
var los = S.map(function (c) { return c[2]; });
// مقياس واحد لكل الشموع — تحجيم كل شمعة لنفسها يعطي مخطّطًا بلا معنى
var hi = Math.max.apply(null, his), lo = Math.min.apply(null, los);
var span = hi - lo || 1;
var chart = root.querySelector('.chart');
var pos = function (v) { return ((hi - v) / span) * 100; };
S.forEach(function (c) {
var o = c[0], h = c[1], l = c[2], cl = c[3];
var d = document.createElement('div');
d.className = 'cd ' + (cl >= o ? 'u' : 'd');
var w = document.createElement('span');
w.className = 'wick';
w.style.top = pos(h) + '%'; w.style.bottom = (100 - pos(l)) + '%';
var b = document.createElement('span');
b.className = 'bd';
b.style.top = pos(Math.max(o, cl)) + '%';
b.style.bottom = (100 - pos(Math.min(o, cl))) + '%';
d.appendChild(w); d.appendChild(b); chart.appendChild(d);
});
var first = S[0][0], last = S[S.length - 1][3];
var chg = ((last - first) / first) * 100;
root.querySelector('.last').textContent = money(last * 1000);
root.querySelector('.lo').textContent = nf(lo);
root.querySelector('.hi').textContent = nf(hi);
var el = root.querySelector('.chg');
el.textContent = (chg >= 0 ? '+' : '−') + nf(Math.abs(chg), 1) + '%';
el.className = 'chg ' + (chg >= 0 ? 'up' : 'dn');
}
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(); });
})();
# Micro Candlestick
**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:** Micro Candlestick — High, low, open and close on one computed scale
**Why this component matters:** Candles must share a single scale derived from the global min and max; scaling each candle to itself produces a chart that looks plausible and is meaningless.
**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.