mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 14:12:36 -05:00
Updates
This commit is contained in:
parent
4d4c4355ad
commit
99e551925a
4 changed files with 49 additions and 17 deletions
|
@ -363,6 +363,8 @@
|
||||||
(update-token-in-set [_ set-name token-name f] "update a token in a set")
|
(update-token-in-set [_ set-name token-name f] "update a token in a set")
|
||||||
(delete-token-from-set [_ set-name token-name] "delete a token from a set")
|
(delete-token-from-set [_ set-name token-name] "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 [_ group-name theme-name 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-tokens [_] "set of set names that are active in the the active themes")
|
||||||
(validate [_]))
|
(validate [_]))
|
||||||
|
|
||||||
(deftype TokensLib [sets set-groups themes active-themes]
|
(deftype TokensLib [sets set-groups themes active-themes]
|
||||||
|
@ -571,6 +573,21 @@
|
||||||
active-themes)
|
active-themes)
|
||||||
this))
|
this))
|
||||||
|
|
||||||
|
(get-active-themes-set-names [this]
|
||||||
|
(into #{}
|
||||||
|
(mapcat :sets)
|
||||||
|
(get-active-themes this)))
|
||||||
|
|
||||||
|
(get-active-themes-set-tokens [this]
|
||||||
|
(mapcat (fn [x]
|
||||||
|
(->> (get x :sets)
|
||||||
|
(map (fn [y]
|
||||||
|
(->
|
||||||
|
(get-set this y)
|
||||||
|
:tokens)))))
|
||||||
|
(get-active-themes this)))
|
||||||
|
|
||||||
|
|
||||||
(validate [_]
|
(validate [_]
|
||||||
(and (valid-token-sets? sets) ;; TODO: validate set-groups
|
(and (valid-token-sets? sets) ;; TODO: validate set-groups
|
||||||
(valid-token-themes? themes)
|
(valid-token-themes? themes)
|
||||||
|
|
|
@ -182,6 +182,19 @@
|
||||||
(t/is (dt/is-after? (:modified-at token-set') (:modified-at token-set)))))
|
(t/is (dt/is-after? (:modified-at token-set') (:modified-at token-set)))))
|
||||||
|
|
||||||
(t/deftest delete-token-set
|
(t/deftest delete-token-set
|
||||||
|
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
|
(ctob/add-set (ctob/make-token-set :name "test-token-set")))
|
||||||
|
|
||||||
|
tokens-lib' (-> tokens-lib
|
||||||
|
(ctob/delete-set "test-token-set")
|
||||||
|
(ctob/delete-set "not-existing-set"))
|
||||||
|
|
||||||
|
token-set' (ctob/get-set tokens-lib' "updated-name")]
|
||||||
|
|
||||||
|
(t/is (= (ctob/set-count tokens-lib') 0))
|
||||||
|
(t/is (nil? token-set'))))
|
||||||
|
|
||||||
|
(t/deftest active-themes-set-names
|
||||||
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
(let [tokens-lib (-> (ctob/make-tokens-lib)
|
||||||
(ctob/add-set (ctob/make-token-set :name "test-token-set")))
|
(ctob/add-set (ctob/make-token-set :name "test-token-set")))
|
||||||
|
|
||||||
|
|
|
@ -474,16 +474,17 @@
|
||||||
(def workspace-active-theme-paths
|
(def workspace-active-theme-paths
|
||||||
(l/derived #(some-> % ctob/get-active-theme-paths) tokens-lib))
|
(l/derived #(some-> % ctob/get-active-theme-paths) tokens-lib))
|
||||||
|
|
||||||
|
(def workspace-active-set-names
|
||||||
|
(l/derived #(some-> % ctob/get-active-themes-set-names) tokens-lib))
|
||||||
|
|
||||||
|
(def workspace-active-theme-sets-tokens
|
||||||
|
#_(l/derived wtts/get-active-theme-sets-tokens-names-map st/state =)
|
||||||
|
(l/derived #(some-> % ctob/get-active-themes-set-tokens) tokens-lib))
|
||||||
|
|
||||||
(dm/legacy
|
(dm/legacy
|
||||||
(def workspace-temp-theme-id
|
(def workspace-temp-theme-id
|
||||||
(l/derived wtts/get-temp-theme-id st/state))
|
(l/derived wtts/get-temp-theme-id st/state))
|
||||||
|
|
||||||
(def workspace-active-set-ids
|
|
||||||
(l/derived wtts/get-active-set-ids st/state))
|
|
||||||
|
|
||||||
(def workspace-active-theme-sets-tokens
|
|
||||||
(l/derived wtts/get-active-theme-sets-tokens-names-map st/state =))
|
|
||||||
|
|
||||||
(def workspace-ordered-token-sets-tokens
|
(def workspace-ordered-token-sets-tokens
|
||||||
(l/derived wtts/get-workspace-ordered-sets-tokens st/state =))
|
(l/derived wtts/get-workspace-ordered-sets-tokens st/state =))
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
(ns app.main.ui.workspace.tokens.sets
|
(ns app.main.ui.workspace.tokens.sets
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.main.data.tokens :as wdt]
|
[app.main.data.tokens :as wdt]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -26,9 +27,9 @@
|
||||||
(defn on-select-token-set-click [name]
|
(defn on-select-token-set-click [name]
|
||||||
(st/emit! (wdt/set-selected-token-set-id name)))
|
(st/emit! (wdt/set-selected-token-set-id name)))
|
||||||
|
|
||||||
(defn on-delete-token-set-click [id name event]
|
(defn on-delete-token-set-click [name event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(st/emit! (wdt/delete-token-set id name)))
|
(st/emit! (wdt/delete-token-set (dm/legacy nil) name)))
|
||||||
|
|
||||||
(defn on-update-token-set [token-set]
|
(defn on-update-token-set [token-set]
|
||||||
(st/emit! (wdt/update-token-set token-set)))
|
(st/emit! (wdt/update-token-set token-set)))
|
||||||
|
@ -71,13 +72,13 @@
|
||||||
on-submit
|
on-submit
|
||||||
on-cancel]
|
on-cancel]
|
||||||
:as _props}]
|
:as _props}]
|
||||||
(let [{:keys [id name _children]} token-set
|
(let [{:keys [name _children]} token-set
|
||||||
selected? (and set? (token-set-selected? name))
|
selected? (and set? (token-set-selected? name))
|
||||||
visible? (token-set-active? id)
|
visible? (token-set-active? name)
|
||||||
collapsed? (mf/use-state false)
|
collapsed? (mf/use-state false)
|
||||||
set? true #_(= type :set)
|
set? true #_(= type :set)
|
||||||
group? false #_(= type :group)
|
group? false #_(= type :group)
|
||||||
editing-node? (editing? id)
|
editing-node? (editing? name)
|
||||||
on-select (mf/use-callback
|
on-select (mf/use-callback
|
||||||
(mf/deps editing-node?)
|
(mf/deps editing-node?)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
|
@ -85,7 +86,7 @@
|
||||||
(when-not editing-node?
|
(when-not editing-node?
|
||||||
(on-select name))))
|
(on-select name))))
|
||||||
on-context-menu (mf/use-callback
|
on-context-menu (mf/use-callback
|
||||||
(mf/deps editing-node? id)
|
(mf/deps editing-node? name)
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
|
@ -93,11 +94,11 @@
|
||||||
(st/emit!
|
(st/emit!
|
||||||
(wdt/show-token-set-context-menu
|
(wdt/show-token-set-context-menu
|
||||||
{:position (dom/get-client-position event)
|
{:position (dom/get-client-position event)
|
||||||
:token-set-id id
|
:token-set-id name
|
||||||
:token-set-name name})))))]
|
:token-set-name name})))))]
|
||||||
[:div {:class (stl/css :set-item-container)
|
[:div {:class (stl/css :set-item-container)
|
||||||
:on-click on-select
|
:on-click on-select
|
||||||
:on-double-click #(on-edit id)
|
:on-double-click #(on-edit name)
|
||||||
:on-context-menu on-context-menu}
|
:on-context-menu on-context-menu}
|
||||||
[:div {:class (stl/css-case :set-item-group group?
|
[:div {:class (stl/css-case :set-item-group group?
|
||||||
:set-item-set set?
|
:set-item-set set?
|
||||||
|
@ -116,14 +117,14 @@
|
||||||
[:*
|
[:*
|
||||||
[:div {:class (stl/css :set-name)} name]
|
[:div {:class (stl/css :set-name)} name]
|
||||||
[:div {:class (stl/css :delete-set)}
|
[:div {:class (stl/css :delete-set)}
|
||||||
[:button {:on-click #(on-delete-token-set-click id name %)
|
[:button {:on-click #(on-delete-token-set-click name %)
|
||||||
:type "button"}
|
:type "button"}
|
||||||
i/delete]]
|
i/delete]]
|
||||||
(if set?
|
(if set?
|
||||||
[:span {:class (stl/css :action-btn)
|
[:span {:class (stl/css :action-btn)
|
||||||
:on-click (fn [event]
|
:on-click (fn [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(on-toggle id))}
|
(on-toggle name))}
|
||||||
(if visible? i/shown i/hide)]
|
(if visible? i/shown i/hide)]
|
||||||
nil
|
nil
|
||||||
#_(when (and children (not @collapsed?))
|
#_(when (and children (not @collapsed?))
|
||||||
|
@ -181,7 +182,7 @@
|
||||||
(mf/deps selected-token-set-id)
|
(mf/deps selected-token-set-id)
|
||||||
(fn [set-name]
|
(fn [set-name]
|
||||||
(= set-name selected-token-set-id)))
|
(= set-name selected-token-set-id)))
|
||||||
active-token-set-ids (mf/deref refs/workspace-active-set-ids)
|
active-token-set-ids (mf/deref refs/workspace-active-set-names)
|
||||||
token-set-active? (mf/use-callback
|
token-set-active? (mf/use-callback
|
||||||
(mf/deps active-token-set-ids)
|
(mf/deps active-token-set-ids)
|
||||||
(fn [id]
|
(fn [id]
|
||||||
|
|
Loading…
Add table
Reference in a new issue