mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
🔧 Read and modify token themes by id
This commit is contained in:
@@ -387,8 +387,7 @@
|
|||||||
[:set-token-theme
|
[:set-token-theme
|
||||||
[:map {:title "SetTokenThemeChange"}
|
[:map {:title "SetTokenThemeChange"}
|
||||||
[:type [:= :set-token-theme]]
|
[:type [:= :set-token-theme]]
|
||||||
[:theme-name :string]
|
[:id ::sm/uuid]
|
||||||
[:group :string]
|
|
||||||
[:theme [:maybe ctob/schema:token-theme-attrs]]]]
|
[:theme [:maybe ctob/schema:token-theme-attrs]]]]
|
||||||
|
|
||||||
[:set-active-token-themes
|
[:set-active-token-themes
|
||||||
@@ -1009,20 +1008,20 @@
|
|||||||
(ctob/update-set lib' id (fn [_] (ctob/make-token-set token-set))))))))
|
(ctob/update-set lib' id (fn [_] (ctob/make-token-set token-set))))))))
|
||||||
|
|
||||||
(defmethod process-change :set-token-theme
|
(defmethod process-change :set-token-theme
|
||||||
[data {:keys [group theme-name theme]}]
|
[data {:keys [id theme]}]
|
||||||
(update data :tokens-lib
|
(update data :tokens-lib
|
||||||
(fn [lib]
|
(fn [lib]
|
||||||
(let [lib' (ctob/ensure-tokens-lib lib)]
|
(let [lib' (ctob/ensure-tokens-lib lib)]
|
||||||
(cond
|
(cond
|
||||||
(not theme)
|
(not theme)
|
||||||
(ctob/delete-theme lib' group theme-name)
|
(ctob/delete-theme lib' id)
|
||||||
|
|
||||||
(not (ctob/get-theme lib' group theme-name))
|
(not (ctob/get-theme lib' id))
|
||||||
(ctob/add-theme lib' (ctob/make-token-theme theme))
|
(ctob/add-theme lib' (ctob/make-token-theme theme))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(ctob/update-theme lib'
|
(ctob/update-theme lib'
|
||||||
group theme-name
|
id
|
||||||
(fn [prev-token-theme]
|
(fn [prev-token-theme]
|
||||||
(ctob/make-token-theme (merge prev-token-theme theme)))))))))
|
(ctob/make-token-theme (merge prev-token-theme theme)))))))))
|
||||||
|
|
||||||
|
|||||||
@@ -987,30 +987,18 @@
|
|||||||
:token-set (datafy prev-token-set)})
|
:token-set (datafy prev-token-set)})
|
||||||
(apply-changes-local))))
|
(apply-changes-local))))
|
||||||
|
|
||||||
(defn set-token-theme [changes group theme-name theme]
|
(defn set-token-theme [changes id theme]
|
||||||
(assert-library! changes)
|
(assert-library! changes)
|
||||||
(let [library-data (::library-data (meta changes))
|
(let [library-data (::library-data (meta changes))
|
||||||
prev-theme (some-> (get library-data :tokens-lib)
|
prev-theme (some-> (get library-data :tokens-lib)
|
||||||
(ctob/get-theme group theme-name))]
|
(ctob/get-theme id))]
|
||||||
(-> changes
|
(-> changes
|
||||||
(update :redo-changes conj {:type :set-token-theme
|
(update :redo-changes conj {:type :set-token-theme
|
||||||
:theme-name theme-name
|
:id id
|
||||||
:group group
|
|
||||||
:theme theme})
|
:theme theme})
|
||||||
(update :undo-changes conj (if prev-theme
|
(update :undo-changes conj {:type :set-token-theme
|
||||||
{:type :set-token-theme
|
:id id
|
||||||
:group group
|
:theme prev-theme})
|
||||||
:theme-name (or
|
|
||||||
;; Undo of edit
|
|
||||||
(:name theme)
|
|
||||||
;; Undo of delete
|
|
||||||
theme-name)
|
|
||||||
:theme prev-theme}
|
|
||||||
;; Undo of create
|
|
||||||
{:type :set-token-theme
|
|
||||||
:group group
|
|
||||||
:theme-name theme-name
|
|
||||||
:theme nil}))
|
|
||||||
(apply-changes-local))))
|
(apply-changes-local))))
|
||||||
|
|
||||||
(defn set-active-token-themes
|
(defn set-active-token-themes
|
||||||
|
|||||||
@@ -25,8 +25,7 @@
|
|||||||
(update-theme-fn))]
|
(update-theme-fn))]
|
||||||
(-> changes
|
(-> changes
|
||||||
(pcb/set-active-token-themes #{(ctob/get-theme-path hidden-theme')})
|
(pcb/set-active-token-themes #{(ctob/get-theme-path hidden-theme')})
|
||||||
(pcb/set-token-theme (:group hidden-theme)
|
(pcb/set-token-theme (ctob/get-id hidden-theme)
|
||||||
(:name hidden-theme)
|
|
||||||
hidden-theme'))))
|
hidden-theme'))))
|
||||||
|
|
||||||
(defn generate-toggle-token-set
|
(defn generate-toggle-token-set
|
||||||
|
|||||||
@@ -544,6 +544,9 @@
|
|||||||
(theme-matches-group-name [_ group name] "if a theme matches the given group & name")
|
(theme-matches-group-name [_ group name] "if a theme matches the given group & name")
|
||||||
(hidden-theme? [_] "if a theme is the (from the user ui) hidden temporary theme"))
|
(hidden-theme? [_] "if a theme is the (from the user ui) hidden temporary theme"))
|
||||||
|
|
||||||
|
(def hidden-theme-id
|
||||||
|
uuid/zero)
|
||||||
|
|
||||||
(def hidden-theme-group
|
(def hidden-theme-group
|
||||||
"")
|
"")
|
||||||
|
|
||||||
@@ -732,20 +735,21 @@
|
|||||||
(defprotocol ITokenThemes
|
(defprotocol ITokenThemes
|
||||||
"Collection of themes in groups"
|
"Collection of themes in groups"
|
||||||
(add-theme [_ token-theme] "add a theme to the library, at the end")
|
(add-theme [_ token-theme] "add a theme to the library, at the end")
|
||||||
(update-theme [_ group name f] "modify a theme in the ilbrary")
|
(update-theme [_ id f] "modify a theme in the ilbrary")
|
||||||
(delete-theme [_ group name] "delete a theme in the library")
|
(delete-theme [_ id] "delete a theme in the library")
|
||||||
(theme-count [_] "get the total number if themes in the library")
|
(theme-count [_] "get the total number if themes in the library")
|
||||||
(get-theme-tree [_] "get a nested tree of all themes in the library")
|
(get-theme-tree [_] "get a nested tree of all themes in the library")
|
||||||
(get-themes [_] "get an ordered sequence of all themes in the library")
|
(get-themes [_] "get an ordered sequence of all themes in the library")
|
||||||
(get-theme [_ group name] "get one theme looking for name")
|
(get-theme [_ id] "get one theme looking for id")
|
||||||
|
(get-theme-by-name [_ group name] "get one theme looking for group and name")
|
||||||
(get-theme-groups [_] "get a sequence of group names by order")
|
(get-theme-groups [_] "get a sequence of group names by order")
|
||||||
(get-active-theme-paths [_] "get the active theme paths")
|
(get-active-theme-paths [_] "get the active theme paths")
|
||||||
(get-active-themes [_] "get an ordered sequence of active themes in the library")
|
(get-active-themes [_] "get an ordered sequence of active themes in the library")
|
||||||
(set-active-themes [_ active-themes] "set active themes in library")
|
(set-active-themes [_ active-themes] "set active themes in library")
|
||||||
(theme-active? [_ group name] "predicate if token theme is active")
|
(theme-active? [_ id] "predicate if token theme is active")
|
||||||
(activate-theme [_ group name] "adds theme from the active-themes")
|
(activate-theme [_ id] "adds theme from the active-themes")
|
||||||
(deactivate-theme [_ group name] "removes theme from the active-themes")
|
(deactivate-theme [_ id] "removes theme from the active-themes")
|
||||||
(toggle-theme-active? [_ group name] "toggles theme in the active-themes")
|
(toggle-theme-active? [_ id] "toggles theme in the active-themes")
|
||||||
(get-hidden-theme [_] "get the hidden temporary theme"))
|
(get-hidden-theme [_] "get the hidden temporary theme"))
|
||||||
|
|
||||||
(def schema:token-themes
|
(def schema:token-themes
|
||||||
@@ -896,7 +900,7 @@
|
|||||||
(get-token-by-name [_ set-name token-name] "get token in a set searching by set and token names")
|
(get-token-by-name [_ set-name token-name] "get token in a set searching by set and token names")
|
||||||
(update-token [_ set-id token-id f] "update a token in a set")
|
(update-token [_ set-id token-id f] "update a token in a set")
|
||||||
(delete-token [_ set-id token-id] "delete a token from a set")
|
(delete-token [_ set-id token-id] "delete a token from a set")
|
||||||
(toggle-set-in-theme [_ group-name theme-name set-name] "toggle a set used / not used in a theme")
|
(toggle-set-in-theme [_ theme-id set-name] "toggle a set used / not used in a theme")
|
||||||
(get-active-themes-set-names [_] "set of set names that are active in the the active themes")
|
(get-active-themes-set-names [_] "set of set names that are active in the the active themes")
|
||||||
(sets-at-path-all-active? [_ group-path] "compute active state for child sets at `group-path`.
|
(sets-at-path-all-active? [_ group-path] "compute active state for child sets at `group-path`.
|
||||||
Will return a value that matches this schema:
|
Will return a value that matches this schema:
|
||||||
@@ -1121,10 +1125,11 @@ Will return a value that matches this schema:
|
|||||||
(update themes (:group token-theme) d/oassoc (:name token-theme) token-theme)
|
(update themes (:group token-theme) d/oassoc (:name token-theme) token-theme)
|
||||||
active-themes)))
|
active-themes)))
|
||||||
|
|
||||||
(update-theme [this group name f]
|
(update-theme [this id f]
|
||||||
(let [theme (dm/get-in themes [group name])]
|
(if-let [theme (get-theme this id)]
|
||||||
(if theme
|
(let [group (:group theme)
|
||||||
(let [theme' (-> (make-token-theme (f theme))
|
name (:name theme)
|
||||||
|
theme' (-> (make-token-theme (f theme))
|
||||||
(assoc :modified-at (ct/now)))
|
(assoc :modified-at (ct/now)))
|
||||||
group' (:group theme')
|
group' (:group theme')
|
||||||
name' (:name theme')
|
name' (:name theme')
|
||||||
@@ -1140,12 +1145,17 @@ Will return a value that matches this schema:
|
|||||||
(if same-path?
|
(if same-path?
|
||||||
active-themes
|
active-themes
|
||||||
(disj active-themes (join-theme-path group name)))))
|
(disj active-themes (join-theme-path group name)))))
|
||||||
this)))
|
this))
|
||||||
|
|
||||||
(delete-theme [_ group name]
|
|
||||||
|
(delete-theme [this id]
|
||||||
|
(let [theme (get-theme this id)
|
||||||
|
[group name] [(:group theme) (:name theme)]]
|
||||||
|
(if theme
|
||||||
(TokensLib. sets
|
(TokensLib. sets
|
||||||
(d/dissoc-in themes [group name])
|
(d/dissoc-in themes [group name])
|
||||||
(disj active-themes (join-theme-path group name))))
|
(disj active-themes (join-theme-path group name)))
|
||||||
|
this)))
|
||||||
|
|
||||||
(get-theme-tree [_]
|
(get-theme-tree [_]
|
||||||
themes)
|
themes)
|
||||||
@@ -1163,7 +1173,11 @@ Will return a value that matches this schema:
|
|||||||
(theme-count [this]
|
(theme-count [this]
|
||||||
(count (get-themes this)))
|
(count (get-themes this)))
|
||||||
|
|
||||||
(get-theme [_ group name]
|
(get-theme [this id]
|
||||||
|
(->> (get-themes this)
|
||||||
|
(d/seek #(= (:id %) id))))
|
||||||
|
|
||||||
|
(get-theme-by-name [_ group name]
|
||||||
(dm/get-in themes [group name]))
|
(dm/get-in themes [group name]))
|
||||||
|
|
||||||
(set-active-themes [_ active-themes]
|
(set-active-themes [_ active-themes]
|
||||||
@@ -1171,9 +1185,10 @@ Will return a value that matches this schema:
|
|||||||
themes
|
themes
|
||||||
active-themes))
|
active-themes))
|
||||||
|
|
||||||
(activate-theme [this group name]
|
(activate-theme [this id]
|
||||||
(if-let [theme (get-theme this group name)]
|
(if-let [theme (get-theme this id)]
|
||||||
(let [group-themes (->> (get themes group)
|
(let [group (:group theme)
|
||||||
|
group-themes (->> (get themes group)
|
||||||
(map (comp get-theme-path val))
|
(map (comp get-theme-path val))
|
||||||
(into #{}))
|
(into #{}))
|
||||||
active-themes' (-> (set/difference active-themes group-themes)
|
active-themes' (-> (set/difference active-themes group-themes)
|
||||||
@@ -1183,18 +1198,21 @@ Will return a value that matches this schema:
|
|||||||
active-themes'))
|
active-themes'))
|
||||||
this))
|
this))
|
||||||
|
|
||||||
(deactivate-theme [_ group name]
|
(deactivate-theme [this id]
|
||||||
|
(if-let [theme (get-theme this id)]
|
||||||
(TokensLib. sets
|
(TokensLib. sets
|
||||||
themes
|
themes
|
||||||
(disj active-themes (join-theme-path group name))))
|
(disj active-themes (get-theme-path theme)))
|
||||||
|
this))
|
||||||
|
|
||||||
(theme-active? [_ group name]
|
(theme-active? [this id]
|
||||||
(contains? active-themes (join-theme-path group name)))
|
(when-let [theme (get-theme this id)]
|
||||||
|
(contains? active-themes (get-theme-path theme))))
|
||||||
|
|
||||||
(toggle-theme-active? [this group name]
|
(toggle-theme-active? [this id]
|
||||||
(if (theme-active? this group name)
|
(if (theme-active? this id)
|
||||||
(deactivate-theme this group name)
|
(deactivate-theme this id)
|
||||||
(activate-theme this group name)))
|
(activate-theme this id)))
|
||||||
|
|
||||||
(get-active-theme-paths [_]
|
(get-active-theme-paths [_]
|
||||||
active-themes)
|
active-themes)
|
||||||
@@ -1204,11 +1222,11 @@ Will return a value that matches this schema:
|
|||||||
(list)
|
(list)
|
||||||
(comp
|
(comp
|
||||||
(filter (partial instance? TokenTheme))
|
(filter (partial instance? TokenTheme))
|
||||||
(filter #(theme-active? this (:group %) (:name %))))
|
(filter #(theme-active? this (get-id %))))
|
||||||
(tree-seq d/ordered-map? vals themes)))
|
(tree-seq d/ordered-map? vals themes)))
|
||||||
|
|
||||||
(get-hidden-theme [this]
|
(get-hidden-theme [this]
|
||||||
(get-theme this hidden-theme-group hidden-theme-name))
|
(get-theme this hidden-theme-id))
|
||||||
|
|
||||||
ITokensLib
|
ITokensLib
|
||||||
(empty-lib? [this]
|
(empty-lib? [this]
|
||||||
@@ -1242,10 +1260,10 @@ Will return a value that matches this schema:
|
|||||||
(delete-token [this set-id token-id]
|
(delete-token [this set-id token-id]
|
||||||
(update-set this set-id #(delete-token- % token-id)))
|
(update-set this set-id #(delete-token- % token-id)))
|
||||||
|
|
||||||
(toggle-set-in-theme [this theme-group theme-name set-name]
|
(toggle-set-in-theme [this theme-id set-name]
|
||||||
(if-let [_theme (get-in themes theme-group theme-name)]
|
(if-let [theme (get-theme this theme-id)]
|
||||||
(TokensLib. sets
|
(TokensLib. sets
|
||||||
(d/oupdate-in themes [theme-group theme-name]
|
(d/oupdate-in themes [(:group theme) (:name theme)]
|
||||||
#(toggle-set % set-name))
|
#(toggle-set % set-name))
|
||||||
active-themes)
|
active-themes)
|
||||||
this))
|
this))
|
||||||
@@ -1643,7 +1661,7 @@ Will return a value that matches this schema:
|
|||||||
ordered-set-names)
|
ordered-set-names)
|
||||||
|
|
||||||
library
|
library
|
||||||
(update-theme library hidden-theme-group hidden-theme-name
|
(update-theme library hidden-theme-id
|
||||||
#(assoc % :sets active-set-names))
|
#(assoc % :sets active-set-names))
|
||||||
|
|
||||||
library
|
library
|
||||||
@@ -1651,8 +1669,9 @@ Will return a value that matches this schema:
|
|||||||
|
|
||||||
library
|
library
|
||||||
(reduce (fn [library theme-path]
|
(reduce (fn [library theme-path]
|
||||||
(let [[group name] (split-theme-path theme-path)]
|
(let [[group name] (split-theme-path theme-path)
|
||||||
(activate-theme library group name)))
|
theme (get-theme-by-name library group name)]
|
||||||
|
(activate-theme library (get-id theme))))
|
||||||
library
|
library
|
||||||
active-theme-names)]
|
active-theme-names)]
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
(pcb/with-library-data (:data file))
|
(pcb/with-library-data (:data file))
|
||||||
(clt/generate-toggle-token-set (tht/get-tokens-lib file) "foo/bar"))
|
(clt/generate-toggle-token-set (tht/get-tokens-lib file) "foo/bar"))
|
||||||
|
|
||||||
|
_ (prn "changes" changes)
|
||||||
redo (thf/apply-changes file changes)
|
redo (thf/apply-changes file changes)
|
||||||
redo-lib (tht/get-tokens-lib redo)
|
redo-lib (tht/get-tokens-lib redo)
|
||||||
undo (thf/apply-undo-changes redo changes)
|
undo (thf/apply-undo-changes redo changes)
|
||||||
@@ -84,84 +85,85 @@
|
|||||||
|
|
||||||
(t/deftest set-token-theme-test
|
(t/deftest set-token-theme-test
|
||||||
(t/testing "delete token theme"
|
(t/testing "delete token theme"
|
||||||
(let [theme-name "foo"
|
(let [theme-id (uuid/next)
|
||||||
group "main"
|
|
||||||
file (setup-file #(-> %
|
file (setup-file #(-> %
|
||||||
(ctob/add-theme (ctob/make-token-theme :name theme-name
|
(ctob/add-theme (ctob/make-token-theme :id theme-id
|
||||||
:group group))))
|
:name "foo"
|
||||||
|
:group "main"))))
|
||||||
changes (-> (pcb/empty-changes)
|
changes (-> (pcb/empty-changes)
|
||||||
(pcb/with-library-data (:data file))
|
(pcb/with-library-data (:data file))
|
||||||
(pcb/set-token-theme group theme-name nil))
|
(pcb/set-token-theme theme-id nil))
|
||||||
|
|
||||||
redo (thf/apply-changes file changes)
|
redo (thf/apply-changes file changes)
|
||||||
redo-lib (tht/get-tokens-lib redo)
|
redo-lib (tht/get-tokens-lib redo)
|
||||||
undo (thf/apply-undo-changes redo changes)
|
undo (thf/apply-undo-changes redo changes)
|
||||||
undo-lib (tht/get-tokens-lib undo)]
|
undo-lib (tht/get-tokens-lib undo)]
|
||||||
;; Redo
|
;; Redo
|
||||||
(t/is (nil? (ctob/get-theme redo-lib group theme-name)))
|
(t/is (nil? (ctob/get-theme redo-lib theme-id)))
|
||||||
;; Undo
|
;; Undo
|
||||||
(t/is (some? (ctob/get-theme undo-lib group theme-name)))))
|
(t/is (some? (ctob/get-theme undo-lib theme-id)))))
|
||||||
|
|
||||||
(t/testing "add token theme"
|
(t/testing "add token theme"
|
||||||
(let [theme-name "foo"
|
(let [theme-id (uuid/next)
|
||||||
group "main"
|
theme (ctob/make-token-theme :id theme-id
|
||||||
theme (ctob/make-token-theme :name theme-name
|
:name "foo"
|
||||||
:group group)
|
:group "main")
|
||||||
file (setup-file identity)
|
file (setup-file identity)
|
||||||
changes (-> (pcb/empty-changes)
|
changes (-> (pcb/empty-changes)
|
||||||
(pcb/with-library-data (:data file))
|
(pcb/with-library-data (:data file))
|
||||||
(pcb/set-token-theme group theme-name theme))
|
(pcb/set-token-theme theme-id theme))
|
||||||
redo (thf/apply-changes file changes)
|
redo (thf/apply-changes file changes)
|
||||||
redo-lib (tht/get-tokens-lib redo)
|
redo-lib (tht/get-tokens-lib redo)
|
||||||
undo (thf/apply-undo-changes redo changes)
|
undo (thf/apply-undo-changes redo changes)
|
||||||
undo-lib (tht/get-tokens-lib undo)]
|
undo-lib (tht/get-tokens-lib undo)]
|
||||||
;; Redo
|
;; Redo
|
||||||
(t/is (some? (ctob/get-theme redo-lib group theme-name)))
|
(t/is (some? (ctob/get-theme redo-lib theme-id)))
|
||||||
;; Undo
|
;; Undo
|
||||||
(t/is (nil? (ctob/get-theme undo-lib group theme-name)))))
|
(t/is (nil? (ctob/get-theme undo-lib theme-id)))))
|
||||||
|
|
||||||
(t/testing "update token theme"
|
(t/testing "update token theme"
|
||||||
(let [theme-name "foo"
|
(let [theme-id (uuid/next)
|
||||||
group "main"
|
prev-theme-name "foo"
|
||||||
prev-theme (ctob/make-token-theme :name theme-name
|
prev-theme (ctob/make-token-theme :id theme-id
|
||||||
:group group)
|
:name prev-theme-name
|
||||||
|
:group "main")
|
||||||
file (setup-file #(ctob/add-theme % prev-theme))
|
file (setup-file #(ctob/add-theme % prev-theme))
|
||||||
new-theme-name "foo1"
|
new-theme-name "foo1"
|
||||||
changes (-> (pcb/empty-changes)
|
changes (-> (pcb/empty-changes)
|
||||||
(pcb/with-library-data (:data file))
|
(pcb/with-library-data (:data file))
|
||||||
(pcb/set-token-theme group new-theme-name prev-theme))
|
(pcb/set-token-theme theme-id (ctob/rename prev-theme new-theme-name)))
|
||||||
redo (thf/apply-changes file changes)
|
redo (thf/apply-changes file changes)
|
||||||
redo-lib (tht/get-tokens-lib redo)
|
redo-lib (tht/get-tokens-lib redo)
|
||||||
|
redo-theme (ctob/get-theme redo-lib theme-id)
|
||||||
undo (thf/apply-undo-changes redo changes)
|
undo (thf/apply-undo-changes redo changes)
|
||||||
undo-lib (tht/get-tokens-lib undo)]
|
undo-lib (tht/get-tokens-lib undo)
|
||||||
|
undo-theme (ctob/get-theme undo-lib theme-id)]
|
||||||
;; Redo
|
;; Redo
|
||||||
(t/is (some? (ctob/get-theme redo-lib group theme-name)))
|
(t/is (= new-theme-name (ctob/get-name redo-theme)))
|
||||||
(t/is (nil? (ctob/get-theme redo-lib group new-theme-name)))
|
|
||||||
;; Undo
|
;; Undo
|
||||||
(t/is (some? (ctob/get-theme undo-lib group theme-name)))
|
(t/is (= prev-theme-name (ctob/get-name undo-theme)))))
|
||||||
(t/is (nil? (ctob/get-theme undo-lib group new-theme-name)))))
|
|
||||||
|
|
||||||
(t/testing "toggling token theme updates using changes history"
|
(t/testing "toggling token theme updates using changes history"
|
||||||
(let [theme-name "foo-theme"
|
(let [theme-id (uuid/next)
|
||||||
group "main"
|
theme (ctob/make-token-theme :id theme-id
|
||||||
|
:name "foo-theme"
|
||||||
|
:group "main")
|
||||||
set-name "bar-set"
|
set-name "bar-set"
|
||||||
token-set (ctob/make-token-set :name set-name)
|
token-set (ctob/make-token-set :name set-name)
|
||||||
theme (ctob/make-token-theme :name theme-name
|
|
||||||
:group group)
|
|
||||||
file (setup-file #(-> %
|
file (setup-file #(-> %
|
||||||
(ctob/add-theme theme)
|
(ctob/add-theme theme)
|
||||||
(ctob/add-set token-set)))
|
(ctob/add-set token-set)))
|
||||||
theme' (assoc theme :sets #{set-name})
|
theme' (assoc theme :sets #{set-name})
|
||||||
changes (-> (pcb/empty-changes)
|
changes (-> (pcb/empty-changes)
|
||||||
(pcb/with-library-data (:data file))
|
(pcb/with-library-data (:data file))
|
||||||
(pcb/set-token-theme group theme-name theme'))
|
(pcb/set-token-theme theme-id theme'))
|
||||||
changed-file (-> file
|
changed-file (-> file
|
||||||
(thf/apply-changes changes)
|
(thf/apply-changes changes)
|
||||||
(thf/apply-undo-changes changes)
|
(thf/apply-undo-changes changes)
|
||||||
(thf/apply-changes changes))
|
(thf/apply-changes changes))
|
||||||
changed-lib (tht/get-tokens-lib changed-file)]
|
changed-lib (tht/get-tokens-lib changed-file)]
|
||||||
(t/is (= #{set-name}
|
(t/is (= #{set-name}
|
||||||
(-> changed-lib (ctob/get-theme group theme-name) :sets))))))
|
(-> changed-lib (ctob/get-theme theme-id) :sets))))))
|
||||||
|
|
||||||
(t/deftest set-token-test
|
(t/deftest set-token-test
|
||||||
(t/testing "delete token"
|
(t/testing "delete token"
|
||||||
|
|||||||
@@ -146,13 +146,15 @@
|
|||||||
(t/is (= ["a/a" "a/b" "b/a" "b/b"] (move ["a" "b"] ["a" "b"] nil true))))))
|
(t/is (= ["a/a" "a/b" "b/a" "b/b"] (move ["a" "b"] ["a" "b"] nil true))))))
|
||||||
|
|
||||||
(t/deftest move-token-set-nested-3
|
(t/deftest move-token-set-nested-3
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [theme-id (uuid/next)
|
||||||
|
tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
(ctob/add-set (ctob/make-token-set :name "Foo/Bar/Baz"))
|
(ctob/add-set (ctob/make-token-set :name "Foo/Bar/Baz"))
|
||||||
(ctob/add-set (ctob/make-token-set :name "Other"))
|
(ctob/add-set (ctob/make-token-set :name "Other"))
|
||||||
(ctob/add-theme (ctob/make-token-theme :name "Theme"
|
(ctob/add-theme (ctob/make-token-theme :id theme-id
|
||||||
|
:name "Theme"
|
||||||
:sets #{"Foo/Bar/Baz"}))
|
:sets #{"Foo/Bar/Baz"}))
|
||||||
(ctob/move-set ["Foo" "Bar" "Baz"] ["Other/Baz"] nil nil))]
|
(ctob/move-set ["Foo" "Bar" "Baz"] ["Other/Baz"] nil nil))]
|
||||||
(t/is (= #{"Other/Baz"} (:sets (ctob/get-theme tokens-lib "" "Theme"))))))
|
(t/is (= #{"Other/Baz"} (:sets (ctob/get-theme tokens-lib theme-id))))))
|
||||||
|
|
||||||
(t/deftest move-token-set-group
|
(t/deftest move-token-set-group
|
||||||
(t/testing "reordering"
|
(t/testing "reordering"
|
||||||
@@ -170,14 +172,16 @@
|
|||||||
(t/is (= ["Bar/Foo" "Foo/A" "Foo/B"] (move ["Bar"] ["Bar"] ["Foo"] true)))))
|
(t/is (= ["Bar/Foo" "Foo/A" "Foo/B"] (move ["Bar"] ["Bar"] ["Foo"] true)))))
|
||||||
|
|
||||||
(t/testing "updates theme set names"
|
(t/testing "updates theme set names"
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [theme-id (uuid/next)
|
||||||
|
tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
(ctob/add-set (ctob/make-token-set :name "Foo/A"))
|
(ctob/add-set (ctob/make-token-set :name "Foo/A"))
|
||||||
(ctob/add-set (ctob/make-token-set :name "Foo/B"))
|
(ctob/add-set (ctob/make-token-set :name "Foo/B"))
|
||||||
(ctob/add-set (ctob/make-token-set :name "Bar/Foo"))
|
(ctob/add-set (ctob/make-token-set :name "Bar/Foo"))
|
||||||
(ctob/add-theme (ctob/make-token-theme :name "Theme"
|
(ctob/add-theme (ctob/make-token-theme :id theme-id
|
||||||
|
:name "Theme"
|
||||||
:sets #{"Foo/A" "Bar/Foo"}))
|
:sets #{"Foo/A" "Bar/Foo"}))
|
||||||
(ctob/move-set-group ["Foo"] ["Bar" "Foo"] nil nil))]
|
(ctob/move-set-group ["Foo"] ["Bar" "Foo"] nil nil))]
|
||||||
(t/is (= #{"Bar/Foo/A" "Bar/Foo"} (:sets (ctob/get-theme tokens-lib "" "Theme")))))))
|
(t/is (= #{"Bar/Foo/A" "Bar/Foo"} (:sets (ctob/get-theme tokens-lib theme-id)))))))
|
||||||
|
|
||||||
(t/deftest tokens-tree
|
(t/deftest tokens-tree
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
@@ -292,16 +296,17 @@
|
|||||||
(t/is (ct/is-after? (ctob/get-modified-at token-set') (ctob/get-modified-at token-set)))))
|
(t/is (ct/is-after? (ctob/get-modified-at token-set') (ctob/get-modified-at token-set)))))
|
||||||
|
|
||||||
(t/deftest rename-token-set-group
|
(t/deftest rename-token-set-group
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [theme-id (uuid/next)
|
||||||
|
tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
(ctob/add-set (ctob/make-token-set :name "foo/bar/baz"))
|
(ctob/add-set (ctob/make-token-set :name "foo/bar/baz"))
|
||||||
(ctob/add-set (ctob/make-token-set :name "foo/bar/baz/baz-child-1"))
|
(ctob/add-set (ctob/make-token-set :name "foo/bar/baz/baz-child-1"))
|
||||||
(ctob/add-set (ctob/make-token-set :name "foo/bar/baz/baz-child-2"))
|
(ctob/add-set (ctob/make-token-set :name "foo/bar/baz/baz-child-2"))
|
||||||
(ctob/add-theme (ctob/make-token-theme :name "theme" :sets #{"foo/bar/baz/baz-child-1"})))
|
(ctob/add-theme (ctob/make-token-theme :id theme-id :name "theme" :sets #{"foo/bar/baz/baz-child-1"})))
|
||||||
tokens-lib' (-> tokens-lib
|
tokens-lib' (-> tokens-lib
|
||||||
(ctob/rename-set-group ["foo" "bar"] "bar-renamed")
|
(ctob/rename-set-group ["foo" "bar"] "bar-renamed")
|
||||||
(ctob/rename-set-group ["foo" "bar-renamed" "baz"] "baz-renamed"))
|
(ctob/rename-set-group ["foo" "bar-renamed" "baz"] "baz-renamed"))
|
||||||
expected-set-names (ctob/get-set-names tokens-lib')
|
expected-set-names (ctob/get-set-names tokens-lib')
|
||||||
expected-theme-sets (-> (ctob/get-theme tokens-lib' "" "theme")
|
expected-theme-sets (-> (ctob/get-theme tokens-lib' theme-id)
|
||||||
:sets)]
|
:sets)]
|
||||||
(t/is (= expected-set-names
|
(t/is (= expected-set-names
|
||||||
'("foo/bar-renamed/baz"
|
'("foo/bar-renamed/baz"
|
||||||
@@ -558,7 +563,7 @@
|
|||||||
(ctob/make-token :name "token-4"
|
(ctob/make-token :name "token-4"
|
||||||
:type :border-radius
|
:type :border-radius
|
||||||
:value 4000)}))
|
:value 4000)}))
|
||||||
(ctob/update-theme ctob/hidden-theme-group ctob/hidden-theme-name
|
(ctob/update-theme ctob/hidden-theme-id
|
||||||
#(ctob/enable-sets % #{"set-a" "set-b"})))
|
#(ctob/enable-sets % #{"set-a" "set-b"})))
|
||||||
|
|
||||||
tokens (ctob/get-tokens-in-active-sets tokens-lib)]
|
tokens (ctob/get-tokens-in-active-sets tokens-lib)]
|
||||||
@@ -760,33 +765,36 @@
|
|||||||
(t/is (= :none expected-invalid-none))))
|
(t/is (= :none expected-invalid-none))))
|
||||||
|
|
||||||
(t/deftest add-token-theme
|
(t/deftest add-token-theme
|
||||||
(let [tokens-lib (ctob/make-tokens-lib)
|
(let [theme-id (uuid/next)
|
||||||
token-theme (ctob/make-token-theme :name "test-token-theme")
|
tokens-lib (ctob/make-tokens-lib)
|
||||||
|
token-theme (ctob/make-token-theme :id theme-id :name "test-token-theme")
|
||||||
tokens-lib' (ctob/add-theme tokens-lib token-theme)
|
tokens-lib' (ctob/add-theme tokens-lib token-theme)
|
||||||
|
|
||||||
token-themes' (ctob/get-themes tokens-lib')
|
token-themes' (ctob/get-themes tokens-lib')
|
||||||
token-theme' (ctob/get-theme tokens-lib' "" "test-token-theme")]
|
token-theme' (ctob/get-theme tokens-lib' theme-id)]
|
||||||
|
|
||||||
(t/is (= (ctob/theme-count tokens-lib') 2))
|
(t/is (= (ctob/theme-count tokens-lib') 2))
|
||||||
(t/is (= (second token-themes') token-theme))
|
(t/is (= (second token-themes') token-theme))
|
||||||
(t/is (= token-theme' token-theme))))
|
(t/is (= token-theme' token-theme))))
|
||||||
|
|
||||||
(t/deftest update-token-theme
|
(t/deftest update-token-theme
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [theme-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :name "test-token-theme")))
|
tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-id
|
||||||
|
:name "test-token-theme")))
|
||||||
|
|
||||||
tokens-lib' (-> tokens-lib
|
tokens-lib' (-> tokens-lib
|
||||||
(ctob/update-theme "" "test-token-theme"
|
(ctob/update-theme theme-id
|
||||||
(fn [token-theme]
|
(fn [token-theme]
|
||||||
(assoc token-theme
|
(assoc token-theme
|
||||||
:description "some description")))
|
:description "some description")))
|
||||||
(ctob/update-theme "" "not-existing-theme"
|
(ctob/update-theme (uuid/next)
|
||||||
(fn [token-theme]
|
(fn [token-theme]
|
||||||
(assoc token-theme
|
(assoc token-theme
|
||||||
:description "no-effect"))))
|
:description "no-effect"))))
|
||||||
|
|
||||||
token-theme (ctob/get-theme tokens-lib "" "test-token-theme")
|
token-theme (ctob/get-theme tokens-lib theme-id)
|
||||||
token-theme' (ctob/get-theme tokens-lib' "" "test-token-theme")]
|
token-theme' (ctob/get-theme tokens-lib' theme-id)]
|
||||||
|
|
||||||
(t/is (= (ctob/theme-count tokens-lib') 2))
|
(t/is (= (ctob/theme-count tokens-lib') 2))
|
||||||
(t/is (= (:name token-theme') "test-token-theme"))
|
(t/is (= (:name token-theme') "test-token-theme"))
|
||||||
@@ -794,49 +802,55 @@
|
|||||||
(t/is (ct/is-after? (:modified-at token-theme') (:modified-at token-theme)))))
|
(t/is (ct/is-after? (:modified-at token-theme') (:modified-at token-theme)))))
|
||||||
|
|
||||||
(t/deftest rename-token-theme
|
(t/deftest rename-token-theme
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [theme-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :name "test-token-theme")))
|
tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-id
|
||||||
|
:name "test-token-theme")))
|
||||||
|
|
||||||
tokens-lib' (-> tokens-lib
|
tokens-lib' (-> tokens-lib
|
||||||
(ctob/update-theme "" "test-token-theme"
|
(ctob/update-theme theme-id
|
||||||
(fn [token-theme]
|
(fn [token-theme]
|
||||||
(assoc token-theme
|
(assoc token-theme
|
||||||
:name "updated-name"))))
|
:name "updated-name"))))
|
||||||
|
|
||||||
token-theme (ctob/get-theme tokens-lib "" "test-token-theme")
|
token-theme (ctob/get-theme tokens-lib theme-id)
|
||||||
token-theme' (ctob/get-theme tokens-lib' "" "updated-name")]
|
token-theme' (ctob/get-theme tokens-lib' theme-id)]
|
||||||
|
|
||||||
(t/is (= (ctob/theme-count tokens-lib') 2))
|
(t/is (= (ctob/theme-count tokens-lib') 2))
|
||||||
(t/is (= (:name token-theme') "updated-name"))
|
(t/is (= (:name token-theme') "updated-name"))
|
||||||
(t/is (ct/is-after? (:modified-at token-theme') (:modified-at token-theme)))))
|
(t/is (ct/is-after? (:modified-at token-theme') (:modified-at token-theme)))))
|
||||||
|
|
||||||
(t/deftest delete-token-theme
|
(t/deftest delete-token-theme
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [theme-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :name "test-token-theme")))
|
tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-id
|
||||||
|
:name "test-token-theme")))
|
||||||
tokens-lib' (-> tokens-lib
|
tokens-lib' (-> tokens-lib
|
||||||
(ctob/delete-theme "" "test-token-theme")
|
(ctob/delete-theme theme-id)
|
||||||
(ctob/delete-theme "" "not-existing-theme"))
|
(ctob/delete-theme (uuid/next)))
|
||||||
|
|
||||||
token-theme' (ctob/get-theme tokens-lib' "" "updated-name")]
|
token-theme' (ctob/get-theme tokens-lib' theme-id)]
|
||||||
|
|
||||||
(t/is (= (ctob/theme-count tokens-lib') 1))
|
(t/is (= (ctob/theme-count tokens-lib') 1))
|
||||||
(t/is (nil? token-theme'))))
|
(t/is (nil? token-theme'))))
|
||||||
|
|
||||||
(t/deftest toggle-set-in-theme
|
(t/deftest toggle-set-in-theme
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [theme-id (uuid/next)
|
||||||
|
tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
(ctob/add-set (ctob/make-token-set :name "token-set-1"))
|
(ctob/add-set (ctob/make-token-set :name "token-set-1"))
|
||||||
(ctob/add-set (ctob/make-token-set :name "token-set-2"))
|
(ctob/add-set (ctob/make-token-set :name "token-set-2"))
|
||||||
(ctob/add-set (ctob/make-token-set :name "token-set-3"))
|
(ctob/add-set (ctob/make-token-set :name "token-set-3"))
|
||||||
(ctob/add-theme (ctob/make-token-theme :name "test-token-theme")))
|
(ctob/add-theme (ctob/make-token-theme :id theme-id
|
||||||
|
:name "test-token-theme"
|
||||||
|
:sets #{"token-set-1" "token-set-2"})))
|
||||||
tokens-lib' (-> tokens-lib
|
tokens-lib' (-> tokens-lib
|
||||||
(ctob/toggle-set-in-theme "" "test-token-theme" "token-set-1")
|
(ctob/toggle-set-in-theme theme-id "token-set-1")
|
||||||
(ctob/toggle-set-in-theme "" "test-token-theme" "token-set-2")
|
(ctob/toggle-set-in-theme theme-id "token-set-3"))
|
||||||
(ctob/toggle-set-in-theme "" "test-token-theme" "token-set-2"))
|
|
||||||
|
|
||||||
token-theme (ctob/get-theme tokens-lib "" "test-token-theme")
|
token-theme (ctob/get-theme tokens-lib theme-id)
|
||||||
token-theme' (ctob/get-theme tokens-lib' "" "test-token-theme")]
|
token-theme' (ctob/get-theme tokens-lib' theme-id)]
|
||||||
|
|
||||||
|
(t/is (= (:sets token-theme') #{"token-set-2" "token-set-3"}))
|
||||||
(t/is (ct/is-after? (:modified-at token-theme') (:modified-at token-theme)))))
|
(t/is (ct/is-after? (:modified-at token-theme') (:modified-at token-theme)))))
|
||||||
|
|
||||||
(t/deftest transit-serialization
|
(t/deftest transit-serialization
|
||||||
@@ -846,8 +860,9 @@
|
|||||||
(ctob/make-token :name "test-token"
|
(ctob/make-token :name "test-token"
|
||||||
:type :boolean
|
:type :boolean
|
||||||
:value true))
|
:value true))
|
||||||
(ctob/add-theme (ctob/make-token-theme :name "test-token-theme"))
|
(ctob/add-theme (ctob/make-token-theme :id (thi/new-id! :test-token-theme)
|
||||||
(ctob/toggle-set-in-theme "" "test-token-theme" "test-token-set"))
|
:name "test-token-theme"))
|
||||||
|
(ctob/toggle-set-in-theme (thi/id :test-token-theme) "test-token-set"))
|
||||||
encoded-str (tr/encode-str tokens-lib)
|
encoded-str (tr/encode-str tokens-lib)
|
||||||
tokens-lib' (tr/decode-str encoded-str)]
|
tokens-lib' (tr/decode-str encoded-str)]
|
||||||
|
|
||||||
@@ -864,8 +879,9 @@
|
|||||||
(ctob/make-token :name "test-token"
|
(ctob/make-token :name "test-token"
|
||||||
:type :boolean
|
:type :boolean
|
||||||
:value true))
|
:value true))
|
||||||
(ctob/add-theme (ctob/make-token-theme :name "test-token-theme"))
|
(ctob/add-theme (ctob/make-token-theme :id (thi/new-id! :test-token-theme)
|
||||||
(ctob/toggle-set-in-theme "" "test-token-theme" "test-token-set"))
|
:name "test-token-theme"))
|
||||||
|
(ctob/toggle-set-in-theme (thi/id :test-token-theme) "test-token-set"))
|
||||||
encoded-blob (fres/encode tokens-lib)
|
encoded-blob (fres/encode tokens-lib)
|
||||||
tokens-lib' (fres/decode encoded-blob)]
|
tokens-lib' (fres/decode encoded-blob)]
|
||||||
|
|
||||||
@@ -1180,14 +1196,18 @@
|
|||||||
(t/is (nil? token-set'))))
|
(t/is (nil? token-set'))))
|
||||||
|
|
||||||
(t/deftest update-token-theme-in-groups
|
(t/deftest update-token-theme-in-groups
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [theme-1-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "" :name "token-theme-1"))
|
theme-2-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "group1" :name "token-theme-2"))
|
theme-3-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "group1" :name "token-theme-3"))
|
theme-4-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "group2" :name "token-theme-4")))
|
tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-1-id :group "" :name "token-theme-1"))
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-2-id :group "group1" :name "token-theme-2"))
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-3-id :group "group1" :name "token-theme-3"))
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-4-id :group "group2" :name "token-theme-4")))
|
||||||
|
|
||||||
tokens-lib' (-> tokens-lib
|
tokens-lib' (-> tokens-lib
|
||||||
(ctob/update-theme "group1" "token-theme-2"
|
(ctob/update-theme theme-2-id
|
||||||
(fn [token-theme]
|
(fn [token-theme]
|
||||||
(assoc token-theme :description "some description"))))
|
(assoc token-theme :description "some description"))))
|
||||||
|
|
||||||
@@ -1215,15 +1235,18 @@
|
|||||||
(t/is (= token-groups ["group1" "group2"]))))
|
(t/is (= token-groups ["group1" "group2"]))))
|
||||||
|
|
||||||
(t/deftest rename-token-theme-in-groups
|
(t/deftest rename-token-theme-in-groups
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [theme-1-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "" :name "token-theme-1"))
|
theme-2-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "group1" :name "token-theme-2"))
|
theme-3-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "group1" :name "token-theme-3"))
|
theme-4-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "group2" :name "token-theme-4")))
|
tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-1-id :group "" :name "token-theme-1"))
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-2-id :group "group1" :name "token-theme-2"))
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-3-id :group "group1" :name "token-theme-3"))
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-4-id :group "group2" :name "token-theme-4")))
|
||||||
|
|
||||||
tokens-lib' (-> tokens-lib
|
tokens-lib' (-> tokens-lib
|
||||||
(ctob/update-theme "group1" "token-theme-2"
|
(ctob/update-theme theme-2-id
|
||||||
(fn [token-theme]
|
(fn [token-theme]
|
||||||
(assoc token-theme
|
(assoc token-theme
|
||||||
:name "updated-name"))))
|
:name "updated-name"))))
|
||||||
@@ -1243,14 +1266,18 @@
|
|||||||
(t/is (ct/is-after? (:modified-at token-theme') (:modified-at token-theme)))))
|
(t/is (ct/is-after? (:modified-at token-theme') (:modified-at token-theme)))))
|
||||||
|
|
||||||
(t/deftest move-token-theme-of-group
|
(t/deftest move-token-theme-of-group
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [theme-1-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "" :name "token-theme-1"))
|
theme-2-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "group1" :name "token-theme-2"))
|
theme-3-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "group1" :name "token-theme-3"))
|
theme-4-id (uuid/next)
|
||||||
#_(ctob/add-theme (ctob/make-token-theme :group "group2" :name "token-theme-4")))
|
tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-1-id :group "" :name "token-theme-1"))
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-2-id :group "group1" :name "token-theme-2"))
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-3-id :group "group1" :name "token-theme-3"))
|
||||||
|
#_(ctob/add-theme (ctob/make-token-theme :in-theme-4-id :group "group2" :name "token-theme-4")))
|
||||||
|
|
||||||
tokens-lib' (-> tokens-lib
|
tokens-lib' (-> tokens-lib
|
||||||
(ctob/update-theme "group1" "token-theme-2"
|
(ctob/update-theme theme-2-id
|
||||||
(fn [token-theme]
|
(fn [token-theme]
|
||||||
(assoc token-theme
|
(assoc token-theme
|
||||||
:name "updated-name"
|
:name "updated-name"
|
||||||
@@ -1273,12 +1300,14 @@
|
|||||||
(t/is (ct/is-after? (:modified-at token-theme') (:modified-at token-theme)))))
|
(t/is (ct/is-after? (:modified-at token-theme') (:modified-at token-theme)))))
|
||||||
|
|
||||||
(t/deftest delete-token-theme-in-group
|
(t/deftest delete-token-theme-in-group
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [theme-1-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "" :name "token-theme-1"))
|
theme-2-id (uuid/next)
|
||||||
(ctob/add-theme (ctob/make-token-theme :group "group1" :name "token-theme-2")))
|
tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-1-id :group "" :name "token-theme-1"))
|
||||||
|
(ctob/add-theme (ctob/make-token-theme :id theme-2-id :group "group1" :name "token-theme-2")))
|
||||||
|
|
||||||
tokens-lib' (-> tokens-lib
|
tokens-lib' (-> tokens-lib
|
||||||
(ctob/delete-theme "group1" "token-theme-2"))
|
(ctob/delete-theme theme-2-id))
|
||||||
|
|
||||||
themes-tree' (ctob/get-theme-tree tokens-lib')
|
themes-tree' (ctob/get-theme-tree tokens-lib')
|
||||||
token-theme' (get-in themes-tree' ["group1" "token-theme-2"])]
|
token-theme' (get-in themes-tree' ["group1" "token-theme-2"])]
|
||||||
@@ -1310,7 +1339,7 @@
|
|||||||
(let [json (-> (slurp "test/common_tests/types/data/tokens-multi-set-legacy-example.json")
|
(let [json (-> (slurp "test/common_tests/types/data/tokens-multi-set-legacy-example.json")
|
||||||
(json/decode {:key-fn identity}))
|
(json/decode {:key-fn identity}))
|
||||||
lib (ctob/parse-decoded-json json "")
|
lib (ctob/parse-decoded-json json "")
|
||||||
token-theme (ctob/get-theme lib "group-1" "theme-1")]
|
token-theme (ctob/get-theme-by-name lib "group-1" "theme-1")]
|
||||||
(t/is (= '("core" "light" "dark" "theme") (ctob/get-set-names lib)))
|
(t/is (= '("core" "light" "dark" "theme") (ctob/get-set-names lib)))
|
||||||
(t/testing "set exists in theme"
|
(t/testing "set exists in theme"
|
||||||
(t/is (= (:group token-theme) "group-1"))
|
(t/is (= (:group token-theme) "group-1"))
|
||||||
@@ -1340,7 +1369,7 @@
|
|||||||
(let [json (-> (slurp "test/common_tests/types/data/tokens-multi-set-example.json")
|
(let [json (-> (slurp "test/common_tests/types/data/tokens-multi-set-example.json")
|
||||||
(json/decode {:key-fn identity}))
|
(json/decode {:key-fn identity}))
|
||||||
lib (ctob/parse-decoded-json json "")
|
lib (ctob/parse-decoded-json json "")
|
||||||
token-theme (ctob/get-theme lib "group-1" "theme-1")]
|
token-theme (ctob/get-theme-by-name lib "group-1" "theme-1")]
|
||||||
(t/is (= '("core" "light" "dark" "theme") (ctob/get-set-names lib)))
|
(t/is (= '("core" "light" "dark" "theme") (ctob/get-set-names lib)))
|
||||||
(t/testing "set exists in theme"
|
(t/testing "set exists in theme"
|
||||||
(t/is (= (:group token-theme) "group-1"))
|
(t/is (= (:group token-theme) "group-1"))
|
||||||
@@ -1525,12 +1554,13 @@
|
|||||||
{:name "button.primary.background"
|
{:name "button.primary.background"
|
||||||
:type :color
|
:type :color
|
||||||
:value "{accent.default}"})}))
|
:value "{accent.default}"})}))
|
||||||
(ctob/add-theme (ctob/make-token-theme :name "theme-1"
|
(ctob/add-theme (ctob/make-token-theme :id (thi/new-id! :theme-1)
|
||||||
|
:name "theme-1"
|
||||||
:group "group-1"
|
:group "group-1"
|
||||||
:external-id "test-id-01"
|
:external-id "test-id-01"
|
||||||
:modified-at now
|
:modified-at now
|
||||||
:sets #{"core"}))
|
:sets #{"core"}))
|
||||||
(ctob/toggle-theme-active? "group-1" "theme-1"))
|
(ctob/toggle-theme-active? (thi/id :theme-1)))
|
||||||
result (ctob/export-dtcg-json tokens-lib)
|
result (ctob/export-dtcg-json tokens-lib)
|
||||||
expected {"$themes" [{"description" ""
|
expected {"$themes" [{"description" ""
|
||||||
"group" "group-1"
|
"group" "group-1"
|
||||||
@@ -1578,12 +1608,13 @@
|
|||||||
{:name "button.primary.background"
|
{:name "button.primary.background"
|
||||||
:type :color
|
:type :color
|
||||||
:value "{accent.default}"})}))
|
:value "{accent.default}"})}))
|
||||||
(ctob/add-theme (ctob/make-token-theme :name "theme-1"
|
(ctob/add-theme (ctob/make-token-theme :id (thi/new-id! :theme-1)
|
||||||
|
:name "theme-1"
|
||||||
:group "group-1"
|
:group "group-1"
|
||||||
:external-id "test-id-01"
|
:external-id "test-id-01"
|
||||||
:modified-at now
|
:modified-at now
|
||||||
:sets #{"some/set"}))
|
:sets #{"some/set"}))
|
||||||
(ctob/toggle-theme-active? "group-1" "theme-1"))
|
(ctob/toggle-theme-active? (thi/id :theme-1)))
|
||||||
result (ctob/export-dtcg-multi-file tokens-lib)
|
result (ctob/export-dtcg-multi-file tokens-lib)
|
||||||
expected {"$themes.json" [{"description" ""
|
expected {"$themes.json" [{"description" ""
|
||||||
"group" "group-1"
|
"group" "group-1"
|
||||||
|
|||||||
@@ -73,39 +73,35 @@
|
|||||||
(let [data (dsh/lookup-file-data state)
|
(let [data (dsh/lookup-file-data state)
|
||||||
tokens-lib (get data :tokens-lib)]
|
tokens-lib (get data :tokens-lib)]
|
||||||
|
|
||||||
(if (and tokens-lib (ctob/get-theme tokens-lib (:group token-theme) (:name token-theme)))
|
(if (and tokens-lib (ctob/get-theme tokens-lib (ctob/get-id token-theme)))
|
||||||
(rx/of (ntf/show {:content (tr "errors.token-theme-already-exists")
|
(rx/of (ntf/show {:content (tr "errors.token-theme-already-exists")
|
||||||
:type :toast
|
:type :toast
|
||||||
:level :error
|
:level :error
|
||||||
:timeout 9000}))
|
:timeout 9000}))
|
||||||
(let [changes (-> (pcb/empty-changes it)
|
(let [changes (-> (pcb/empty-changes it)
|
||||||
(pcb/with-library-data data)
|
(pcb/with-library-data data)
|
||||||
(pcb/set-token-theme (:group new-token-theme)
|
(pcb/set-token-theme (ctob/get-id new-token-theme)
|
||||||
(:name new-token-theme)
|
|
||||||
new-token-theme))]
|
new-token-theme))]
|
||||||
(rx/of (dch/commit-changes changes)))))))))
|
(rx/of (dch/commit-changes changes)))))))))
|
||||||
|
|
||||||
(defn update-token-theme [[group name] token-theme]
|
(defn update-token-theme [id token-theme]
|
||||||
(ptk/reify ::update-token-theme
|
(ptk/reify ::update-token-theme
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [data (dsh/lookup-file-data state)
|
(let [data (dsh/lookup-file-data state)
|
||||||
tokens-lib (get data :tokens-lib)]
|
tokens-lib (get data :tokens-lib)]
|
||||||
(if (and (or (not= group (:group token-theme))
|
(if (and (not= id (ctob/get-id token-theme))
|
||||||
(not= name (:name token-theme)))
|
(ctob/get-theme tokens-lib (ctob/get-id token-theme)))
|
||||||
(ctob/get-theme tokens-lib
|
|
||||||
(:group token-theme)
|
|
||||||
(:name token-theme)))
|
|
||||||
(rx/of (ntf/show {:content (tr "errors.token-theme-already-exists")
|
(rx/of (ntf/show {:content (tr "errors.token-theme-already-exists")
|
||||||
:type :toast
|
:type :toast
|
||||||
:level :error
|
:level :error
|
||||||
:timeout 9000}))
|
:timeout 9000}))
|
||||||
(let [changes (-> (pcb/empty-changes it)
|
(let [changes (-> (pcb/empty-changes it)
|
||||||
(pcb/with-library-data data)
|
(pcb/with-library-data data)
|
||||||
(pcb/set-token-theme group name token-theme))]
|
(pcb/set-token-theme (ctob/get-id token-theme) token-theme))]
|
||||||
(rx/of (dch/commit-changes changes))))))))
|
(rx/of (dch/commit-changes changes))))))))
|
||||||
|
|
||||||
(defn toggle-token-theme-active? [group name]
|
(defn toggle-token-theme-active? [id]
|
||||||
(ptk/reify ::toggle-token-theme-active?
|
(ptk/reify ::toggle-token-theme-active?
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
@@ -113,7 +109,7 @@
|
|||||||
|
|
||||||
tokens-lib (get-tokens-lib state)
|
tokens-lib (get-tokens-lib state)
|
||||||
active-token-themes (some-> tokens-lib
|
active-token-themes (some-> tokens-lib
|
||||||
(ctob/toggle-theme-active? group name)
|
(ctob/toggle-theme-active? id)
|
||||||
(ctob/get-active-theme-paths))
|
(ctob/get-active-theme-paths))
|
||||||
active-token-themes' (if (= active-token-themes #{ctob/hidden-theme-path})
|
active-token-themes' (if (= active-token-themes #{ctob/hidden-theme-path})
|
||||||
active-token-themes
|
active-token-themes
|
||||||
@@ -125,14 +121,14 @@
|
|||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(dwtp/propagate-workspace-tokens))))))
|
(dwtp/propagate-workspace-tokens))))))
|
||||||
|
|
||||||
(defn delete-token-theme [group theme-name]
|
(defn delete-token-theme [id]
|
||||||
(ptk/reify ::delete-token-theme
|
(ptk/reify ::delete-token-theme
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [data (dsh/lookup-file-data state)
|
(let [data (dsh/lookup-file-data state)
|
||||||
changes (-> (pcb/empty-changes it)
|
changes (-> (pcb/empty-changes it)
|
||||||
(pcb/with-library-data data)
|
(pcb/with-library-data data)
|
||||||
(pcb/set-token-theme group theme-name nil))]
|
(pcb/set-token-theme id nil))]
|
||||||
(rx/of
|
(rx/of
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(dwtp/propagate-workspace-tokens))))))
|
(dwtp/propagate-workspace-tokens))))))
|
||||||
@@ -341,8 +337,7 @@
|
|||||||
(pcb/with-library-data data)
|
(pcb/with-library-data data)
|
||||||
(pcb/set-token-set (ctob/get-id token-set) token-set)
|
(pcb/set-token-set (ctob/get-id token-set) token-set)
|
||||||
(pcb/set-token (ctob/get-id token-set) (:id token) token)
|
(pcb/set-token (ctob/get-id token-set) (:id token) token)
|
||||||
(pcb/set-token-theme (:group hidden-theme)
|
(pcb/set-token-theme (ctob/get-id hidden-theme)
|
||||||
(:name hidden-theme)
|
|
||||||
hidden-theme-with-set)
|
hidden-theme-with-set)
|
||||||
(pcb/set-active-token-themes #{ctob/hidden-theme-path}))]
|
(pcb/set-active-token-themes #{ctob/hidden-theme-path}))]
|
||||||
(rx/of (dch/commit-changes changes)
|
(rx/of (dch/commit-changes changes)
|
||||||
|
|||||||
@@ -437,18 +437,18 @@
|
|||||||
(l/derived (d/nilf ctob/get-theme-groups) tokens-lib))
|
(l/derived (d/nilf ctob/get-theme-groups) tokens-lib))
|
||||||
|
|
||||||
(defn workspace-token-theme
|
(defn workspace-token-theme
|
||||||
[group name]
|
[id]
|
||||||
(l/derived
|
(l/derived
|
||||||
(fn [lib]
|
(fn [lib]
|
||||||
(when lib
|
(when lib
|
||||||
(ctob/get-theme lib group name)))
|
(ctob/get-theme lib id)))
|
||||||
tokens-lib))
|
tokens-lib))
|
||||||
|
|
||||||
(def workspace-token-theme-tree-no-hidden
|
(def workspace-token-theme-tree-no-hidden
|
||||||
(l/derived (fn [lib]
|
(l/derived (fn [lib]
|
||||||
(or
|
(or
|
||||||
(some-> lib
|
(some-> lib
|
||||||
(ctob/delete-theme ctob/hidden-theme-group ctob/hidden-theme-name)
|
(ctob/delete-theme ctob/hidden-theme-id)
|
||||||
(ctob/get-theme-tree))
|
(ctob/get-theme-tree))
|
||||||
[]))
|
[]))
|
||||||
tokens-lib))
|
tokens-lib))
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
|
[app.common.types.tokens-lib :as ctob]
|
||||||
[app.main.constants :refer [max-input-length]]
|
[app.main.constants :refer [max-input-length]]
|
||||||
[app.main.data.common :as dcm]
|
[app.main.data.common :as dcm]
|
||||||
[app.main.data.event :as-alias ev]
|
[app.main.data.event :as-alias ev]
|
||||||
@@ -159,11 +160,10 @@
|
|||||||
(fn [_]
|
(fn [_]
|
||||||
(let [;; We want to create a token on the first set
|
(let [;; We want to create a token on the first set
|
||||||
;; if there are many in this group
|
;; if there are many in this group
|
||||||
complete-name (str (:group set) "/" (first (:sets set)))
|
|
||||||
path-set (group->paths set)]
|
path-set (group->paths set)]
|
||||||
(st/emit! (dcm/go-to-workspace :layout :tokens)
|
(st/emit! (dcm/go-to-workspace :layout :tokens)
|
||||||
(ptk/data-event :expand-token-sets {:paths path-set})
|
(ptk/data-event :expand-token-sets {:paths path-set})
|
||||||
(dwtl/set-selected-token-set-name complete-name)
|
(dwtl/set-selected-token-set-id (ctob/get-id set))
|
||||||
(dwtl/set-token-type-section-open :color true)
|
(dwtl/set-token-type-section-open :color true)
|
||||||
(let [{:keys [modal title]} (get dwta/token-properties :color)
|
(let [{:keys [modal title]} (get dwta/token-properties :color)
|
||||||
window-size (dom/get-window-size)
|
window-size (dom/get-window-size)
|
||||||
|
|||||||
@@ -362,7 +362,7 @@
|
|||||||
(fn []
|
(fn []
|
||||||
(rx/dispose! sub))))
|
(rx/dispose! sub))))
|
||||||
|
|
||||||
(for [{:keys [token-set id index is-new is-group path parent-path depth] :as node}
|
(for [{:keys [token-set id index is-new is-group path depth] :as node}
|
||||||
(ctob/sets-tree-seq token-sets
|
(ctob/sets-tree-seq token-sets
|
||||||
{:skip-children-pred collapsed?
|
{:skip-children-pred collapsed?
|
||||||
:new-at-path new-path})]
|
:new-at-path new-path})]
|
||||||
|
|||||||
@@ -78,7 +78,7 @@
|
|||||||
|
|
||||||
(mf/defc themes-overview
|
(mf/defc themes-overview
|
||||||
[{:keys [change-view]}]
|
[{:keys [change-view]}]
|
||||||
(let [active-theme-ids (mf/deref refs/workspace-active-theme-paths)
|
(let [active-theme-paths (mf/deref refs/workspace-active-theme-paths)
|
||||||
themes-groups (mf/deref refs/workspace-token-theme-tree-no-hidden)
|
themes-groups (mf/deref refs/workspace-token-theme-tree-no-hidden)
|
||||||
|
|
||||||
create-theme
|
create-theme
|
||||||
@@ -105,20 +105,20 @@
|
|||||||
[:> icon* {:icon-id i/group :class (stl/css :group-title-icon)}]
|
[:> icon* {:icon-id i/group :class (stl/css :group-title-icon)}]
|
||||||
[:> text* {:as "span" :typography "body-medium" :class (stl/css :group-title-name)} group]]])
|
[:> text* {:as "span" :typography "body-medium" :class (stl/css :group-title-name)} group]]])
|
||||||
[:ul {:class (stl/css :theme-group-rows-wrapper)}
|
[:ul {:class (stl/css :theme-group-rows-wrapper)}
|
||||||
(for [[_ {:keys [group name] :as theme}] themes
|
(for [[_ {:keys [id name] :as theme}] themes
|
||||||
:let [theme-id (ctob/get-theme-path theme)
|
:let [theme-path (ctob/get-theme-path theme)
|
||||||
selected? (some? (get active-theme-ids theme-id))
|
selected? (some? (get active-theme-paths theme-path))
|
||||||
delete-theme
|
delete-theme
|
||||||
(fn [e]
|
(fn [e]
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
(st/emit! (dwtl/delete-token-theme group name)))
|
(st/emit! (dwtl/delete-token-theme id)))
|
||||||
on-edit-theme
|
on-edit-theme
|
||||||
(fn [e]
|
(fn [e]
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
(change-view :edit-theme {:theme-path [(:id theme) (:group theme) (:name theme)]}))]]
|
(change-view :edit-theme {:theme-info [(:id theme) (:group theme) (:name theme)]}))]]
|
||||||
[:li {:key theme-id
|
[:li {:key theme-path
|
||||||
:class (stl/css :theme-row)}
|
:class (stl/css :theme-row)}
|
||||||
[:div {:class (stl/css :theme-switch-row)}
|
[:div {:class (stl/css :theme-switch-row)}
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@
|
|||||||
[:div {:on-click (fn [e]
|
[:div {:on-click (fn [e]
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
(st/emit! (dwtl/toggle-token-theme-active? group name)))}
|
(st/emit! (dwtl/toggle-token-theme-active? id)))}
|
||||||
[:& switch {:name (tr "workspace.tokens.theme-name" name)
|
[:& switch {:name (tr "workspace.tokens.theme-name" name)
|
||||||
:on-change (constantly nil)
|
:on-change (constantly nil)
|
||||||
:selected? selected?}]]]
|
:selected? selected?}]]]
|
||||||
@@ -238,7 +238,7 @@
|
|||||||
(let [tlib (-> (ctob/make-tokens-lib)
|
(let [tlib (-> (ctob/make-tokens-lib)
|
||||||
(ctob/add-theme theme))
|
(ctob/add-theme theme))
|
||||||
tlib (reduce ctob/add-set tlib sets)]
|
tlib (reduce ctob/add-set tlib sets)]
|
||||||
(ctob/activate-theme tlib (:group theme) (:name theme))))
|
(ctob/activate-theme tlib (ctob/get-id theme))))
|
||||||
|
|
||||||
(mf/defc edit-create-theme*
|
(mf/defc edit-create-theme*
|
||||||
[{:keys [change-view theme on-save is-editing has-prev-view]}]
|
[{:keys [change-view theme on-save is-editing has-prev-view]}]
|
||||||
@@ -285,7 +285,7 @@
|
|||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps current-theme on-back)
|
(mf/deps current-theme on-back)
|
||||||
(fn []
|
(fn []
|
||||||
(st/emit! (dwtl/delete-token-theme (:group current-theme) (:name current-theme)))
|
(st/emit! (dwtl/delete-token-theme (ctob/get-id current-theme)))
|
||||||
(on-back)))
|
(on-back)))
|
||||||
|
|
||||||
;; Sets tree handlers
|
;; Sets tree handlers
|
||||||
@@ -369,16 +369,16 @@
|
|||||||
|
|
||||||
(mf/defc edit-theme
|
(mf/defc edit-theme
|
||||||
[{:keys [state change-view]}]
|
[{:keys [state change-view]}]
|
||||||
(let [{:keys [theme-path]} state
|
(let [{:keys [theme-info]} state
|
||||||
[_ theme-group theme-name] theme-path
|
[theme-id _ _] theme-info
|
||||||
theme (mf/deref (refs/workspace-token-theme theme-group theme-name))
|
theme (mf/deref (refs/workspace-token-theme theme-id))
|
||||||
has-prev-view (has-prev-view (:prev-type state))
|
has-prev-view (has-prev-view (:prev-type state))
|
||||||
|
|
||||||
on-save
|
on-save
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps theme)
|
(mf/deps theme)
|
||||||
(fn [theme']
|
(fn [theme']
|
||||||
(st/emit! (dwtl/update-token-theme [(:group theme) (:name theme)] theme'))))]
|
(st/emit! (dwtl/update-token-theme (ctob/get-id theme) theme'))))]
|
||||||
|
|
||||||
[:> edit-create-theme*
|
[:> edit-create-theme*
|
||||||
{:change-view change-view
|
{:change-view change-view
|
||||||
@@ -413,12 +413,12 @@
|
|||||||
state (deref state*)
|
state (deref state*)
|
||||||
|
|
||||||
change-view (mf/use-fn
|
change-view (mf/use-fn
|
||||||
(fn [type & {:keys [theme-path]}]
|
(fn [type & {:keys [theme-info]}]
|
||||||
(swap! state* (fn [current-state]
|
(swap! state* (fn [current-state]
|
||||||
(cond-> current-state
|
(cond-> current-state
|
||||||
:always (assoc :type type
|
:always (assoc :type type
|
||||||
:prev-type (:type current-state))
|
:prev-type (:type current-state))
|
||||||
:theme-path (assoc :theme-path theme-path))))))
|
:theme-info (assoc :theme-info theme-info))))))
|
||||||
|
|
||||||
component (case (:type state)
|
component (case (:type state)
|
||||||
:empty-themes empty-themes
|
:empty-themes empty-themes
|
||||||
|
|||||||
@@ -26,12 +26,12 @@
|
|||||||
[{:keys [themes active-theme-paths on-close grouped?]}]
|
[{:keys [themes active-theme-paths on-close grouped?]}]
|
||||||
(when (seq themes)
|
(when (seq themes)
|
||||||
[:ul {:class (stl/css :theme-options)}
|
[:ul {:class (stl/css :theme-options)}
|
||||||
(for [[_ {:keys [group name] :as theme}] themes
|
(for [[_ {:keys [id name] :as theme}] themes
|
||||||
:let [theme-id (ctob/get-theme-path theme)
|
:let [theme-id (ctob/get-theme-path theme)
|
||||||
selected? (get active-theme-paths theme-id)
|
selected? (get active-theme-paths theme-id)
|
||||||
select-theme (fn [e]
|
select-theme (fn [e]
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
(st/emit! (dwtl/toggle-token-theme-active? group name))
|
(st/emit! (dwtl/toggle-token-theme-active? id))
|
||||||
(on-close))]]
|
(on-close))]]
|
||||||
[:li {:key theme-id
|
[:li {:key theme-id
|
||||||
:role "option"
|
:role "option"
|
||||||
|
|||||||
Reference in New Issue
Block a user