diff --git a/frontend/src/app/main/ui/components/numeric_input.cljs b/frontend/src/app/main/ui/components/numeric_input.cljs index 3f25417563..c603ccf1d1 100644 --- a/frontend/src/app/main/ui/components/numeric_input.cljs +++ b/frontend/src/app/main/ui/components/numeric_input.cljs @@ -30,7 +30,7 @@ on-change (obj/get props "onChange") on-blur (obj/get props "onBlur") title (obj/get props "title") - default-val (obj/get props "default" 0) + default-val (obj/get props "default") ;; We need a ref pointing to the input dom element, but the user ;; of this component may provide one (that is forwarded here). diff --git a/frontend/src/app/main/ui/formats.cljs b/frontend/src/app/main/ui/formats.cljs index 18e0e2abad..8cc39d56bc 100644 --- a/frontend/src/app/main/ui/formats.cljs +++ b/frontend/src/app/main/ui/formats.cljs @@ -6,31 +6,38 @@ (ns app.main.ui.formats (:require + [app.common.data :as d] [app.common.data.macros :as dm] [app.common.math :as mth])) (defn format-percent ([value] (format-percent value nil)) + ([value {:keys [precision] :or {precision 2}}] - (let [percent-val (mth/precision (* value 100) precision)] - (dm/str percent-val "%")))) + (when (d/num? value) + (let [percent-val (mth/precision (* value 100) precision)] + (dm/str percent-val "%"))))) (defn format-number ([value] (format-number value nil)) ([value {:keys [precision] :or {precision 2}}] - (let [value (mth/precision value precision)] - (dm/str value)))) + (when (d/num? value) + (let [value (mth/precision value precision)] + (dm/str value))))) (defn format-pixels ([value] (format-pixels value nil)) + ([value {:keys [precision] :or {precision 2}}] - (let [value (mth/precision value precision)] - (dm/str value "px")))) + (when (d/num? value) + (let [value (mth/precision value precision)] + (dm/str value "px"))))) (defn format-int [value] - (let [value (mth/precision value 0)] - (dm/str value))) + (when (d/num? value) + (let [value (mth/precision value 0)] + (dm/str value)))) diff --git a/frontend/src/app/main/ui/shapes/text/svg_text.cljs b/frontend/src/app/main/ui/shapes/text/svg_text.cljs index 02ecf4f212..cbed80c747 100644 --- a/frontend/src/app/main/ui/shapes/text/svg_text.cljs +++ b/frontend/src/app/main/ui/shapes/text/svg_text.cljs @@ -8,6 +8,7 @@ (:require [app.common.data :as d] [app.common.geom.shapes :as gsh] + [app.common.math :as mth] [app.main.ui.context :as muc] [app.main.ui.shapes.attrs :as attrs] [app.main.ui.shapes.custom-stroke :refer [shape-custom-strokes]] @@ -24,6 +25,7 @@ (let [render-id (mf/use-ctx muc/render-ctx) {:keys [x y width height position-data] :as shape} (obj/get props "shape") + transform (str (gsh/transform-matrix shape)) ;; These position attributes are not really necesary but they are convenient for for the export @@ -48,8 +50,8 @@ [:> :g group-props (for [[index data] (d/enumerate position-data)] - (let [props (-> #js {:x (:x data) - :y (:y data) + (let [props (-> #js {:x (mth/round (:x data)) + :y (mth/round (:y data)) :dominantBaseline "ideographic" :style (-> #js {:fontFamily (:font-family data) :fontSize (:font-size data) @@ -61,7 +63,18 @@ :whiteSpace "pre"} (obj/set! "fill" (str "url(#fill-" index "-" render-id ")")))}) shape (assoc shape :fills (:fills data))] - [:& shape-custom-strokes {:shape shape} - [:> :text props (:text data)]]))]])) + [:* + #_[:rect {:x (:x data) + :y (- (:y data) (:height data)) + :width (:width data) + :height (:height data) + :style {:fill "none" :stroke-width 1 :stroke "red"}}] + [:line {:x1 (mth/round (:x data)) + :y1 (mth/round (:y data)) + :x2 (mth/round (+ (:x data) (:width data))) + :y2 (mth/round (:y data)) + :style {:fill "none" :stroke-width 0.5 :stroke "blue"}}] + [:& shape-custom-strokes {:shape shape} + [:> :text props (:text data)]]]))]])) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs index 8ea1e112bb..831e544f61 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/measures.cljs @@ -201,8 +201,8 @@ (fn [] (when (and (= radius-mode :radius-1) (= @radius-multi? false)) - ;; when going back from radius-multi to normal radius-1, - ;; restore focus to the newly created numeric-input + ;; when going back from radius-multi to normal radius-1, + ;; restore focus to the newly created numeric-input (let [radius-input (mf/ref-val radius-input-ref)] (dom/focus! radius-input)))))