0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-06 14:50:20 -05:00

Add create token-set event

This commit is contained in:
Florian Schroedl 2024-08-15 18:52:42 +02:00
parent 1f0c1dbbe6
commit f3d4346c0d

View file

@ -20,6 +20,7 @@
[clojure.data :as data]
[cuerdas.core :as str]
[potok.v2.core :as ptk]
[app.main.ui.workspace.tokens.changes :as wdt]
[app.main.ui.workspace.tokens.token-set :as wtts]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -87,6 +88,20 @@
(update [_ state]
(wtts/assoc-selected-token-set-id state id))))
(defn create-token-set [token-set]
(let [new-token-set (merge
{:id (uuid/next)
:name "Token Set"
:tokens []}
token-set)]
(ptk/reify ::update-create-token
ptk/WatchEvent
(watch [it _ _]
(let [changes (-> (pcb/empty-changes it)
(pcb/add-token-set new-token-set))]
(rx/of
(dch/commit-changes changes)))))))
(defn update-create-token
[token]
(let [token (update token :id #(or % (uuid/next)))]