refactor: extract inline style blocks to App.css (H1)

The 130-line (Dashboard) and 155-line (Comparison) inline <style> JSX
blocks are removed and replaced with static CSS in App.css.

Font-family values that changed per language are now set as CSS custom
properties (--alt-body-font, --alt-display-font, --alt-mono-font) via
the root element's style prop — 3 vars instead of re-injecting 130+
lines of CSS on every language switch.

The redundant @import font URLs are dropped (fonts already preloaded
in index.html). Default values for the three font vars are defined in
:root so the page renders correctly before JS executes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
fahed
2026-04-26 17:46:41 +03:00
parent ef9a960e5d
commit 25cb91e31b
3 changed files with 202 additions and 291 deletions
+9 -135
View File
@@ -501,141 +501,15 @@ export default function DashboardDemo({ data, seasons: _seasons, includeVAT, set
const hasFilters = selDistricts.length>0 || selChannels.length>0 || selMuseums.length>0;
return (
<div className="alt-page" dir={L.dir}>
<style>{`
${L.fontImport}
.alt-page { max-width:1400px; margin:0 auto; padding:48px 24px 80px; font-family:${L.bodyFont}; width:100%; box-sizing:border-box; }
/* ── header ── */
.alt-back { display:inline-flex; align-items:center; gap:6px; font-size:.8125rem; color:var(--text-muted); text-decoration:none; margin-bottom:28px; transition:color .15s; }
.alt-back:hover { color:var(--accent); }
.alt-page-title { font-family:${L.displayFont}; font-size:2.25rem; font-weight:400; color:var(--text-primary); margin:0 0 6px; letter-spacing:-.03em; line-height:1.15; }
.alt-page-sub { font-size:.9375rem; color:var(--text-muted); margin:0 0 40px; font-weight:300; }
/* ── hero ── */
.dalt-hero { border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); overflow:hidden; margin-bottom:24px; }
.dalt-hero-inner { display:flex; align-items:center; justify-content:space-between; padding:24px 28px; gap:16px; flex-wrap:wrap; }
.dalt-hero-name { font-family:${L.displayFont}; font-size:2.5rem; font-weight:400; color:var(--text-primary); line-height:1; letter-spacing:-.025em; margin-bottom:6px; }
.dalt-hero-range { font-family:${L.monoFont}; font-size:.875rem; color:var(--text-muted); letter-spacing:.01em; }
.dalt-hero-btn { display:inline-flex; align-items:center; gap:5px; font-family:${L.bodyFont}; font-size:.8125rem; font-weight:500; color:var(--text-muted); background:none; border:1px solid var(--border); border-radius:8px; padding:7px 12px; cursor:pointer; transition:color .15s,border-color .15s; white-space:nowrap; }
.dalt-hero-btn:hover { color:var(--accent); border-color:var(--accent); }
/* ── picker ── */
.alt-picker { border-top:1px solid var(--border); padding:16px 24px 20px; background:var(--bg); animation:altPickIn 180ms cubic-bezier(.16,1,.3,1); }
@keyframes altPickIn { from{opacity:0;transform:translateY(-8px)} to{opacity:1;transform:translateY(0)} }
.alt-picker-year { display:flex; align-items:center; gap:16px; margin-bottom:16px; padding-bottom:12px; border-bottom:1px solid var(--border); }
.alt-yr-val { font-family:${L.displayFont}; font-size:1.25rem; color:var(--text-primary); min-width:50px; text-align:center; }
.alt-yr-btn { width:28px; height:28px; display:flex; align-items:center; justify-content:center; border:1px solid var(--border); border-radius:7px; background:var(--surface); color:var(--text-secondary); cursor:pointer; transition:background .12s,border-color .12s,color .12s; }
.alt-yr-btn:hover:not(:disabled) { background:var(--accent); border-color:var(--accent); color:var(--text-inverse); }
.alt-yr-btn:disabled { opacity:.3; cursor:not-allowed; }
.alt-picker-section { font-size:.625rem; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--text-muted); margin:10px 0 6px; }
.alt-chips { display:flex; flex-wrap:wrap; gap:5px; margin-bottom:4px; }
.alt-chip { font-family:${L.bodyFont}; padding:4px 9px; border:1px solid var(--border); border-radius:6px; background:var(--surface); color:var(--text-secondary); font-size:.8rem; font-weight:500; cursor:pointer; transition:background .1s,border-color .1s,color .1s; }
.alt-chip:hover { border-color:var(--accent); color:var(--accent); background:var(--accent-light); }
.alt-chip-on { background:var(--accent)!important; border-color:var(--accent)!important; color:var(--text-inverse)!important; font-weight:600!important; }
.alt-chip-wide { padding-left:14px; padding-right:14px; }
.alt-picker-div { height:1px; background:var(--border); margin:12px 0 10px; }
.alt-custom { display:flex; align-items:flex-end; gap:8px; }
.alt-custom-f { flex:1; display:flex; flex-direction:column; gap:4px; }
.alt-custom-f label { font-size:.625rem; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--text-muted); }
.alt-custom-f input[type="date"] { padding:7px 9px; border:1px solid var(--border); border-radius:7px; font-size:.825rem; background:var(--surface); color:var(--text-primary); width:100%; }
.alt-custom-f input[type="date"]:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 2px rgba(37,99,235,.12); }
.alt-custom-arrow { font-size:.75rem; color:var(--text-muted); padding-bottom:9px; flex-shrink:0; }
.alt-footer { display:flex; justify-content:flex-end; gap:8px; }
.alt-cancel,.alt-apply { padding:7px 16px; border-radius:7px; font-size:.825rem; font-weight:600; cursor:pointer; font-family:${L.bodyFont}; transition:background .12s,color .12s; }
.alt-cancel { background:transparent; border:1px solid var(--border); color:var(--text-secondary); }
.alt-cancel:hover { background:var(--bg-secondary); }
.alt-apply { background:var(--accent); border:1px solid transparent; color:#fff; }
.alt-apply:hover { opacity:.88; }
/* ── multi-select ── */
.altms { position:relative; }
.altms-trigger { display:inline-flex; align-items:center; gap:6px; padding:6px 10px; border:1px solid var(--border); border-radius:8px; background:var(--surface); color:var(--text-secondary); font-family:${L.bodyFont}; font-size:.875rem; cursor:pointer; transition:border-color .15s,color .15s,background .15s; white-space:nowrap; }
.altms-trigger:hover { border-color:var(--accent); color:var(--accent); }
.altms-trigger--active { border-color:var(--accent); color:var(--accent); background:var(--accent-light); }
.altms-label { max-width:140px; overflow:hidden; text-overflow:ellipsis; }
.altms-chevron { transition:transform .18s; flex-shrink:0; color:currentColor; }
.altms-chevron--open { transform:rotate(180deg); }
.altms-dropdown { position:absolute; top:calc(100% + 6px); left:0; z-index:200; min-width:200px; background:var(--surface); border:1px solid var(--border); border-radius:10px; box-shadow:0 8px 24px rgba(0,0,0,.12); overflow:hidden; animation:altPickIn 140ms cubic-bezier(.16,1,.3,1); }
[dir="rtl"] .altms-dropdown { left:auto; right:0; }
.altms-list { max-height:220px; overflow-y:auto; padding:6px; display:flex; flex-direction:column; gap:2px; }
.altms-option { display:flex; align-items:center; gap:8px; padding:6px 8px; border-radius:6px; cursor:pointer; transition:background .1s; }
.altms-option:hover { background:var(--bg); }
.altms-option--checked { background:var(--accent-light); }
.altms-check { position:absolute; opacity:0; width:0; height:0; pointer-events:none; }
.altms-check-box { width:16px; height:16px; border:1.5px solid var(--border); border-radius:4px; display:flex; align-items:center; justify-content:center; flex-shrink:0; transition:background .1s,border-color .1s; }
.altms-option--checked .altms-check-box { background:var(--accent); border-color:var(--accent); color:var(--text-inverse); }
.altms-opt-label { font-family:${L.bodyFont}; font-size:.875rem; color:var(--text-primary); }
.altms-clear { width:100%; padding:8px 14px; border-top:1px solid var(--border); background:none; border-left:none; border-right:none; border-bottom:none; font-family:${L.bodyFont}; font-size:.8125rem; color:var(--danger); cursor:pointer; text-align:start; transition:background .1s; }
.altms-clear:hover { background:var(--danger-light); }
/* ── filter bar ── */
.alt-filter-bar { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:32px; padding:14px 20px; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); }
.alt-filter-label { font-size:.6875rem; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--text-muted); white-space:nowrap; }
.alt-filter-sep { width:1px; height:20px; background:var(--border); flex-shrink:0; }
.alt-filter-spacer { flex:1; min-width:0; }
.alt-vat-toggle { display:flex; align-items:center; border:1px solid var(--border); border-radius:8px; overflow:hidden; }
.alt-vat-opt { font-family:${L.bodyFont}; font-size:.75rem; font-weight:500; padding:5px 10px; background:var(--surface); color:var(--text-muted); cursor:pointer; border:none; transition:background .1s,color .1s; }
.alt-vat-opt--on { background:var(--accent); color:var(--text-inverse); }
.alt-filter-reset { font-size:.8125rem; color:var(--text-muted); background:none; border:none; cursor:pointer; padding:4px 6px; transition:color .15s; font-family:${L.bodyFont}; }
.alt-filter-reset:hover { color:var(--danger); }
/* ── metrics ── */
.alt-metrics { display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:1px; background:var(--border); border:1px solid var(--border); border-radius:var(--radius); overflow:hidden; margin-bottom:40px; }
.alt-metric { background:var(--surface); padding:24px 22px; }
.alt-metric-title { font-size:.6875rem; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--text-muted); margin:0 0 12px; }
.alt-metric-value { font-family:${L.displayFont}; font-size:1.875rem; font-weight:400; color:var(--text-primary); line-height:1; margin-bottom:10px; letter-spacing:-.02em; }
.alt-metric-footer { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.alt-change { font-size:.75rem; font-weight:600; padding:2px 8px; border-radius:20px; white-space:nowrap; font-family:${L.bodyFont}; }
.alt-change--up { background:var(--success-light); color:var(--success); }
.alt-change--down { background:var(--danger-light); color:var(--danger); }
.alt-change--flat { background:var(--muted-light); color:var(--text-muted); }
.alt-metric-prev { font-size:.75rem; color:var(--text-muted); font-family:${L.monoFont}; }
/* ── section heading ── */
.alt-section-heading { display:flex; align-items:center; gap:12px; margin:0 0 20px; }
.alt-section-heading h2 { font-family:${L.displayFont}; font-size:1.375rem; font-weight:400; color:var(--text-primary); margin:0; letter-spacing:-.02em; }
.alt-section-heading::after { content:''; flex:1; height:1px; background:var(--border); }
/* ── charts ── */
.dalt-charts-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.dalt-chart-full { grid-column:1/-1; }
.alt-chart-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:24px 24px 20px; min-width:0; overflow:hidden; }
.alt-chart-header { display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:20px; gap:12px; flex-wrap:wrap; }
.alt-chart-title { font-family:${L.displayFont}; font-size:1.25rem; font-weight:400; color:var(--text-primary); margin:0; letter-spacing:-.02em; font-style:italic; }
.alt-chart-controls { display:flex; gap:5px; flex-wrap:wrap; }
.alt-ctrl { font-family:${L.bodyFont}; font-size:.75rem; font-weight:500; padding:4px 10px; border:1px solid var(--border); border-radius:6px; background:var(--bg); color:var(--text-secondary); cursor:pointer; transition:background .1s,border-color .1s,color .1s; }
.alt-ctrl:hover { border-color:var(--accent); color:var(--accent); }
.alt-ctrl-on { background:var(--accent)!important; border-color:var(--accent)!important; color:var(--text-inverse)!important; }
.alt-ctrl-sep { width:1px; height:20px; background:var(--border); align-self:center; }
.alt-chart-wrap { position:relative; height:260px; overflow:hidden; direction:ltr; width:100%; }
.alt-chart-wrap--tall { height:320px; }
/* ── responsive ── */
@media (max-width:700px) {
.dalt-hero-name { font-size:1.875rem; }
.dalt-charts-grid { grid-template-columns:1fr; }
.dalt-chart-full { grid-column:auto; }
.alt-metrics { grid-template-columns:1fr 1fr; }
.alt-page-title { font-size:1.75rem; }
.altms-label { max-width:100px; }
.alt-filter-bar { overflow-x:auto; flex-wrap:nowrap; padding-inline:12px; -webkit-overflow-scrolling:touch; }
.altms-trigger { flex-shrink:0; }
.alt-vat-toggle { flex-shrink:0; }
.alt-filter-spacer { display:none; }
}
/* ── focus-visible ── */
.alt-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.alt-ctrl:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.alt-yr-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dalt-hero-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.altms-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.altms-clear:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.alt-cancel:focus-visible, .alt-apply:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
`}</style>
<div
className="alt-page"
dir={L.dir}
style={{
'--alt-body-font': L.bodyFont,
'--alt-display-font': L.displayFont,
'--alt-mono-font': L.monoFont,
} as React.CSSProperties}
>
<h1 className="alt-page-title">{L.pageTitle}</h1>
<p className="alt-page-sub">{L.pageSub}</p>