mirror of
https://github.com/penpot/penpot.git
synced 2025-06-17 00:01:39 +02:00
Token theme deletion
This commit is contained in:
parent
844819a50c
commit
ec96e7918d
5 changed files with 20 additions and 17 deletions
|
@ -281,7 +281,7 @@
|
||||||
[:del-token-theme
|
[:del-token-theme
|
||||||
[:map {:title "DelTokenThemeChange"}
|
[:map {:title "DelTokenThemeChange"}
|
||||||
[:type [:= :del-token-theme]]
|
[:type [:= :del-token-theme]]
|
||||||
[:id ::sm/uuid]
|
[:group :string]
|
||||||
[:name :string]]]
|
[:name :string]]]
|
||||||
|
|
||||||
[:add-token-set
|
[:add-token-set
|
||||||
|
@ -885,9 +885,8 @@
|
||||||
(update :sets (partial set-ids->names data))))))))))
|
(update :sets (partial set-ids->names data))))))))))
|
||||||
|
|
||||||
(defmethod process-change :del-token-theme
|
(defmethod process-change :del-token-theme
|
||||||
[data {:keys [id group name]}]
|
[data {:keys [group name]}]
|
||||||
(-> data
|
(-> data
|
||||||
(ctotl/delete-token-theme id)
|
|
||||||
(update :tokens-lib
|
(update :tokens-lib
|
||||||
#(-> %
|
#(-> %
|
||||||
(ctob/ensure-tokens-lib)
|
(ctob/ensure-tokens-lib)
|
||||||
|
|
|
@ -20,7 +20,8 @@
|
||||||
[app.common.types.component :as ctk]
|
[app.common.types.component :as ctk]
|
||||||
[app.common.types.file :as ctf]
|
[app.common.types.file :as ctf]
|
||||||
[app.common.types.shape.layout :as ctl]
|
[app.common.types.shape.layout :as ctl]
|
||||||
[app.common.uuid :as uuid]))
|
[app.common.uuid :as uuid]
|
||||||
|
[app.common.types.tokens-lib :as ctob]))
|
||||||
|
|
||||||
;; Auxiliary functions to help create a set of changes (undo + redo)
|
;; Auxiliary functions to help create a set of changes (undo + redo)
|
||||||
|
|
||||||
|
@ -724,12 +725,13 @@
|
||||||
(apply-changes-local)))
|
(apply-changes-local)))
|
||||||
|
|
||||||
(defn delete-token-theme
|
(defn delete-token-theme
|
||||||
[changes token-theme-id]
|
[changes group name]
|
||||||
(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-themes-index token-theme-id])]
|
prev-token-theme (some-> (get library-data :tokens-lib)
|
||||||
|
(ctob/get-theme group name))]
|
||||||
(-> changes
|
(-> changes
|
||||||
(update :redo-changes conj {:type :del-token-theme :id token-theme-id :name (:name prev-token-theme)})
|
(update :redo-changes conj {:type :del-token-theme :group group :name name})
|
||||||
(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})
|
||||||
(apply-changes-local))))
|
(apply-changes-local))))
|
||||||
|
|
||||||
|
|
|
@ -154,14 +154,14 @@
|
||||||
(rx/of
|
(rx/of
|
||||||
(dch/commit-changes changes))))))
|
(dch/commit-changes changes))))))
|
||||||
|
|
||||||
(defn delete-token-theme [token-theme-id]
|
(defn delete-token-theme [group name]
|
||||||
(ptk/reify ::delete-token-theme
|
(ptk/reify ::delete-token-theme
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [data (get state :workspace-data)
|
(let [data (get state :workspace-data)
|
||||||
changes (-> (pcb/empty-changes it)
|
changes (-> (pcb/empty-changes it)
|
||||||
(pcb/with-library-data data)
|
(pcb/with-library-data data)
|
||||||
(pcb/delete-token-theme token-theme-id))]
|
(pcb/delete-token-theme group name))]
|
||||||
(rx/of
|
(rx/of
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(wtu/update-workspace-tokens))))))
|
(wtu/update-workspace-tokens))))))
|
||||||
|
|
|
@ -70,9 +70,10 @@
|
||||||
(when (seq group)
|
(when (seq group)
|
||||||
[:span {:class (stl/css :theme-group-label)} group])
|
[:span {:class (stl/css :theme-group-label)} group])
|
||||||
[:ul {:class (stl/css :theme-group-rows-wrapper)}
|
[:ul {:class (stl/css :theme-group-rows-wrapper)}
|
||||||
(for [[_ {:keys [id group name] :as theme}] themes
|
(for [[_ {:keys [group name] :as theme}] themes
|
||||||
:let [selected? (some? (get active-theme-ids (ctob/theme-path theme)))]]
|
:let [theme-id (ctob/theme-path theme)
|
||||||
[:li {:key (str "token-theme-" id)
|
selected? (some? (get active-theme-ids theme-id))]]
|
||||||
|
[:li {:key theme-id
|
||||||
:class (stl/css :theme-row)}
|
:class (stl/css :theme-row)}
|
||||||
[:div {:class (stl/css :theme-row-left)}
|
[:div {:class (stl/css :theme-row-left)}
|
||||||
[:div {:on-click (fn [e]
|
[:div {:on-click (fn [e]
|
||||||
|
@ -97,7 +98,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-theme id)))}
|
(st/emit! (wdt/delete-token-theme group name)))}
|
||||||
i/delete]]]])]])]
|
i/delete]]]])]])]
|
||||||
[:div {:class (stl/css :button-footer)}
|
[:div {:class (stl/css :button-footer)}
|
||||||
[:button {:class (stl/css :create-theme-button)
|
[:button {:class (stl/css :create-theme-button)
|
||||||
|
@ -195,7 +196,7 @@
|
||||||
[:button {:class (stl/css :button-secondary)
|
[:button {:class (stl/css :button-secondary)
|
||||||
:type "button"
|
:type "button"
|
||||||
:on-click (fn []
|
:on-click (fn []
|
||||||
(st/emit! (wdt/delete-token-theme (:id theme)))
|
(st/emit! (wdt/delete-token-theme (:group theme) (:name theme)))
|
||||||
(on-back))}
|
(on-back))}
|
||||||
"Delete"]
|
"Delete"]
|
||||||
[:div])
|
[:div])
|
||||||
|
|
|
@ -23,9 +23,10 @@
|
||||||
[{:keys [themes active-theme-ids on-close grouped?]}]
|
[{:keys [themes active-theme-ids on-close grouped?]}]
|
||||||
(when (seq themes)
|
(when (seq themes)
|
||||||
[:ul
|
[:ul
|
||||||
(for [[_ {:keys [id group name] :as theme}] themes
|
(for [[_ {:keys [group name] :as theme}] themes
|
||||||
:let [selected? (get active-theme-ids (ctob/theme-path theme))]]
|
:let [theme-id (ctob/theme-path theme)
|
||||||
[:li {:key id
|
selected? (get active-theme-ids theme-id)]]
|
||||||
|
[:li {:key theme-id
|
||||||
:class (stl/css-case
|
:class (stl/css-case
|
||||||
:checked-element true
|
:checked-element true
|
||||||
:sub-item grouped?
|
:sub-item grouped?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue