From 577c2b39dc63e1a9f83aaa53335cd1b74fe20cfb Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 24 Jul 2023 15:50:35 +0200 Subject: [PATCH] :recycle: Rename helper root-frame? to is-direct-child-of-root? --- common/src/app/common/geom/snap.cljc | 2 +- common/src/app/common/pages/helpers.cljc | 8 ++++---- common/src/app/common/types/shape/interactions.cljc | 2 +- frontend/src/app/main/ui/viewer/inspect/render.cljs | 4 ++-- frontend/src/app/main/ui/workspace/shapes.cljs | 4 ++-- frontend/src/app/main/ui/workspace/shapes/frame.cljs | 2 +- frontend/src/app/main/ui/workspace/viewport.cljs | 4 ++-- frontend/src/app/main/ui/workspace/viewport/guides.cljs | 2 +- frontend/src/app/main/ui/workspace/viewport/hooks.cljs | 6 +++--- .../src/app/main/ui/workspace/viewport/pixel_overlay.cljs | 2 +- frontend/src/app/util/code_gen/style_css_values.cljs | 6 +++--- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/common/src/app/common/geom/snap.cljc b/common/src/app/common/geom/snap.cljc index 04e19c11b2..18e025e028 100644 --- a/common/src/app/common/geom/snap.cljc +++ b/common/src/app/common/geom/snap.cljc @@ -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)) diff --git a/common/src/app/common/pages/helpers.cljc b/common/src/app/common/pages/helpers.cljc index 299fd26243..a4cfb81008 100644 --- a/common/src/app/common/pages/helpers.cljc +++ b/common/src/app/common/pages/helpers.cljc @@ -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 diff --git a/common/src/app/common/types/shape/interactions.cljc b/common/src/app/common/types/shape/interactions.cljc index ef2caabe1b..a821cdfec2 100644 --- a/common/src/app/common/types/shape/interactions.cljc +++ b/common/src/app/common/types/shape/interactions.cljc @@ -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)))] diff --git a/frontend/src/app/main/ui/viewer/inspect/render.cljs b/frontend/src/app/main/ui/viewer/inspect/render.cljs index 01adf3e355..a3cf6cc4dc 100644 --- a/frontend/src/app/main/ui/viewer/inspect/render.cljs +++ b/frontend/src/app/main/ui/viewer/inspect/render.cljs @@ -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 diff --git a/frontend/src/app/main/ui/workspace/shapes.cljs b/frontend/src/app/main/ui/workspace/shapes.cljs index e7b5ae517d..36f02ddc38 100644 --- a/frontend/src/app/main/ui/workspace/shapes.cljs +++ b/frontend/src/app/main/ui/workspace/shapes.cljs @@ -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) diff --git a/frontend/src/app/main/ui/workspace/shapes/frame.cljs b/frontend/src/app/main/ui/workspace/shapes/frame.cljs index b18e6b5478..a9b23e647e 100644 --- a/frontend/src/app/main/ui/workspace/shapes/frame.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/frame.cljs @@ -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 diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 8919d25c33..096415c59d 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -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) diff --git a/frontend/src/app/main/ui/workspace/viewport/guides.cljs b/frontend/src/app/main/ui/workspace/viewport/guides.cljs index 1182ca4ea4..5d8a254e74 100644 --- a/frontend/src/app/main/ui/workspace/viewport/guides.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/guides.cljs @@ -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? diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs index 2ae9b2ceaa..c8e5978665 100644 --- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs @@ -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)) diff --git a/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs b/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs index c7129b3a14..be6c30f88a 100644 --- a/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/pixel_overlay.cljs @@ -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) diff --git a/frontend/src/app/util/code_gen/style_css_values.cljs b/frontend/src/app/util/code_gen/style_css_values.cljs index 53805f28f2..c45e2679d3 100644 --- a/frontend/src/app/util/code_gen/style_css_values.cljs +++ b/frontend/src/app/util/code_gen/style_css_values.cljs @@ -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))