mirror of
https://github.com/penpot/penpot.git
synced 2025-06-19 12:31:38 +02:00
💄 Add cosmetic improvements to workspace shapes/bool ns
This commit is contained in:
parent
c7ae8b6510
commit
469de48af2
1 changed files with 18 additions and 28 deletions
|
@ -6,47 +6,37 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace.shapes.bool
|
(ns app.main.ui.workspace.shapes.bool
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.workspace :as dw]
|
[app.common.data.macros :as dm]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.streams :as ms]
|
|
||||||
[app.main.ui.shapes.bool :as bool]
|
[app.main.ui.shapes.bool :as bool]
|
||||||
[app.main.ui.shapes.shape :refer [shape-container]]
|
[app.main.ui.shapes.shape :refer [shape-container]]
|
||||||
[app.util.dom :as dom]
|
[app.main.ui.workspace.shapes.common :refer [check-shape-props]]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(defn use-double-click [{:keys [id]}]
|
|
||||||
(mf/use-callback
|
|
||||||
(mf/deps id)
|
|
||||||
(fn [event]
|
|
||||||
(dom/stop-propagation event)
|
|
||||||
(dom/prevent-default event)
|
|
||||||
(st/emit! (dw/select-inside-group id @ms/mouse-position)))))
|
|
||||||
|
|
||||||
(defn bool-wrapper-factory
|
(defn bool-wrapper-factory
|
||||||
[shape-wrapper]
|
[shape-wrapper]
|
||||||
(let [shape-component (bool/bool-shape shape-wrapper)]
|
(let [bool-shape (bool/bool-shape shape-wrapper)]
|
||||||
(mf/fnc bool-wrapper
|
(mf/fnc bool-wrapper
|
||||||
{::mf/wrap [#(mf/memo' % (mf/check-props ["shape"]))]
|
{::mf/wrap [#(mf/memo' % check-shape-props)]
|
||||||
::mf/wrap-props false}
|
::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
child-sel-ref (mf/use-memo
|
shape-id (dm/get-prop shape :id)
|
||||||
(mf/deps (:id shape))
|
|
||||||
#(refs/is-child-selected? (:id shape)))
|
|
||||||
|
|
||||||
childs-ref (mf/use-memo
|
child-sel* (mf/with-memo [shape-id]
|
||||||
(mf/deps (:id shape))
|
(refs/is-child-selected? shape-id))
|
||||||
#(refs/select-bool-children (:id shape)))
|
|
||||||
|
|
||||||
child-sel? (mf/deref child-sel-ref)
|
childs* (mf/with-memo [shape-id]
|
||||||
childs (mf/deref childs-ref)
|
(refs/select-bool-children shape-id))
|
||||||
|
|
||||||
shape (cond-> shape
|
child-sel? (mf/deref child-sel*)
|
||||||
child-sel?
|
childs (mf/deref childs*)
|
||||||
(dissoc :bool-content))]
|
|
||||||
|
shape (cond-> shape
|
||||||
|
^boolean child-sel?
|
||||||
|
(dissoc :bool-content))]
|
||||||
|
|
||||||
[:> shape-container {:shape shape}
|
[:> shape-container {:shape shape}
|
||||||
[:& shape-component {:shape shape
|
[:& bool-shape {:shape shape
|
||||||
:childs childs}]]))))
|
:childs childs}]]))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue