From 4bd15b5de1783cad1cf256839469b0c856ff445d Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 4 May 2023 17:07:08 +0200 Subject: [PATCH] :sparkles: Adds child layout options to grid children --- frontend/src/app/main/refs.cljs | 8 ++++---- .../ui/workspace/sidebar/options/shapes/bool.cljs | 8 ++++---- .../workspace/sidebar/options/shapes/circle.cljs | 8 ++++---- .../ui/workspace/sidebar/options/shapes/frame.cljs | 10 +++++----- .../ui/workspace/sidebar/options/shapes/group.cljs | 8 ++++---- .../ui/workspace/sidebar/options/shapes/image.cljs | 8 ++++---- .../workspace/sidebar/options/shapes/multiple.cljs | 14 +++++++------- .../ui/workspace/sidebar/options/shapes/path.cljs | 8 ++++---- .../ui/workspace/sidebar/options/shapes/rect.cljs | 8 ++++---- .../workspace/sidebar/options/shapes/svg_raw.cljs | 8 ++++---- .../ui/workspace/sidebar/options/shapes/text.cljs | 8 ++++---- 11 files changed, 48 insertions(+), 48 deletions(-) diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index bcb78e7a4a..51a90a6386 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -485,22 +485,22 @@ (defn workspace-text-modifier-by-id [id] (l/derived #(get % id) workspace-text-modifier =)) -(defn is-flex-layout-child? +(defn is-layout-child? [ids] (l/derived (fn [objects] (->> ids (map (d/getf objects)) - (some (partial ctl/flex-layout-immediate-child? objects)))) + (some (partial ctl/any-layout-immediate-child? objects)))) workspace-page-objects)) -(defn all-flex-layout-child? +(defn all-layout-child? [ids] (l/derived (fn [objects] (->> ids (map (d/getf objects)) - (every? (partial ctl/flex-layout-immediate-child? objects)))) + (every? (partial ctl/any-layout-immediate-child? objects)))) workspace-page-objects)) (defn get-flex-child-viewer diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/bool.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/bool.cljs index 458acf5d91..9803d57c67 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/bool.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/bool.cljs @@ -30,8 +30,8 @@ layout-item-values (select-keys shape layout-item-attrs) layout-container-values (select-keys shape layout-container-flex-attrs) - is-flex-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-flex-layout-child? ids)) - is-flex-layout-child? (mf/deref is-flex-layout-child-ref) + is-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids)) + is-layout-child? (mf/deref is-layout-child-ref) is-layout-child-absolute? (ctl/layout-absolute? shape)] [:* @@ -41,7 +41,7 @@ :shape shape}] [:& layout-container-menu {:type type :ids [(:id shape)] :values layout-container-values :multiple false}] - (when is-flex-layout-child? + (when is-layout-child? [:& layout-item-menu {:ids ids :type type @@ -49,7 +49,7 @@ :is-layout-child? true :shape shape}]) - (when (or (not is-flex-layout-child?) is-layout-child-absolute?) + (when (or (not is-layout-child?) is-layout-child-absolute?) [:& constraints-menu {:ids ids :values constraint-values}]) [:& layer-menu {:ids ids diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/circle.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/circle.cljs index 78b938ca72..0820c9be81 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/circle.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/circle.cljs @@ -32,8 +32,8 @@ layout-item-values (select-keys shape layout-item-attrs) layout-container-values (select-keys shape layout-container-flex-attrs) - is-flex-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-flex-layout-child? ids)) - is-flex-layout-child? (mf/deref is-flex-layout-child-ref) + is-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids)) + is-layout-child? (mf/deref is-layout-child-ref) is-layout-child-absolute? (ctl/layout-absolute? shape)] [:* [:& measures-menu {:ids ids @@ -42,14 +42,14 @@ :shape shape}] [:& layout-container-menu {:type type :ids [(:id shape)] :values layout-container-values :multiple false}] - (when is-flex-layout-child? + (when is-layout-child? [:& layout-item-menu {:ids ids :type type :values layout-item-values :is-layout-child? true :is-layout-container? false :shape shape}]) - (when (or (not is-flex-layout-child?) is-layout-child-absolute?) + (when (or (not is-layout-child?) is-layout-child-absolute?) [:& constraints-menu {:ids ids :values constraint-values}]) [:& layer-menu {:ids ids diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/frame.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/frame.cljs index f92c7f542a..21a9ae46cb 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/frame.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/frame.cljs @@ -36,8 +36,8 @@ layout-item-values (select-keys shape layout-item-attrs) [comp-ids comp-values] [[(:id shape)] (select-keys shape component-attrs)] - is-flex-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-flex-layout-child? ids)) - is-flex-layout-child? (mf/deref is-flex-layout-child-ref) + is-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids)) + is-layout-child? (mf/deref is-layout-child-ref) is-flex-layout-container? (ctl/flex-layout? shape) is-layout-child-absolute? (ctl/layout-absolute? shape)] [:* @@ -48,17 +48,17 @@ [:& component-menu {:ids comp-ids :values comp-values :shape shape}] - (when (or (not is-flex-layout-child?) is-layout-child-absolute?) + (when (or (not is-layout-child?) is-layout-child-absolute?) [:& constraints-menu {:ids ids :values constraint-values}]) [:& layout-container-menu {:type type :ids [(:id shape)] :values layout-container-values :multiple false}] - (when (or is-flex-layout-child? is-flex-layout-container?) + (when (or is-layout-child? is-flex-layout-container?) [:& layout-item-menu {:ids ids :type type :values layout-item-values - :is-layout-child? is-flex-layout-child? + :is-layout-child? is-layout-child? :is-layout-container? is-flex-layout-container? :shape shape}]) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/group.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/group.cljs index b840728358..842f554811 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/group.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/group.cljs @@ -36,8 +36,8 @@ file-id (unchecked-get props "file-id") layout-container-values (select-keys shape layout-container-flex-attrs) ids [(:id shape)] - is-flex-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-flex-layout-child? ids)) - is-flex-layout-child? (mf/deref is-flex-layout-child-ref) + is-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids)) + is-layout-child? (mf/deref is-layout-child-ref) is-layout-child-absolute? (ctl/layout-absolute? shape) type :group @@ -58,7 +58,7 @@ [:& component-menu {:ids comp-ids :values comp-values :shape shape}] ;;remove this in components-v2 [:& layout-container-menu {:type type :ids [(:id shape)] :values layout-container-values :multiple false}] - (when is-flex-layout-child? + (when is-layout-child? [:& layout-item-menu {:type type :ids layout-item-ids @@ -66,7 +66,7 @@ :is-layout-container? false :values layout-item-values}]) - (when (or (not is-flex-layout-child?) is-layout-child-absolute?) + (when (or (not is-layout-child?) is-layout-child-absolute?) [:& constraints-menu {:ids constraint-ids :values constraint-values}]) [:& layer-menu {:type type :ids layer-ids :values layer-values}] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/image.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/image.cljs index 7d93273044..0f3bf75fb1 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/image.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/image.cljs @@ -32,8 +32,8 @@ layout-item-values (select-keys shape layout-item-attrs) layout-container-values (select-keys shape layout-container-flex-attrs) - is-flex-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-flex-layout-child? ids)) - is-flex-layout-child? (mf/deref is-flex-layout-child-ref) + is-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids)) + is-layout-child? (mf/deref is-layout-child-ref) is-layout-child-absolute? (ctl/layout-absolute? shape)] [:* [:& measures-menu {:ids ids @@ -42,7 +42,7 @@ :shape shape}] [:& layout-container-menu {:type type :ids [(:id shape)] :values layout-container-values :multiple false}] - (when is-flex-layout-child? + (when is-layout-child? [:& layout-item-menu {:ids ids :type type @@ -50,7 +50,7 @@ :is-layout-child? true :shape shape}]) - (when (or (not is-flex-layout-child?) is-layout-child-absolute?) + (when (or (not is-layout-child?) is-layout-child-absolute?) [:& constraints-menu {:ids ids :values constraint-values}]) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs index bdef18f32c..179474d1a6 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs @@ -294,15 +294,15 @@ all-types (into #{} (map :type shapes)) ids (->> shapes (map :id)) - is-flex-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-flex-layout-child? ids)) - is-flex-layout-child? (mf/deref is-flex-layout-child-ref) + is-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids)) + is-layout-child? (mf/deref is-layout-child-ref) has-text? (contains? all-types :text) has-flex-layout-container? (->> shapes (some ctl/flex-layout?)) - all-flex-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/all-flex-layout-child? ids)) - all-flex-layout-child? (mf/deref all-flex-layout-child-ref) + all-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/all-layout-child? ids)) + all-layout-child? (mf/deref all-layout-child-ref) all-flex-layout-container? (->> shapes (every? ctl/flex-layout?)) @@ -342,15 +342,15 @@ [:& layout-container-menu {:type type :ids layout-container-ids :values layout-container-values :multiple true}] - (when (or is-flex-layout-child? has-flex-layout-container?) + (when (or is-layout-child? has-flex-layout-container?) [:& layout-item-menu {:type type :ids layout-item-ids - :is-layout-child? all-flex-layout-child? + :is-layout-child? all-layout-child? :is-layout-container? all-flex-layout-container? :values layout-item-values}]) - (when-not (or (empty? constraint-ids) is-flex-layout-child?) + (when-not (or (empty? constraint-ids) is-layout-child?) [:& constraints-menu {:ids constraint-ids :values constraint-values}]) (when-not (empty? layer-ids) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/path.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/path.cljs index 5a7b1bd953..28494c225e 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/path.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/path.cljs @@ -32,8 +32,8 @@ layout-item-values (select-keys shape layout-item-attrs) layout-container-values (select-keys shape layout-container-flex-attrs) - is-flex-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-flex-layout-child? ids)) - is-flex-layout-child? (mf/deref is-flex-layout-child-ref) + is-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids)) + is-layout-child? (mf/deref is-layout-child-ref) is-layout-child-absolute? (ctl/layout-absolute? shape)] [:* [:& measures-menu {:ids ids @@ -42,14 +42,14 @@ :shape shape}] [:& layout-container-menu {:type type :ids [(:id shape)] :values layout-container-values :multiple false}] - (when is-flex-layout-child? + (when is-layout-child? [:& layout-item-menu {:ids ids :type type :values layout-item-values :is-layout-child? true :is-layout-container? false :shape shape}]) - (when (or (not is-flex-layout-child?) is-layout-child-absolute?) + (when (or (not is-layout-child?) is-layout-child-absolute?) [:& constraints-menu {:ids ids :values constraint-values}]) [:& layer-menu {:ids ids diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/rect.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/rect.cljs index 401ef70ef4..5ee633fcf0 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/rect.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/rect.cljs @@ -32,8 +32,8 @@ stroke-values (select-keys shape stroke-attrs) layout-item-values (select-keys shape layout-item-attrs) layout-container-values (select-keys shape layout-container-flex-attrs) - is-flex-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-flex-layout-child? ids)) - is-flex-layout-child? (mf/deref is-flex-layout-child-ref) + is-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids)) + is-layout-child? (mf/deref is-layout-child-ref) is-layout-child-absolute? (ctl/layout-absolute? shape)] [:* [:& measures-menu {:ids ids @@ -41,7 +41,7 @@ :values measure-values :shape shape}] [:& layout-container-menu {:type type :ids [(:id shape)] :values layout-container-values :multiple false}] - (when is-flex-layout-child? + (when is-layout-child? [:& layout-item-menu {:ids ids :type type @@ -49,7 +49,7 @@ :is-layout-child? true :shape shape}]) - (when (or (not is-flex-layout-child?) is-layout-child-absolute?) + (when (or (not is-layout-child?) is-layout-child-absolute?) [:& constraints-menu {:ids ids :values constraint-values}]) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/svg_raw.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/svg_raw.cljs index 0560de5494..a8ec66fb9e 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/svg_raw.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/svg_raw.cljs @@ -106,8 +106,8 @@ layout-item-values (select-keys shape layout-item-attrs) layout-container-values (select-keys shape layout-container-flex-attrs) - is-flex-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-flex-layout-child? ids)) - is-flex-layout-child? (mf/deref is-flex-layout-child-ref) + is-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids)) + is-layout-child? (mf/deref is-layout-child-ref) is-layout-child-absolute? (ctl/layout-absolute? shape)] (when (contains? svg-elements tag) @@ -118,7 +118,7 @@ :shape shape}] [:& layout-container-menu {:type type :ids [(:id shape)] :values layout-container-values :multiple false}] - (when is-flex-layout-child? + (when is-layout-child? [:& layout-item-menu {:ids ids :type type @@ -126,7 +126,7 @@ :is-layout-child? true :shape shape}]) - (when (or (not is-flex-layout-child?) is-layout-child-absolute?) + (when (or (not is-layout-child?) is-layout-child-absolute?) [:& constraints-menu {:ids ids :values constraint-values}]) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/text.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/text.cljs index 8c93c8f9e1..6bfcb5dda5 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/text.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/text.cljs @@ -28,8 +28,8 @@ (let [ids [(:id shape)] type (:type shape) - is-flex-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-flex-layout-child? ids)) - is-flex-layout-child? (mf/deref is-flex-layout-child-ref) + is-layout-child-ref (mf/use-memo (mf/deps ids) #(refs/is-layout-child? ids)) + is-layout-child? (mf/deref is-layout-child-ref) layout-container-values (select-keys shape layout-container-flex-attrs) is-layout-child-absolute? (ctl/layout-absolute? shape) state-map (mf/deref refs/workspace-editor-state) @@ -76,7 +76,7 @@ :shape shape}] [:& layout-container-menu {:type type :ids [(:id shape)] :values layout-container-values :multiple false}] - (when is-flex-layout-child? + (when is-layout-child? [:& layout-item-menu {:ids ids :type type @@ -84,7 +84,7 @@ :is-layout-child? true :shape shape}]) - (when (or (not is-flex-layout-child?) is-layout-child-absolute?) + (when (or (not is-layout-child?) is-layout-child-absolute?) [:& constraints-menu {:ids ids :values (select-keys shape constraint-attrs)}])