Commits

Anonymous committed f74cfe9

Changed the way properties are specified.

  • Participants
  • Parent commits d8e2b98

Comments (0)

Files changed (1)

src/net/ksojat/neman/css.clj

 ;; agreeing to be bound by the terms of this license.  You must not
 ;; remove this notice, or any other, from this software.
 
-(ns net.ksojat.neman.css)
+(ns net.ksojat.neman.css
+  (:use net.ksojat.neman.core))
 
 (defmulti property (fn [name arg] name))
 
 (defn property-str [[k v]]
   (apply str (map property-str* (partition 2 (property k v)))))
 
-(defn group-str [group]
-  (apply str (map property-str (partition 2 group))))
-
-(defn rule-str [[selector & groups]]
-  (str selector " {\n" (apply str (map group-str groups)) "}\n"))
+(defn rule-str [[selector & props]]
+  (let [props (partition 2 (flatten props))]
+    (str selector " {\n" (apply str (map property-str props)) "}\n")))
 
 (defn to-css [css-spec]
   (apply str (map rule-str css-spec)))
          "blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, "
          "q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, "
          "caption, tbody, tfoot, thead, tr, th, td")
-    [:margin  "0"
-     :padding "0"
-     :border  "0"
-     :font-weight :inherit
-     :font-style  :inherit
-     :font-size   "100%"
-     :font-family :inherit
-     :vertical-align :baseline]]
+    :margin  "0"
+    :padding "0"
+    :border  "0"
+    :font-weight :inherit
+    :font-style  :inherit
+    :font-size   "100%"
+    :font-family :inherit
+    :vertical-align :baseline]
 
    ["body"
-    [:line-height "1.5"]]
+    :line-height "1.5"]
 
    ["table"
-    [:border-collapse :separate
-     :border-spacing  "0"]]
+    :border-collapse :separate
+     :border-spacing  "0"]
 
    ["caption, th, td"
-    [:text-align  :left
-     :font-weight :normal]]
+    :text-align  :left
+    :font-weight :normal]
 
    ["table, td, th"
-    [:vertical-align :middle]]
+    :vertical-align :middle]
 
    ["blockquote:before, blockquote:after, q:before, q:after"
-    [:content ""]]
+    :content ""]
 
    ["a img"
-    [:border :none]]])
+    :border :none]])
 
 (def main
   [:width      "70em"
 
 (def clear
   [".clear"
-   [:clear :both]])
+   :clear :both])
 
 (def fluid
   [[".fluid"
-    [:width :auto, :float :none]]
+    :width :auto, :float :none]
    ["div .fluid"
-    [:padding "0em 0em 0em 0.1em"]]])
+    :padding "0em 0em 0em 0.1em"]])
 
 (def hp
   [[".hp"
-    [:width "100%", :float :left]]])
+    :width "100%", :float :left]])
 
 ;(def base
 ;  (concat
 (comment
   (to-css
     [["h1"
-      [:font-size   "2em"
+      :font-size   "2em"
        :font-weight :bold
-       :font-family "Verdana"]]
+       :font-family "Verdana"]
      ["h2"
-      [:font-size "1.8em"
-       :color     "#383334"]]]))
+      :font-size "1.8em"
+       :color     "#383334"]]))