0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-06 14:50:20 -05:00

Abstract functions

This commit is contained in:
Florian Schroedl 2024-05-22 16:20:40 +02:00
parent 2eb5efb274
commit 5806ae7426
2 changed files with 7 additions and 3 deletions

View file

@ -6,6 +6,7 @@
(ns app.main.data.tokens
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.files.changes-builder :as pcb]
[app.common.geom.point :as gpt]
@ -57,6 +58,9 @@
(->> (map (fn [attr] [attr token-id]) attributes)
(into {})))
(defn unapply-token-id [shape attributes]
(update shape :applied-tokens d/without-keys attributes))
(defn apply-token-id-to-attributes [{:keys [shape token-id attributes]}]
(let [token (token-from-attributes token-id attributes)]
(toggle-or-apply-token shape token)))

View file

@ -291,14 +291,14 @@
(on-switch-to-radius-4)
(on-switch-to-radius-1))))
on-border-radius-token-unlink
on-border-radius-token-unapply
(mf/use-fn
(mf/deps ids change-radius border-radius-tokens)
(fn [token]
(let [token-value (some-> token wtc/resolve-token-value)]
(st/emit!
(change-radius (fn [shape]
(-> (update shape :applied-tokens d/without-keys #{:rx :ry :r1 :r2 :r3 :r4})
(-> (dt/unapply-token-id shape (wtc/token-attributes :border-radius))
(ctsr/set-radius-1 token-value))))))))
on-radius-1-change
@ -498,7 +498,7 @@
[:span {:class (stl/css :icon)} i/corner-radius]
[:& editable-select
{:placeholder (if (= :multiple (:rx values)) (tr "settings.multiple") "--")
:on-token-remove on-border-radius-token-unlink
:on-token-remove on-border-radius-token-unapply
:class (stl/css :token-select)
:type "number"
:min 0