Files
clj-ui-framework/bb.edn
Florian Schroedl d6d205cb3b feat: add calendar docs with inline markdown rendering
Add src/ui/calendar.md with full documentation for both calendar
namespaces (picker props, event grid, ticker, agenda, event data
format, date utilities, CSS classes).

Add a minimal markdown-to-hiccup renderer (ui.markdown) that handles
headings, fenced code blocks, tables, lists, inline code, and bold.
Styled with ui/markdown.css using theme tokens.

Each dev target renders the docs inline on the Calendar page:
- Hiccup: slurps the .md file at render time
- Replicant: embeds via compile-time macro (ui.macros/inline-file)
- Squint: fetches from /calendar.md served by Vite

Also fixes calendar event grid day cells to be square (aspect-ratio: 1
with overflow: hidden instead of min-height).
2026-03-29 09:59:31 +02:00

159 lines
7.2 KiB
Clojure

{:deps {com.github.jramosg/color-tools {:mvn/version "1.1.0"}}
:paths ["src" "test" "dev/hiccup/src"]
:tasks
{build-theme
{:doc "Generate dist/theme.css from tokens.edn and copy to dev targets"
:requires ([ui.css.gen :as gen]
[clojure.java.io :as io])
:task (do (gen/build-theme! {:input "src/theme/tokens.edn"
:output "dist/theme.css"})
(let [css (slurp "dist/theme.css")]
(spit "dev/replicant/public/theme.css" css)
(io/make-parents "dev/squint/public/theme.css")
(spit "dev/squint/public/theme.css" css)
(println "Copied theme.css to dev targets"))
(let [adapter (slurp "dev/theme-adapter.js")]
(spit "dev/replicant/public/theme-adapter.js" adapter)
(spit "dev/squint/public/theme-adapter.js" adapter)
(println "Copied theme-adapter.js to dev targets"))
(let [lr (slurp "dev/css-live-reload.js")]
(spit "dev/replicant/public/css-live-reload.js" lr)
(spit "dev/squint/public/css-live-reload.js" lr)
(println "Copied css-live-reload.js to dev targets"))
(doseq [md (.listFiles (io/file "src/ui")
(reify java.io.FileFilter
(accept [_ f] (.endsWith (.getName f) ".md"))))]
(spit (str "dev/squint/public/" (.getName md)) (slurp md)))
(println "Copied component docs to dev/squint"))}
watch-theme
{:doc "Watch src/ui/*.css and tokens.edn, rebuild theme on changes"
:task (load-file "scripts/watch-theme.bb")}
test
{:doc "Run all unit tests"
:requires ([clojure.test :as t]
[ui.button-test]
[ui.alert-test]
[ui.badge-test]
[ui.card-test]
[ui.accordion-test]
[ui.table-test]
[ui.dialog-test]
[ui.spinner-test]
[ui.skeleton-test]
[ui.progress-test]
[ui.switch-test]
[ui.tooltip-test]
[ui.breadcrumb-test]
[ui.pagination-test]
[ui.form-test]
[ui.icon-test]
[ui.sidebar-test]
[ui.chip-test]
[ui.separator-test]
[ui.calendar-test]
[ui.calendar-events-test]
[ui.theme-test])
:task (let [{:keys [fail error]} (t/run-tests
'ui.button-test
'ui.alert-test
'ui.badge-test
'ui.card-test
'ui.accordion-test
'ui.table-test
'ui.dialog-test
'ui.spinner-test
'ui.skeleton-test
'ui.progress-test
'ui.switch-test
'ui.tooltip-test
'ui.breadcrumb-test
'ui.pagination-test
'ui.form-test
'ui.icon-test
'ui.sidebar-test
'ui.chip-test
'ui.separator-test
'ui.calendar-test
'ui.calendar-events-test
'ui.theme-test)]
(when (pos? (+ fail error))
(System/exit 1)))}
ensure-npm
{:doc "Install node_modules in dev/replicant and dev/squint if missing"
:task (do
(when-not (.exists (clojure.java.io/file "dev/replicant/node_modules"))
(println "Installing node_modules in dev/replicant...")
(shell {:dir "dev/replicant"} "npm install"))
(when-not (.exists (clojure.java.io/file "dev/squint/node_modules"))
(println "Installing node_modules in dev/squint...")
(shell {:dir "dev/squint"} "npm install")))}
dev-hiccup
{:doc "Start hiccup dev server (--port PORT, default 3003)"
:depends [build-theme]
:requires ([dev.hiccup])
:task (let [port (or (some-> (System/getenv "PORT") parse-long) 3003)]
(dev.hiccup/start! {:port port})
(deref (promise)))}
dev-replicant
{:doc "Start replicant dev server (PORT env var, default 3001)"
:depends [build-theme ensure-npm]
:task (let [port (some-> (System/getenv "PORT") parse-long)
env (cond-> {} port (assoc "SHADOW_HTTP_PORT" (str port)))]
(shell {:dir "dev/replicant" :extra-env env}
"npx" "shadow-cljs" "watch" "app"))}
dev-squint
{:doc "Start squint dev server (PORT env var, default 3002)"
:depends [build-theme ensure-npm]
:task (let [port (or (some-> (System/getenv "PORT") parse-long) 3002)]
(shell {:dir "dev/squint"}
"bash" "-c" (str "npx squint watch & exec npx vite --port " port)))}
dev
{:doc "Start all dev servers"
:depends [build-theme]
:requires ([dev.hiccup])
:task (let [port (or (some-> (System/getenv "PORT") parse-long) 3003)]
(dev.hiccup/start! {:port port})
(println "Dev servers running:")
(println (str " Hiccup: http://localhost:" port))
(println " Replicant: cd dev/replicant && npx shadow-cljs watch app")
(println " Squint: cd dev/squint && npm run dev")
(println " Test page: dev/index.html")
(deref (promise)))}
check-dev
{:doc "Check all ui-dev tmux panes for errors and verify dev servers"
:task (load-file "scripts/check-dev.bb")}
dev-all
{:doc "Start all dev servers in tmux panes (bb dev-all [BASE_PORT], default 3000)"
:depends [build-theme ensure-npm]
:task (let [base (or (some-> (first *command-line-args*) parse-long) 3000)
rport (+ base 1)
sport (+ base 2)
hport (+ base 3)
session "ui-dev"]
(shell {:continue true} "tmux kill-session -t" session)
(shell "tmux new-session -d -s" session
(str "bash -c 'bb watch-theme & PORT=" hport " bb dev-hiccup'"))
(shell "tmux split-window -h -t" session
(str "bash -c 'cd dev/replicant && SHADOW_HTTP_PORT=" rport " npx shadow-cljs watch app'"))
(shell "tmux split-window -v -t" session
(str "bash -c 'cd dev/squint && npx squint watch"
" & cd dev/squint && npx vite --port " sport "'"))
(shell "tmux select-layout -t" session "tiled")
(println (str "Tmux session 'ui-dev' created (base port " base "):"))
(println (str " Pane 0: Hiccup → http://localhost:" hport))
(println (str " Pane 1: Replicant → http://localhost:" rport))
(println (str " Pane 2: Squint → http://localhost:" sport))
(println)
(when-not (zero? (:exit (shell {:continue true} "tmux attach -t" session)))
(println "Attach with: tmux attach -t" session)))}}}