From 23dab28d7b355bc20aa3386b8e6929f2bb2bb13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Thu, 22 Dec 2016 19:00:30 +0100 Subject: [PATCH] Adding precision to options in the sidebar --- .../sidebar/options/circle_measures.cljs | 11 ++++++----- .../workspace/sidebar/options/icon_measures.cljs | 11 ++++++----- .../workspace/sidebar/options/line_measures.cljs | 11 ++++++----- .../workspace/sidebar/options/rect_measures.cljs | 15 ++++++++------- .../main/ui/workspace/sidebar/options/stroke.cljs | 3 ++- .../main/ui/workspace/sidebar/options/text.cljs | 7 ++++--- 6 files changed, 32 insertions(+), 26 deletions(-) diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/circle_measures.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/circle_measures.cljs index 7ef2657ee..95b1f129d 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/circle_measures.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/circle_measures.cljs @@ -19,6 +19,7 @@ [uxbox.util.mixins :as mx :include-macros true] [uxbox.main.geom :as geom] [uxbox.util.dom :as dom] + [uxbox.util.math :refer (precision)] [uxbox.util.data :refer (parse-int parse-float read-string)])) (mx/defc circle-measures-menu @@ -56,7 +57,7 @@ {:placeholder "Width" :type "number" :min "0" - :value (:rx shape) + :value (precision (:rx shape 0) 2) :on-change (partial on-size-change :rx)}]] [:div.lock-size {:class (when (:proportion-lock shape) "selected") @@ -67,7 +68,7 @@ {:placeholder "Height" :type "number" :min "0" - :value (:ry shape) + :value (precision (:ry shape 0) 2) :on-change (partial on-size-change :ry)}]]] [:span "Position"] @@ -76,13 +77,13 @@ [:input.input-text {:placeholder "cx" :type "number" - :value (:cx shape "") + :value (precision (:cx shape 0) 2) :on-change (partial on-pos-change :x)}]] [:div.input-element.pixels [:input.input-text {:placeholder "cy" :type "number" - :value (:cy shape "") + :value (precision (:cy shape 0) 2) :on-change (partial on-pos-change :y)}]]] [:span "Rotation"] @@ -101,7 +102,7 @@ :type "number" :min 0 :max 360 - :value (:rotation shape "0") + :value (precision (:rotation shape "0") 2) :on-change on-rotation-change }]] [:input.input-text diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/icon_measures.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/icon_measures.cljs index b2fe62839..f53109397 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/icon_measures.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/icon_measures.cljs @@ -19,6 +19,7 @@ [uxbox.util.mixins :as mx :include-macros true] [uxbox.main.geom :as geom] [uxbox.util.dom :as dom] + [uxbox.util.math :refer (precision)] [uxbox.util.data :refer (parse-int parse-float read-string)])) (defn- icon-measures-menu-render @@ -53,7 +54,7 @@ {:placeholder "Width" :type "number" :min "0" - :value (:width size) + :value (precision (:width size) 2) :on-change (partial on-size-change :width)}]] [:div.lock-size i/lock] [:div.input-element.pixels @@ -61,7 +62,7 @@ {:placeholder "Height" :type "number" :min "0" - :value (:height size) + :value (precision (:height size) 2) :on-change (partial on-size-change :height)}]]] [:span "Position"] @@ -70,13 +71,13 @@ [:input.input-text {:placeholder "X" :type "number" - :value (:x1 shape "") + :value (precision (:x1 shape 0) 2) :on-change (partial on-pos-change :x)}]] [:div.input-element.pixels [:input.input-text {:placeholder "Y" :type "number" - :value (:y1 shape "") + :value (precision (:y1 shape 0) 2) :on-change (partial on-pos-change :y)}]]] [:span "Rotation"] @@ -95,7 +96,7 @@ :type "number" :min 0 :max 360 - :value (:rotation shape "0") + :value (precision (:rotation shape 0) 2) :on-change on-rotation-change }]] [:input.input-text diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/line_measures.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/line_measures.cljs index f062b5e1e..85b3c535b 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/line_measures.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/line_measures.cljs @@ -19,6 +19,7 @@ [uxbox.util.mixins :as mx :include-macros true] [uxbox.main.geom :as geom] [uxbox.util.dom :as dom] + [uxbox.util.math :refer (precision)] [uxbox.util.data :refer (parse-int parse-float read-string)])) (defn- line-measures-menu-render @@ -43,24 +44,24 @@ [:input.input-text {:placeholder "x1" :type "number" - :value (:x1 shape "") + :value (precision (:x1 shape 0) 2) :on-change (partial on-pos-change :x1)}] [:input.input-text {:placeholder "y1" :type "number" - :value (:y1 shape "") + :value (precision (:y1 shape 0) 2) :on-change (partial on-pos-change :y1)}]] [:div.row-flex [:input.input-text {:placeholder "x2" :type "number" - :value (:x2 shape "") + :value (precision (:x2 shape 0) 2) :on-change (partial on-pos-change :x2)}] [:input.input-text {:placeholder "y2" :type "number" - :value (:y2 shape "") + :value (precision (:y2 shape 0) 2) :on-change (partial on-pos-change :y2)}]] [:span "Rotation"] @@ -78,7 +79,7 @@ :type "number" :min 0 :max 360 - :value (:rotation shape "0") + :value (precision (:rotation shape 0) 2) :on-change on-rotation-change }] [:input.input-text diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/rect_measures.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/rect_measures.cljs index 46b207678..04f1af600 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/rect_measures.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/rect_measures.cljs @@ -17,6 +17,7 @@ [uxbox.util.mixins :as mx :include-macros true] [uxbox.main.geom :as geom] [uxbox.util.dom :as dom] + [uxbox.util.math :refer (precision)] [uxbox.util.data :refer (parse-int parse-float read-string)])) (mx/defc rect-measures-menu @@ -60,7 +61,7 @@ {:placeholder "Width" :type "number" :min "0" - :value (:width size) + :value (precision (:width size) 2) :on-change (partial on-size-change :width)}]] [:div.lock-size {:class (when (:proportion-lock shape) "selected") @@ -71,7 +72,7 @@ {:placeholder "Height" :type "number" :min "0" - :value (:height size) + :value (precision (:height size) 2) :on-change (partial on-size-change :height)}]]] [:span "Position"] @@ -80,13 +81,13 @@ [:input.input-text {:placeholder "x" :type "number" - :value (:x1 shape "") + :value (precision (:x1 shape 0) 2) :on-change (partial on-pos-change :x)}]] [:div.input-element.pixels [:input.input-text {:placeholder "y" :type "number" - :value (:y1 shape "") + :value (precision (:y1 shape 0) 2) :on-change (partial on-pos-change :y)}]]] [:span "Border radius"] @@ -94,13 +95,13 @@ [:input.input-text {:placeholder "rx" :type "number" - :value (:rx shape "") + :value (precision (:rx shape 0) 2) :on-change (partial on-border-change :rx)}] [:div.lock-size i/lock] [:input.input-text {:placeholder "ry" :type "number" - :value (:ry shape "") + :value (precision (:ry shape 0) 2) :on-change (partial on-border-change :ry)}]] [:span "Rotation"] @@ -119,7 +120,7 @@ :type "number" :min 0 :max 360 - :value (:rotation shape "0") + :value (precision (:rotation shape "0") 2) :on-change on-rotation-change }]] [:input.input-text diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/stroke.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/stroke.cljs index a009ab1c3..7b3375ef2 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/stroke.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/stroke.cljs @@ -19,6 +19,7 @@ [uxbox.util.mixins :as mx :include-macros true] [uxbox.util.dom :as dom] [uxbox.util.data :refer (parse-int parse-float read-string)] + [uxbox.util.math :refer (precision)] [uxbox.util.spec :refer (color?)])) (defn- stroke-menu-render @@ -71,7 +72,7 @@ {:placeholder "Width" :type "number" :min "0" - :value (:stroke-width shape "1") + :value (precision (:stroke-width shape 1) 2) :on-change on-width-change}]]] [:span "Color"] diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/text.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/text.cljs index 0d077eeb3..4031ef164 100644 --- a/frontend/src/uxbox/main/ui/workspace/sidebar/options/text.cljs +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/text.cljs @@ -21,6 +21,7 @@ [uxbox.main.ui.workspace.base :as wb] [uxbox.main.geom :as geom] [uxbox.util.dom :as dom] + [uxbox.util.math :refer (precision)] [uxbox.util.data :refer (parse-int parse-float read-string @@ -94,7 +95,7 @@ :type "number" :min "0" :max "200" - :value size + :value (precision size 2) :on-change on-font-size-change}] [:select.input-select {:value (pr-str [weight style]) :on-change on-font-style-change} @@ -111,7 +112,7 @@ :step "0.1" :min "0" :max "200" - :value line-height + :value (precision line-height 2) :on-change on-font-line-height-change}] [:input.input-text {:placeholder "Letter spacing" @@ -119,7 +120,7 @@ :step "0.1" :min "0" :max "200" - :value letter-spacing + :value (precision letter-spacing 2) :on-change on-font-letter-spacing-change}]]