mirror of
https://github.com/penpot/penpot.git
synced 2025-03-10 14:51:37 -05:00
✨ Move some functions from file helpers to types.shape.layout
This commit is contained in:
parent
85d06b10c2
commit
3412658286
3 changed files with 17 additions and 18 deletions
|
@ -12,7 +12,6 @@
|
|||
[app.common.schema :as sm]
|
||||
[app.common.types.components-list :as ctkl]
|
||||
[app.common.types.pages-list :as ctpl]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.common.uuid :as uuid]
|
||||
[clojure.set :as set]
|
||||
[cuerdas.core :as str]))
|
||||
|
@ -741,22 +740,6 @@
|
|||
(d/seek root-frame?)
|
||||
:id))
|
||||
|
||||
(defn comparator-layout-z-index
|
||||
[[idx-a child-a] [idx-b child-b]]
|
||||
(cond
|
||||
(> (ctl/layout-z-index child-a) (ctl/layout-z-index child-b)) 1
|
||||
(< (ctl/layout-z-index child-a) (ctl/layout-z-index child-b)) -1
|
||||
(< idx-a idx-b) 1
|
||||
(> idx-a idx-b) -1
|
||||
:else 0))
|
||||
|
||||
(defn sort-layout-children-z-index
|
||||
[children]
|
||||
(->> children
|
||||
(d/enumerate)
|
||||
(sort comparator-layout-z-index)
|
||||
(mapv second)))
|
||||
|
||||
(defn common-parent-frame
|
||||
"Search for the common frame for the selected shapes. Otherwise returns the root frame"
|
||||
[objects selected]
|
||||
|
|
|
@ -536,6 +536,22 @@
|
|||
([shape]
|
||||
(or (:layout-item-z-index shape) 0)))
|
||||
|
||||
(defn- comparator-layout-z-index
|
||||
[[idx-a child-a] [idx-b child-b]]
|
||||
(cond
|
||||
(> (layout-z-index child-a) (layout-z-index child-b)) 1
|
||||
(< (layout-z-index child-a) (layout-z-index child-b)) -1
|
||||
(< idx-a idx-b) 1
|
||||
(> idx-a idx-b) -1
|
||||
:else 0))
|
||||
|
||||
(defn sort-layout-children-z-index
|
||||
[children]
|
||||
(->> children
|
||||
(d/enumerate)
|
||||
(sort comparator-layout-z-index)
|
||||
(mapv second)))
|
||||
|
||||
(defn change-h-sizing?
|
||||
[frame-id objects children-ids]
|
||||
(and (flex-layout? objects frame-id)
|
||||
|
|
|
@ -168,7 +168,7 @@
|
|||
childs (unchecked-get props "childs")
|
||||
childs (cond-> childs
|
||||
(ctl/any-layout? shape)
|
||||
(cfh/sort-layout-children-z-index))]
|
||||
(ctl/sort-layout-children-z-index))]
|
||||
|
||||
[:> frame-container props
|
||||
[:g.frame-children {:opacity (:opacity shape)}
|
||||
|
|
Loading…
Add table
Reference in a new issue