0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-09 06:11:23 -05:00

Add theme deletion

This commit is contained in:
Florian Schroedl 2024-08-19 09:41:23 +02:00
parent 3413d4b42f
commit 8660c372dc
4 changed files with 17 additions and 4 deletions

View file

@ -727,7 +727,7 @@
[changes token-theme-id]
(assert-library! 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
(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})

View file

@ -48,8 +48,11 @@
(d/update-in-when file-data [:token-themes-index token-theme-id] #(-> (apply f % args) (touch))))
(defn delete-token-theme
[file-data token-id]
file-data)
[file-data theme-id]
(-> 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
[file-data {:keys [index id] :as token-set}]

View file

@ -128,6 +128,16 @@
(pcb/update-active-token-themes new-themes themes))]
(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]
(let [new-token-set (merge
{:id (uuid/next)

View file

@ -214,7 +214,7 @@
[:button {:on-click (fn [e]
(dom/prevent-default e)
(dom/stop-propagation e)
(st/emit! (wdt/delete-token-set id)))}
(st/emit! (wdt/delete-token-theme id)))}
"🗑️"]]]])]])]]
[:div.spaced
[:b "Sets"]