Skip to content

Commit 818d6d4

Browse files
author
yash gupta
committed
refactor(svg): document auto-theme css variables
1 parent e15a46a commit 818d6d4

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

lib/svg/generator.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,10 @@ function generateAutoThemeSVG(
304304
305305
<style>
306306
@import url('https://fonts.googleapis.com/css2?family=Fira+Code&amp;family=JetBrains+Mono&amp;family=Roboto&amp;display=swap');
307+
/* Auto-theme strategy: expose the palette as CSS variables so the SVG can
308+
switch from light to dark through prefers-color-scheme. Shapes use classes
309+
instead of inline fills because inline fill attributes would override these
310+
variables and prevent the theme from updating automatically. */
307311
:root { --cp-bg: #${light.bg}; --cp-text: #${light.text}; --cp-accent: #${light.accent}; }
308312
@media (prefers-color-scheme: dark) { :root { --cp-bg: #${dark.bg}; --cp-text: #${dark.text}; --cp-accent: #${dark.accent}; } }
309313
.cp-bg-fill { fill: var(--cp-bg); } .cp-text-fill { fill: var(--cp-text); color: var(--cp-text); } .cp-accent-fill { fill: var(--cp-accent); color: var(--cp-accent); }

0 commit comments

Comments
 (0)