Fix image loading on view app.

And add cosmetic improvements to the
main image shape component.
This commit is contained in:
Andrey Antukh 2017-01-17 20:45:02 +01:00
parent 922a2494ed
commit 680fa49f27
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
3 changed files with 66 additions and 20 deletions

View file

@ -27,20 +27,18 @@
(declare image-shape)
(defn- will-mount
[own]
(let [{:keys [image]} (first (:rum/args own))]
(st/emit! (udi/fetch-image image))
own))
(mx/defcs image-component
{:mixins [mx/static mx/reactive]
:will-mount will-mount}
:will-mount (fn [own]
;; TODO: maybe do it conditionally
;; (only fetch when it's not fetched)
(when-let [id (-> own :rum/args first :image)]
(st/emit! (udi/fetch-image id)))
own)}
[own {:keys [id image] :as shape}]
(let [selected (mx/react common/selected-ref)
image (mx/react (image-ref image))
selected? (contains? selected id)
local (:rum/local own)
on-mouse-down #(common/on-mouse-down % shape selected)]
(when image
[:g.shape {:class (when selected? "selected")