From 55d085117ba1be820344e32a146842dd33baaf64 Mon Sep 17 00:00:00 2001 From: BitCompass <1698200+bitcompass@users.noreply.github.com> Date: Wed, 6 May 2026 13:11:45 -0400 Subject: [PATCH] :recycle: Rename measurement and svg-defs components to defc* form (#9306) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-authored-by: Andrey Antukh --- .../main/ui/inspect/selection_feedback.cljs | 12 +++--- frontend/src/app/main/ui/measurements.cljs | 38 +++++++++---------- frontend/src/app/main/ui/shapes/shape.cljs | 2 +- frontend/src/app/main/ui/shapes/svg_defs.cljs | 30 +++++++-------- .../src/app/main/ui/workspace/viewport.cljs | 6 +-- .../app/main/ui/workspace/viewport_wasm.cljs | 2 +- 6 files changed, 44 insertions(+), 46 deletions(-) diff --git a/frontend/src/app/main/ui/inspect/selection_feedback.cljs b/frontend/src/app/main/ui/inspect/selection_feedback.cljs index 9b52adb05a..73899c679e 100644 --- a/frontend/src/app/main/ui/inspect/selection_feedback.cljs +++ b/frontend/src/app/main/ui/inspect/selection_feedback.cljs @@ -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}]]))) diff --git a/frontend/src/app/main/ui/measurements.cljs b/frontend/src/app/main/ui/measurements.cljs index 370830fdb8..0e9d823996 100644 --- a/frontend/src/app/main/ui/measurements.cljs +++ b/frontend/src/app/main/ui/measurements.cljs @@ -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}]])]))) diff --git a/frontend/src/app/main/ui/shapes/shape.cljs b/frontend/src/app/main/ui/shapes/shape.cljs index ba69c5753e..d8df772a89 100644 --- a/frontend/src/app/main/ui/shapes/shape.cljs +++ b/frontend/src/app/main/ui/shapes/shape.cljs @@ -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) diff --git a/frontend/src/app/main/ui/shapes/svg_defs.cljs b/frontend/src/app/main/ui/shapes/svg_defs.cljs index 39328b752c..e4404b8311 100644 --- a/frontend/src/app/main/ui/shapes/svg_defs.cljs +++ b/frontend/src/app/main/ui/shapes/svg_defs.cljs @@ -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)}]))) diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 26553b35d8..529e569f07 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -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 diff --git a/frontend/src/app/main/ui/workspace/viewport_wasm.cljs b/frontend/src/app/main/ui/workspace/viewport_wasm.cljs index 915fc01f81..c15d0bcbad 100644 --- a/frontend/src/app/main/ui/workspace/viewport_wasm.cljs +++ b/frontend/src/app/main/ui/workspace/viewport_wasm.cljs @@ -654,7 +654,7 @@ :zoom zoom}]) (when show-measures? - [:& msr/measurement + [:> msr/measurement* {:bounds vbox :selected-shapes selected-shapes :frame selected-frame