From 9dcad7ebef649e090f42450ac84d26b2fbc9c43b Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Tue, 19 Apr 2022 19:29:11 +0200 Subject: [PATCH] :bug: Round the size values on handoff to two decimals --- CHANGES.md | 1 + .../ui/viewer/handoff/attributes/layout.cljs | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3b0ed9a90..09a3ab9d2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -50,6 +50,7 @@ - Constraints are not well assigned when default and multiselection [Taiga #3069](https://tree.taiga.io/project/penpot/issue/3069) - Duplicate artboards create new flows if needed [Taiga #2221](https://tree.taiga.io/project/penpot/issue/2221) +- Round the size values on handoff to two decimals [Taiga #3227](https://tree.taiga.io/project/penpot/issue/3227) - Fix paste shapes while editing text [Taiga #2396](https://tree.taiga.io/project/penpot/issue/2396) - Fix blend modes ignored in component updates [Taiga #2626](https://tree.taiga.io/project/penpot/issue/2626) - Fix internal error when hoverin over shape [Taiga #3237](https://tree.taiga.io/project/penpot/issue/3237) diff --git a/frontend/src/app/main/ui/viewer/handoff/attributes/layout.cljs b/frontend/src/app/main/ui/viewer/handoff/attributes/layout.cljs index fe7c7faa6..fe748716c 100644 --- a/frontend/src/app/main/ui/viewer/handoff/attributes/layout.cljs +++ b/frontend/src/app/main/ui/viewer/handoff/attributes/layout.cljs @@ -10,6 +10,7 @@ [app.main.ui.components.copy-button :refer [copy-button]] [app.util.code-gen :as cg] [app.util.i18n :refer [tr]] + [app.util.strings :as ust] [cuerdas.core :as str] [rumext.alpha :as mf])) @@ -38,46 +39,46 @@ [:* [:div.attributes-unit-row [:div.attributes-label (tr "handoff.attributes.layout.width")] - [:div.attributes-value width "px"] + [:div.attributes-value (ust/format-precision width 2) "px"] [:& copy-button {:data (copy-data selrect :width)}]] [:div.attributes-unit-row [:div.attributes-label (tr "handoff.attributes.layout.height")] - [:div.attributes-value height "px"] + [:div.attributes-value (ust/format-precision height 2) "px"] [:& copy-button {:data (copy-data selrect :height)}]] (when (not= (:x shape) 0) [:div.attributes-unit-row [:div.attributes-label (tr "handoff.attributes.layout.left")] - [:div.attributes-value x "px"] + [:div.attributes-value (ust/format-precision x 2) "px"] [:& copy-button {:data (copy-data selrect :x)}]]) (when (not= (:y shape) 0) [:div.attributes-unit-row [:div.attributes-label (tr "handoff.attributes.layout.top")] - [:div.attributes-value y "px"] + [:div.attributes-value (ust/format-precision y 2) "px"] [:& copy-button {:data (copy-data selrect :y)}]]) (when (ctr/radius-1? shape) [:div.attributes-unit-row [:div.attributes-label (tr "handoff.attributes.layout.radius")] - [:div.attributes-value (:rx shape 0) "px"] + [:div.attributes-value (ust/format-precision (:rx shape 0) 2) "px"] [:& copy-button {:data (copy-data shape :rx)}]]) (when (ctr/radius-4? shape) [:div.attributes-unit-row [:div.attributes-label (tr "handoff.attributes.layout.radius")] [:div.attributes-value - (:r1 shape) ", " - (:r2 shape) ", " - (:r3 shape) ", " - (:r4 shape) "px"] + (ust/format-precision (:r1 shape) 2) ", " + (ust/format-precision (:r2 shape) 2) ", " + (ust/format-precision (:r3 shape) 2) ", " + (ust/format-precision (:r4 shape) 2) "px"] [:& copy-button {:data (copy-data shape :r1)}]]) (when (not= (:rotation shape 0) 0) [:div.attributes-unit-row [:div.attributes-label (tr "handoff.attributes.layout.rotation")] - [:div.attributes-value (:rotation shape) "deg"] + [:div.attributes-value (ust/format-precision (:rotation shape) 2) "deg"] [:& copy-button {:data (copy-data shape :rotation)}]])]))