Browse code

Add view for dice rolls

Joseph Weston authored on 23/10/2022 00:54:05
Showing 2 changed files
... ...
@@ -113,6 +113,11 @@
113 113
       :font-style :italic
114 114
       :font-size :0.8rem}])
115 115
 
116
+(defclass dice-roll []
117
+    {}
118
+    [s/first-child {} (content-after " = ")]
119
+    [(s/nth-child 2) {:font-weight :bold}])
120
+
116 121
 (defclass spell-panel []
117 122
     {}
118 123
     title-style
... ...
@@ -359,6 +359,11 @@
359 359
        #(weight % :unit "lb" :no-quantity true)]
360 360
    [listing-license-notice items]])
361 361
 
362
+(defn dice-roll [{:keys [rolls]}]
363
+  [:article {:class (styles/dice-roll)}
364
+   [:span (str rolls)]
365
+   [:span (reduce + rolls)]])
366
+
362 367
 (defn error-message
363 368
     [{e :err}]
364 369
     [:div {:class (styles/error-message)} e])
... ...
@@ -366,6 +371,7 @@
366 371
 (defn input [x]
367 372
     [:div.input x])
368 373
 
374
+(def is-dice-roll? :rolls)
369 375
 (def is-license? :license-name)
370 376
 (def is-spell? #(some-> % :url (string/starts-with? "/api/spells")))
371 377
 (def is-spell-list? #(some-> % first is-spell?))
... ...
@@ -378,6 +384,7 @@
378 384
 (defn output [x]
379 385
     [:div.output
380 386
      (cond
387
+      (is-dice-roll? x) [dice-roll x]
381 388
       (is-license? x) [license-panel x]
382 389
       (is-equipment-list? x) [equipment-list-panel x]
383 390
       (is-spell-list? x) [spell-list-panel x]