|
234 | 234 | (clojure.string/join " ") |
235 | 235 | (str "@media ")))) |
236 | 236 |
|
237 | | -(defn compile-media-dispatch [styles] |
| 237 | +(defn compile-media-dispatch [styles _] |
238 | 238 | (cond |
239 | 239 | (contains? styles :media) :media |
240 | 240 | (contains? styles :styles) :styles)) |
241 | 241 |
|
242 | 242 | (defmulti compile-media #'compile-media-dispatch) |
243 | 243 |
|
244 | | -(defmethod compile-media :media [{media :media}] |
| 244 | +(defmethod compile-media :media [{media :media} cls] |
245 | 245 | (->> (seq media) |
246 | 246 | (reduce |
247 | 247 | (fn [[sstyles svalues] [query styles]] |
248 | | - (let [[static values] (compile-media {:styles styles}) |
| 248 | + (let [[static values] (compile-media {:styles styles} cls) |
249 | 249 | query (-compile-media-query query)] |
250 | 250 | [(str sstyles query static) (concat svalues values)])) |
251 | 251 | ["" []]))) |
252 | 252 |
|
253 | | -(defmethod compile-media :styles [{styles :styles}] |
| 253 | +(defmethod compile-media :styles [{styles :styles} cls] |
254 | 254 | (let [pseudo (filterv utils/pseudo? styles) |
255 | 255 | pstyles (->> pseudo |
256 | 256 | (reduce |
257 | 257 | (fn [coll [rule styles]] |
258 | | - (conj coll (c/collect-styles (str (:cls @c/env*) (subs (name rule) 1)) styles))) |
| 258 | + (conj coll (c/collect-styles (str cls (subs (name rule) 1)) styles))) |
259 | 259 | [])) |
260 | 260 | styles (filterv (comp not utils/pseudo?) styles) |
261 | | - [static values] (c/collect-styles (:cls @c/env*) styles) |
| 261 | + [static values] (c/collect-styles cls styles) |
262 | 262 | values (->> pstyles |
263 | 263 | (mapcat second) |
264 | 264 | (into values))] |
265 | 265 | [(str "{" (apply str static (map first pstyles)) "}") |
266 | 266 | values])) |
267 | 267 |
|
268 | | -(defn build-media [styles] |
269 | | - (compile-media {:media styles})) |
| 268 | +(defn build-media [cls styles] |
| 269 | + (compile-media {:media styles} cls)) |
270 | 270 |
|
271 | 271 | (comment |
272 | | - (c/reset-env! {:cls "class"}) |
273 | | - |
274 | 272 | (build-media |
| 273 | + "class" |
275 | 274 | {[[:only :screen :and [:min-width "300px"]] |
276 | 275 | [:print :and [:color]]] |
277 | 276 | {:font-size 'p |
|
0 commit comments