mirror of
https://github.com/penpot/penpot.git
synced 2025-02-24 07:46:13 -05:00
✨ Removed constraints when layout child
This commit is contained in:
parent
4ecc166055
commit
7caf4b9136
14 changed files with 67 additions and 52 deletions
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.workspace.sidebar.options
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.main.data.workspace :as udw]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
|
@ -36,24 +37,27 @@
|
|||
(mf/defc shape-options
|
||||
{::mf/wrap [#(mf/throttle % 60)]}
|
||||
[{:keys [shape shapes-with-children page-id file-id shared-libs]}]
|
||||
[:*
|
||||
(case (:type shape)
|
||||
:frame [:& frame/options {:shape shape}]
|
||||
:group [:& group/options {:shape shape :shape-with-children shapes-with-children :file-id file-id :shared-libs shared-libs}]
|
||||
:text [:& text/options {:shape shape :file-id file-id :shared-libs shared-libs}]
|
||||
:rect [:& rect/options {:shape shape}]
|
||||
:circle [:& circle/options {:shape shape}]
|
||||
:path [:& path/options {:shape shape}]
|
||||
:image [:& image/options {:shape shape}]
|
||||
:svg-raw [:& svg-raw/options {:shape shape}]
|
||||
:bool [:& bool/options {:shape shape}]
|
||||
nil)
|
||||
[:& exports-menu
|
||||
{:ids [(:id shape)]
|
||||
:values (select-keys shape [:exports])
|
||||
:shape shape
|
||||
:page-id page-id
|
||||
:file-id file-id}]])
|
||||
(let [workspace-modifiers (mf/deref refs/workspace-modifiers)
|
||||
modifiers (get-in workspace-modifiers [(:id shape) :modifiers])
|
||||
shape (gsh/transform-shape shape modifiers)]
|
||||
[:*
|
||||
(case (:type shape)
|
||||
:frame [:& frame/options {:shape shape}]
|
||||
:group [:& group/options {:shape shape :shape-with-children shapes-with-children :file-id file-id :shared-libs shared-libs}]
|
||||
:text [:& text/options {:shape shape :file-id file-id :shared-libs shared-libs}]
|
||||
:rect [:& rect/options {:shape shape}]
|
||||
:circle [:& circle/options {:shape shape}]
|
||||
:path [:& path/options {:shape shape}]
|
||||
:image [:& image/options {:shape shape}]
|
||||
:svg-raw [:& svg-raw/options {:shape shape}]
|
||||
:bool [:& bool/options {:shape shape}]
|
||||
nil)
|
||||
[:& exports-menu
|
||||
{:ids [(:id shape)]
|
||||
:values (select-keys shape [:exports])
|
||||
:shape shape
|
||||
:page-id page-id
|
||||
:file-id file-id}]]))
|
||||
|
||||
(mf/defc options-content
|
||||
{::mf/wrap [mf/memo]}
|
||||
|
|
|
@ -30,7 +30,6 @@
|
|||
frames (map #(deref (refs/object-by-id (:frame-id %))) old-shapes)
|
||||
|
||||
shapes (as-> old-shapes $
|
||||
#_(map gsh/transform-shape $)
|
||||
(map gsh/translate-to-frame $ frames))
|
||||
|
||||
values (let [{:keys [x y]} (-> shapes first :points gsh/points->selrect)]
|
||||
|
|
|
@ -77,18 +77,18 @@
|
|||
:stretch nil))
|
||||
|
||||
:align-self (if is-col?
|
||||
(case val
|
||||
:start i/align-self-column-top
|
||||
:end i/align-self-column-bottom
|
||||
:center i/align-self-column-center
|
||||
:stretch i/align-self-column-strech
|
||||
:baseline i/align-self-column-baseline)
|
||||
(case val
|
||||
:start i/align-self-row-left
|
||||
:end i/align-self-row-right
|
||||
:center i/align-self-row-center
|
||||
:stretch i/align-self-row-strech
|
||||
:baseline i/align-self-row-baseline))))
|
||||
:baseline i/align-self-row-baseline)
|
||||
(case val
|
||||
:start i/align-self-column-top
|
||||
:end i/align-self-column-bottom
|
||||
:center i/align-self-column-center
|
||||
:stretch i/align-self-column-strech
|
||||
:baseline i/align-self-column-baseline))))
|
||||
|
||||
(mf/defc direction-btn
|
||||
[{:keys [dir saved-dir set-direction] :as props}]
|
||||
|
@ -170,7 +170,8 @@
|
|||
[{:keys [values on-change-style on-change] :as props}]
|
||||
|
||||
(let [padding-type (:layout-padding-type values)
|
||||
rx (if (apply = (vals (:layout-padding values)))
|
||||
rx (if (and (not (= :multiple (:layout-padding values)))
|
||||
(apply = (vals (:layout-padding values))))
|
||||
(:p1 (:layout-padding values))
|
||||
"--")]
|
||||
|
||||
|
|
|
@ -69,9 +69,7 @@
|
|||
;; -- User/drawing coords
|
||||
(mf/defc measures-menu
|
||||
[{:keys [ids ids-with-children values type all-types shape] :as props}]
|
||||
(let [workspace-modifiers (mf/deref refs/workspace-modifiers)
|
||||
|
||||
options (if (= type :multiple)
|
||||
(let [options (if (= type :multiple)
|
||||
(reduce #(union %1 %2) (map #(get type->options %) all-types))
|
||||
(get type->options type))
|
||||
|
||||
|
@ -97,9 +95,6 @@
|
|||
;; the shape with the mouse, generate a copy of the shapes applying
|
||||
;; the transient transformations.
|
||||
shapes (as-> old-shapes $
|
||||
(map (fn [shape]
|
||||
(let [modifiers (get-in workspace-modifiers [(:id shape) :modifiers])]
|
||||
(gsh/transform-shape shape modifiers))) $)
|
||||
(map gsh/translate-to-frame $ frames))
|
||||
|
||||
;; For rotated or stretched shapes, the origin point we show in the menu
|
||||
|
|
|
@ -41,8 +41,10 @@
|
|||
:values layout-item-values
|
||||
:is-layout-child? true
|
||||
:shape shape}])
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}]
|
||||
|
||||
(when (not is-layout-child?)
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}])
|
||||
[:& layer-menu {:ids ids
|
||||
:type type
|
||||
:values layer-values}]
|
||||
|
|
|
@ -43,8 +43,9 @@
|
|||
:is-layout-child? true
|
||||
:is-layout-container? false
|
||||
:shape shape}])
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}]
|
||||
(when (not is-layout-child?)
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}])
|
||||
[:& layer-menu {:ids ids
|
||||
:type type
|
||||
:values layer-values}]
|
||||
|
|
|
@ -43,8 +43,9 @@
|
|||
:values measure-values
|
||||
:type type
|
||||
:shape shape}]
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}]
|
||||
(when (not is-layout-child?)
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}])
|
||||
(when (or layout-active? is-layout-container?)
|
||||
[:& layout-container-menu {:type type :ids [(:id shape)] :values layout-container-values}])
|
||||
|
||||
|
|
|
@ -62,7 +62,8 @@
|
|||
:is-layout-container? false
|
||||
:values layout-item-values}])
|
||||
|
||||
[:& constraints-menu {:ids constraint-ids :values constraint-values}]
|
||||
(when (not is-layout-child?)
|
||||
[:& constraints-menu {:ids constraint-ids :values constraint-values}])
|
||||
[:& layer-menu {:type type :ids layer-ids :values layer-values}]
|
||||
|
||||
(when-not (empty? fill-ids)
|
||||
|
|
|
@ -44,8 +44,9 @@
|
|||
:is-layout-child? true
|
||||
:shape shape}])
|
||||
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}]
|
||||
(when (not is-layout-child?)
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}])
|
||||
|
||||
[:& layer-menu {:ids ids
|
||||
:type type
|
||||
|
|
|
@ -253,6 +253,10 @@
|
|||
[props]
|
||||
(let [shapes (unchecked-get props "shapes")
|
||||
shapes-with-children (unchecked-get props "shapes-with-children")
|
||||
|
||||
workspace-modifiers (mf/deref refs/workspace-modifiers)
|
||||
shapes (map #(gsh/transform-shape % (get-in workspace-modifiers [(:id %) :modifiers])) shapes)
|
||||
|
||||
page-id (unchecked-get props "page-id")
|
||||
file-id (unchecked-get props "file-id")
|
||||
shared-libs (unchecked-get props "shared-libs")
|
||||
|
@ -319,7 +323,7 @@
|
|||
:is-layout-container? true
|
||||
:values layout-item-values}])
|
||||
|
||||
(when-not (empty? constraint-ids)
|
||||
(when-not (or (empty? constraint-ids) is-layout-child?)
|
||||
[:& constraints-menu {:ids constraint-ids :values constraint-values}])
|
||||
|
||||
(when-not (empty? layer-ids)
|
||||
|
|
|
@ -43,8 +43,9 @@
|
|||
:is-layout-child? true
|
||||
:is-layout-container? false
|
||||
:shape shape}])
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}]
|
||||
(when (not is-layout-child?)
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}])
|
||||
[:& layer-menu {:ids ids
|
||||
:type type
|
||||
:values layer-values}]
|
||||
|
|
|
@ -44,8 +44,10 @@
|
|||
:values layout-item-values
|
||||
:is-layout-child? true
|
||||
:shape shape}])
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}]
|
||||
|
||||
(when (not is-layout-child?)
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}])
|
||||
|
||||
[:& layer-menu {:ids ids
|
||||
:type type
|
||||
|
|
|
@ -120,8 +120,9 @@
|
|||
:is-layout-child? true
|
||||
:shape shape}])
|
||||
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}]
|
||||
(when (not is-layout-child?)
|
||||
[:& constraints-menu {:ids ids
|
||||
:values constraint-values}])
|
||||
|
||||
[:& fill-menu {:ids ids
|
||||
:type type
|
||||
|
|
|
@ -78,9 +78,11 @@
|
|||
:values layout-item-values
|
||||
:is-layout-child? true
|
||||
:shape shape}])
|
||||
[:& constraints-menu
|
||||
{:ids ids
|
||||
:values (select-keys shape constraint-attrs)}]
|
||||
|
||||
(when (not is-layout-child?)
|
||||
[:& constraints-menu
|
||||
{:ids ids
|
||||
:values (select-keys shape constraint-attrs)}])
|
||||
|
||||
[:& layer-menu {:ids ids
|
||||
:type type
|
||||
|
|
Loading…
Add table
Reference in a new issue