0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-18 10:41:29 -05:00

Properly persist as int the grid axis on workspace settings lightbox.

This commit is contained in:
Andrey Antukh 2016-04-10 18:05:04 +03:00
parent e9d3e7578e
commit 9bd358a119
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95

View file

@ -16,7 +16,8 @@
[uxbox.ui.lightbox :as lightbox]
[uxbox.ui.colorpicker :as uucp]
[uxbox.ui.workspace.base :as wb]
[uxbox.util.dom :as dom]))
[uxbox.util.dom :as dom]
[uxbox.util.data :refer (parse-int)]))
;; --- Lentes
@ -33,7 +34,8 @@
opts (merge (:options page)
(deref local))]
(letfn [(on-field-change [field event]
(let [value (dom/event->value event)]
(let [value (dom/event->value event)
value (parse-int value)]
(swap! local assoc field value)))
(on-color-change [color]
(swap! local assoc :grid/color color))
@ -42,6 +44,7 @@
(dom/checked?))]
(swap! local assoc :grid/align checked?)))
(on-submit [event]
(dom/prevent-default event)
(let [page (assoc page :options opts)]
(rs/emit! (udp/update-page-metadata page))
(lightbox/close!)))]
@ -52,14 +55,15 @@
[:input#grid-x.input-text
{:placeholder "X px"
:type "number"
:value (:grid/x-axis opts "2")
;; TODO: put here the default from constants
:value (:grid/x-axis opts "10")
:on-change (partial on-field-change :grid/x-axis)
:min 1 ;;TODO check this value
:max 100}]
[:input#grid-y.input-text
{:placeholder "Y px"
:type "number"
:value (:grid/y-axis opts "2")
:value (:grid/y-axis opts "10")
:on-change (partial on-field-change :grid/y-axis)
:min 1
:max 100}]]