From 581ced0ab82055fd2abc887e35339a7d4c735e63 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Thu, 4 Jul 2024 10:00:44 +0200 Subject: [PATCH] Abstract into helper --- frontend/src/app/main/ui/workspace/tokens/core.cljs | 3 +-- frontend/src/app/main/ui/workspace/tokens/token.cljs | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/tokens/core.cljs b/frontend/src/app/main/ui/workspace/tokens/core.cljs index 29d004720..23940a28a 100644 --- a/frontend/src/app/main/ui/workspace/tokens/core.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/core.cljs @@ -77,8 +77,7 @@ (fn [sd-tokens] (let [resolved-value (-> (get sd-tokens (:id token)) (resolve-token-value)) - tokenized-attributes (->> (map (fn [attr] {attr (:id token)}) attributes) - (into {}))] + tokenized-attributes (wtt/attributes-map attributes (:id token))] (rx/of (dch/update-shapes shape-ids (fn [shape] (update shape :applied-tokens merge tokenized-attributes))) diff --git a/frontend/src/app/main/ui/workspace/tokens/token.cljs b/frontend/src/app/main/ui/workspace/tokens/token.cljs index e52079f8f..2db7c24cf 100644 --- a/frontend/src/app/main/ui/workspace/tokens/token.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/token.cljs @@ -2,6 +2,12 @@ (:require [cuerdas.core :as str])) +(defn attributes-map + "Creats an attributes map using collection of `attributes` for `id`." + [attributes id] + (->> (map (fn [attr] {attr id}) attributes) + (into {}))) + (defn token-applied? "Test if `token` is applied to a `shape` with the given `token-attributes`." [token shape token-attributes]