mirror of
https://github.com/penpot/penpot.git
synced 2025-03-16 01:31:22 -05:00
✨ Expand mask when selected in workspace
This commit is contained in:
parent
0ddf6d30b8
commit
823aa426ed
3 changed files with 23 additions and 13 deletions
|
@ -159,7 +159,6 @@
|
|||
(let [page-id (:current-page-id state)
|
||||
objects (get-in state [:workspace-data :pages-index page-id :objects])
|
||||
selected (get-in state [:workspace-local :selected])
|
||||
shape (get objects id)
|
||||
children (cph/get-children id objects)]
|
||||
(some selected children)))]
|
||||
(l/derived selector st/state)))
|
||||
|
|
|
@ -22,15 +22,16 @@
|
|||
(mf/fnc group-shape
|
||||
{::mf/wrap-props false}
|
||||
[props]
|
||||
(let [frame (unchecked-get props "frame")
|
||||
shape (unchecked-get props "shape")
|
||||
childs (unchecked-get props "childs")
|
||||
mask (if (:masked-group? shape)
|
||||
(first childs)
|
||||
nil)
|
||||
childs (if (:masked-group? shape)
|
||||
(rest childs)
|
||||
childs)
|
||||
(let [frame (unchecked-get props "frame")
|
||||
shape (unchecked-get props "shape")
|
||||
childs (unchecked-get props "childs")
|
||||
expand-mask (unchecked-get props "expand-mask")
|
||||
mask (if (and (:masked-group? shape) (not expand-mask))
|
||||
(first childs)
|
||||
nil)
|
||||
childs (if (and (:masked-group? shape) (not expand-mask))
|
||||
(rest childs)
|
||||
childs)
|
||||
is-child-selected? (unchecked-get props "is-child-selected?")
|
||||
{:keys [id x y width height]} shape
|
||||
transform (geom/transform-matrix shape)]
|
||||
|
|
|
@ -46,8 +46,8 @@
|
|||
on-context-menu
|
||||
(mf/use-callback (mf/deps shape) #(common/on-context-menu % shape))
|
||||
|
||||
childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape)))
|
||||
childs (mf/deref childs-ref)
|
||||
childs-ref (mf/use-memo (mf/deps shape) #(refs/objects-by-id (:shapes shape)))
|
||||
childs (mf/deref childs-ref)
|
||||
|
||||
is-child-selected-ref
|
||||
(mf/use-memo (mf/deps (:id shape)) #(refs/is-child-selected? (:id shape)))
|
||||
|
@ -55,6 +55,15 @@
|
|||
is-child-selected?
|
||||
(mf/deref is-child-selected-ref)
|
||||
|
||||
mask-id (when (:masked-group? shape) (first (:shapes shape)))
|
||||
|
||||
is-mask-selected-ref
|
||||
(mf/use-memo (mf/deps mask-id)
|
||||
#(refs/make-selected-ref mask-id))
|
||||
|
||||
is-mask-selected?
|
||||
(mf/deref is-mask-selected-ref)
|
||||
|
||||
on-double-click
|
||||
(mf/use-callback
|
||||
(mf/deps (:id shape))
|
||||
|
@ -72,5 +81,6 @@
|
|||
{:frame frame
|
||||
:shape shape
|
||||
:childs childs
|
||||
:is-child-selected? is-child-selected?}]]))))
|
||||
:is-child-selected? is-child-selected?
|
||||
:expand-mask is-mask-selected?}]]))))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue