From d9dbaad281558b7b56cba37655f3c0af462f002c Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Wed, 15 May 2024 18:20:28 +0200 Subject: [PATCH] Add tokens map generators --- frontend/src/app/main/ui/workspace/tokens/core.cljs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/frontend/src/app/main/ui/workspace/tokens/core.cljs b/frontend/src/app/main/ui/workspace/tokens/core.cljs index 2fd5bfc1a..c237cae76 100644 --- a/frontend/src/app/main/ui/workspace/tokens/core.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/core.cljs @@ -43,6 +43,17 @@ (->> (vals tokens) (group-by :type))) +(defn tokens-name-map + "Convert tokens into a map with their `:name` as the key." + [tokens] + (->> (map (fn [{:keys [name] :as token}] [name token]) tokens) + (into {}))) + +(defn tokens-name-map-for-type [token-type tokens] + (-> (group-tokens-by-type tokens) + (get token-type []) + (tokens-name-map))) + ;; Update functions ------------------------------------------------------------ (defn on-apply-token [{:keys [token token-type-props selected-shapes] :as _props}]