💄 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,30 +71,35 @@
[: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")}
[:input.input-text {:type "number" (when show-options
:min "0" [:input.input-text {:type "number"
:value (-> (:stroke-width shape) :min "0"
(math/precision 2) :value (-> (:stroke-width shape)
(d/coalesce-str "1")) (math/precision 2)
:on-change on-stroke-width-change}]]] (d/coalesce-str "1"))
:on-change on-stroke-width-change}])]]
;; Stroke Color ;; Stroke Color
[:span (tr "workspace.options.color")] (when show-options
[:div.row-flex.color-data [:*
[:span.color-th {:style {:background-color (:stroke-color shape)} [:span (tr "workspace.options.color")]
:on-click show-color-picker}]
[:div.color-info
[:input {:read-only true
:default-value (:stroke-color shape "")}]]]
[:span (tr "workspace.options.opacity")] [:div.row-flex.color-data
[:div.row-flex [:span.color-th {:style {:background-color (:stroke-color shape)}
[:input.slidebar {:type "range" :on-click show-color-picker}]
:min "0" [:div.color-info
:max "10000" [:input {:read-only true
:value (-> (:stroke-opacity shape 1) :default-value (:stroke-color shape "")}]]]
(* 10000)
(d/coalesce-str "1")) [:span (tr "workspace.options.opacity")]
:step "1"
:on-change on-stroke-opacity-change}]]]])) [:div.row-flex
[:input.slidebar {:type "range"
:min "0"
:max "10000"
:value (-> (:stroke-opacity shape 1)
(* 10000)
(d/coalesce-str "1"))
:step "1"
:on-change on-stroke-opacity-change}]]])]]))