Fix theme select

This commit is contained in:
Florian Schroedl 2024-09-19 16:22:47 +02:00
parent 191d957984
commit 9b2993a344
2 changed files with 15 additions and 15 deletions

View file

@ -16,6 +16,10 @@
[cljs.analyzer.api :as aapi] [cljs.analyzer.api :as aapi]
[cuerdas.core :as str])) [cuerdas.core :as str]))
(defmacro fixme
"Purely annotational macro to find instances later to remove when the refactor to tokens-lib is done."
[& body] `(do ~@body))
(defmacro legacy (defmacro legacy
"Purely annotational macro to find instances later to remove when the refactor to tokens-lib is done." "Purely annotational macro to find instances later to remove when the refactor to tokens-lib is done."
[& body] `(do ~@body)) [& body] `(do ~@body))

View file

@ -7,6 +7,7 @@
(ns app.main.ui.workspace.tokens.theme-select (ns app.main.ui.workspace.tokens.theme-select
(:require-macros [app.main.style :as stl]) (:require-macros [app.main.style :as stl])
(:require (:require
[app.common.data.macros :as dm]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
[app.main.data.tokens :as wdt] [app.main.data.tokens :as wdt]
@ -21,7 +22,7 @@
[{:keys [themes active-theme-ids on-close grouped?]}] [{:keys [themes active-theme-ids on-close grouped?]}]
(when (seq themes) (when (seq themes)
[:ul [:ul
(for [{:keys [id name]} themes (for [[_ {:keys [id name]}] themes
:let [selected? (get active-theme-ids id)]] :let [selected? (get active-theme-ids id)]]
[:li {:key id [:li {:key id
:class (stl/css-case :class (stl/css-case
@ -37,17 +38,12 @@
(mf/defc theme-options (mf/defc theme-options
[{:keys [on-close]}] [{:keys [on-close]}]
(let [active-theme-ids (mf/deref refs/workspace-active-theme-ids) (let [active-theme-ids (dm/fixme (mf/deref refs/workspace-active-theme-ids))
ordered-themes (mf/deref refs/workspace-ordered-token-themes-OLD) theme-groups (mf/deref refs/workspace-token-theme-tree)]
grouped-themes (dissoc ordered-themes nil)
ungrouped-themes (get ordered-themes nil)]
[:ul [:ul
[:& themes-list {:themes ungrouped-themes (for [[group themes] theme-groups]
:active-theme-ids active-theme-ids
:on-close on-close}]
(for [[group themes] grouped-themes]
[:li {:key group} [:li {:key group}
(when group (when (seq group)
[:span {:class (stl/css :group)} group]) [:span {:class (stl/css :group)} group])
[:& themes-list {:themes themes [:& themes-list {:themes themes
:active-theme-ids active-theme-ids :active-theme-ids active-theme-ids
@ -62,16 +58,16 @@
(mf/defc theme-select (mf/defc theme-select
[{:keys []}] [{:keys []}]
(let [;; Store (let [;; Store
temp-theme-id (mf/deref refs/workspace-temp-theme-id) temp-theme-id (dm/legacy (mf/deref refs/workspace-temp-theme-id))
active-theme-ids (-> (mf/deref refs/workspace-active-theme-ids) active-theme-ids (dm/legacy (-> (mf/deref refs/workspace-active-theme-ids)
(disj temp-theme-id)) (disj temp-theme-id)))
active-themes-count (count active-theme-ids) active-themes-count (count active-theme-ids)
themes (mf/deref refs/workspace-token-themes-OLD) themes (mf/deref refs/workspace-token-theme-tree)
;; Data ;; Data
current-label (cond current-label (cond
(> active-themes-count 1) (str active-themes-count " themes active") (> active-themes-count 1) (str active-themes-count " themes active")
(pos? active-themes-count) (get-in themes [(first active-theme-ids) :name]) ;; (pos? active-themes-count) (get-in themes [(first active-theme-ids) :name])
:else "No theme active") :else "No theme active")
;; State ;; State