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:
parent
1f0c1dbbe6
commit
f3d4346c0d
1 changed files with 15 additions and 0 deletions
|
@ -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)))]
|
||||
|
|
Loading…
Reference in a new issue