From 152a5e8b94adebb3408e87fbe1b3e4eb6e7d661a Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 7 Jan 2020 17:00:52 +0100 Subject: [PATCH] :bug: Add missing files. --- .../ui/workspace/sidebar/options/image.cljs | 135 ++++++++++++++++++ .../workspace/sidebar/options/measures.cljs | 119 +++++++++++++++ .../ui/workspace/sidebar/options/path.cljs | 19 +++ 3 files changed, 273 insertions(+) create mode 100644 frontend/src/uxbox/main/ui/workspace/sidebar/options/image.cljs create mode 100644 frontend/src/uxbox/main/ui/workspace/sidebar/options/measures.cljs create mode 100644 frontend/src/uxbox/main/ui/workspace/sidebar/options/path.cljs diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/image.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/image.cljs new file mode 100644 index 000000000..9067fd91a --- /dev/null +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/image.cljs @@ -0,0 +1,135 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) 2015-2017 Andrey Antukh +;; Copyright (c) 2015-2017 Juan de la Cruz + +(ns uxbox.main.ui.workspace.sidebar.options.image + (:require + [rumext.alpha :as mf] + [uxbox.common.data :as d] + [uxbox.builtins.icons :as i] + [uxbox.main.data.workspace :as udw] + [uxbox.main.geom :as geom] + [uxbox.main.store :as st] + [uxbox.util.dom :as dom] + [uxbox.util.geom.point :as gpt] + [uxbox.util.i18n :refer [tr]] + [uxbox.util.math :as math])) + +(mf/defc measures-menu + [{:keys [shape] :as props}] + (let [on-size-change + (fn [event attr] + (let [value (-> (dom/get-target event) + (dom/get-value) + (d/parse-integer 0))] + (st/emit! (udw/update-dimensions (:id shape) {attr value})))) + + on-proportion-lock-change + (fn [event] + (st/emit! (udw/toggle-shape-proportion-lock (:id shape)))) + + on-position-change + (fn [event attr] + (let [value (-> (dom/get-target event) + (dom/get-value) + (d/parse-integer)) + point (gpt/point {attr value})] + (st/emit! (udw/update-position (:id shape) point)))) + + on-rotation-change + (fn [event] + (let [value (-> (dom/get-target event) + (dom/get-value) + (d/parse-integer 0))] + (st/emit! (udw/update-shape (:id shape) {:rotation value})))) + + on-radius-change + (fn [event] + (let [value (-> (dom/get-target event) + (dom/get-value) + (d/parse-double 0))] + (st/emit! (udw/update-shape (:id shape) {:rx value :ry value})))) + + on-width-change #(on-size-change % :width) + on-height-change #(on-size-change % :height) + on-pos-x-change #(on-position-change % :x) + on-pos-y-change #(on-position-change % :y)] + + [:div.element-set + [:div.element-set-title (tr "workspace.options.measures")] + [:div.element-set-content + [:span (tr "workspace.options.size")] + + ;; WIDTH & HEIGHT + [:div.row-flex + [:div.input-element.pixels + [:input.input-text {:type "number" + :min "0" + :on-change on-width-change + :value (-> (:width shape) + (math/precision 2) + (d/coalesce-str "0"))}]] + + [:div.lock-size {:class (when (:proportion-lock shape) "selected") + :on-click on-proportion-lock-change} + (if (:proportion-lock shape) + i/lock + i/unlock)] + + [:div.input-element.pixels + [:input.input-text {:type "number" + :min "0" + :on-change on-height-change + :value (-> (:height shape) + (math/precision 2) + (d/coalesce-str "0"))}]]] + + ;; POSITION + [:span (tr "workspace.options.position")] + [:div.row-flex + [:div.input-element.pixels + [:input.input-text {:placeholder "x" + :type "number" + :on-change on-pos-x-change + :value (-> (:x shape) + (math/precision 2) + (d/coalesce-str "0"))}]] + [:div.input-element.pixels + [:input.input-text {:placeholder "y" + :type "number" + :on-change on-pos-y-change + :value (-> (:y shape) + (math/precision 2) + (d/coalesce-str "0"))}]]] + + [:span (tr "workspace.options.rotation-radius")] + [:div.row-flex + [:div.input-element.degrees + [:input.input-text {:placeholder "" + :type "number" + :min 0 + :max 360 + :on-change on-rotation-change + :value (-> (:rotation shape 0) + (math/precision 2) + (d/coalesce-str "0"))}]] + + [:div.input-element.pixels + [:input.input-text + {:placeholder "rx" + :type "number" + :on-change on-radius-change + :value (-> (:rx shape) + (math/precision 2) + (d/coalesce-str "0"))}]]]]])) + + +(mf/defc options + [{:keys [shape] :as props}] + [:div + [:& measures-menu {:shape shape}] + #_[:& fill-menu {:shape shape}] + #_[:& stroke-menu {:shape shape}]]) diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/measures.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/measures.cljs new file mode 100644 index 000000000..1bc01b38f --- /dev/null +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/measures.cljs @@ -0,0 +1,119 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) 2015-2016 Juan de la Cruz +;; Copyright (c) 2015-2019 Andrey Antukh + +(ns uxbox.main.ui.workspace.sidebar.options.measures + (:require + [rumext.alpha :as mf] + [uxbox.common.data :as d] + [uxbox.builtins.icons :as i] + [uxbox.main.data.workspace :as udw] + [uxbox.main.geom :as geom] + [uxbox.main.store :as st] + [uxbox.util.dom :as dom] + [uxbox.util.geom.point :as gpt] + [uxbox.util.i18n :refer [tr]] + [uxbox.util.math :as math])) + +(mf/defc size-options + [{:keys [shape] :as props}] + (let [on-size-change + (fn [event attr] + (let [value (-> (dom/get-target event) + (dom/get-value) + (d/parse-integer 0))] + (st/emit! (udw/update-dimensions (:id shape) {attr value})))) + + on-proportion-lock-change + (fn [event] + (st/emit! (udw/toggle-shape-proportion-lock (:id shape)))) + + on-size-rx-change #(on-size-change % :rx) + on-size-ry-change #(on-size-change % :ry) + ] + [:* + [:span (tr "workspace.options.size")] + [:div.row-flex + [:div.input-element.pixels + [:input.input-text {:type "number" + :min "0" + :on-change on-size-rx-change + :value (-> (:rx shape) + (math/precision 2) + (d/coalesce-str "0"))}]] + [:div.lock-size {:class (when (:proportion-lock shape) "selected") + :on-click on-proportion-lock-change} + (if (:proportion-lock shape) + i/lock + i/unlock)] + + [:div.input-element.pixels + [:input.input-text {:type "number" + :min "0" + :on-change on-size-ry-change + :value (-> (:ry shape) + (math/precision 2) + (d/coalesce-str "0"))}]]]])) + +(mf/defc position-options + [{:keys [shape] :as props}] + (let [on-position-change + (fn [event attr] + (let [value (-> (dom/get-target event) + (dom/get-value) + (d/parse-integer)) + point (gpt/point {attr value})] + (st/emit! (udw/update-position (:id shape) point)))) + + on-pos-cx-change #(on-position-change % :x) + on-pos-cy-change #(on-position-change % :y)] + [:* + [:span (tr "workspace.options.position")] + [:div.row-flex + [:div.input-element.pixels + [:input.input-text {:type "number" + :on-change on-pos-cx-change + :value (-> (:cx shape) + (math/precision 2) + (d/coalesce-str "0"))}]] + [:div.input-element.pixels + [:input.input-text {:type "number" + :on-change on-pos-cy-change + :value (-> (:cy shape) + (math/precision 2) + (d/coalesce-str "0"))}]]]])) + +(mf/defc rotation-and-radius-options + [{:keys [shape] :as props}] + [:* + [:span (tr "workspace.options.rotation-radius")] + [:div.row-flex + [:div.input-element.degrees + [:input.input-text {:placeholder "" + :type "number" + :min 0 + :max 360 + ;; :on-change on-rotation-change + :value (-> (:rotation shape 0) + (math/precision 2) + (d/coalesce-str "0"))}]] + + [:div.input-element.pixels + [:input.input-text + {:type "number" + ;; :on-change on-radius-change + :value (-> (:rx shape) + (math/precision 2) + (d/coalesce-str "0"))}]]]]) + +(mf/defc measures-menu + [{:keys [shape] :as props}] + [:div.element-set + [:div.element-set-title (tr "workspace.options.measures")] + [:div.element-set-content + [:& size-options {:shape shape}] + [:& position-options {:shape shape}] + [:& rotation-and-radius-options {:shape shape}]]]) diff --git a/frontend/src/uxbox/main/ui/workspace/sidebar/options/path.cljs b/frontend/src/uxbox/main/ui/workspace/sidebar/options/path.cljs new file mode 100644 index 000000000..cccb9de03 --- /dev/null +++ b/frontend/src/uxbox/main/ui/workspace/sidebar/options/path.cljs @@ -0,0 +1,19 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) 2015-2016 Juan de la Cruz +;; Copyright (c) 2015-2019 Andrey Antukh + +(ns uxbox.main.ui.workspace.sidebar.options.path + (:require + [rumext.alpha :as mf] + [uxbox.common.data :as d] + [uxbox.main.ui.workspace.sidebar.options.fill :refer [fill-menu]] + [uxbox.main.ui.workspace.sidebar.options.stroke :refer [stroke-menu]])) + +(mf/defc options + [{:keys [shape] :as props}] + [:div + [:& fill-menu {:shape shape}] + [:& stroke-menu {:shape shape}]])