🐛 Fix border-radius applied to all corners on token update (#5697)

This commit is contained in:
Florian Schrödl 2025-01-30 12:54:19 +01:00 committed by GitHub
parent 4524d6c216
commit 773debafda
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 62 additions and 9 deletions

View file

@ -97,19 +97,15 @@
(defn update-shape-radius-all [value shape-ids]
(dwsh/update-shapes shape-ids
(fn [shape]
(when (ctsr/can-get-border-radius? shape)
(ctsr/set-radius-to-all-corners shape value)))
(ctsr/set-radius-to-all-corners shape value))
{:reg-objects? true
:ignore-touched true
:attrs ctt/border-radius-keys}))
(defn update-shape-radius-single-corner [value shape-ids attributes]
;; NOTE: This key should be namespaced on data tokens, but these events are not there.
(st/emit! (ptk/data-event :expand-border-radius))
(defn update-shape-radius-for-corners [value shape-ids attributes]
(dwsh/update-shapes shape-ids
(fn [shape]
(when (ctsr/can-get-border-radius? shape)
(ctsr/set-radius-to-single-corner shape (first attributes) value)))
(ctsr/set-radius-for-corners shape attributes value))
{:reg-objects? true
:ignore-touched true
:attrs ctt/border-radius-keys}))

View file

@ -23,6 +23,7 @@
[app.util.i18n :refer [tr]]
[app.util.timers :as timers]
[okulary.core :as l]
[potok.v2.core :as ptk]
[rumext.v2 :as mf]))
;; Actions ---------------------------------------------------------------------
@ -179,6 +180,11 @@
:on-update-shape wtch/update-layout-sizing-limits}
context-data)))
(defn update-shape-radius-for-corners [value shape-ids attributes]
(st/emit!
(ptk/data-event :expand-border-radius)
(wtch/update-shape-radius-for-corners value shape-ids attributes)))
(def shape-attribute-actions-map
(let [stroke-width (partial generic-attribute-actions #{:stroke-width} "Stroke Width")]
{:border-radius (partial all-or-sepearate-actions {:attribute-labels {:r1 "Top Left"
@ -186,7 +192,7 @@
:r4 "Bottom Left"
:r3 "Bottom Right"}
:on-update-shape-all wtch/update-shape-radius-all
:on-update-shape wtch/update-shape-radius-single-corner})
:on-update-shape update-shape-radius-for-corners})
:color (fn [context-data]
[(generic-attribute-actions #{:fill} "Fill" (assoc context-data :on-update-shape wtch/update-fill))
(generic-attribute-actions #{:stroke-color} "Stroke" (assoc context-data :on-update-shape wtch/update-stroke-color))])

View file

@ -17,7 +17,7 @@
(def filter-existing-values? false)
(def attributes->shape-update
{#{:r1 :r2 :r3 :r4} wtch/update-shape-radius-all
{ctt/border-radius-keys wtch/update-shape-radius-for-corners
ctt/color-keys wtch/update-fill-stroke
ctt/stroke-width-keys wtch/update-stroke-width
ctt/sizing-keys wtch/update-shape-dimensions