mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 21:21:37 +02:00
♻️ Rename helper root-frame? to is-direct-child-of-root?
This commit is contained in:
parent
35f931c05a
commit
577c2b39dc
11 changed files with 21 additions and 21 deletions
|
@ -51,7 +51,7 @@
|
||||||
(cond
|
(cond
|
||||||
(and (some? frame)
|
(and (some? frame)
|
||||||
(not ^boolean (ctst/rotated-frame? 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))
|
(= :x (:axis guide))
|
||||||
|
|
|
@ -26,9 +26,9 @@
|
||||||
(and (= (dm/get-prop shape :type) :frame)
|
(and (= (dm/get-prop shape :type) :frame)
|
||||||
(= (dm/get-prop shape :id) uuid/zero)))
|
(= (dm/get-prop shape :id) uuid/zero)))
|
||||||
|
|
||||||
(defn root-frame?
|
(defn is-direct-child-of-root?
|
||||||
([objects id]
|
([objects id]
|
||||||
(root-frame? (get objects id)))
|
(is-direct-child-of-root? (get objects id)))
|
||||||
([{:keys [frame-id type]}]
|
([{:keys [frame-id type]}]
|
||||||
(and (= type :frame)
|
(and (= type :frame)
|
||||||
(= frame-id uuid/zero))))
|
(= frame-id uuid/zero))))
|
||||||
|
@ -228,7 +228,7 @@
|
||||||
(or (root? frame) (nil? frame))
|
(or (root? frame) (nil? frame))
|
||||||
nil
|
nil
|
||||||
|
|
||||||
(root-frame? frame)
|
(is-direct-child-of-root? frame)
|
||||||
frame
|
frame
|
||||||
|
|
||||||
:else
|
:else
|
||||||
|
@ -613,7 +613,7 @@
|
||||||
(->> (get-parent-ids objects shape-id)
|
(->> (get-parent-ids objects shape-id)
|
||||||
(cons shape-id)
|
(cons shape-id)
|
||||||
(map (d/getf objects))
|
(map (d/getf objects))
|
||||||
(d/seek root-frame?)
|
(d/seek is-direct-child-of-root?)
|
||||||
:id))
|
:id))
|
||||||
|
|
||||||
(defn comparator-layout-z-index
|
(defn comparator-layout-z-index
|
||||||
|
|
|
@ -501,7 +501,7 @@
|
||||||
|
|
||||||
frame-offset (if (or (not= :manual (:overlay-pos-type interaction))
|
frame-offset (if (or (not= :manual (:overlay-pos-type interaction))
|
||||||
(nil? shape-frame)
|
(nil? shape-frame)
|
||||||
(cph/root-frame? shape-frame)
|
(cph/is-direct-child-of-root? shape-frame)
|
||||||
(cph/root? shape-frame))
|
(cph/root? shape-frame))
|
||||||
frame-offset
|
frame-offset
|
||||||
(gpt/add frame-offset (gpt/point shape-frame)))]
|
(gpt/add frame-offset (gpt/point shape-frame)))]
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
[shape hover?]
|
[shape hover?]
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(when-not (or (cph/group-shape? shape)
|
(when-not (or (cph/group-shape? shape)
|
||||||
(cph/root-frame? shape))
|
(cph/is-direct-child-of-root? shape))
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(st/emit! (dv/hover-shape (:id shape) hover?)))))
|
(st/emit! (dv/hover-shape (:id shape) hover?)))))
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
(defn select-shape [shape]
|
(defn select-shape [shape]
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(when-not (or (cph/group-shape? shape)
|
(when-not (or (cph/group-shape? shape)
|
||||||
(cph/root-frame? shape))
|
(cph/is-direct-child-of-root? shape))
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(cond
|
(cond
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
[:& shape-wrapper
|
[:& shape-wrapper
|
||||||
{:shape shape}]
|
{:shape shape}]
|
||||||
|
|
||||||
(cph/root-frame? shape)
|
(cph/is-direct-child-of-root? shape)
|
||||||
[:& root-frame-wrapper
|
[:& root-frame-wrapper
|
||||||
{:shape shape
|
{:shape shape
|
||||||
:objects (get frame-objects (:id shape))
|
:objects (get frame-objects (:id shape))
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
(let [shape (obj/get props "shape")
|
(let [shape (obj/get props "shape")
|
||||||
|
|
||||||
active-frames
|
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?
|
thumbnail?
|
||||||
(and (some? active-frames)
|
(and (some? active-frames)
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
childs (mf/deref childs-ref)]
|
childs (mf/deref childs-ref)]
|
||||||
|
|
||||||
[:& (mf/provider embed/context) {:value true}
|
[:& (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} ]]]))))
|
[:& frame-shape {:shape shape :childs childs} ]]]))))
|
||||||
|
|
||||||
(defn check-props
|
(defn check-props
|
||||||
|
|
|
@ -141,7 +141,7 @@
|
||||||
(fn []
|
(fn []
|
||||||
(let [parent-id
|
(let [parent-id
|
||||||
(->> @hover-ids
|
(->> @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)
|
(when (some? parent-id)
|
||||||
(get base-objects parent-id)))))
|
(get base-objects parent-id)))))
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@
|
||||||
|
|
||||||
first-selected-shape (first selected-shapes)
|
first-selected-shape (first selected-shapes)
|
||||||
selecting-first-level-frame? (and one-selected-shape?
|
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?
|
offset-x (if selecting-first-level-frame?
|
||||||
(:x first-selected-shape)
|
(:x first-selected-shape)
|
||||||
|
|
|
@ -293,7 +293,7 @@
|
||||||
(not (is-guide-inside-frame? (assoc guide :position pos) frame)))]
|
(not (is-guide-inside-frame? (assoc guide :position pos) frame)))]
|
||||||
|
|
||||||
(when (or (nil? frame)
|
(when (or (nil? frame)
|
||||||
(and (cph/root-frame? frame)
|
(and (cph/is-direct-child-of-root? frame)
|
||||||
(not (ctst/rotated-frame? frame))))
|
(not (ctst/rotated-frame? frame))))
|
||||||
[:g.guide-area {:opacity (when frame-guide-outside? 0)}
|
[:g.guide-area {:opacity (when frame-guide-outside? 0)}
|
||||||
(when-not disabled-guides?
|
(when-not disabled-guides?
|
||||||
|
|
|
@ -217,7 +217,7 @@
|
||||||
|
|
||||||
root-frame-with-data?
|
root-frame-with-data?
|
||||||
#(as-> (get objects %) obj
|
#(as-> (get objects %) obj
|
||||||
(and (cph/root-frame? obj)
|
(and (cph/is-direct-child-of-root? obj)
|
||||||
(d/not-empty? (:shapes obj))
|
(d/not-empty? (:shapes obj))
|
||||||
(not (ctk/instance-head? obj))
|
(not (ctk/instance-head? obj))
|
||||||
(not (ctk/main-instance? obj))))
|
(not (ctk/main-instance? obj))))
|
||||||
|
@ -241,7 +241,7 @@
|
||||||
no-fill-nested-frames?
|
no-fill-nested-frames?
|
||||||
(fn [id]
|
(fn [id]
|
||||||
(and (cph/frame-shape? objects 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]))))
|
(empty? (dm/get-in objects [id :fills]))))
|
||||||
|
|
||||||
hover-shape
|
hover-shape
|
||||||
|
@ -276,7 +276,7 @@
|
||||||
(let [all-frames (mf/use-memo (mf/deps objects) #(ctt/get-root-frames-ids objects))
|
(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)))
|
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 %)))
|
(map #(cph/get-shape-id-root-frame objects %)))
|
||||||
|
|
||||||
selected-shapes-frames (mf/use-memo (mf/deps selected) #(into #{} xf-selected-frame selected))
|
selected-shapes-frames (mf/use-memo (mf/deps selected) #(into #{} xf-selected-frame selected))
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
{:shape shape
|
{:shape shape
|
||||||
:key (:id shape)}]
|
:key (:id shape)}]
|
||||||
|
|
||||||
(cph/root-frame? shape)
|
(cph/is-direct-child-of-root? shape)
|
||||||
[:& shapes/root-frame-wrapper
|
[:& shapes/root-frame-wrapper
|
||||||
{:shape shape
|
{:shape shape
|
||||||
:key (:id shape)
|
:key (:id shape)
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
(not (ctl/layout-absolute? shape))
|
(not (ctl/layout-absolute? shape))
|
||||||
(or (cph/group-shape? shape)
|
(or (cph/group-shape? shape)
|
||||||
(cph/frame-shape? shape)))
|
(cph/frame-shape? shape)))
|
||||||
(cph/root-frame? shape))
|
(cph/is-direct-child-of-root? shape))
|
||||||
:relative
|
:relative
|
||||||
|
|
||||||
(and (ctl/any-layout-immediate-child? objects shape)
|
(and (ctl/any-layout-immediate-child? objects shape)
|
||||||
|
@ -54,14 +54,14 @@
|
||||||
;;shape (gsh/transform-shape)
|
;;shape (gsh/transform-shape)
|
||||||
shape-value (get selrect coord)
|
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))
|
(or (not (ctl/any-layout-immediate-child? objects shape))
|
||||||
(ctl/layout-absolute? shape)))
|
(ctl/layout-absolute? shape)))
|
||||||
(- shape-value parent-value))))
|
(- shape-value parent-value))))
|
||||||
|
|
||||||
#_(defn get-shape-position
|
#_(defn get-shape-position
|
||||||
[shape objects coord]
|
[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)
|
(and (ctl/any-layout-immediate-child? objects shape)
|
||||||
(not (ctl/layout-absolute? shape))))
|
(not (ctl/layout-absolute? shape))))
|
||||||
(let [parent (get objects (:parent-id shape))
|
(let [parent (get objects (:parent-id shape))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue