mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 07:29:08 -05:00
✨ Put new objects at the top
This commit is contained in:
parent
317895d39d
commit
69c27ca24d
5 changed files with 8 additions and 59 deletions
|
@ -247,10 +247,10 @@
|
|||
(let [shapes (:shapes obj)
|
||||
cindex (d/index-of shapes id)
|
||||
nindex (case loc
|
||||
:top 0
|
||||
:down (min (- (count shapes) 1) (inc cindex))
|
||||
:up (max 0 (- cindex 1))
|
||||
:bottom (- (count shapes) 1))]
|
||||
:top (- (count shapes) 1)
|
||||
:down (max 0 (- cindex 1))
|
||||
:up (min (- (count shapes) 1) (inc cindex))
|
||||
:bottom 0)]
|
||||
(update obj :shapes
|
||||
(fn [shapes]
|
||||
(let [[fst snd] (->> (remove #(= % id) shapes)
|
||||
|
|
|
@ -1374,57 +1374,6 @@
|
|||
|
||||
;; --- Shape Vertical Ordering
|
||||
|
||||
(declare impl-order-shape)
|
||||
|
||||
;; TODO
|
||||
(defn order-selected-shapes
|
||||
[loc]
|
||||
(us/verify ::direction loc)
|
||||
(ptk/reify ::move-selected-layer
|
||||
IBatchedChange
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [id (first (get-in state [:workspace-local :selected]))
|
||||
type (get-in state [:workspace-data :objects id :type])]
|
||||
;; NOTE: multiple selection ordering not supported
|
||||
(if (and id (not= type :frame))
|
||||
(impl-order-shape state id loc)
|
||||
state)))))
|
||||
|
||||
(defn impl-order-shape
|
||||
[state sid opt]
|
||||
(let [shapes (get-in state [:workspace-data :shapes])
|
||||
index (case opt
|
||||
:top 0
|
||||
:down (min (- (count shapes) 1) (inc (d/index-of shapes sid)))
|
||||
:up (max 0 (- (d/index-of shapes sid) 1))
|
||||
:bottom (- (count shapes) 1))]
|
||||
(update-in state [:workspace-data :shapes]
|
||||
(fn [items]
|
||||
(let [[fst snd] (->> (remove #(= % sid) items)
|
||||
(split-at index))]
|
||||
(into [] (concat fst [sid] snd)))))))
|
||||
|
||||
(defn impl-vertical-order
|
||||
[state id loc]
|
||||
(let [page-id (::page-id state)
|
||||
objects (get-in state [:workspace-data page-id :objects])
|
||||
|
||||
frame-id (get-in objects [id :frame-id])
|
||||
shapes (get-in objects [frame-id :shapes])
|
||||
|
||||
cindex (d/index-of shapes id)
|
||||
nindex (case loc
|
||||
:top 0
|
||||
:down (min (- (count shapes) 1) (inc cindex))
|
||||
:up (max 0 (- cindex 1))
|
||||
:bottom (- (count shapes) 1))]
|
||||
(update-in state [:workspace-data page-id :objects frame-id :shapes]
|
||||
(fn [shapes]
|
||||
(let [[fst snd] (->> (remove #(= % id) shapes)
|
||||
(split-at nindex))]
|
||||
(d/concat [] fst [id] snd))))))
|
||||
|
||||
(defn vertical-order-selected
|
||||
[loc]
|
||||
(us/verify ::loc loc)
|
||||
|
|
|
@ -143,7 +143,7 @@
|
|||
translate #(translate-to-frame % ds-modifier (gpt/point (- x) (- y)))]
|
||||
[:svg {:x x :y y :width width :height height}
|
||||
[:> "rect" props]
|
||||
(for [item (reverse childs)]
|
||||
(for [item childs]
|
||||
[:& shape-wrapper {:shape (translate item) :key (:id item)}])]))
|
||||
|
||||
(defn- translate-to-frame
|
||||
|
|
|
@ -250,7 +250,7 @@
|
|||
i/arrow-slide]]
|
||||
(when-not collapsed?
|
||||
[:ul
|
||||
(for [[index id] (d/enumerate (:shapes item))]
|
||||
(for [[index id] (d/enumerate (reverse (:shapes item)))]
|
||||
(let [item (get objects id)]
|
||||
(if (= (:type item) :frame)
|
||||
[:& layer-frame-item
|
||||
|
@ -273,7 +273,7 @@
|
|||
objects (:objects data)
|
||||
root (get objects uuid/zero)]
|
||||
[:ul.element-list
|
||||
(for [[index id] (d/enumerate (:shapes root))]
|
||||
(for [[index id] (d/enumerate (reverse (:shapes root)))]
|
||||
(let [item (get objects id)]
|
||||
(if (= (:type item) :frame)
|
||||
[:& layer-frame-item
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
shapes (->> (:shapes root)
|
||||
(map #(get objects %)))]
|
||||
[:g.shapes
|
||||
(for [item (reverse shapes)]
|
||||
(for [item shapes]
|
||||
(if (= (:type item) :frame)
|
||||
[:& frame-wrapper {:shape item
|
||||
:key (:id item)
|
||||
|
|
Loading…
Add table
Reference in a new issue