mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 06:02:32 -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/deps ids change-radius border-radius-tokens)
|
||||
(fn [token]
|
||||
(let [token-value (some-> token wtc/resolve-token-value)]
|
||||
(let [token-value (wtc/maybe-resolve-token-value token)]
|
||||
(st/emit!
|
||||
(change-radius (fn [shape]
|
||||
(-> (dt/unapply-token-id shape (wtc/token-attributes :border-radius))
|
||||
|
@ -305,11 +305,10 @@
|
|||
(mf/use-fn
|
||||
(mf/deps ids change-radius border-radius-tokens)
|
||||
(fn [value]
|
||||
(let [token (when (map? value) value)
|
||||
token-value (some-> token wtc/resolve-token-value)]
|
||||
(let [token-value (wtc/maybe-resolve-token-value value)]
|
||||
(st/emit!
|
||||
(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
|
||||
:attributes (wtc/token-attributes :border-radius)})
|
||||
(ctsr/set-radius-1 (or token-value value)))))))))
|
||||
|
|
|
@ -37,6 +37,9 @@
|
|||
int-or-double
|
||||
(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
|
||||
"Groups tokens by their `:type` property."
|
||||
[tokens]
|
||||
|
|
Loading…
Add table
Reference in a new issue