4 ms·
After Reagent + Hiccup, I'm ruined. Nothing feels as natural as a full, general-purpose language (Clojure) combined with a natural keyword-based DSL for styling
by pgt 10y ago
After Reagent + Hiccup, I'm ruined. Nothing feels as natural as a full, general-purpose language (Clojure) combined with a natural keyword-based DSL for styling:
(defn right-cell [& body]
[:td.right.aligned body]) ;; renders <td class="right aligned>{...body}</td>
(defn person-row [{:keys [name age] :as p}]
[:tr
[:td name]
[right-cell age]])
(defn person-table [font-size people]
(let [heading-size (* font-size 1.6)]
[:div
[:h1 {:style {:font-size (str heading-size "em")}
"People List"]
[:table.ui.basic.table
[:tbody (map person-row people)]]]))
(defn main []
[person-table 2 [{:name "John" :age 21} {:name "Sally" :age 22}])