mirror of
https://github.com/penpot/penpot.git
synced 2025-06-08 01:11:37 +02:00
🔥 Remove not necessary API from tokens-lib: add-sets
This commit is contained in:
parent
802c67ace4
commit
1e10e3818e
5 changed files with 29 additions and 41 deletions
|
@ -376,11 +376,6 @@
|
|||
[:type [:= :update-active-token-themes]]
|
||||
[:theme-ids [:set :string]]]]
|
||||
|
||||
[:add-token-sets
|
||||
[:map {:title "AddTokenSetsChange"}
|
||||
[:type [:= :add-token-sets]]
|
||||
[:token-sets [:sequential ::ctot/token-set]]]]
|
||||
|
||||
[:rename-token-set-group
|
||||
[:map {:title "RenameTokenSetGroup"}
|
||||
[:type [:= :rename-token-set-group]]
|
||||
|
@ -1049,12 +1044,6 @@
|
|||
(update data :tokens-lib #(-> % (ctob/ensure-tokens-lib)
|
||||
(ctob/set-active-themes theme-ids))))
|
||||
|
||||
(defmethod process-change :add-token-sets
|
||||
[data {:keys [token-sets]}]
|
||||
(update data :tokens-lib #(-> %
|
||||
(ctob/ensure-tokens-lib)
|
||||
(ctob/add-sets (map ctob/make-token-set token-sets)))))
|
||||
|
||||
(defmethod process-change :rename-token-set-group
|
||||
[data {:keys [set-group-path set-group-fname]}]
|
||||
(update data :tokens-lib (fn [lib]
|
||||
|
|
|
@ -430,7 +430,6 @@
|
|||
Prefixed set full path or pfpath: a full path wit prefixes [\"G-some-group\", \"G-some-subgroup\", \"S-some-set\"].
|
||||
Prefixed set final name or pfname: a final name with prefix \"S-some-set\"."
|
||||
(add-set [_ token-set] "add a set to the library, at the end")
|
||||
(add-sets [_ token-set] "add a collection of sets to the library, at the end")
|
||||
(update-set [_ set-name f] "modify a set in the library")
|
||||
(delete-set-path [_ set-path] "delete a set in the library")
|
||||
(delete-set [_ set-name] "delete a set at `set-name` in the library and disable the `set-name` in all themes")
|
||||
|
@ -875,9 +874,6 @@ Will return a value that matches this schema:
|
|||
themes
|
||||
active-themes)))
|
||||
|
||||
(add-sets [this token-sets]
|
||||
(reduce add-set this token-sets))
|
||||
|
||||
(update-set [this set-name f]
|
||||
(let [prefixed-full-path (set-name->prefixed-full-path set-name)
|
||||
set (get-in sets prefixed-full-path)]
|
||||
|
@ -1483,10 +1479,12 @@ Will return a value that matches this schema:
|
|||
prev-sets (->> (fres/read-object! r)
|
||||
(tree-seq d/ordered-map? vals)
|
||||
(filter (partial instance? TokenSet)))
|
||||
sets (-> (make-tokens-lib)
|
||||
(add-sets prev-sets)
|
||||
|
||||
;; FIXME: wtf we usind deref here?
|
||||
sets (-> (reduce add-set (make-tokens-lib) prev-sets)
|
||||
(deref)
|
||||
:sets)
|
||||
(:sets))
|
||||
|
||||
_set-groups (fres/read-object! r)
|
||||
themes (fres/read-object! r)
|
||||
active-themes (fres/read-object! r)]
|
||||
|
|
|
@ -139,7 +139,7 @@
|
|||
(let [data (dsh/lookup-file-data state)
|
||||
tokens-lib (get data :tokens-lib)
|
||||
set-name (ctob/normalize-set-name set-name)]
|
||||
(if (ctob/get-set tokens-lib set-name)
|
||||
(if (and tokens-lib (ctob/get-set tokens-lib set-name))
|
||||
(rx/of (ntf/show {:content (tr "errors.token-set-already-exists")
|
||||
:type :toast
|
||||
:level :error
|
||||
|
|
|
@ -293,11 +293,12 @@
|
|||
:on-save-form on-save-form
|
||||
:disabled? disabled?}]]]]]))
|
||||
|
||||
(defn- make-lib-with-theme [theme sets]
|
||||
(-> (ctob/make-tokens-lib)
|
||||
(ctob/add-theme theme)
|
||||
(ctob/add-sets sets)
|
||||
(ctob/activate-theme (:group theme) (:name theme))))
|
||||
(defn- make-lib-with-theme
|
||||
[theme sets]
|
||||
(let [tlib (-> (ctob/make-tokens-lib)
|
||||
(ctob/add-theme theme))
|
||||
tlib (reduce ctob/add-set tlib sets)]
|
||||
(ctob/activate-theme tlib (:group theme) (:name theme))))
|
||||
|
||||
(mf/defc controlled-edit-theme
|
||||
[{:keys [state set-state]}]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue