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:
@@ -32,13 +32,14 @@
|
|||||||
|
|
||||||
(defn page []
|
(defn page []
|
||||||
(str
|
(str
|
||||||
|
"<!DOCTYPE html>\n"
|
||||||
(h/html
|
(h/html
|
||||||
[:html
|
[:html
|
||||||
[:head
|
[:head
|
||||||
[:meta {:charset "utf-8"}]
|
[:meta {:charset "utf-8"}]
|
||||||
[:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]
|
[:meta {:name "viewport" :content "width=device-width, initial-scale=1"}]
|
||||||
[:link {:rel "stylesheet" :href "/theme.css"}]
|
[:link {:rel "stylesheet" :href "/theme.css"}]
|
||||||
[:style "body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; padding: 2rem; background: var(--bg-0); color: var(--fg-0); margin: 0; transition: background-color 0.2s, color 0.2s; }"]]
|
[:style (h/raw "body { padding: 2rem; }")]]
|
||||||
[:body
|
[:body
|
||||||
[:div {:style "max-width: 800px; margin: 0 auto;"}
|
[:div {:style "max-width: 800px; margin: 0 auto;"}
|
||||||
[:div {:style "display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem;"}
|
[:div {:style "display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem;"}
|
||||||
|
|||||||
@@ -5,14 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="stylesheet" href="/theme.css" />
|
<link rel="stylesheet" href="/theme.css" />
|
||||||
<style>
|
<style>
|
||||||
body {
|
body { padding: 2rem; }
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
||||||
padding: 2rem;
|
|
||||||
background: var(--bg-0);
|
|
||||||
color: var(--fg-0);
|
|
||||||
margin: 0;
|
|
||||||
transition: background-color 0.2s, color 0.2s;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -5,14 +5,7 @@
|
|||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link rel="stylesheet" href="/theme.css" />
|
<link rel="stylesheet" href="/theme.css" />
|
||||||
<style>
|
<style>
|
||||||
body {
|
body { padding: 2rem; }
|
||||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
||||||
padding: 2rem;
|
|
||||||
background: var(--bg-0);
|
|
||||||
color: var(--fg-0);
|
|
||||||
margin: 0;
|
|
||||||
transition: background-color 0.2s, color 0.2s;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
@@ -21,6 +21,17 @@
|
|||||||
(map (fn [[k v]] (str " " (token->css-var k) ": " v ";")))
|
(map (fn [[k v]] (str " " (token->css-var k) ": " v ";")))
|
||||||
(str/join "\n")))
|
(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
|
(defn component-css-button
|
||||||
"Generate BEM-lite CSS for the button component."
|
"Generate BEM-lite CSS for the button component."
|
||||||
[]
|
[]
|
||||||
@@ -94,8 +105,9 @@
|
|||||||
" :root:not([data-theme=\"light\"]) {\n"
|
" :root:not([data-theme=\"light\"]) {\n"
|
||||||
(str/replace (tokens->css-block dark-tokens) #"(?m)^ " " ")
|
(str/replace (tokens->css-block dark-tokens) #"(?m)^ " " ")
|
||||||
"\n }\n}")
|
"\n }\n}")
|
||||||
|
base (base-css)
|
||||||
components (component-css-button)]
|
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!
|
(defn build-theme!
|
||||||
"Read tokens from file and write generated CSS to output."
|
"Read tokens from file and write generated CSS to output."
|
||||||
|
|||||||
Reference in New Issue
Block a user