brutcss/bb/brut/main.clj

89 lines
3.1 KiB
Clojure
Raw Normal View History

2022-10-03 14:53:52 +00:00
(ns brut.main
2022-10-06 11:16:25 +00:00
(:require [hiccup.core :as h]
[babashka.fs :as fs]
))
2022-10-03 14:53:52 +00:00
2022-10-06 11:16:25 +00:00
(defn nav [rel-pref]
(let [to (fn [path] (str rel-pref path))]
[:div
[:nav.nav {:tabindex "-1" :onclick "this.focus()"}
[:div.container
[:a.pagename {:href (to "index.html")} "BRUT"]
[:a {:href (to "h/docs.html")} "Docs"]
[:a {:href (to "h/download.html")} "Download"]
[:a {:href "https://gitea.esy.fun/yogsototh/brutcss"} "Code"]]]
[:button.btn.sn.btn-close "×"]]))
2022-10-03 14:53:52 +00:00
(defn footer []
[:div.row
[:div.block
[:span "By"
[:a {:href "https://yannesposito.com"}
"Yann Esposito"]]]])
2022-10-06 11:16:25 +00:00
(defn mk-page [rel-pref {:keys [title] :as _metas} content]
2022-10-03 14:53:52 +00:00
(h/html
[:head
[:meta {:http-equiv "Content-Type" :content "text/html; charset=UTF-8"}]
[:meta {:name "viewport" :content "width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"}]
2022-10-06 11:16:25 +00:00
[:title title]
[:link {:href (str rel-pref "brut-nocolors.min.css") :rel "stylesheet" :type "text/css"}]]
[:body.col
(nav rel-pref)
content
(footer)]))
2022-10-03 14:53:52 +00:00
2022-10-06 11:16:25 +00:00
(defn gen-page [file-path metas content-fn]
(let [{:keys [title]} metas
depth (or (some-> file-path
fs/parent
fs/components
count)
0)
rel-pref (apply str (repeat depth "../"))
html (mk-page rel-pref metas (content-fn rel-pref metas))]
(println "Generates: " file-path)
(spit file-path html)))
(defn index-content [rel-pref _metas]
(let [to (fn [path] (str rel-pref path))
hero [:div.hero.bg-neutral
2022-10-03 21:28:51 +00:00
[:div.row
2022-10-06 11:16:25 +00:00
[:div.col.block.c3 [:img {:src (to "h/img/brutalism.webp") :alt "brutalism"}]]
2022-10-03 21:28:51 +00:00
[:div.col.block.c6
[:h1.title "BRUT"]
[:h4 "A Brutalist and Minimalist CSS Framework"]
[:p (str "This CSS framework is ideal to be used for admin interface where you"
"want to make it clear, this is not for any kind of end user but only"
"advanced technical people.")]]
2022-10-06 11:16:25 +00:00
[:div.col.block.c3 [:img {:src (to "h/img/brutalism.webp") :alt "brutalism"}]]]]
2022-10-03 21:28:51 +00:00
cards [:div.row
[:div.col.block
[:div.card
[:h3 "Docs"]
[:p "Docs"]
[:p "Docs"]
2022-10-06 11:16:25 +00:00
[:a.btn.err.big.push {:href (to "h/docs.html")}
2022-10-03 21:28:51 +00:00
"Docs"]]]
[:div.col.block
[:div.card
[:h3 "Download"]
[:div.block
[:p "Download BRUT"]]
2022-10-06 11:16:25 +00:00
[:a.btn.err.big.push {:href (to "h/download.html")}
2022-10-03 21:28:51 +00:00
"Download"]]]]]
2022-10-06 11:16:25 +00:00
[:div hero cards]))
(defn download-content [rel-pref _metas]
(let [to (fn [path] (str rel-pref path))]
[:div.central.fill
{:style (str "background:url('" (to "h/img/brutalism.webp") "')")}
[:a.btn.warn.huge {:href (to "brut.min.css")}
"Download BRUT"]])
)
2022-10-03 21:28:51 +00:00
2022-10-03 14:53:52 +00:00
(defn -main [& _args]
2022-10-06 11:16:25 +00:00
(gen-page "index.html" "BRUT" index-content)
(gen-page "h/download.html" "BRUT - download" download-content)
)