mirror of
https://github.com/penpot/penpot.git
synced 2025-01-22 14:39:45 -05:00
Add token set deletion
This commit is contained in:
parent
ae39586d8c
commit
9329513949
4 changed files with 28 additions and 5 deletions
|
@ -737,7 +737,7 @@
|
||||||
[changes token-set-id]
|
[changes token-set-id]
|
||||||
(assert-library! changes)
|
(assert-library! changes)
|
||||||
(let [library-data (::library-data (meta changes))
|
(let [library-data (::library-data (meta changes))
|
||||||
prev-token-set (get-in library-data [:token-set token-set-id])]
|
prev-token-set (get-in library-data [:token-sets-index token-set-id])]
|
||||||
(-> changes
|
(-> changes
|
||||||
(update :redo-changes conj {:type :del-token-set :id token-set-id})
|
(update :redo-changes conj {:type :del-token-set :id token-set-id})
|
||||||
(update :undo-changes conj {:type :add-token-set :token-set prev-token-set})
|
(update :undo-changes conj {:type :add-token-set :token-set prev-token-set})
|
||||||
|
|
|
@ -51,5 +51,8 @@
|
||||||
(d/update-in-when file-data [:token-sets-index token-set-id] #(-> (apply f % args) (touch))))
|
(d/update-in-when file-data [:token-sets-index token-set-id] #(-> (apply f % args) (touch))))
|
||||||
|
|
||||||
(defn delete-token-set
|
(defn delete-token-set
|
||||||
[file-data token-id]
|
[file-data token-set-id]
|
||||||
file-data)
|
(-> file-data
|
||||||
|
(update :token-set-groups (fn [xs] (into [] (remove #(= (:id %) token-set-id) xs))))
|
||||||
|
(update :token-sets-index dissoc token-set-id)
|
||||||
|
(update :token-themes-index (fn [xs] (update-vals xs #(update % :sets disj token-set-id))))))
|
||||||
|
|
|
@ -116,6 +116,16 @@
|
||||||
(rx/of
|
(rx/of
|
||||||
(dch/commit-changes changes)))))))
|
(dch/commit-changes changes)))))))
|
||||||
|
|
||||||
|
(defn delete-token-set [token-set-id]
|
||||||
|
(ptk/reify ::delete-token-set
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [it state _]
|
||||||
|
(let [data (get state :workspace-data)
|
||||||
|
changes (-> (pcb/empty-changes it)
|
||||||
|
(pcb/with-library-data data)
|
||||||
|
(pcb/delete-token-set token-set-id))]
|
||||||
|
(rx/of (dch/commit-changes changes))))))
|
||||||
|
|
||||||
(defn update-create-token
|
(defn update-create-token
|
||||||
[token]
|
[token]
|
||||||
(let [token (update token :id #(or % (uuid/next)))]
|
(let [token (update token :id #(or % (uuid/next)))]
|
||||||
|
|
|
@ -197,14 +197,24 @@
|
||||||
#_[:button "Delete"]]
|
#_[:button "Delete"]]
|
||||||
[:ul
|
[:ul
|
||||||
{:style {:list-style "disk"
|
{:style {:list-style "disk"
|
||||||
:margin-left "20px"}}
|
:margin-left "20px"
|
||||||
|
:display "flex"
|
||||||
|
:flex-direction "column"
|
||||||
|
:gap "10px"}}
|
||||||
(for [[_ {:keys [id name]}] token-sets]
|
(for [[_ {:keys [id name]}] token-sets]
|
||||||
[:li {:style {:font-weight (when (= selected-token-set-id id) "bold")}
|
[:li {:style {:font-weight (when (= selected-token-set-id id) "bold")}
|
||||||
:on-click (fn []
|
:on-click (fn []
|
||||||
(st/emit!
|
(st/emit!
|
||||||
(wdt/set-selected-token-set-id id)
|
(wdt/set-selected-token-set-id id)
|
||||||
(wtu/update-workspace-tokens)))}
|
(wtu/update-workspace-tokens)))}
|
||||||
name])]
|
[:div {:style {:display "flex"
|
||||||
|
:justify-content "space-between"}}
|
||||||
|
name
|
||||||
|
[:button {:on-click (fn [e]
|
||||||
|
(dom/prevent-default e)
|
||||||
|
(dom/stop-propagation e)
|
||||||
|
(st/emit! (wdt/delete-token-set id)))}
|
||||||
|
"Delete"]]])]
|
||||||
[:hr]]))
|
[:hr]]))
|
||||||
|
|
||||||
(mf/defc tokens-explorer
|
(mf/defc tokens-explorer
|
||||||
|
|
Loading…
Add table
Reference in a new issue