|
8 | 8 | (defn varid [cls idx [rule]]
|
9 | 9 | [rule (str "--var-" cls "-" idx)])
|
10 | 10 |
|
11 |
| -(defn collect-styles [cls styles rule-index] |
12 |
| - (let [dynamic (filterv dynamic? styles) |
13 |
| - static (filterv (comp not dynamic?) styles) |
14 |
| - [vars rule-index] (reduce |
15 |
| - (fn [[vars idx] ds] |
16 |
| - (let [ret (conj vars (varid cls idx ds))] |
17 |
| - [ret (inc idx)])) |
18 |
| - [[] rule-index] |
19 |
| - dynamic) |
20 |
| - _ (println "static" static) |
21 |
| - _ (println "vars" vars) |
22 |
| - _ (println "dynamic" dynamic) |
23 |
| - vals (mapv (fn [[_ var] [_ exp]] [var exp]) vars dynamic) |
24 |
| - _ (println "vals" vals) |
25 |
| - static (->> vars |
26 |
| - (map (fn [[rule var]] [rule (str "var(" var ")")])) |
27 |
| - (concat static) |
28 |
| - (build-css cls))] |
29 |
| - [static vals rule-index])) |
| 11 | +(defn collect-styles |
| 12 | + ([cls styles rule-index] (collect-styles cls styles rule-index nil)) |
| 13 | + ([cls styles rule-index tail-class] |
| 14 | + (let [dynamic (filterv dynamic? styles) |
| 15 | + static (filterv (comp not dynamic?) styles) |
| 16 | + [vars rule-index] (reduce |
| 17 | + (fn [[vars idx] ds] |
| 18 | + (let [ret (conj vars (varid cls idx ds))] |
| 19 | + [ret (inc idx)])) |
| 20 | + [[] rule-index] |
| 21 | + dynamic) |
| 22 | + vals (mapv (fn [[_ var] [_ exp]] [var exp]) vars dynamic) |
| 23 | + static (->> vars |
| 24 | + (map (fn [[rule var]] [rule (str "var(" var ")")])) |
| 25 | + (concat static) |
| 26 | + (build-css (str cls tail-class)))] |
| 27 | + [static vals rule-index]))) |
30 | 28 |
|
31 |
| -(defn collect-dynamic-styles [rule-index rules class-generator] |
| 29 | +(defn collect-dynamic-styles [rule-index rules cls tail-class-g] |
32 | 30 | (loop
|
33 | 31 | [idx rule-index
|
34 | 32 | acc []
|
35 | 33 | coll rules]
|
36 | 34 | (if (not (seq coll))
|
37 | 35 | [acc idx]
|
38 | 36 | (let [[rule styles] (first coll)
|
39 |
| - [static vals nxt-idx] (collect-styles (class-generator rule) styles idx)] |
| 37 | + [static vals nxt-idx] (collect-styles cls styles idx (tail-class-g rule))] |
40 | 38 | (recur nxt-idx
|
41 | 39 | (conj acc [static vals])
|
42 | 40 | (rest coll))))))
|
0 commit comments