mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
Create temporary theme when creating set
This commit is contained in:
@@ -249,6 +249,16 @@
|
||||
[:type [:= :del-typography]]
|
||||
[:id ::sm/uuid]]]
|
||||
|
||||
[:add-temporary-token-theme
|
||||
[:map {:title "AddTemporaryTokenThemeChange"}
|
||||
[:type [:= :add-temporary-token-theme]]
|
||||
[:token-theme ::ctot/token-theme]]]
|
||||
|
||||
[:delete-temporary-token-theme
|
||||
[:map {:title "DeleteTemporaryTokenThemeChange"}
|
||||
[:type [:= :delete-temporary-token-theme]]
|
||||
[:id ::sm/uuid]]]
|
||||
|
||||
[:add-token-theme
|
||||
[:map {:title "AddTokenThemeChange"}
|
||||
[:type [:= :add-token-theme]]
|
||||
@@ -776,6 +786,14 @@
|
||||
[data {:keys [id]}]
|
||||
(ctol/delete-token data id))
|
||||
|
||||
(defmethod process-change :add-temporary-token-theme
|
||||
[data {:keys [token-theme]}]
|
||||
(ctotl/add-temporary-token-theme data token-theme))
|
||||
|
||||
(defmethod process-change :delete-temporary-token-theme
|
||||
[data {:keys [id]}]
|
||||
(ctotl/delete-temporary-token-theme data id))
|
||||
|
||||
(defmethod process-change :add-token-theme
|
||||
[data {:keys [token-theme]}]
|
||||
(ctotl/add-token-theme data token-theme))
|
||||
|
||||
@@ -695,6 +695,13 @@
|
||||
(update :undo-changes conj {:type :add-typography :typography prev-typography})
|
||||
(apply-changes-local))))
|
||||
|
||||
(defn add-temporary-token-theme
|
||||
[changes token-theme]
|
||||
(-> changes
|
||||
(update :redo-changes conj {:type :add-temporary-token-theme :token-theme token-theme})
|
||||
(update :undo-changes conj {:type :delete-temporary-token-theme :id (:id token-theme)})
|
||||
(apply-changes-local)))
|
||||
|
||||
(defn add-token-theme
|
||||
[changes token-theme]
|
||||
(-> changes
|
||||
|
||||
@@ -65,6 +65,9 @@
|
||||
[:map-of {:gen/max 5} :keyword ::ctpg/plugin-data]]
|
||||
[:token-theme-temporary-id {:optional true}
|
||||
::sm/uuid]
|
||||
[:token-active-themes {:optional true
|
||||
:default #{}}
|
||||
[:set ::sm/uuid]]
|
||||
[:token-themes {:optional true}
|
||||
[:vector ::sm/uuid]]
|
||||
[:token-themes-index {:optional true}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
[:id ::sm/uuid]
|
||||
[:name :string]
|
||||
[:group {:optional true} :string]
|
||||
[:selected [:enum :enabled :disabled #_:source]]
|
||||
[:source? {:optional true} :boolean]
|
||||
[:description {:optional true} :string]
|
||||
[:modified-at {:optional true} ::sm/inst]
|
||||
[:sets [:set {:gen/max 10 :gen/min 1} ::sm/uuid]]])
|
||||
|
||||
@@ -14,6 +14,19 @@
|
||||
[token-set]
|
||||
(assoc token-set :modified-at (dt/now)))
|
||||
|
||||
(defn add-temporary-token-theme
|
||||
[file-data {:keys [id] :as token-theme}]
|
||||
(-> file-data
|
||||
(d/dissoc-in [:token-themes-index (:token-theme-temporary-id file-data)])
|
||||
(assoc :token-theme-temporary-id id)
|
||||
(update :token-themes-index assoc id token-theme)))
|
||||
|
||||
(defn delete-temporary-token-theme
|
||||
[file-data token-theme-id]
|
||||
(cond-> file-data
|
||||
(= (:token-theme-temporary-id file-data) token-theme-id) (dissoc :token-theme-temporary-id)
|
||||
:always (d/dissoc-in [:token-themes-index (:token-theme-temporary-id file-data)])))
|
||||
|
||||
(defn add-token-theme
|
||||
[file-data {:keys [index id] :as token-theme}]
|
||||
(-> file-data
|
||||
|
||||
Reference in New Issue
Block a user