🐛 Fix export touched attributes

This commit is contained in:
Andrés Moya 2024-06-10 16:19:29 +02:00
parent 257dab4775
commit 9a4c45c8a3
6 changed files with 89 additions and 9 deletions

View file

@ -50,6 +50,9 @@
(defn bool->str [val]
(when (some? val) (str val)))
(defn touched->str [val]
(str/join " " (map str val)))
(defn add-factory [shape]
(fn add!
([props attr]
@ -136,7 +139,6 @@
(cond-> bool?
(add! :bool-type)))))
(defn add-library-refs [props shape]
(let [add! (add-factory shape)]
(-> props
@ -150,7 +152,8 @@
(add! :component-id)
(add! :component-root)
(add! :main-instance)
(add! :shape-ref))))
(add! :shape-ref)
(add! :touched touched->str))))
(defn prefix-keys [m]
(letfn [(prefix-entry [[k v]]

View file

@ -12,6 +12,7 @@
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.svg.path :as svg.path]
[app.common.types.component :as ctk]
[app.common.types.shape.interactions :as ctsi]
[app.common.uuid :as uuid]
[app.util.json :as json]
@ -129,6 +130,15 @@
(into {}))
style-str))
(defn parse-touched
"Transform a string of :touched-groups into a set"
[touched-str]
(let [touched (->> (str/split touched-str " ")
(map #(keyword (subs % 1)))
(filter ctk/valid-touched-group?)
(into #{}))]
touched))
(defn add-attrs
[m attrs]
(reduce-kv
@ -424,7 +434,8 @@
component-file (get-meta node :component-file uuid/uuid)
shape-ref (get-meta node :shape-ref uuid/uuid)
component-root? (get-meta node :component-root str->bool)
main-instance? (get-meta node :main-instance str->bool)]
main-instance? (get-meta node :main-instance str->bool)
touched (get-meta node :touched parse-touched)]
(cond-> props
(some? stroke-color-ref-id)
@ -442,7 +453,10 @@
(assoc :main-instance main-instance?)
(some? shape-ref)
(assoc :shape-ref shape-ref))))
(assoc :shape-ref shape-ref)
(seq touched)
(assoc :touched touched))))
(defn add-fill
[props node svg-data]