mirror of
https://github.com/penpot/penpot.git
synced 2025-03-09 14:21:42 -05:00
Add theme deletion
This commit is contained in:
parent
3413d4b42f
commit
8660c372dc
4 changed files with 17 additions and 4 deletions
|
@ -727,7 +727,7 @@
|
||||||
[changes token-theme-id]
|
[changes token-theme-id]
|
||||||
(assert-library! changes)
|
(assert-library! changes)
|
||||||
(let [library-data (::library-data (meta changes))
|
(let [library-data (::library-data (meta changes))
|
||||||
prev-token-theme (get-in library-data [:token-theme token-theme-id])]
|
prev-token-theme (get-in library-data [:token-themes-index token-theme-id])]
|
||||||
(-> changes
|
(-> changes
|
||||||
(update :redo-changes conj {:type :del-token-theme :id token-theme-id})
|
(update :redo-changes conj {:type :del-token-theme :id token-theme-id})
|
||||||
(update :undo-changes conj {:type :add-token-theme :token-theme prev-token-theme})
|
(update :undo-changes conj {:type :add-token-theme :token-theme prev-token-theme})
|
||||||
|
|
|
@ -48,8 +48,11 @@
|
||||||
(d/update-in-when file-data [:token-themes-index token-theme-id] #(-> (apply f % args) (touch))))
|
(d/update-in-when file-data [:token-themes-index token-theme-id] #(-> (apply f % args) (touch))))
|
||||||
|
|
||||||
(defn delete-token-theme
|
(defn delete-token-theme
|
||||||
[file-data token-id]
|
[file-data theme-id]
|
||||||
file-data)
|
(-> file-data
|
||||||
|
(update :token-themes (fn [ids] (d/removev #(= % theme-id) ids)))
|
||||||
|
(update :token-themes-index dissoc theme-id)
|
||||||
|
(update :token-active-themes disj theme-id)))
|
||||||
|
|
||||||
(defn add-token-set
|
(defn add-token-set
|
||||||
[file-data {:keys [index id] :as token-set}]
|
[file-data {:keys [index id] :as token-set}]
|
||||||
|
|
|
@ -128,6 +128,16 @@
|
||||||
(pcb/update-active-token-themes new-themes themes))]
|
(pcb/update-active-token-themes new-themes themes))]
|
||||||
(rx/of (dch/commit-changes changes))))))
|
(rx/of (dch/commit-changes changes))))))
|
||||||
|
|
||||||
|
(defn delete-token-theme [token-theme-id]
|
||||||
|
(ptk/reify ::delete-token-theme
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [it state _]
|
||||||
|
(let [data (get state :workspace-data)
|
||||||
|
changes (-> (pcb/empty-changes it)
|
||||||
|
(pcb/with-library-data data)
|
||||||
|
(pcb/delete-token-theme token-theme-id))]
|
||||||
|
(rx/of (dch/commit-changes 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)
|
||||||
|
|
|
@ -214,7 +214,7 @@
|
||||||
[:button {:on-click (fn [e]
|
[:button {:on-click (fn [e]
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
(st/emit! (wdt/delete-token-set id)))}
|
(st/emit! (wdt/delete-token-theme id)))}
|
||||||
"🗑️"]]]])]])]]
|
"🗑️"]]]])]])]]
|
||||||
[:div.spaced
|
[:div.spaced
|
||||||
[:b "Sets"]
|
[:b "Sets"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue