diff --git a/common/src/app/common/spec/radius.cljc b/common/src/app/common/spec/radius.cljc index e6754f321..8d13019e8 100644 --- a/common/src/app/common/spec/radius.cljc +++ b/common/src/app/common/spec/radius.cljc @@ -30,17 +30,11 @@ ;; shapes that has border radius, and so it hasn't :rx nor :r1. ;; In this case operations must leave shape untouched. -(defn has-radius? - [shape] - (#{:rect :image :frame} (:type shape))) - (defn radius-mode [shape] - (cond (:rx shape) :radius-1 - (:r1 shape) :radius-4 - :else (if (has-radius? shape) - :radius-1 - nil))) + (if (:r1 shape) + :radius-4 + :radius-1)) (defn radius-1? [shape] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs index 968a69840..6eb5201bb 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs @@ -19,6 +19,7 @@ [app.main.ui.icons :as i] [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] + [clojure.set :refer [union]] [rumext.alpha :as mf])) (def measure-attrs @@ -30,6 +31,17 @@ :r1 :r2 :r3 :r4 :selrect]) +(def ^:private type->options + {:bool #{:size :position :rotation} + :circle #{:size :position :rotation} + :frame #{:size :position :rotation :radius :presets} + :group #{:size :position :rotation} + :image #{:size :position :rotation :radius} + :path #{:size :position :rotation} + :rect #{:size :position :rotation :radius} + :svg-raw #{:size :position :rotation} + :text #{:size :position :rotation}}) + (defn- attr->string [attr values] (let [value (attr values)] (if (= value :multiple) @@ -42,8 +54,11 @@ ;; -- User/drawing coords (mf/defc measures-menu - [{:keys [options ids ids-with-children values type] :as props}] - (let [options (or options #{:size :position :rotation :radius}) + [{:keys [ids ids-with-children values type all-types] :as props}] + (let [options (if (= type :multiple) + (reduce #(union %1 %2) (map #(get type->options %) all-types)) + (get type->options type)) + ids-with-children (or ids-with-children ids) old-shapes (deref (refs/objects-by-id ids)) @@ -183,9 +198,11 @@ [:* [:div.element-set [:div.element-set-content + ;; FRAME PRESETS - (when (= type :frame) - [:div.row-flex + (when (and (options :presets) + (or (nil? all-types) (= (count all-types) 1))) ;; Dont' show presets if multi selected + [:div.row-flex ;; some frames and some non frames [:div.presets.custom-select.flex-grow {:on-click #(reset! show-presets-dropdown? true)} [:span (tr "workspace.options.size-presets")] [:span.dropdown-button i/arrow-down] @@ -251,7 +268,7 @@ :precision 2}]]]) ;; ROTATION - (when (and (options :rotation) (not (= type :frame))) + (when (options :rotation) [:div.row-flex [:span.element-set-subtitle (tr "workspace.options.rotation")] [:div.input-element.degrees {:title (tr "workspace.options.rotation")} @@ -274,7 +291,7 @@ :value (attr->string :rotation values)}]]) ;; RADIUS - (when (and (options :radius) (some? radius-mode)) + (when (options :radius) [:div.row-flex [:div.radius-options [:div.radius-icon.tooltip.tooltip-bottom @@ -343,7 +360,7 @@ :on-click select-all :on-change on-radius-r4-change :value (attr->string :r4 values)}]]])])]]])) - + (def +size-presets+ [{:name "APPLE"} {:name "iPhone 12/12 Pro" 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 713022c43..7fad14c2b 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 @@ -27,8 +27,7 @@ [:* [:& measures-menu {:ids ids :type type - :values measure-values - :options #{:size :position :rotation}}] + :values measure-values}] [:& 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 96e298cfc..5cae0756a 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 @@ -25,8 +25,7 @@ [:* [:& measures-menu {:ids [(:id shape)] :values measure-values - :type type - :options #{:size :position :rotation :presets :radius}}] + :type type}] [:& layer-menu {:ids ids :type type :values layer-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 2c3fa4a0a..d28786b6f 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 @@ -214,6 +214,7 @@ objects-no-measures (hooks/use-equal-memo objects-no-measures) type :multiple + all-types (into #{} (map :type shapes)) [measure-ids measure-values] (get-attrs shapes objects :measure) @@ -240,7 +241,7 @@ [:div.options (when-not (empty? measure-ids) - [:& measures-menu {:type type :ids measure-ids :values measure-values}]) + [:& measures-menu {:type type :all-types all-types :ids measure-ids :values measure-values}]) (when-not (empty? constraint-ids) [:& constraints-menu {:ids constraint-ids :values constraint-values}])