mirror of
https://github.com/penpot/penpot.git
synced 2025-05-29 07:26:12 +02:00
♻️ Use new call convention for path drawing components
This commit is contained in:
parent
09c3490cae
commit
4f6dffabb4
5 changed files with 29 additions and 30 deletions
|
@ -204,7 +204,7 @@
|
|||
angle (gpt/angle-with-other v1 v2)]
|
||||
(<= (- 180 angle) 0.1))))
|
||||
|
||||
(mf/defc path-editor
|
||||
(mf/defc path-editor*
|
||||
[{:keys [shape zoom]}]
|
||||
|
||||
(let [editor-ref (mf/use-ref nil)
|
||||
|
@ -261,11 +261,12 @@
|
|||
[(->> selected-points (map base->point) (into #{}))
|
||||
(->> points (remove selected-points) (into #{}))])
|
||||
|
||||
show-snap? (and snap-toggled
|
||||
(or (some? drag-handler)
|
||||
(some? preview)
|
||||
(some? moving-handler)
|
||||
moving-nodes))
|
||||
show-snap?
|
||||
(and snap-toggled
|
||||
(or (some? drag-handler)
|
||||
(some? preview)
|
||||
(some? moving-handler)
|
||||
moving-nodes))
|
||||
|
||||
handle-double-click-outside
|
||||
(fn [_]
|
||||
|
|
|
@ -501,7 +501,7 @@
|
|||
:on-frame-select on-frame-select}])
|
||||
|
||||
(when show-draw-area?
|
||||
[:& drawarea/draw-area
|
||||
[:> drawarea/draw-area*
|
||||
{:shape drawing-obj
|
||||
:zoom zoom
|
||||
:tool drawing-tool}])
|
||||
|
|
|
@ -11,29 +11,13 @@
|
|||
[app.common.types.shape :as cts]
|
||||
[app.main.ui.shapes.path :refer [path-shape]]
|
||||
[app.main.ui.workspace.shapes :as shapes]
|
||||
[app.main.ui.workspace.shapes.path.editor :refer [path-editor]]
|
||||
[app.main.ui.workspace.shapes.path.editor :refer [path-editor*]]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(declare generic-draw-area)
|
||||
(declare path-draw-area)
|
||||
|
||||
(mf/defc draw-area
|
||||
[{:keys [shape zoom tool] :as props}]
|
||||
|
||||
;; Prevent rendering something that it's not a shape.
|
||||
(when (cts/shape? shape)
|
||||
[:g.draw-area
|
||||
[:g {:style {:pointer-events "none"}}
|
||||
[:& shapes/shape-wrapper {:shape shape}]]
|
||||
|
||||
(case tool
|
||||
:path [:& path-editor {:shape shape :zoom zoom}]
|
||||
:curve [:& path-shape {:shape shape :zoom zoom}]
|
||||
#_:default [:& generic-draw-area {:shape shape :zoom zoom}])]))
|
||||
|
||||
(mf/defc generic-draw-area
|
||||
(mf/defc generic-draw-area*
|
||||
{::mf/private true}
|
||||
[{:keys [shape zoom]}]
|
||||
(let [{:keys [x y width height]} (:selrect shape)]
|
||||
(let [{:keys [x y width height]} (get shape :selrect)]
|
||||
(when (and x y
|
||||
(not (mth/nan? x))
|
||||
(not (mth/nan? y)))
|
||||
|
@ -45,3 +29,17 @@
|
|||
:fill "none"
|
||||
:stroke-width (/ 1 zoom)}}])))
|
||||
|
||||
(mf/defc draw-area*
|
||||
[{:keys [shape zoom tool] :as props}]
|
||||
|
||||
;; Prevent rendering something that it's not a shape.
|
||||
(when (cts/shape? shape)
|
||||
[:g.draw-area
|
||||
[:g {:style {:pointer-events "none"}}
|
||||
[:& shapes/shape-wrapper {:shape shape}]]
|
||||
|
||||
(case tool
|
||||
:path [:> path-editor* props]
|
||||
:curve [:& path-shape {:shape shape :zoom zoom}]
|
||||
#_:default [:> generic-draw-area* props])]))
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
[app.main.store :as st]
|
||||
[app.main.ui.context :as ctx]
|
||||
[app.main.ui.css-cursors :as cur]
|
||||
[app.main.ui.workspace.shapes.path.editor :refer [path-editor]]
|
||||
[app.main.ui.workspace.shapes.path.editor :refer [path-editor*]]
|
||||
[app.util.array :as array]
|
||||
[app.util.debug :as dbg]
|
||||
[app.util.dom :as dom]
|
||||
|
@ -603,7 +603,7 @@
|
|||
nil
|
||||
|
||||
(= edition shape-id)
|
||||
[:& path-editor
|
||||
[:> path-editor*
|
||||
{:zoom zoom
|
||||
:shape shape}]
|
||||
|
||||
|
|
|
@ -507,7 +507,7 @@
|
|||
:on-frame-select on-frame-select}])
|
||||
|
||||
(when show-draw-area?
|
||||
[:& drawarea/draw-area
|
||||
[:> drawarea/draw-area*
|
||||
{:shape drawing-obj
|
||||
:zoom zoom
|
||||
:tool drawing-tool}])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue