♻️ Rename measurement and svg-defs components to defc* form (#9306)

Adopts the rumext * suffix convention for the following components,
invoking them with the [:> JS-style syntax to match the rest of the
codebase (see e.g. rea*, single-selection* in viewport/selection):

- measurements: size-display, distance-display-pill, selection-rect,
  distance-display, selection-guides, measurement
- shapes/svg-defs: svg-node, svg-defs (also drop the now-redundant
  {::mf/wrap-props false} annotations)

Updates all call sites in inspect/selection_feedback, shapes/shape,
workspace/viewport, and workspace/viewport_wasm. Pure rename — no
behavioral change.

Signed-off-by: bitcompass <devwiz.sh@gmail.com>
Co-authored-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
BitCompass 2026-05-06 13:11:45 -04:00 committed by GitHub
parent 3885c9ee74
commit 3433b41aa8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 44 additions and 46 deletions

View File

@ -8,7 +8,7 @@
(:require
[app.common.data :as d]
[app.common.geom.shapes :as gsh]
[app.main.ui.measurements :refer [size-display measurement]]
[app.main.ui.measurements :refer [size-display* measurement*]]
[rumext.v2 :as mf]))
;; ------------------------------------------------
@ -64,9 +64,9 @@
[:g.selection-feedback {:pointer-events "none"}
[:g.selected-shapes
[:& selection-rect {:selrect selrect :zoom zoom}]
[:& size-display {:selrect selrect :zoom zoom}]]
[:> size-display* {:selrect selrect :zoom zoom}]]
[:& measurement {:bounds (assoc size :x 0 :y 0)
:selected-shapes selected-shapes
:hover-shape hover-shape
:zoom zoom}]])))
[:> measurement* {:bounds (assoc size :x 0 :y 0)
:selected-shapes selected-shapes
:hover-shape hover-shape
:zoom zoom}]])))

View File

@ -96,7 +96,7 @@
;; COMPONENTS
;; ------------------------------------------------
(mf/defc size-display [{:keys [selrect zoom]}]
(mf/defc size-display* [{:keys [selrect zoom]}]
(let [{:keys [x y width height]} selrect
size-label (dm/str (fmt/format-number width) " x " (fmt/format-number height))
@ -123,7 +123,7 @@
:font-size (/ font-size zoom)}}
size-label]]))
(mf/defc distance-display-pill [{:keys [x y zoom distance bounds]}]
(mf/defc distance-display-pill* [{:keys [x y zoom distance bounds]}]
(let [distance-pill-width (/ distance-pill-width zoom)
distance-pill-height (/ distance-pill-height zoom)
font-size (/ font-size zoom)
@ -167,7 +167,7 @@
:font-size font-size}}
(fmt/format-pixels distance)]]))
(mf/defc selection-rect [{:keys [selrect zoom]}]
(mf/defc selection-rect* [{:keys [selrect zoom]}]
(let [{:keys [x y width height]} selrect
selection-rect-width (/ selection-rect-width zoom)]
[:g.selection-rect
@ -179,7 +179,7 @@
:stroke hover-color
:stroke-width selection-rect-width}}]]))
(mf/defc distance-display [{:keys [from to zoom bounds]}]
(mf/defc distance-display* [{:keys [from to zoom bounds]}]
(let [fixed-x (if (gsh/fully-contained? from to)
(+ (:x to) (/ (:width to) 2))
(+ (:x from) (/ (:width from) 2)))
@ -211,14 +211,14 @@
:style {:stroke distance-color
:stroke-width distance-line-stroke}}]
[:& distance-display-pill
[:> distance-display-pill*
{:x center-x
:y center-y
:zoom zoom
:distance distance
:bounds bounds}]])))))
(mf/defc selection-guides [{:keys [bounds selrect zoom]}]
(mf/defc selection-guides* [{:keys [bounds selrect zoom]}]
[:g.selection-guides
(for [[idx [x1 y1 x2 y2]] (d/enumerate (calculate-guides bounds selrect))]
[:line {:key (dm/str "guide-" idx)
@ -230,7 +230,7 @@
:stroke-width (/ select-guide-width zoom)
:stroke-dasharray (/ select-guide-dasharray zoom)}}])])
(mf/defc measurement
(mf/defc measurement*
[{:keys [bounds frame selected-shapes hover-shape zoom]}]
(let [selected-ids (into #{} (map :id) selected-shapes)
selected-selrect (gsh/shapes->rect selected-shapes)
@ -240,23 +240,23 @@
(when (seq selected-shapes)
[:g.measurement-feedback {:pointer-events "none"}
[:& selection-guides {:selrect selected-selrect
:bounds bounds
:zoom zoom}]
[:& size-display {:selrect selected-selrect :zoom zoom}]
[:> selection-guides* {:selrect selected-selrect
:bounds bounds
:zoom zoom}]
[:> size-display* {:selrect selected-selrect :zoom zoom}]
(if (or (not hover-shape) (not hover-selected-shape?))
(when (and frame (not= uuid/zero (:id frame)))
(let [frame-bb (-> (:points frame) (grc/points->rect))]
[:g.hover-shapes
[:& selection-rect {:type :hover :selrect frame-bb :zoom zoom}]
[:& distance-display {:from frame-bb
:to selected-selrect
:zoom zoom
:bounds bounds-selrect}]]))
[:> selection-rect* {:type :hover :selrect frame-bb :zoom zoom}]
[:> distance-display* {:from frame-bb
:to selected-selrect
:zoom zoom
:bounds bounds-selrect}]]))
[:g.hover-shapes
[:& selection-rect {:type :hover :selrect hover-selrect :zoom zoom}]
[:& size-display {:selrect hover-selrect :zoom zoom}]
[:& distance-display {:from hover-selrect :to selected-selrect :zoom zoom :bounds bounds-selrect}]])])))
[:> selection-rect* {:type :hover :selrect hover-selrect :zoom zoom}]
[:> size-display* {:selrect hover-selrect :zoom zoom}]
[:> distance-display* {:from hover-selrect :to selected-selrect :zoom zoom :bounds bounds-selrect}]])])))

View File

@ -125,7 +125,7 @@
[:& ed/export-data {:shape shape}])
[:defs
[:& defs/svg-defs {:shape shape :render-id render-id}]
[:> defs/svg-defs* {:shape shape :render-id render-id}]
;; The filters for frames should be setup inside the container.
(when-not (cfh/frame-shape? shape)

View File

@ -24,8 +24,7 @@
(str transform-matrix " " val)
(str transform-matrix)))))
(mf/defc svg-node
{::mf/wrap-props false}
(mf/defc svg-node*
[{:keys [type node prefix-id transform bounds]}]
(cond
(string? node) node
@ -91,12 +90,12 @@
[:> (name tag) props
[:> wrapper wrapper-props
(for [[index node] (d/enumerate content)]
[:& svg-node {:key (dm/str "node-" index)
:type type
:node node
:prefix-id prefix-id
:transform transform
:bounds bounds}])]])))
[:> svg-node* {:key (dm/str "node-" index)
:type type
:node node
:prefix-id prefix-id
:transform transform
:bounds bounds}])]])))
(defn- get-svg-def-bounds
[{:keys [tag attrs] :as node} shape transform]
@ -108,8 +107,7 @@
(gsh/transform-rect transform))
(gsb/get-shape-filter-bounds shape)))
(mf/defc svg-defs
{::mf/wrap-props false}
(mf/defc svg-defs*
[{:keys [shape render-id]}]
(let [defs (:svg-defs shape)
@ -131,9 +129,9 @@
(contains? defs id) (str render-id "-"))))]
(for [[key node] defs]
[:& svg-node {:key (dm/str key)
:type (:type shape)
:node node
:prefix-id prefix-id
:transform transform
:bounds (get-svg-def-bounds node shape transform)}])))
[:> svg-node* {:key (dm/str key)
:type (:type shape)
:node node
:prefix-id prefix-id
:transform transform
:bounds (get-svg-def-bounds node shape transform)}])))

View File

@ -501,7 +501,7 @@
:modifiers modifiers}])
(when show-measures?
[:& msr/measurement
[:> msr/measurement*
{:bounds vbox
:selected-shapes selected-shapes
:frame selected-frame
@ -510,7 +510,7 @@
;; Show distances during movement with ALT
(when (and (= transform :move) @alt? (seq selected-shapes))
[:& msr/measurement
[:> msr/measurement*
{:bounds vbox
:selected-shapes selected-shapes
:frame selected-frame
@ -522,7 +522,7 @@
duplicated-info (get-in @(deref state-var) [:workspace-local :duplicated])]
(when (and (= transform :move) @alt? duplicated-info)
[:g.duplicated-distance
[:& msr/distance-display
[:> msr/distance-display*
{:from (get duplicated-info :selrect-original)
:to (get duplicated-info :selrect-duplicated)
:zoom zoom

View File

@ -654,7 +654,7 @@
:zoom zoom}])
(when show-measures?
[:& msr/measurement
[:> msr/measurement*
{:bounds vbox
:selected-shapes selected-shapes
:frame selected-frame