Browse code

Cosmetic refactors in views

Joseph Weston authored on 05/12/2021 19:34:25
Showing 1 changed files
... ...
@@ -34,20 +34,16 @@
34 34
                    "th")]
35 35
         (str n suffix)))
36 36
 
37
-(defn- join-lines
38
-    [coll]
37
+(defn- join-lines [coll]
39 38
     (string/join \newline coll))
40 39
 
41
-(defn- comma-separated
42
-    [coll]
40
+(defn- comma-separated [coll]
43 41
     (string/join ", " coll))
44 42
 
45
-(defn- parenthesize
46
-    [s]
43
+(defn- parenthesize [s]
47 44
     (when s (str "(" s ")")))
48 45
 
49
-(defn- spaced
50
-    [& elements]
46
+(defn- spaced [& elements]
51 47
     (string/join " " (filter identity elements)))
52 48
 
53 49
 (defn- with-default [default x]
... ...
@@ -88,12 +84,10 @@
88 84
         [:section.license-notice
89 85
          (spaced (x :name) "is" (l :content-kind) "subject to the" (l :license-name))])))
90 86
 
91
-(defn- description
92
-    [x]
87
+(defn- description [x]
93 88
     (some->> x :desc (map #(vector :p %)) (into [:section.description])))
94 89
 
95
-(defn- heading
96
-    [x]
90
+(defn- heading [x]
97 91
     [:h1 (get x :name (str x))])
98 92
 
99 93
 (defn- pounds [w]
... ...
@@ -118,6 +112,9 @@
118 112
           (when (not no-quantity)
119 113
             (some->> x :quantity (str "for ") parenthesize))))))
120 114
 
115
+(defn- capacity [x]
116
+    (some-> x :capacity))
117
+
121 118
 (defn- short-spell-description [spell]
122 119
   (spaced
123 120
     (-> spell :level ordinal)
... ...
@@ -129,7 +126,8 @@
129 126
     [:article {:class (styles/license-panel)}
130 127
      [:h1 (license :license-name)]
131 128
      [:p (license :preamble)]
132
-     (into [:ol.clauses] (->> license :clauses (map #(vector :li %))))
129
+     [:ol.clauses
130
+       (for [clause (license :clauses)] [:li clause])]
133 131
      [:div.copyright-notice (->> license :copyright-notice (map #(vector :p %)))]])
134 132
 
135 133
 (defn spell-panel [spell]
... ...
@@ -176,6 +174,8 @@
176 174
      (property-list
177 175
       :Speed
178 176
         (speed item)
177
+      "Carrying Capacity"
178
+        (capacity item)
179 179
       :Weight
180 180
         (weight item)
181 181
       :Cost
... ...
@@ -237,7 +237,8 @@
237 237
     [{e :err}]
238 238
     [:div {:class (styles/error-message)} e])
239 239
 
240
-(defn input [x] [:div.input x])
240
+(defn input [x]
241
+    [:div.input x])
241 242
 
242 243
 (def is-license? :license-name)
243 244
 (def is-spell? #(some-> % :url (string/starts-with? "/api/spells")))
... ...
@@ -259,15 +260,11 @@
259 260
       (is-equipment? x) (equipment-panel x)
260 261
       (is-error? x) (error-message x))])
261 262
 
262
-
263 263
 (defn history []
264 264
   (let [history (re-frame/subscribe [::subs/cmd-history])]
265
-    (into
266
-     [:ul {:class (styles/history-style)}]
267
-     (map #(vector :li
268
-                   (-> % :input input)
269
-                   (-> % :output output))
270
-          @history))))
265
+    [:ul {:class (styles/history-style)}
266
+      (for [item @history]
267
+        [:li (-> item :input input) (-> item :output output)])]))
271 268
 
272 269
 (defn main-panel []
273 270
   [:div {:class (styles/screen)}