💄 Hide strike options when strike is none

This commit is contained in:
Andrés Moya 2020-04-03 13:30:40 +02:00 committed by Andrey Antukh
parent 9f664f5239
commit 5809a67e4c

View file

@ -21,7 +21,9 @@
(mf/defc stroke-menu (mf/defc stroke-menu
[{:keys [shape] :as props}] [{:keys [shape] :as props}]
(let [on-stroke-style-change (let [show-options (not= (:stroke-style shape) :none)
on-stroke-style-change
(fn [event] (fn [event]
(let [value (-> (dom/get-target event) (let [value (-> (dom/get-target event)
(dom/get-value) (dom/get-value)
@ -69,16 +71,20 @@
[:option {:value ":dashed"} (tr "workspace.options.stroke.dashed")] [:option {:value ":dashed"} (tr "workspace.options.stroke.dashed")]
[:option {:value ":mixed"} (tr "workspace.options.stroke.mixed")]] [:option {:value ":mixed"} (tr "workspace.options.stroke.mixed")]]
[:div.input-element.pixels [:div.input-element {:class (when show-options "pixels")}
(when show-options
[:input.input-text {:type "number" [:input.input-text {:type "number"
:min "0" :min "0"
:value (-> (:stroke-width shape) :value (-> (:stroke-width shape)
(math/precision 2) (math/precision 2)
(d/coalesce-str "1")) (d/coalesce-str "1"))
:on-change on-stroke-width-change}]]] :on-change on-stroke-width-change}])]]
;; Stroke Color ;; Stroke Color
(when show-options
[:*
[:span (tr "workspace.options.color")] [:span (tr "workspace.options.color")]
[:div.row-flex.color-data [:div.row-flex.color-data
[:span.color-th {:style {:background-color (:stroke-color shape)} [:span.color-th {:style {:background-color (:stroke-color shape)}
:on-click show-color-picker}] :on-click show-color-picker}]
@ -87,6 +93,7 @@
:default-value (:stroke-color shape "")}]]] :default-value (:stroke-color shape "")}]]]
[:span (tr "workspace.options.opacity")] [:span (tr "workspace.options.opacity")]
[:div.row-flex [:div.row-flex
[:input.slidebar {:type "range" [:input.slidebar {:type "range"
:min "0" :min "0"
@ -95,4 +102,4 @@
(* 10000) (* 10000)
(d/coalesce-str "1")) (d/coalesce-str "1"))
:step "1" :step "1"
:on-change on-stroke-opacity-change}]]]])) :on-change on-stroke-opacity-change}]]])]]))