mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 23:16:11 +02:00
✨ Upgrade rumext and add some examples of syntax sugar.
This commit is contained in:
parent
dcd53183a8
commit
c754a757eb
8 changed files with 67 additions and 89 deletions
|
@ -78,28 +78,24 @@
|
|||
vbox (str/join " " coords)
|
||||
|
||||
frame-wrapper
|
||||
(mf/use-memo
|
||||
(mf/deps objects)
|
||||
#(render/frame-wrapper-factory objects))
|
||||
(mf/with-memo [objects]
|
||||
(render/frame-wrapper-factory objects))
|
||||
|
||||
group-wrapper
|
||||
(mf/use-memo
|
||||
(mf/deps objects)
|
||||
#(render/group-wrapper-factory objects))
|
||||
(mf/with-memo [objects]
|
||||
(render/group-wrapper-factory objects))
|
||||
|
||||
shape-wrapper
|
||||
(mf/use-memo
|
||||
(mf/deps objects)
|
||||
#(render/shape-wrapper-factory objects))
|
||||
(mf/with-memo [objects]
|
||||
(render/shape-wrapper-factory objects))
|
||||
|
||||
text-shapes
|
||||
(->> objects
|
||||
(filter (fn [[_ shape]] (= :text (:type shape))))
|
||||
(mapv second))]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps width height)
|
||||
#(dom/set-page-style {:size (str (mth/ceil width) "px "
|
||||
(mf/with-effect [width height]
|
||||
(dom/set-page-style {:size (str (mth/ceil width) "px "
|
||||
(mth/ceil height) "px")}))
|
||||
|
||||
[:& (mf/provider embed/context) {:value false}
|
||||
|
@ -148,20 +144,19 @@
|
|||
(mf/defc render-object
|
||||
[{:keys [file-id page-id object-id render-texts?] :as props}]
|
||||
(let [objects (mf/use-state nil)]
|
||||
(mf/use-effect
|
||||
(mf/deps file-id page-id object-id)
|
||||
(fn []
|
||||
(->> (rx/zip
|
||||
(repo/query! :font-variants {:file-id file-id})
|
||||
(repo/query! :trimmed-file {:id file-id :page-id page-id :object-id object-id}))
|
||||
(rx/subs
|
||||
(fn [[fonts {:keys [data]}]]
|
||||
(when (seq fonts)
|
||||
(st/emit! (df/fonts-fetched fonts)))
|
||||
(let [objs (get-in data [:pages-index page-id :objects])
|
||||
objs (adapt-root-frame objs object-id)]
|
||||
(reset! objects objs)))))
|
||||
(constantly nil)))
|
||||
|
||||
(mf/with-effect [file-id page-id object-id]
|
||||
(->> (rx/zip
|
||||
(repo/query! :font-variants {:file-id file-id})
|
||||
(repo/query! :trimmed-file {:id file-id :page-id page-id :object-id object-id}))
|
||||
(rx/subs
|
||||
(fn [[fonts {:keys [data]}]]
|
||||
(when (seq fonts)
|
||||
(st/emit! (df/fonts-fetched fonts)))
|
||||
(let [objs (get-in data [:pages-index page-id :objects])
|
||||
objs (adapt-root-frame objs object-id)]
|
||||
(reset! objects objs)))))
|
||||
(constantly nil))
|
||||
|
||||
(when @objects
|
||||
[:& object-svg {:objects @objects
|
||||
|
@ -172,14 +167,13 @@
|
|||
(mf/defc render-sprite
|
||||
[{:keys [file-id component-id] :as props}]
|
||||
(let [file (mf/use-state nil)]
|
||||
(mf/use-effect
|
||||
(mf/deps file-id)
|
||||
(fn []
|
||||
(->> (repo/query! :file {:id file-id})
|
||||
(rx/subs
|
||||
(fn [result]
|
||||
(reset! file result))))
|
||||
(constantly nil)))
|
||||
|
||||
(mf/with-effect [file-id]
|
||||
(->> (repo/query! :file {:id file-id})
|
||||
(rx/subs
|
||||
(fn [result]
|
||||
(reset! file result))))
|
||||
(constantly nil))
|
||||
|
||||
(when @file
|
||||
[:*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue