mirror of
https://github.com/penpot/penpot.git
synced 2025-02-22 14:57:01 -05:00
⚡ Improve interactions and after-review fixes
This commit is contained in:
parent
c28a2acfc7
commit
493a7680e0
5 changed files with 51 additions and 25 deletions
|
@ -15,12 +15,16 @@
|
|||
|
||||
(defn calc-bool-content
|
||||
[shape objects]
|
||||
(->> (:shapes shape)
|
||||
(map (d/getf objects))
|
||||
(filter (comp not :hidden))
|
||||
(map #(stp/convert-to-path % objects))
|
||||
(mapv :content)
|
||||
(pb/content-bool (:bool-type shape))))
|
||||
|
||||
(let [extract-content-xf
|
||||
(comp (map (d/getf objects))
|
||||
(filter (comp not :hidden))
|
||||
(map #(stp/convert-to-path % objects))
|
||||
(map :content))
|
||||
|
||||
shapes-content
|
||||
(into [] extract-content-xf (:shapes shape))]
|
||||
(pb/content-bool (:bool-type shape) shapes-content)))
|
||||
|
||||
(defn update-bool-selrect
|
||||
"Calculates the selrect+points for the boolean shape"
|
||||
|
|
|
@ -116,6 +116,14 @@
|
|||
:show-distances?])
|
||||
workspace-local =))
|
||||
|
||||
(def interactions-data
|
||||
(l/derived #(select-keys % [:editing-interaction-index
|
||||
:draw-interaction-to
|
||||
:draw-interaction-to-frame
|
||||
:move-overlay-to
|
||||
:move-overlay-index])
|
||||
workspace-local =))
|
||||
|
||||
(def local-displacement
|
||||
(l/derived #(select-keys % [:modifiers :selected])
|
||||
workspace-local =))
|
||||
|
@ -235,9 +243,8 @@
|
|||
[ids]
|
||||
(let [selector
|
||||
(fn [state]
|
||||
(let [objects (wsh/lookup-page-objects state)
|
||||
xform (comp (map (d/getf objects)) (remove nil?))]
|
||||
(into [] xform ids)))]
|
||||
(let [objects (wsh/lookup-page-objects state)]
|
||||
(into [] (keep (d/getf objects)) ids)))]
|
||||
(l/derived selector st/state =)))
|
||||
|
||||
(defn- set-content-modifiers [state]
|
||||
|
|
|
@ -46,10 +46,17 @@
|
|||
(rx/subs #(reset! buffer (vec %))))
|
||||
buffer))
|
||||
|
||||
(def emit! (partial ptk/emit! state))
|
||||
(defn emit!
|
||||
([] nil)
|
||||
([event]
|
||||
(ptk/emit! state event)
|
||||
nil)
|
||||
([event & events]
|
||||
(apply ptk/emit! state (cons event events))
|
||||
nil))
|
||||
|
||||
(defn emitf
|
||||
[& events]
|
||||
#(ptk/emit! state events))
|
||||
#(apply ptk/emit! state events))
|
||||
|
||||
|
||||
|
|
|
@ -92,8 +92,7 @@
|
|||
drawing-tool (:tool drawing)
|
||||
drawing-obj (:object drawing)
|
||||
|
||||
xf-select-shape (comp (map (d/getf objects-modified)) (filter some?))
|
||||
selected-shapes (into [] xf-select-shape selected)
|
||||
selected-shapes (into [] (keep (d/getf objects-modified)) selected)
|
||||
selected-frames (into #{} (map :frame-id) selected-shapes)
|
||||
|
||||
;; Only when we have all the selected shapes in one frame
|
||||
|
@ -329,6 +328,9 @@
|
|||
(when show-prototypes?
|
||||
[:& interactions/interactions
|
||||
{:selected selected
|
||||
:zoom zoom
|
||||
:objects objects-modified
|
||||
:current-transform transform
|
||||
:hover-disabled? hover-disabled?}])
|
||||
|
||||
(when show-selrect?
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"Visually show shape interactions in workspace"
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.types.interactions :as cti]
|
||||
[app.main.data.workspace :as dw]
|
||||
|
@ -235,18 +236,23 @@
|
|||
:fill "var(--color-primary)"}]]))))
|
||||
|
||||
(mf/defc interactions
|
||||
[{:keys [selected hover-disabled?] :as props}]
|
||||
(let [local (mf/deref refs/workspace-local)
|
||||
zoom (mf/deref refs/selected-zoom)
|
||||
current-transform (:transform local)
|
||||
objects (mf/deref refs/workspace-page-objects)
|
||||
active-shapes (filter #(seq (:interactions %)) (vals objects))
|
||||
selected-shapes (map #(get objects %) selected)
|
||||
editing-interaction-index (:editing-interaction-index local)
|
||||
draw-interaction-to (:draw-interaction-to local)
|
||||
draw-interaction-to-frame (:draw-interaction-to-frame local)
|
||||
move-overlay-to (:move-overlay-to local)
|
||||
move-overlay-index (:move-overlay-index local)
|
||||
[{:keys [current-transform objects zoom selected hover-disabled?] :as props}]
|
||||
(let [active-shapes (into []
|
||||
(comp (filter #(seq (:interactions %)))
|
||||
(map gsh/transform-shape))
|
||||
(vals objects))
|
||||
|
||||
selected-shapes (into []
|
||||
(comp (map (d/getf objects))
|
||||
(map gsh/transform-shape))
|
||||
selected)
|
||||
|
||||
{:keys [editing-interaction-index
|
||||
draw-interaction-to
|
||||
draw-interaction-to-frame
|
||||
move-overlay-to
|
||||
move-overlay-index]} (mf/deref refs/interactions-data)
|
||||
|
||||
first-selected (first selected-shapes)
|
||||
|
||||
calc-level (fn [index interactions]
|
||||
|
|
Loading…
Add table
Reference in a new issue