Spaces:
Sleeping
Sleeping
Download dashboard/note_css.py from Viney/readthrough: direct link, hf CLI and curl.
- Browser
- Download file 14.5 kB
-
https://huggingface.co/spaces/Viney/readthrough/resolve/main/dashboard/note_css.py
- Command line
-
hf download hf://spaces/Viney/readthrough/dashboard/note_css.py
-
curl -L -o note_css.py https://huggingface.co/spaces/Viney/readthrough/resolve/main/dashboard/note_css.py
14.5 kB
| """The research-note design system, lifted verbatim from the published note. | |
| Source of truth: the artifact "NVIDIA T2 FY2027 Readthrough" | |
| (https://claude.ai/code/artifact/a552e2bc-add9-48ea-b706-4b95f122d0e5). | |
| Every colour, font stack, size, weight, border and breakpoint below is the | |
| artifact's own value, copied unchanged. The only transform applied is a | |
| ``.rt-note`` prefix on each selector: Streamlit ships base styles for ``p``, | |
| ``h1``, ``ul``, ``table`` and friends that are class-scoped and would | |
| otherwise win on specificity. Scoping the note lets the artifact's bare | |
| selectors keep their values and still beat the host page. | |
| Three exports: | |
| ``FONT_IMPORT`` the artifact's three families, by @import instead of <link>. | |
| ``TOKENS`` the artifact's ``:root`` palette, deliberately *not* scoped β | |
| the app chrome reads the same variables, which is what makes | |
| the two halves one design. | |
| ``NOTE_CSS`` the note itself, masthead through footer. | |
| **Never write an angle bracket in this file's CSS, comments included.** The | |
| stylesheet reaches the page inside a ``<style>`` element; a ``<`` in a comment | |
| is read as the start of a tag and truncates the element there, silently | |
| dropping every rule after it β and, because the app concatenates this | |
| stylesheet with its own chrome CSS, everything after it too. A comment | |
| mentioning the svg tag once cost the whole page its layout. | |
| """ | |
| from __future__ import annotations | |
| # ββ Typefaces ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # The artifact loads these with a <link>; Streamlit strips link tags out of | |
| # markdown, so the same three families arrive by @import instead. Same | |
| # families, same weights, same optical-size range, same display=swap. | |
| FONT_IMPORT = ( | |
| "@import url('https://fonts.googleapis.com/css2?" | |
| "family=Newsreader:ital,opsz,wght@0,6..72,400;0,6..72,500;0,6..72,600;1,6..72,400" | |
| "&family=IBM+Plex+Sans:wght@400;500;600" | |
| "&family=IBM+Plex+Mono:wght@400;500&display=swap');" | |
| ) | |
| # ββ Tokens β the artifact's :root, unscoped so the chrome inherits it ββββββββ | |
| TOKENS = """ | |
| :root{ | |
| --paper:#F5F6F3; --paper-2:#ECEEE9; --ink:#15201B; --ink-2:#3E4A44; --ink-3:#8C968F; --rule:#D5DAD4; | |
| --accent:#1E6B55; --accent-ink:#134A3B; --accent-soft:#DCEBE3; --warn:#B8791F; --warn-soft:#F4E8D2; --crit:#A63A2B; --crit-soft:#F3DDD8; | |
| --pos:#1E6B55; --neg:#A63A2B; | |
| } | |
| @media (prefers-color-scheme: dark){ | |
| :root:not([data-theme="light"]){ | |
| --paper:#111715; --paper-2:#181F1C; --ink:#E7ECE8; --ink-2:#B4BDB7; --ink-3:#77817B; --rule:#2A332E; | |
| --accent:#5FBF9E; --accent-ink:#8ED8BE; --accent-soft:#1B2E27; --warn:#D9A24A; --warn-soft:#332816; --crit:#E07A69; --crit-soft:#3A1F1B; | |
| --pos:#5FBF9E; --neg:#E07A69; | |
| } | |
| } | |
| :root[data-theme="dark"]{ | |
| --paper:#111715; --paper-2:#181F1C; --ink:#E7ECE8; --ink-2:#B4BDB7; --ink-3:#77817B; --rule:#2A332E; | |
| --accent:#5FBF9E; --accent-ink:#8ED8BE; --accent-soft:#1B2E27; --warn:#D9A24A; --warn-soft:#332816; --crit:#E07A69; --crit-soft:#3A1F1B; | |
| --pos:#5FBF9E; --neg:#E07A69; | |
| } | |
| """ | |
| # ββ Tokens, light only βββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # The same :root values with the dark branches dropped. The app uses this one. | |
| # | |
| # Not a preference: the app's charts go through plotly, which takes literal | |
| # colours and cannot read a CSS variable, so those cannot follow a media | |
| # query. Letting the note flip to dark while the charts beside it stayed light | |
| # would split the page in two. Pinning the whole app to the note's light | |
| # palette keeps it one document β and it is the appearance the note was | |
| # published with. The dark tokens stay in TOKENS for anything rendered outside | |
| # Streamlit, where nothing is pinned. | |
| TOKENS_LIGHT = """ | |
| :root{ | |
| --paper:#F5F6F3; --paper-2:#ECEEE9; --ink:#15201B; --ink-2:#3E4A44; --ink-3:#8C968F; --rule:#D5DAD4; | |
| --accent:#1E6B55; --accent-ink:#134A3B; --accent-soft:#DCEBE3; --warn:#B8791F; --warn-soft:#F4E8D2; --crit:#A63A2B; --crit-soft:#F3DDD8; | |
| --pos:#1E6B55; --neg:#A63A2B; | |
| color-scheme:light; | |
| } | |
| """ | |
| # ββ The note βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| NOTE_CSS = """ | |
| .rt-note *{box-sizing:border-box} | |
| .rt-note{background:var(--paper);color:var(--ink);font-family:"IBM Plex Sans",-apple-system,"Segoe UI",Helvetica,Arial,sans-serif;font-size:15px;line-height:1.55;-webkit-font-smoothing:antialiased} | |
| .rt-note .wrap{max-width:1080px;margin:0 auto;padding:0 28px 80px} | |
| .rt-note h1,.rt-note h2,.rt-note h3{font-family:"Newsreader",Georgia,"Times New Roman",serif;font-weight:500;letter-spacing:-0.005em;text-wrap:balance;margin:0} | |
| .rt-note h1{font-size:clamp(30px,4.2vw,44px);line-height:1.1;font-weight:500} | |
| .rt-note h2{font-size:26px;line-height:1.2;margin:0 0 14px} | |
| .rt-note h3{font-size:19px;line-height:1.25;margin:22px 0 8px} | |
| .rt-note p{margin:0 0 14px;max-width:68ch} | |
| .rt-note ul,.rt-note ol{margin:0 0 14px;padding-left:20px;max-width:68ch} | |
| .rt-note li{margin-bottom:8px} | |
| .rt-note a{color:var(--accent-ink)} | |
| .rt-note .eyebrow{font-family:"IBM Plex Mono",ui-monospace,Menlo,Consolas,monospace;font-size:11.5px;letter-spacing:.12em;text-transform:uppercase;color:var(--ink-3)} | |
| /* masthead */ | |
| .rt-note .mast{display:grid;grid-template-columns:1fr auto;gap:24px;align-items:end;padding:26px 0 18px;border-bottom:2px solid var(--ink)} | |
| .rt-note .mast .house{font-family:"Newsreader",serif;font-size:22px;font-weight:600;letter-spacing:.01em} | |
| .rt-note .mast .house small{display:block;font-family:"IBM Plex Mono",monospace;font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--ink-3);font-weight:400;margin-top:2px} | |
| .rt-note .mast .meta{text-align:right;font-family:"IBM Plex Mono",monospace;font-size:12px;color:var(--ink-2);line-height:1.7} | |
| .rt-note .mast .meta b{color:var(--ink);font-weight:500} | |
| .rt-note .head{padding:34px 0 22px;border-bottom:1px solid var(--rule)} | |
| .rt-note .head .ticker{display:flex;gap:14px;align-items:baseline;flex-wrap:wrap;margin-bottom:12px} | |
| .rt-note .head .ticker .co{font-family:"Newsreader",serif;font-size:22px;font-weight:600} | |
| .rt-note .head .ticker .tk{font-family:"IBM Plex Mono",monospace;font-size:13px;color:var(--ink-2);background:var(--paper-2);padding:3px 8px;border-radius:3px} | |
| .rt-note .head .lede{font-family:"Newsreader",serif;font-size:20px;line-height:1.4;color:var(--ink-2);max-width:62ch;margin:16px 0 0;font-weight:400} | |
| /* en bref */ | |
| .rt-note .enbref{border-top:2px solid var(--ink);padding-top:14px;margin-top:22px} | |
| .rt-note .enbref h2{font-family:"IBM Plex Mono",monospace;font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--ink-3);margin:0 0 10px;font-weight:500} | |
| .rt-note .enbref ul{list-style:none;margin:0;padding:0;max-width:none} | |
| .rt-note .enbref li{font-size:15px;line-height:1.5;margin:0 0 10px} | |
| .rt-note .enbref li:last-child{margin-bottom:0} | |
| /* toc */ | |
| .rt-note nav.toc{position:sticky;top:0;background:var(--paper);border-bottom:1px solid var(--rule);z-index:2;display:flex;gap:18px;overflow-x:auto;padding:10px 0;font-family:"IBM Plex Mono",monospace;font-size:11px;letter-spacing:.06em;text-transform:uppercase;white-space:nowrap} | |
| .rt-note nav.toc a{color:var(--ink-2);text-decoration:none} | |
| .rt-note nav.toc a:hover{color:var(--accent-ink)} | |
| /* key tiles */ | |
| .rt-note .tiles{display:grid;grid-template-columns:repeat(6,1fr);border:1px solid var(--rule);border-radius:4px;margin:26px 0 0;overflow:hidden;background:var(--paper-2)} | |
| .rt-note .tile{padding:14px 16px;background:var(--paper);border-right:1px solid var(--rule)} | |
| .rt-note .tile:last-child{border-right:0} | |
| .rt-note .tile .k{font-family:"IBM Plex Mono",monospace;font-size:10.5px;letter-spacing:.1em;text-transform:uppercase;color:var(--ink-3)} | |
| .rt-note .tile .v{font-family:"Newsreader",serif;font-size:30px;line-height:1.1;margin:6px 0 4px;font-variant-numeric:tabular-nums} | |
| .rt-note .tile .s{font-size:12px;color:var(--ink-2)} | |
| .rt-note .tile .v.warn{color:var(--warn)} .rt-note .tile .v.pos{color:var(--pos)} | |
| /* layout */ | |
| .rt-note .grid{display:grid;grid-template-columns:minmax(0,1fr) 280px;gap:48px;margin-top:34px} | |
| .rt-note main>section{padding:30px 0;border-bottom:1px solid var(--rule)} | |
| .rt-note main>section:first-child{padding-top:6px} | |
| .rt-note aside{position:sticky;top:20px;align-self:start;font-size:13px} | |
| .rt-note aside .box{border-top:2px solid var(--ink);padding:12px 0 6px;margin-bottom:22px} | |
| .rt-note aside .box h4{font-family:"IBM Plex Mono",monospace;font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--ink-3);margin:0 0 10px;font-weight:500} | |
| .rt-note aside dl{margin:0;display:grid;grid-template-columns:1fr auto;gap:5px 12px} | |
| .rt-note aside dt{color:var(--ink-2)} .rt-note aside dd{margin:0;text-align:right;font-family:"IBM Plex Mono",monospace;font-variant-numeric:tabular-nums;color:var(--ink)} | |
| .rt-note aside .note{font-size:12px;color:var(--ink-3);margin-top:8px;line-height:1.45} | |
| /* source tags */ | |
| .rt-note .src{display:inline-flex;gap:0;vertical-align:middle;margin-left:6px;font-family:"IBM Plex Mono",monospace;font-size:10px;letter-spacing:.04em;line-height:1;white-space:nowrap} | |
| .rt-note .src .tag{padding:3px 6px;border:1px solid var(--rule);border-right:0;border-radius:3px 0 0 3px;color:var(--ink-2);background:var(--paper-2)} | |
| .rt-note .src .rel{padding:3px 6px;border:1px solid var(--rule);border-radius:0 3px 3px 0;font-weight:500} | |
| .rt-note .rel.hi{background:var(--accent-soft);color:var(--accent-ink);border-color:var(--accent-soft)} | |
| .rt-note .rel.med{background:var(--warn-soft);color:var(--warn);border-color:var(--warn-soft)} | |
| .rt-note .rel.low{background:var(--crit-soft);color:var(--crit);border-color:var(--crit-soft)} | |
| /* callouts */ | |
| .rt-note .thesis{border-left:3px solid var(--accent);padding:4px 0 4px 18px;margin:0 0 22px} | |
| .rt-note .thesis p{font-family:"Newsreader",serif;font-size:19px;line-height:1.4;margin:0} | |
| .rt-note .flag{background:var(--warn-soft);border-left:3px solid var(--warn);padding:12px 16px;margin:18px 0;font-size:14px;max-width:none} | |
| .rt-note .flag p{margin:0;max-width:none} | |
| .rt-note .quote{margin:14px 0 16px;padding:12px 18px;border-left:2px solid var(--rule);color:var(--ink-2);font-size:14px;max-width:70ch} | |
| .rt-note .quote p{margin:0 0 6px} .rt-note .quote .gl{font-size:13px;color:var(--ink-3);font-style:italic} | |
| /* two-col bull/bear */ | |
| .rt-note .bb{display:grid;grid-template-columns:1fr 1fr;gap:28px} | |
| .rt-note .bb h3{margin-top:0;padding-bottom:6px;border-bottom:1px solid var(--rule)} | |
| .rt-note .bb ol{padding-left:18px} .rt-note .bb li{font-size:14px} | |
| /* tables */ | |
| .rt-note .tblwrap{overflow-x:auto;margin:14px 0 6px} | |
| .rt-note table.fin{border-collapse:collapse;width:100%;font-family:"IBM Plex Mono",ui-monospace,Menlo,Consolas,monospace;font-size:12px;font-variant-numeric:tabular-nums;white-space:nowrap} | |
| .rt-note table.fin th{text-align:right;font-weight:500;color:var(--ink-2);padding:8px 10px;border-bottom:1.5px solid var(--ink);font-family:"IBM Plex Sans",sans-serif;font-size:12px} | |
| .rt-note table.fin th:first-child{text-align:left} | |
| .rt-note table.fin td{text-align:right;padding:6px 10px;border-bottom:1px solid var(--rule)} | |
| .rt-note table.fin td:first-child{text-align:left;font-family:"IBM Plex Sans",sans-serif;color:var(--ink)} | |
| .rt-note table.fin tr.sub td:first-child{padding-left:22px;color:var(--ink-2)} | |
| .rt-note table.fin td.pos{color:var(--pos)} .rt-note table.fin td.neg{color:var(--neg)} | |
| .rt-note table.fin sup{color:var(--warn);font-size:9px} | |
| /* charts */ | |
| .rt-note figure{margin:16px 0 10px;padding:14px 12px 8px;border:1px solid var(--rule);border-radius:4px;background:var(--paper)} | |
| .rt-note figure svg{width:100%;height:auto;display:block} | |
| .rt-note figure .ct{font-family:"IBM Plex Mono",monospace;font-size:11px;fill:var(--ink-3)} | |
| .rt-note figure .cv{font-family:"IBM Plex Mono",monospace;font-size:11px;fill:var(--ink)} | |
| .rt-note figure .cb{font-family:"IBM Plex Mono",monospace;font-size:11px;fill:var(--accent-ink)} | |
| .rt-note figure .cb.warn{fill:var(--warn)} | |
| .rt-note figcaption{font-size:12.5px;color:var(--ink-2);padding:6px 4px 0;max-width:none} | |
| /* timeline */ | |
| .rt-note .tl{list-style:none;padding:0;max-width:none} | |
| .rt-note .tl li{display:grid;grid-template-columns:120px 1fr;gap:14px;padding:9px 0;border-bottom:1px solid var(--rule)} | |
| .rt-note .tl .d{font-family:"IBM Plex Mono",monospace;font-size:12px;color:var(--ink-2)} | |
| /* annexes */ | |
| .rt-note .annexe{margin-top:30px;padding-top:22px;border-top:1px solid var(--rule)} | |
| .rt-note .annexe:first-of-type{margin-top:18px;padding-top:0;border-top:0} | |
| /* footer */ | |
| .rt-note .foot{margin-top:34px;padding-top:18px;border-top:2px solid var(--ink);font-size:12.5px;color:var(--ink-2)} | |
| .rt-note .foot h4{font-family:"IBM Plex Mono",monospace;font-size:11px;letter-spacing:.12em;text-transform:uppercase;color:var(--ink-3);margin:18px 0 8px;font-weight:500} | |
| .rt-note .foot ul{max-width:none} .rt-note .foot li{margin-bottom:5px} | |
| .rt-note .legend{display:flex;gap:16px;flex-wrap:wrap;font-family:"IBM Plex Mono",monospace;font-size:11px;margin:8px 0} | |
| @media (max-width:900px){ | |
| .rt-note .grid{grid-template-columns:1fr} .rt-note aside{position:static} | |
| .rt-note .tiles{grid-template-columns:repeat(3,1fr)} .rt-note .tile{border-bottom:1px solid var(--rule)} .rt-note .tile:nth-child(3n){border-right:0} | |
| .rt-note .bb{grid-template-columns:1fr} | |
| .rt-note .mast{grid-template-columns:1fr} .rt-note .mast .meta{text-align:left} | |
| } | |
| @media (max-width:560px){ .rt-note .tiles{grid-template-columns:repeat(2,1fr)} .rt-note .tile:nth-child(3n){border-right:1px solid var(--rule)} .rt-note .tile:nth-child(2n){border-right:0} .rt-note .wrap{padding:0 16px 60px} } | |
| @media (prefers-reduced-motion: reduce){ .rt-note *{animation:none!important;transition:none!important} } | |
| @media print{ | |
| .rt-note nav.toc{display:none} | |
| .rt-note .grid{display:block} | |
| .rt-note aside{position:static;margin-top:34px} | |
| .rt-note main{display:block} | |
| .rt-note figure,.rt-note table,.rt-note .quote{break-inside:avoid} | |
| .rt-note #annexes{break-before:page} | |
| .rt-note{font-size:11pt} | |
| .rt-note .wrap{padding-left:0;padding-right:0} | |
| .rt-note *{-webkit-print-color-adjust:exact;print-color-adjust:exact;color-adjust:exact} | |
| } | |
| """ | |