mirror of
https://github.com/penpot/penpot.git
synced 2025-02-23 23:35:58 -05:00
🔧 Fix multiple edition
This commit is contained in:
parent
17fc15138a
commit
087d896569
5 changed files with 31 additions and 21 deletions
|
@ -30,17 +30,11 @@
|
||||||
;; shapes that has border radius, and so it hasn't :rx nor :r1.
|
;; shapes that has border radius, and so it hasn't :rx nor :r1.
|
||||||
;; In this case operations must leave shape untouched.
|
;; In this case operations must leave shape untouched.
|
||||||
|
|
||||||
(defn has-radius?
|
|
||||||
[shape]
|
|
||||||
(#{:rect :image :frame} (:type shape)))
|
|
||||||
|
|
||||||
(defn radius-mode
|
(defn radius-mode
|
||||||
[shape]
|
[shape]
|
||||||
(cond (:rx shape) :radius-1
|
(if (:r1 shape)
|
||||||
(:r1 shape) :radius-4
|
:radius-4
|
||||||
:else (if (has-radius? shape)
|
:radius-1))
|
||||||
:radius-1
|
|
||||||
nil)))
|
|
||||||
|
|
||||||
(defn radius-1?
|
(defn radius-1?
|
||||||
[shape]
|
[shape]
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :as i18n :refer [tr]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
|
[clojure.set :refer [union]]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(def measure-attrs
|
(def measure-attrs
|
||||||
|
@ -30,6 +31,17 @@
|
||||||
:r1 :r2 :r3 :r4
|
:r1 :r2 :r3 :r4
|
||||||
:selrect])
|
: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]
|
(defn- attr->string [attr values]
|
||||||
(let [value (attr values)]
|
(let [value (attr values)]
|
||||||
(if (= value :multiple)
|
(if (= value :multiple)
|
||||||
|
@ -42,8 +54,11 @@
|
||||||
|
|
||||||
;; -- User/drawing coords
|
;; -- User/drawing coords
|
||||||
(mf/defc measures-menu
|
(mf/defc measures-menu
|
||||||
[{:keys [options ids ids-with-children values type] :as props}]
|
[{:keys [ids ids-with-children values type all-types] :as props}]
|
||||||
(let [options (or options #{:size :position :rotation :radius})
|
(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)
|
ids-with-children (or ids-with-children ids)
|
||||||
|
|
||||||
old-shapes (deref (refs/objects-by-id ids))
|
old-shapes (deref (refs/objects-by-id ids))
|
||||||
|
@ -183,9 +198,11 @@
|
||||||
[:*
|
[:*
|
||||||
[:div.element-set
|
[:div.element-set
|
||||||
[:div.element-set-content
|
[:div.element-set-content
|
||||||
|
|
||||||
;; FRAME PRESETS
|
;; FRAME PRESETS
|
||||||
(when (= type :frame)
|
(when (and (options :presets)
|
||||||
[:div.row-flex
|
(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)}
|
[:div.presets.custom-select.flex-grow {:on-click #(reset! show-presets-dropdown? true)}
|
||||||
[:span (tr "workspace.options.size-presets")]
|
[:span (tr "workspace.options.size-presets")]
|
||||||
[:span.dropdown-button i/arrow-down]
|
[:span.dropdown-button i/arrow-down]
|
||||||
|
@ -251,7 +268,7 @@
|
||||||
:precision 2}]]])
|
:precision 2}]]])
|
||||||
|
|
||||||
;; ROTATION
|
;; ROTATION
|
||||||
(when (and (options :rotation) (not (= type :frame)))
|
(when (options :rotation)
|
||||||
[:div.row-flex
|
[:div.row-flex
|
||||||
[:span.element-set-subtitle (tr "workspace.options.rotation")]
|
[:span.element-set-subtitle (tr "workspace.options.rotation")]
|
||||||
[:div.input-element.degrees {:title (tr "workspace.options.rotation")}
|
[:div.input-element.degrees {:title (tr "workspace.options.rotation")}
|
||||||
|
@ -274,7 +291,7 @@
|
||||||
:value (attr->string :rotation values)}]])
|
:value (attr->string :rotation values)}]])
|
||||||
|
|
||||||
;; RADIUS
|
;; RADIUS
|
||||||
(when (and (options :radius) (some? radius-mode))
|
(when (options :radius)
|
||||||
[:div.row-flex
|
[:div.row-flex
|
||||||
[:div.radius-options
|
[:div.radius-options
|
||||||
[:div.radius-icon.tooltip.tooltip-bottom
|
[:div.radius-icon.tooltip.tooltip-bottom
|
||||||
|
@ -343,7 +360,7 @@
|
||||||
:on-click select-all
|
:on-click select-all
|
||||||
:on-change on-radius-r4-change
|
:on-change on-radius-r4-change
|
||||||
:value (attr->string :r4 values)}]]])])]]]))
|
:value (attr->string :r4 values)}]]])])]]]))
|
||||||
|
|
||||||
(def +size-presets+
|
(def +size-presets+
|
||||||
[{:name "APPLE"}
|
[{:name "APPLE"}
|
||||||
{:name "iPhone 12/12 Pro"
|
{:name "iPhone 12/12 Pro"
|
||||||
|
|
|
@ -27,8 +27,7 @@
|
||||||
[:*
|
[:*
|
||||||
[:& measures-menu {:ids ids
|
[:& measures-menu {:ids ids
|
||||||
:type type
|
:type type
|
||||||
:values measure-values
|
:values measure-values}]
|
||||||
:options #{:size :position :rotation}}]
|
|
||||||
[:& constraints-menu {:ids ids
|
[:& constraints-menu {:ids ids
|
||||||
:values constraint-values}]
|
:values constraint-values}]
|
||||||
[:& layer-menu {:ids ids
|
[:& layer-menu {:ids ids
|
||||||
|
|
|
@ -25,8 +25,7 @@
|
||||||
[:*
|
[:*
|
||||||
[:& measures-menu {:ids [(:id shape)]
|
[:& measures-menu {:ids [(:id shape)]
|
||||||
:values measure-values
|
:values measure-values
|
||||||
:type type
|
:type type}]
|
||||||
:options #{:size :position :rotation :presets :radius}}]
|
|
||||||
[:& layer-menu {:ids ids
|
[:& layer-menu {:ids ids
|
||||||
:type type
|
:type type
|
||||||
:values layer-values}]
|
:values layer-values}]
|
||||||
|
|
|
@ -214,6 +214,7 @@
|
||||||
objects-no-measures (hooks/use-equal-memo objects-no-measures)
|
objects-no-measures (hooks/use-equal-memo objects-no-measures)
|
||||||
|
|
||||||
type :multiple
|
type :multiple
|
||||||
|
all-types (into #{} (map :type shapes))
|
||||||
|
|
||||||
[measure-ids measure-values] (get-attrs shapes objects :measure)
|
[measure-ids measure-values] (get-attrs shapes objects :measure)
|
||||||
|
|
||||||
|
@ -240,7 +241,7 @@
|
||||||
|
|
||||||
[:div.options
|
[:div.options
|
||||||
(when-not (empty? measure-ids)
|
(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)
|
(when-not (empty? constraint-ids)
|
||||||
[:& constraints-menu {:ids constraint-ids :values constraint-values}])
|
[:& constraints-menu {:ids constraint-ids :values constraint-values}])
|
||||||
|
|
Loading…
Add table
Reference in a new issue