mirror of
https://github.com/penpot/penpot.git
synced 2025-06-13 13:21:39 +02:00
✨ Add items to grid cells
This commit is contained in:
parent
fde0bcfd3e
commit
ca7f17efd1
5 changed files with 55 additions and 21 deletions
|
@ -112,7 +112,6 @@
|
|||
(dwu/commit-undo-transaction undo-id)))
|
||||
|
||||
(catch :default cause
|
||||
(js/console.log (.-stack cause))
|
||||
(rx/throw {:type :svg-parser
|
||||
:data cause})))))))
|
||||
|
||||
|
|
|
@ -831,7 +831,7 @@
|
|||
:ignore-constraints false
|
||||
:ignore-snap-pixel true}))))))
|
||||
|
||||
(defn- move-shapes-to-frame
|
||||
(defn move-shapes-to-frame
|
||||
[ids frame-id drop-index [row column :as cell]]
|
||||
(ptk/reify ::move-shapes-to-frame
|
||||
ptk/WatchEvent
|
||||
|
@ -923,24 +923,32 @@
|
|||
changes
|
||||
(-> (pcb/empty-changes it page-id)
|
||||
(pcb/with-objects objects)
|
||||
|
||||
;; Remove layout-item properties when moving a shape outside a layout
|
||||
(cond-> (not (ctl/any-layout? objects frame-id))
|
||||
(pcb/update-shapes moving-shapes-ids ctl/remove-layout-item-data))
|
||||
|
||||
;; Remove the swap slots if it is moving to a different component
|
||||
(pcb/update-shapes child-heads
|
||||
(fn [shape]
|
||||
(cond-> shape
|
||||
(not= component-main-frame (ctn/find-component-main objects shape false))
|
||||
(ctk/remove-swap-slot))))
|
||||
(pcb/update-shapes
|
||||
child-heads
|
||||
(fn [shape]
|
||||
(cond-> shape
|
||||
(not= component-main-frame (ctn/find-component-main objects shape false))
|
||||
(ctk/remove-swap-slot))))
|
||||
|
||||
;; Remove component-root property when moving a shape inside a component
|
||||
(cond-> (ctn/get-instance-root objects frame)
|
||||
(pcb/update-shapes moving-shapes-children-ids #(dissoc % :component-root)))
|
||||
|
||||
;; Add component-root property when moving a component outside a component
|
||||
(cond-> (not (ctn/get-instance-root objects frame))
|
||||
(pcb/update-shapes child-heads #(assoc % :component-root true)))
|
||||
|
||||
(pcb/update-shapes moving-shapes-ids #(cond-> % (cfh/frame-shape? %) (assoc :hide-in-viewer true)))
|
||||
(pcb/update-shapes shape-ids-to-detach ctk/detach-shape)
|
||||
(pcb/change-parent frame-id moving-shapes drop-index)
|
||||
|
||||
;; Change the grid cell in a grid layout
|
||||
(cond-> (ctl/grid-layout? objects frame-id)
|
||||
(-> (pcb/update-shapes
|
||||
[frame-id]
|
||||
|
@ -948,7 +956,8 @@
|
|||
(-> frame
|
||||
;; Assign the cell when pushing into a specific grid cell
|
||||
(cond-> (some? cell)
|
||||
(-> (ctl/push-into-cell moving-shapes-ids row column)
|
||||
(-> (ctl/free-cell-shapes moving-shapes-ids)
|
||||
(ctl/push-into-cell moving-shapes-ids row column)
|
||||
(ctl/assign-cells objects)))
|
||||
(ctl/assign-cell-positions objects)))
|
||||
{:with-objects? true})
|
||||
|
|
|
@ -127,7 +127,6 @@
|
|||
state
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
_ (prn "??" (->> ids (map #(get objects %)) (map :name)))
|
||||
srect (->> ids
|
||||
(map #(get objects %))
|
||||
(gsh/shapes->rect))]
|
||||
|
|
|
@ -10,9 +10,13 @@
|
|||
[app.common.record :as crc]
|
||||
[app.common.spec :as us]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace.shape-layout :as dwsl]
|
||||
[app.main.data.workspace.transforms :as dwt]
|
||||
[app.main.store :as st]
|
||||
[app.plugins.utils :as utils :refer [get-data get-state]]))
|
||||
[app.plugins.utils :as utils :refer [get-data get-state]]
|
||||
[app.util.object :as obj]
|
||||
[potok.v2.core :as ptk]))
|
||||
|
||||
(defn- make-tracks
|
||||
[tracks]
|
||||
|
@ -72,7 +76,14 @@
|
|||
(remove
|
||||
[self]
|
||||
(let [id (get-data self :id)]
|
||||
(st/emit! (dwsl/remove-layout #{id})))))
|
||||
(st/emit! (dwsl/remove-layout #{id}))))
|
||||
|
||||
(appendChild
|
||||
[self child row column]
|
||||
(let [parent-id (get-data self :id)
|
||||
child-id (uuid/uuid (obj/get child "id"))]
|
||||
(st/emit! (dwt/move-shapes-to-frame #{child-id} parent-id nil [row column])
|
||||
(ptk/data-event :layout/update {:ids [parent-id]})))))
|
||||
|
||||
(defn grid-layout-proxy
|
||||
[data]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue