brutcss/bb/brut/main.clj
Yann Esposito (Yogsototh) 6e69d5218d
major update using flex
2022-10-06 16:26:57 +02:00

88 lines
3.1 KiB
Clojure
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

(ns brut.main
(:require [hiccup.core :as h]
[babashka.fs :as fs]
))
(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 "×"]]))
(defn footer []
[:div.row
[:div.block
[:span "By"
[:a {:href "https://yannesposito.com"}
"Yann Esposito"]]]])
(defn mk-page [rel-pref {:keys [title] :as _metas} content]
(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"}]
[:title title]
[:link {:href (str rel-pref "brut-nocolors.min.css") :rel "stylesheet" :type "text/css"}]]
[:body.col
(nav rel-pref)
content
(footer)]))
(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
[:div.row
[:div.col.block.c3 [:img {:src (to "h/img/brutalism.webp") :alt "brutalism"}]]
[: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.")]]
[:div.col.block.c3 [:img {:src (to "h/img/brutalism.webp") :alt "brutalism"}]]]]
cards [:div.row
[:div.col.block
[:div.card
[:h3 "Docs"]
[:p "Docs"]
[:p "Docs"]
[:a.btn.err.big.push {:href (to "h/docs.html")}
"Docs"]]]
[:div.col.block
[:div.card
[:h3 "Download"]
[:div.block
[:p "Download BRUT"]]
[:a.btn.err.big.push {:href (to "h/download.html")}
"Download"]]]]]
[: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"]])
)
(defn -main [& _args]
(gen-page "index.html" "BRUT" index-content)
(gen-page "h/download.html" "BRUT - download" download-content)
)