mirror of
https://github.com/penpot/penpot.git
synced 2025-06-04 01:31:38 +02:00
Fix image loading on view app.
And add cosmetic improvements to the main image shape component.
This commit is contained in:
parent
922a2494ed
commit
680fa49f27
3 changed files with 66 additions and 20 deletions
|
@ -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")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue