mirror of
https://github.com/penpot/penpot.git
synced 2025-02-01 11:59:17 -05:00
Add new sets to active theme
This commit is contained in:
parent
3e41e7d234
commit
0f95ddef8f
1 changed files with 23 additions and 16 deletions
|
@ -102,6 +102,22 @@
|
||||||
(rx/of
|
(rx/of
|
||||||
(dch/commit-changes changes)))))))
|
(dch/commit-changes changes)))))))
|
||||||
|
|
||||||
|
(defn ensure-token-theme-changes [changes state {:keys [id new-set?]}]
|
||||||
|
(let [theme-id (wtts/update-theme-id state)
|
||||||
|
theme (some-> theme-id (wtts/get-workspace-token-theme state))]
|
||||||
|
(cond
|
||||||
|
(not theme-id) (-> changes
|
||||||
|
(pcb/add-temporary-token-theme
|
||||||
|
|
||||||
|
{:id (uuid/next)
|
||||||
|
:name ""
|
||||||
|
:sets #{id}}))
|
||||||
|
new-set? (-> changes
|
||||||
|
(pcb/update-token-theme
|
||||||
|
(wtts/add-token-set-to-token-theme id theme)
|
||||||
|
theme))
|
||||||
|
:else changes)))
|
||||||
|
|
||||||
(defn create-token-set [token-set]
|
(defn create-token-set [token-set]
|
||||||
(let [new-token-set (merge
|
(let [new-token-set (merge
|
||||||
{:id (uuid/next)
|
{:id (uuid/next)
|
||||||
|
@ -110,9 +126,11 @@
|
||||||
token-set)]
|
token-set)]
|
||||||
(ptk/reify ::create-token-set
|
(ptk/reify ::create-token-set
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it _ _]
|
(watch [it state _]
|
||||||
(let [changes (-> (pcb/empty-changes it)
|
(let [changes (-> (pcb/empty-changes it)
|
||||||
(pcb/add-token-set new-token-set))]
|
(pcb/add-token-set new-token-set)
|
||||||
|
(ensure-token-theme-changes state {:id (:id new-token-set)
|
||||||
|
:new-set? true}))]
|
||||||
(rx/of
|
(rx/of
|
||||||
(dch/commit-changes changes)))))))
|
(dch/commit-changes changes)))))))
|
||||||
|
|
||||||
|
@ -155,20 +173,9 @@
|
||||||
(update token-set :tokens conj (:id token)))]
|
(update token-set :tokens conj (:id token)))]
|
||||||
(-> token-changes
|
(-> token-changes
|
||||||
(pcb/update-token-set updated-token-set token-set))))
|
(pcb/update-token-set updated-token-set token-set))))
|
||||||
theme-id (wtts/update-theme-id state)
|
theme-changes (-> set-changes
|
||||||
theme (some-> theme-id (wtts/get-workspace-token-theme state))
|
(ensure-token-theme-changes state {:new-set? create-set?
|
||||||
theme-changes (cond
|
:set-id selected-token-set-id}))]
|
||||||
(not theme-id) (-> set-changes
|
|
||||||
(pcb/add-temporary-token-theme
|
|
||||||
|
|
||||||
{:id (uuid/next)
|
|
||||||
:name ""
|
|
||||||
:sets #{selected-token-set-id}}))
|
|
||||||
create-set? (-> set-changes
|
|
||||||
(pcb/update-token-theme
|
|
||||||
(wtts/add-token-set-to-token-theme selected-token-set-id theme)
|
|
||||||
theme))
|
|
||||||
:else set-changes)]
|
|
||||||
(rx/of
|
(rx/of
|
||||||
(set-selected-token-set-id selected-token-set-id)
|
(set-selected-token-set-id selected-token-set-id)
|
||||||
(dch/commit-changes theme-changes)))))))
|
(dch/commit-changes theme-changes)))))))
|
||||||
|
|
Loading…
Add table
Reference in a new issue