mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 08:41:38 +02:00
🐛 Fix copying layout values with only multiple decimals
This commit is contained in:
parent
1102bc9cba
commit
37fdf51eaf
2 changed files with 14 additions and 12 deletions
|
@ -8,9 +8,9 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.spec.radius :as ctr]
|
[app.common.spec.radius :as ctr]
|
||||||
[app.main.ui.components.copy-button :refer [copy-button]]
|
[app.main.ui.components.copy-button :refer [copy-button]]
|
||||||
|
[app.main.ui.formats :as fmt]
|
||||||
[app.util.code-gen :as cg]
|
[app.util.code-gen :as cg]
|
||||||
[app.util.i18n :refer [tr]]
|
[app.util.i18n :refer [tr]]
|
||||||
[app.util.strings :as ust]
|
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
|
@ -35,50 +35,51 @@
|
||||||
(mf/defc layout-block
|
(mf/defc layout-block
|
||||||
[{:keys [shape]}]
|
[{:keys [shape]}]
|
||||||
(let [selrect (:selrect shape)
|
(let [selrect (:selrect shape)
|
||||||
|
_ (prn shape)
|
||||||
{:keys [width height x y]} selrect]
|
{:keys [width height x y]} selrect]
|
||||||
[:*
|
[:*
|
||||||
[:div.attributes-unit-row
|
[:div.attributes-unit-row
|
||||||
[:div.attributes-label (tr "handoff.attributes.layout.width")]
|
[:div.attributes-label (tr "handoff.attributes.layout.width")]
|
||||||
[:div.attributes-value (ust/format-precision width 2) "px"]
|
[:div.attributes-value (fmt/format-pixels width)]
|
||||||
[:& copy-button {:data (copy-data selrect :width)}]]
|
[:& copy-button {:data (copy-data selrect :width)}]]
|
||||||
|
|
||||||
[:div.attributes-unit-row
|
[:div.attributes-unit-row
|
||||||
[:div.attributes-label (tr "handoff.attributes.layout.height")]
|
[:div.attributes-label (tr "handoff.attributes.layout.height")]
|
||||||
[:div.attributes-value (ust/format-precision height 2) "px"]
|
[:div.attributes-value (fmt/format-pixels height)]
|
||||||
[:& copy-button {:data (copy-data selrect :height)}]]
|
[:& copy-button {:data (copy-data selrect :height)}]]
|
||||||
|
|
||||||
(when (not= (:x shape) 0)
|
(when (not= (:x shape) 0)
|
||||||
[:div.attributes-unit-row
|
[:div.attributes-unit-row
|
||||||
[:div.attributes-label (tr "handoff.attributes.layout.left")]
|
[:div.attributes-label (tr "handoff.attributes.layout.left")]
|
||||||
[:div.attributes-value (ust/format-precision x 2) "px"]
|
[:div.attributes-value (fmt/format-pixels x)]
|
||||||
[:& copy-button {:data (copy-data selrect :x)}]])
|
[:& copy-button {:data (copy-data selrect :x)}]])
|
||||||
|
|
||||||
(when (not= (:y shape) 0)
|
(when (not= (:y shape) 0)
|
||||||
[:div.attributes-unit-row
|
[:div.attributes-unit-row
|
||||||
[:div.attributes-label (tr "handoff.attributes.layout.top")]
|
[:div.attributes-label (tr "handoff.attributes.layout.top")]
|
||||||
[:div.attributes-value (ust/format-precision y 2) "px"]
|
[:div.attributes-value (fmt/format-pixels y)]
|
||||||
[:& copy-button {:data (copy-data selrect :y)}]])
|
[:& copy-button {:data (copy-data selrect :y)}]])
|
||||||
|
|
||||||
(when (ctr/radius-1? shape)
|
(when (ctr/radius-1? shape)
|
||||||
[:div.attributes-unit-row
|
[:div.attributes-unit-row
|
||||||
[:div.attributes-label (tr "handoff.attributes.layout.radius")]
|
[:div.attributes-label (tr "handoff.attributes.layout.radius")]
|
||||||
[:div.attributes-value (ust/format-precision (:rx shape 0) 2) "px"]
|
[:div.attributes-value (fmt/format-pixels (:rx shape 0))]
|
||||||
[:& copy-button {:data (copy-data shape :rx)}]])
|
[:& copy-button {:data (copy-data shape :rx)}]])
|
||||||
|
|
||||||
(when (ctr/radius-4? shape)
|
(when (ctr/radius-4? shape)
|
||||||
[:div.attributes-unit-row
|
[:div.attributes-unit-row
|
||||||
[:div.attributes-label (tr "handoff.attributes.layout.radius")]
|
[:div.attributes-label (tr "handoff.attributes.layout.radius")]
|
||||||
[:div.attributes-value
|
[:div.attributes-value
|
||||||
(ust/format-precision (:r1 shape) 2) ", "
|
(fmt/format-number (:r1 shape)) ", "
|
||||||
(ust/format-precision (:r2 shape) 2) ", "
|
(fmt/format-number (:r2 shape)) ", "
|
||||||
(ust/format-precision (:r3 shape) 2) ", "
|
(fmt/format-number (:r3 shape))", "
|
||||||
(ust/format-precision (:r4 shape) 2) "px"]
|
(fmt/format-pixels (:r4 shape))]
|
||||||
[:& copy-button {:data (copy-data shape :r1)}]])
|
[:& copy-button {:data (copy-data shape :r1)}]])
|
||||||
|
|
||||||
(when (not= (:rotation shape 0) 0)
|
(when (not= (:rotation shape 0) 0)
|
||||||
[:div.attributes-unit-row
|
[:div.attributes-unit-row
|
||||||
[:div.attributes-label (tr "handoff.attributes.layout.rotation")]
|
[:div.attributes-label (tr "handoff.attributes.layout.rotation")]
|
||||||
[:div.attributes-value (ust/format-precision (:rotation shape) 2) "deg"]
|
[:div.attributes-value (fmt/format-number (:rotation shape)) "deg"]
|
||||||
[:& copy-button {:data (copy-data shape :rotation)}]])]))
|
[:& copy-button {:data (copy-data shape :rotation)}]])]))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
|
[app.main.ui.formats :as fmt]
|
||||||
[app.util.color :as uc]
|
[app.util.color :as uc]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
|
@ -108,7 +109,7 @@
|
||||||
(every? #(or (nil? %) (= % 0)) value)
|
(every? #(or (nil? %) (= % 0)) value)
|
||||||
(or (nil? value) (= value 0))))
|
(or (nil? value) (= value 0))))
|
||||||
|
|
||||||
default-format (fn [value] (str value "px"))
|
default-format (fn [value] (str (fmt/format-pixels value)))
|
||||||
format-property (fn [prop]
|
format-property (fn [prop]
|
||||||
(let [css-prop (or (prop to-prop) (name prop))
|
(let [css-prop (or (prop to-prop) (name prop))
|
||||||
format-fn (or (prop format) default-format)
|
format-fn (or (prop format) default-format)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue