0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-13 16:21:57 -05:00

♻️ Rename helper root-frame? to is-direct-child-of-root?

This commit is contained in:
Pablo Alba 2023-07-24 15:50:35 +02:00 committed by Andrey Antukh
parent 35f931c05a
commit 577c2b39dc
11 changed files with 21 additions and 21 deletions

View file

@ -51,7 +51,7 @@
(cond
(and (some? frame)
(not ^boolean (ctst/rotated-frame? frame))
(not ^boolean (cph/root-frame? frame)))
(not ^boolean (cph/is-direct-child-of-root? frame)))
#{}
(= :x (:axis guide))

View file

@ -26,9 +26,9 @@
(and (= (dm/get-prop shape :type) :frame)
(= (dm/get-prop shape :id) uuid/zero)))
(defn root-frame?
(defn is-direct-child-of-root?
([objects id]
(root-frame? (get objects id)))
(is-direct-child-of-root? (get objects id)))
([{:keys [frame-id type]}]
(and (= type :frame)
(= frame-id uuid/zero))))
@ -228,7 +228,7 @@
(or (root? frame) (nil? frame))
nil
(root-frame? frame)
(is-direct-child-of-root? frame)
frame
:else
@ -613,7 +613,7 @@
(->> (get-parent-ids objects shape-id)
(cons shape-id)
(map (d/getf objects))
(d/seek root-frame?)
(d/seek is-direct-child-of-root?)
:id))
(defn comparator-layout-z-index

View file

@ -501,7 +501,7 @@
frame-offset (if (or (not= :manual (:overlay-pos-type interaction))
(nil? shape-frame)
(cph/root-frame? shape-frame)
(cph/is-direct-child-of-root? shape-frame)
(cph/root? shape-frame))
frame-offset
(gpt/add frame-offset (gpt/point shape-frame)))]

View file

@ -34,7 +34,7 @@
[shape hover?]
(fn [event]
(when-not (or (cph/group-shape? shape)
(cph/root-frame? shape))
(cph/is-direct-child-of-root? shape))
(dom/prevent-default event)
(dom/stop-propagation event)
(st/emit! (dv/hover-shape (:id shape) hover?)))))
@ -42,7 +42,7 @@
(defn select-shape [shape]
(fn [event]
(when-not (or (cph/group-shape? shape)
(cph/root-frame? shape))
(cph/is-direct-child-of-root? shape))
(dom/stop-propagation event)
(dom/prevent-default event)
(cond

View file

@ -74,7 +74,7 @@
[:& shape-wrapper
{:shape shape}]
(cph/root-frame? shape)
(cph/is-direct-child-of-root? shape)
[:& root-frame-wrapper
{:shape shape
:objects (get frame-objects (:id shape))
@ -92,7 +92,7 @@
(let [shape (obj/get props "shape")
active-frames
(when (cph/root-frame? shape) (mf/use-ctx ctx/active-frames))
(when (cph/is-direct-child-of-root? shape) (mf/use-ctx ctx/active-frames))
thumbnail?
(and (some? active-frames)

View file

@ -39,7 +39,7 @@
childs (mf/deref childs-ref)]
[:& (mf/provider embed/context) {:value true}
[:& shape-container {:shape shape :ref ref :disable-shadows? (cph/root-frame? shape)}
[:& shape-container {:shape shape :ref ref :disable-shadows? (cph/is-direct-child-of-root? shape)}
[:& frame-shape {:shape shape :childs childs} ]]]))))
(defn check-props

View file

@ -141,7 +141,7 @@
(fn []
(let [parent-id
(->> @hover-ids
(d/seek (partial cph/root-frame? base-objects)))]
(d/seek (partial cph/is-direct-child-of-root? base-objects)))]
(when (some? parent-id)
(get base-objects parent-id)))))
@ -244,7 +244,7 @@
first-selected-shape (first selected-shapes)
selecting-first-level-frame? (and one-selected-shape?
(cph/root-frame? first-selected-shape))
(cph/is-direct-child-of-root? first-selected-shape))
offset-x (if selecting-first-level-frame?
(:x first-selected-shape)

View file

@ -293,7 +293,7 @@
(not (is-guide-inside-frame? (assoc guide :position pos) frame)))]
(when (or (nil? frame)
(and (cph/root-frame? frame)
(and (cph/is-direct-child-of-root? frame)
(not (ctst/rotated-frame? frame))))
[:g.guide-area {:opacity (when frame-guide-outside? 0)}
(when-not disabled-guides?

View file

@ -217,7 +217,7 @@
root-frame-with-data?
#(as-> (get objects %) obj
(and (cph/root-frame? obj)
(and (cph/is-direct-child-of-root? obj)
(d/not-empty? (:shapes obj))
(not (ctk/instance-head? obj))
(not (ctk/main-instance? obj))))
@ -241,7 +241,7 @@
no-fill-nested-frames?
(fn [id]
(and (cph/frame-shape? objects id)
(not (cph/root-frame? objects id))
(not (cph/is-direct-child-of-root? objects id))
(empty? (dm/get-in objects [id :fills]))))
hover-shape
@ -276,7 +276,7 @@
(let [all-frames (mf/use-memo (mf/deps objects) #(ctt/get-root-frames-ids objects))
selected-frames (mf/use-memo (mf/deps selected) #(->> all-frames (filter selected)))
xf-selected-frame (comp (remove cph/root-frame?)
xf-selected-frame (comp (remove cph/is-direct-child-of-root?)
(map #(cph/get-shape-id-root-frame objects %)))
selected-shapes-frames (mf/use-memo (mf/deps selected) #(into #{} xf-selected-frame selected))

View file

@ -74,7 +74,7 @@
{:shape shape
:key (:id shape)}]
(cph/root-frame? shape)
(cph/is-direct-child-of-root? shape)
[:& shapes/root-frame-wrapper
{:shape shape
:key (:id shape)

View file

@ -30,7 +30,7 @@
(not (ctl/layout-absolute? shape))
(or (cph/group-shape? shape)
(cph/frame-shape? shape)))
(cph/root-frame? shape))
(cph/is-direct-child-of-root? shape))
:relative
(and (ctl/any-layout-immediate-child? objects shape)
@ -54,14 +54,14 @@
;;shape (gsh/transform-shape)
shape-value (get selrect coord)
]
(when (and (not (cph/root-frame? shape))
(when (and (not (cph/is-direct-child-of-root? shape))
(or (not (ctl/any-layout-immediate-child? objects shape))
(ctl/layout-absolute? shape)))
(- shape-value parent-value))))
#_(defn get-shape-position
[shape objects coord]
(when-not (or (cph/root-frame? shape)
(when-not (or (cph/is-direct-child-of-root? shape)
(and (ctl/any-layout-immediate-child? objects shape)
(not (ctl/layout-absolute? shape))))
(let [parent (get objects (:parent-id shape))