mirror of
https://github.com/penpot/penpot.git
synced 2025-04-01 01:21:21 -05:00
✨ Adapt scale to flex elements
This commit is contained in:
parent
44c35e6aee
commit
3a2e1b5c94
5 changed files with 50 additions and 13 deletions
|
@ -288,25 +288,25 @@
|
||||||
|
|
||||||
constraints-h
|
constraints-h
|
||||||
(cond
|
(cond
|
||||||
|
ignore-constraints
|
||||||
|
:scale
|
||||||
|
|
||||||
(and (ctl/any-layout? parent) (not (ctl/layout-absolute? child)))
|
(and (ctl/any-layout? parent) (not (ctl/layout-absolute? child)))
|
||||||
:left
|
:left
|
||||||
|
|
||||||
(not ignore-constraints)
|
|
||||||
(:constraints-h child (default-constraints-h child))
|
|
||||||
|
|
||||||
:else
|
:else
|
||||||
:scale)
|
(:constraints-h child (default-constraints-h child)))
|
||||||
|
|
||||||
constraints-v
|
constraints-v
|
||||||
(cond
|
(cond
|
||||||
|
ignore-constraints
|
||||||
|
:scale
|
||||||
|
|
||||||
(and (ctl/any-layout? parent) (not (ctl/layout-absolute? child)))
|
(and (ctl/any-layout? parent) (not (ctl/layout-absolute? child)))
|
||||||
:top
|
:top
|
||||||
|
|
||||||
(not ignore-constraints)
|
|
||||||
(:constraints-v child (default-constraints-v child))
|
|
||||||
|
|
||||||
:else
|
:else
|
||||||
:scale)]
|
(:constraints-v child (default-constraints-v child)))]
|
||||||
|
|
||||||
(if (and (= :scale constraints-h) (= :scale constraints-v))
|
(if (and (= :scale constraints-h) (= :scale constraints-v))
|
||||||
modifiers
|
modifiers
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
|
[app.common.types.shape.layout :as ctl]
|
||||||
#?(:cljs [cljs.core :as c]
|
#?(:cljs [cljs.core :as c]
|
||||||
:clj [clojure.core :as c])))
|
:clj [clojure.core :as c])))
|
||||||
|
|
||||||
|
@ -672,7 +673,13 @@
|
||||||
(gse/update-shadows-scale value)
|
(gse/update-shadows-scale value)
|
||||||
|
|
||||||
(some? (:blur shape))
|
(some? (:blur shape))
|
||||||
(gse/update-blur-scale value)))]
|
(gse/update-blur-scale value)
|
||||||
|
|
||||||
|
(ctl/flex-layout? shape)
|
||||||
|
(ctl/update-flex-scale value)
|
||||||
|
|
||||||
|
:always
|
||||||
|
(ctl/update-flex-child value)))]
|
||||||
|
|
||||||
(let [remove-children
|
(let [remove-children
|
||||||
(fn [shapes children-to-remove]
|
(fn [shapes children-to-remove]
|
||||||
|
|
|
@ -497,6 +497,30 @@
|
||||||
:layout-item-align-self
|
:layout-item-align-self
|
||||||
:layout-item-absolute
|
:layout-item-absolute
|
||||||
:layout-item-z-index))
|
:layout-item-z-index))
|
||||||
|
|
||||||
|
(defn update-flex-scale
|
||||||
|
[shape scale]
|
||||||
|
(-> shape
|
||||||
|
(d/update-in-when [:layout-gap :row-gap] * scale)
|
||||||
|
(d/update-in-when [:layout-gap :column-gap] * scale)
|
||||||
|
(d/update-in-when [:layout-padding :p1] * scale)
|
||||||
|
(d/update-in-when [:layout-padding :p2] * scale)
|
||||||
|
(d/update-in-when [:layout-padding :p3] * scale)
|
||||||
|
(d/update-in-when [:layout-padding :p4] * scale)))
|
||||||
|
|
||||||
|
(defn update-flex-child
|
||||||
|
[shape scale]
|
||||||
|
(-> shape
|
||||||
|
(d/update-when :layout-item-max-h * scale)
|
||||||
|
(d/update-when :layout-item-min-h * scale)
|
||||||
|
(d/update-when :layout-item-max-w * scale)
|
||||||
|
(d/update-when :layout-item-min-w * scale)
|
||||||
|
(d/update-in-when [:layout-item-margin :m1] * scale)
|
||||||
|
(d/update-in-when [:layout-item-margin :m2] * scale)
|
||||||
|
(d/update-in-when [:layout-item-margin :m3] * scale)
|
||||||
|
(d/update-in-when [:layout-item-margin :m4] * scale)))
|
||||||
|
|
||||||
|
|
||||||
(declare assign-cells)
|
(declare assign-cells)
|
||||||
|
|
||||||
(def grid-cell-defaults
|
(def grid-cell-defaults
|
||||||
|
|
|
@ -438,14 +438,20 @@
|
||||||
:flip-x
|
:flip-x
|
||||||
:flip-y
|
:flip-y
|
||||||
:grow-type
|
:grow-type
|
||||||
:layout-item-h-sizing
|
:position-data
|
||||||
:layout-item-v-sizing
|
:layout-gap
|
||||||
:layout-padding
|
:layout-padding
|
||||||
|
:layout-item-h-sizing
|
||||||
|
:layout-item-margin
|
||||||
|
:layout-item-max-h
|
||||||
|
:layout-item-max-w
|
||||||
|
:layout-item-min-h
|
||||||
|
:layout-item-min-w
|
||||||
|
:layout-item-v-sizing
|
||||||
:layout-padding-type
|
:layout-padding-type
|
||||||
:layout-gap
|
:layout-gap
|
||||||
:layout-item-margin
|
:layout-item-margin
|
||||||
:layout-item-margin-type
|
:layout-item-margin-type
|
||||||
:position-data
|
|
||||||
]})
|
]})
|
||||||
;; We've applied the text-modifier so we can dissoc the temporary data
|
;; We've applied the text-modifier so we can dissoc the temporary data
|
||||||
(fn [state]
|
(fn [state]
|
||||||
|
|
|
@ -193,7 +193,7 @@
|
||||||
(ctm/scale-content (:x scalev))))
|
(ctm/scale-content (:x scalev))))
|
||||||
|
|
||||||
modif-tree (dwm/create-modif-tree ids modifiers)]
|
modif-tree (dwm/create-modif-tree ids modifiers)]
|
||||||
(rx/of (dwm/set-modifiers modif-tree (and (= :frame (:type shape)) scale-text)))))
|
(rx/of (dwm/set-modifiers modif-tree scale-text))))
|
||||||
|
|
||||||
;; Unifies the instantaneous proportion lock modifier
|
;; Unifies the instantaneous proportion lock modifier
|
||||||
;; activated by Shift key and the shapes own proportion
|
;; activated by Shift key and the shapes own proportion
|
||||||
|
|
Loading…
Add table
Reference in a new issue