mirror of
https://github.com/penpot/penpot.git
synced 2025-02-14 19:19:09 -05:00
Fix iterating over unordered sets
This commit is contained in:
parent
965016b63f
commit
db22beb857
4 changed files with 12 additions and 5 deletions
|
@ -259,10 +259,10 @@
|
||||||
(def workspace-ordered-token-themes
|
(def workspace-ordered-token-themes
|
||||||
(l/derived wtts/get-workspace-ordered-themes st/state))
|
(l/derived wtts/get-workspace-ordered-themes st/state))
|
||||||
|
|
||||||
(def workspace-token-sets
|
(def workspace-ordered-token-sets
|
||||||
(l/derived
|
(l/derived
|
||||||
(fn [data]
|
(fn [data]
|
||||||
(or (wtts/get-workspace-sets data) {}))
|
(or (wtts/get-workspace-ordered-sets data) {}))
|
||||||
st/state
|
st/state
|
||||||
=))
|
=))
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@
|
||||||
(mf/defc controlled-edit-theme
|
(mf/defc controlled-edit-theme
|
||||||
[{:keys [state set-state]}]
|
[{:keys [state set-state]}]
|
||||||
(let [{:keys [theme-id]} @state
|
(let [{:keys [theme-id]} @state
|
||||||
token-sets (mf/deref refs/workspace-token-sets)
|
token-sets (mf/deref refs/workspace-ordered-token-sets)
|
||||||
theme (mf/deref (refs/workspace-token-theme theme-id))]
|
theme (mf/deref (refs/workspace-token-theme theme-id))]
|
||||||
[:& edit-theme
|
[:& edit-theme
|
||||||
{:token-sets token-sets
|
{:token-sets token-sets
|
||||||
|
@ -192,7 +192,7 @@
|
||||||
|
|
||||||
(mf/defc create-theme
|
(mf/defc create-theme
|
||||||
[{:keys [set-state]}]
|
[{:keys [set-state]}]
|
||||||
(let [token-sets (mf/deref refs/workspace-token-sets)
|
(let [token-sets (mf/deref refs/workspace-ordered-token-sets)
|
||||||
theme {:name "Theme" :sets #{}}]
|
theme {:name "Theme" :sets #{}}]
|
||||||
[:& edit-theme
|
[:& edit-theme
|
||||||
{:token-sets token-sets
|
{:token-sets token-sets
|
||||||
|
|
|
@ -135,7 +135,7 @@
|
||||||
|
|
||||||
(mf/defc sets-list
|
(mf/defc sets-list
|
||||||
[{:keys []}]
|
[{:keys []}]
|
||||||
(let [token-sets (mf/deref refs/workspace-token-sets)
|
(let [token-sets (mf/deref refs/workspace-ordered-token-sets)
|
||||||
selected-token-set-id (mf/deref refs/workspace-selected-token-set-id)
|
selected-token-set-id (mf/deref refs/workspace-selected-token-set-id)
|
||||||
token-set-selected? (mf/use-callback
|
token-set-selected? (mf/use-callback
|
||||||
(mf/deps selected-token-set-id)
|
(mf/deps selected-token-set-id)
|
||||||
|
|
|
@ -115,6 +115,13 @@
|
||||||
(defn get-workspace-sets [state]
|
(defn get-workspace-sets [state]
|
||||||
(get-in state [:workspace-data :token-sets-index]))
|
(get-in state [:workspace-data :token-sets-index]))
|
||||||
|
|
||||||
|
(defn get-workspace-ordered-sets [state]
|
||||||
|
;; TODO Include groups
|
||||||
|
(let [top-level-set-ids (get-in state [:workspace-data :token-set-groups])
|
||||||
|
token-sets (get-workspace-sets state)]
|
||||||
|
(->> (map (fn [id] [id (get token-sets id)]) top-level-set-ids)
|
||||||
|
(into (ordered-map)))))
|
||||||
|
|
||||||
(defn get-token-set [set-id state]
|
(defn get-token-set [set-id state]
|
||||||
(some-> (get-workspace-sets state)
|
(some-> (get-workspace-sets state)
|
||||||
(get set-id)))
|
(get set-id)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue