mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
🐛 Create new layouts without clip content
This commit is contained in:
parent
f4f1f80050
commit
da60911d81
2 changed files with 11 additions and 8 deletions
|
@ -56,14 +56,17 @@
|
||||||
{:layout :grid})
|
{:layout :grid})
|
||||||
|
|
||||||
(defn get-layout-initializer
|
(defn get-layout-initializer
|
||||||
[type]
|
[type from-frame?]
|
||||||
(let [initial-layout-data (if (= type :flex) initial-flex-layout initial-grid-layout)]
|
(let [initial-layout-data (if (= type :flex) initial-flex-layout initial-grid-layout)]
|
||||||
(fn [shape]
|
(fn [shape]
|
||||||
(-> shape
|
(-> shape
|
||||||
(merge shape initial-layout-data)))))
|
(merge initial-layout-data)
|
||||||
|
;; If the original shape is not a frame we set clip content and show-viewer to false
|
||||||
|
(cond-> (not from-frame?)
|
||||||
|
(assoc :show-content true :hide-in-viewer true))))))
|
||||||
|
|
||||||
(defn create-layout-from-id
|
(defn create-layout-from-id
|
||||||
[ids type]
|
[ids type from-frame?]
|
||||||
(ptk/reify ::create-layout-from-id
|
(ptk/reify ::create-layout-from-id
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
|
@ -71,7 +74,7 @@
|
||||||
children-ids (into [] (mapcat #(get-in objects [% :shapes])) ids)
|
children-ids (into [] (mapcat #(get-in objects [% :shapes])) ids)
|
||||||
undo-id (js/Symbol)]
|
undo-id (js/Symbol)]
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dwc/update-shapes ids (get-layout-initializer type))
|
(dwc/update-shapes ids (get-layout-initializer type from-frame?))
|
||||||
(ptk/data-event :layout/update ids)
|
(ptk/data-event :layout/update ids)
|
||||||
(dwc/update-shapes children-ids #(dissoc % :constraints-h :constraints-v))
|
(dwc/update-shapes children-ids #(dissoc % :constraints-h :constraints-v))
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
@ -173,7 +176,7 @@
|
||||||
(dws/create-artboard-from-selection new-shape-id parent-id group-index)
|
(dws/create-artboard-from-selection new-shape-id parent-id group-index)
|
||||||
(cl/remove-all-fills [new-shape-id] {:color clr/black
|
(cl/remove-all-fills [new-shape-id] {:color clr/black
|
||||||
:opacity 1})
|
:opacity 1})
|
||||||
(create-layout-from-id [new-shape-id] type)
|
(create-layout-from-id [new-shape-id] type false)
|
||||||
(dwc/update-shapes
|
(dwc/update-shapes
|
||||||
[new-shape-id]
|
[new-shape-id]
|
||||||
(fn [shape]
|
(fn [shape]
|
||||||
|
@ -193,7 +196,7 @@
|
||||||
(dws/create-artboard-from-selection new-shape-id)
|
(dws/create-artboard-from-selection new-shape-id)
|
||||||
(cl/remove-all-fills [new-shape-id] {:color clr/black
|
(cl/remove-all-fills [new-shape-id] {:color clr/black
|
||||||
:opacity 1})
|
:opacity 1})
|
||||||
(create-layout-from-id [new-shape-id] type)
|
(create-layout-from-id [new-shape-id] type false)
|
||||||
(dwc/update-shapes
|
(dwc/update-shapes
|
||||||
[new-shape-id]
|
[new-shape-id]
|
||||||
(fn [shape]
|
(fn [shape]
|
||||||
|
@ -233,7 +236,7 @@
|
||||||
(if (and single? is-frame?)
|
(if (and single? is-frame?)
|
||||||
(rx/of
|
(rx/of
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
(create-layout-from-id [(first selected)] :flex)
|
(create-layout-from-id [(first selected)] :flex true)
|
||||||
(dwu/commit-undo-transaction undo-id))
|
(dwu/commit-undo-transaction undo-id))
|
||||||
(rx/of
|
(rx/of
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
|
|
|
@ -375,7 +375,7 @@
|
||||||
is-flex-container? (and is-frame? (= :flex (:layout (first shapes))))
|
is-flex-container? (and is-frame? (= :flex (:layout (first shapes))))
|
||||||
ids (->> shapes (map :id))
|
ids (->> shapes (map :id))
|
||||||
add-flex #(st/emit! (if is-frame?
|
add-flex #(st/emit! (if is-frame?
|
||||||
(dwsl/create-layout-from-id ids :flex)
|
(dwsl/create-layout-from-id ids :flex true)
|
||||||
(dwsl/create-layout-from-selection :flex)))
|
(dwsl/create-layout-from-selection :flex)))
|
||||||
remove-flex #(st/emit! (dwsl/remove-layout ids))]
|
remove-flex #(st/emit! (dwsl/remove-layout ids))]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue