diff --git a/src/uxbox/data/shapes.cljs b/src/uxbox/data/shapes.cljs index ecf708968..38d341b76 100644 --- a/src/uxbox/data/shapes.cljs +++ b/src/uxbox/data/shapes.cljs @@ -56,6 +56,7 @@ {:family [sc/string] :style [sc/string] :weight [sc/string] + :align [sc/string] :size [sc/number]}) (def ^:static +shape-radius-attrs-schema+ @@ -166,13 +167,14 @@ (when opacity {:opacity opacity}))))) (defn update-font-attrs - [sid {:keys [family style weight size] :as opts}] + [sid {:keys [family style weight size align] :as opts}] (sc/validate! +shape-font-attrs-schema+ opts) (reify rs/UpdateEvent (-apply-update [_ state] (update-in state [:shapes-by-id sid :font] merge + (when align {:align align}) (when family {:family family}) (when style {:style style}) (when weight {:weight weight}) diff --git a/src/uxbox/ui/shapes/text.cljs b/src/uxbox/ui/shapes/text.cljs index 91b05dbcc..5966cb0c6 100644 --- a/src/uxbox/ui/shapes/text.cljs +++ b/src/uxbox/ui/shapes/text.cljs @@ -135,12 +135,14 @@ (defn- build-style [{:keys [font]}] - (let [{:keys [family weight style size] + (let [{:keys [family weight style size align] :or {family "sourcesanspro" weight "normal" style "normal" + align "left" size 16}} font] {:fontSize (str size "px") + :textAlign align :fontFamily family :fontWeight weight :fontStyle style})) diff --git a/src/uxbox/ui/workspace/sidebar/options.cljs b/src/uxbox/ui/workspace/sidebar/options.cljs index b7c570472..19097aea2 100644 --- a/src/uxbox/ui/workspace/sidebar/options.cljs +++ b/src/uxbox/ui/workspace/sidebar/options.cljs @@ -511,6 +511,10 @@ params {:size (parse-int value)} sid (:id shape)] (rs/emit! (uds/update-font-attrs sid params)))) + (on-font-align-change [event value] + (let [params {:align value} + sid (:id shape)] + (rs/emit! (uds/update-font-attrs sid params)))) (on-font-style-change [event] (let [value (dom/event->value event) [weight style] (read-string value) @@ -518,8 +522,9 @@ params {:style style :weight weight}] (rs/emit! (uds/update-font-attrs sid params))))] - (let [{:keys [family style weight size] + (let [{:keys [family style weight size align] :or {family "sourcesanspro" + align "left" style "normal" weight "normal" size 16}} font @@ -553,10 +558,18 @@ [:span "Text align"] [:div.row-flex.align-icons - [:span.current i/align-left] - [:span i/align-right] - [:span i/align-center] - [:span i/align-justify] + [:span {:class (when (= align "left") "current") + :on-click #(on-font-align-change % "left")} + i/align-left] + [:span {:class (when (= align "right") "current") + :on-click #(on-font-align-change % "right")} + i/align-right] + [:span {:class (when (= align "center") "current") + :on-click #(on-font-align-change % "center")} + i/align-center] + [:span {:class (when (= align "justify") "current") + :on-click #(on-font-align-change % "justify")} + i/align-justify] ]]])))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;