mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
Add align facilities.
This commit is contained in:
parent
4499dfc787
commit
5d66a7e967
3 changed files with 24 additions and 7 deletions
|
@ -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})
|
||||
|
|
|
@ -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}))
|
||||
|
|
|
@ -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]
|
||||
]]]))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
Loading…
Add table
Reference in a new issue