From e68689aa4fcc106adf34c9d467ab3f4392d70a77 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 eaa92da3b..4b20564be 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -49,6 +49,7 @@ ### :bug: Bugs fixed +- Round the size values on handoff to two decimals [Taiga #3227](https://tree.taiga.io/project/penpot/issue/3227) - Fix hidden file name on import [Taiga #3172](https://tree.taiga.io/project/penpot/issue/3172) - Fix unneccessary scrollbars at the color list [Taiga #3211](https://tree.taiga.io/project/penpot/issue/3211) - "Show in exports" is showing in multiselections [Taiga #3194](https://tree.taiga.io/project/penpot/issue/3194) 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)}]])]))