mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 14:12:36 -05:00
Abstract functionality
This commit is contained in:
parent
557195cd55
commit
1ed692230b
2 changed files with 6 additions and 4 deletions
|
@ -295,7 +295,7 @@
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps ids change-radius border-radius-tokens)
|
(mf/deps ids change-radius border-radius-tokens)
|
||||||
(fn [token]
|
(fn [token]
|
||||||
(let [token-value (some-> token wtc/resolve-token-value)]
|
(let [token-value (wtc/maybe-resolve-token-value token)]
|
||||||
(st/emit!
|
(st/emit!
|
||||||
(change-radius (fn [shape]
|
(change-radius (fn [shape]
|
||||||
(-> (dt/unapply-token-id shape (wtc/token-attributes :border-radius))
|
(-> (dt/unapply-token-id shape (wtc/token-attributes :border-radius))
|
||||||
|
@ -305,11 +305,10 @@
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps ids change-radius border-radius-tokens)
|
(mf/deps ids change-radius border-radius-tokens)
|
||||||
(fn [value]
|
(fn [value]
|
||||||
(let [token (when (map? value) value)
|
(let [token-value (wtc/maybe-resolve-token-value value)]
|
||||||
token-value (some-> token wtc/resolve-token-value)]
|
|
||||||
(st/emit!
|
(st/emit!
|
||||||
(change-radius (fn [shape]
|
(change-radius (fn [shape]
|
||||||
(-> (dt/maybe-apply-token-to-shape {:token token
|
(-> (dt/maybe-apply-token-to-shape {:token (when token-value value)
|
||||||
:shape shape
|
:shape shape
|
||||||
:attributes (wtc/token-attributes :border-radius)})
|
:attributes (wtc/token-attributes :border-radius)})
|
||||||
(ctsr/set-radius-1 (or token-value value)))))))))
|
(ctsr/set-radius-1 (or token-value value)))))))))
|
||||||
|
|
|
@ -37,6 +37,9 @@
|
||||||
int-or-double
|
int-or-double
|
||||||
(throw (ex-info (str "Implement token value resolve for " value) token))))
|
(throw (ex-info (str "Implement token value resolve for " value) token))))
|
||||||
|
|
||||||
|
(defn maybe-resolve-token-value [{:keys [value] :as token}]
|
||||||
|
(when value (resolve-token-value token)))
|
||||||
|
|
||||||
(defn group-tokens-by-type
|
(defn group-tokens-by-type
|
||||||
"Groups tokens by their `:type` property."
|
"Groups tokens by their `:type` property."
|
||||||
[tokens]
|
[tokens]
|
||||||
|
|
Loading…
Add table
Reference in a new issue