mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
Abstract into helper
This commit is contained in:
parent
e85de19a5e
commit
581ced0ab8
2 changed files with 7 additions and 2 deletions
|
@ -77,8 +77,7 @@
|
||||||
(fn [sd-tokens]
|
(fn [sd-tokens]
|
||||||
(let [resolved-value (-> (get sd-tokens (:id token))
|
(let [resolved-value (-> (get sd-tokens (:id token))
|
||||||
(resolve-token-value))
|
(resolve-token-value))
|
||||||
tokenized-attributes (->> (map (fn [attr] {attr (:id token)}) attributes)
|
tokenized-attributes (wtt/attributes-map attributes (:id token))]
|
||||||
(into {}))]
|
|
||||||
(rx/of
|
(rx/of
|
||||||
(dch/update-shapes shape-ids (fn [shape]
|
(dch/update-shapes shape-ids (fn [shape]
|
||||||
(update shape :applied-tokens merge tokenized-attributes)))
|
(update shape :applied-tokens merge tokenized-attributes)))
|
||||||
|
|
|
@ -2,6 +2,12 @@
|
||||||
(:require
|
(:require
|
||||||
[cuerdas.core :as str]))
|
[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?
|
(defn token-applied?
|
||||||
"Test if `token` is applied to a `shape` with the given `token-attributes`."
|
"Test if `token` is applied to a `shape` with the given `token-attributes`."
|
||||||
[token shape token-attributes]
|
[token shape token-attributes]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue