refactor: centralize body base styles in theme.css

Move font-family, background, color, margin, and transition from
duplicated inline <style> blocks in each dev target into the CSS
generator (base-css). Dev pages now only set page-specific padding.

Also fixes hiccup target rendering the wrong font due to hiccup2
HTML-escaping quotes inside <style> tags, and adds missing <!DOCTYPE>.
This commit is contained in:
Florian Schroedl
2026-03-03 11:04:27 +01:00
parent 42ddb56d65
commit 6b4899f8bf
4 changed files with 17 additions and 18 deletions

View File

@@ -21,6 +21,17 @@
(map (fn [[k v]] (str " " (token->css-var k) ": " v ";")))
(str/join "\n")))
(defn base-css
"Generate base body/reset styles."
[]
"body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
margin: 0;
background: var(--bg-0);
color: var(--fg-0);
transition: background-color 0.2s, color 0.2s;
}")
(defn component-css-button
"Generate BEM-lite CSS for the button component."
[]
@@ -94,8 +105,9 @@
" :root:not([data-theme=\"light\"]) {\n"
(str/replace (tokens->css-block dark-tokens) #"(?m)^ " " ")
"\n }\n}")
base (base-css)
components (component-css-button)]
(str/join "\n\n" [root-block dark-attr dark-media components ""])))
(str/join "\n\n" [root-block dark-attr dark-media base components ""])))
(defn build-theme!
"Read tokens from file and write generated CSS to output."