mirror of
https://github.com/penpot/penpot.git
synced 2025-08-02 21:08:31 +02:00
♻️ Components refactor: generator for relocate shapes (and tests)
This commit is contained in:
parent
78d0611632
commit
f354942487
7 changed files with 499 additions and 229 deletions
33
common/test/common_tests/helpers/debug.cljc
Normal file
33
common/test/common_tests/helpers/debug.cljc
Normal file
|
@ -0,0 +1,33 @@
|
|||
(ns common-tests.helpers.debug
|
||||
(:require
|
||||
[app.common.uuid :as uuid]
|
||||
[common-tests.helpers.ids-map :as thi]))
|
||||
|
||||
(defn dump-shape
|
||||
"Dumps a shape, with each attribute in a line"
|
||||
[shape]
|
||||
(println "{")
|
||||
(doseq [[k v] (sort shape)]
|
||||
(when (some? v)
|
||||
(println (str " " k " : " v))))
|
||||
(println "}"))
|
||||
|
||||
(defn- stringify-keys [m keys]
|
||||
(apply str (interpose ", " (map #(str % ": " (get m %)) keys))))
|
||||
|
||||
(defn dump-page
|
||||
"Dumps the layer tree of the page. Prints the label of each shape, and the specified keys.
|
||||
Example: (thd/dump-page (thf/current-page file) [:id :touched])"
|
||||
([page keys]
|
||||
(dump-page page uuid/zero "" keys))
|
||||
([page id padding keys]
|
||||
(let [objects (vals (:objects page))
|
||||
root-objects (filter #(and
|
||||
(= (:parent-id %) id)
|
||||
(not= (:id %) id))
|
||||
objects)]
|
||||
(doseq [val root-objects]
|
||||
(println padding (thi/label (:id val))
|
||||
(when keys
|
||||
(str "[" (stringify-keys val keys) "]")))
|
||||
(dump-page page (:id val) (str padding " ") keys)))))
|
Loading…
Add table
Add a link
Reference in a new issue