0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 17:00:36 -05:00

Simplify alignment related flags and its activation impl.

This commit is contained in:
Andrey Antukh 2016-04-13 21:02:23 +03:00
parent 75a22381d2
commit e77764f693
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
3 changed files with 11 additions and 16 deletions

View file

@ -186,8 +186,11 @@
:height c/viewport-height
:x-axis (:grid/x-axis opts c/grid-x-axis)
:y-axis (:grid/y-axis opts c/grid-y-axis)}]
(->> (uw/send! worker message)
(rx/map #(activate-flag :alignment/indexed))))))
(rx/merge
(->> (uw/send! worker message)
(rx/map #(activate-flag :grid/indexed)))
(when (:grid/align opts)
(rx/of (activate-flag :grid/alignment)))))))
(defn initialize-alignment-index
[id]

View file

@ -38,19 +38,13 @@
(-> (l/getter resolve-selected)
(l/focus-atom st/state)))
;; (def ^:const ^:privae page-options-l
;; (-> (l/key :options)
;; (l/focus-atom wb/page-l)))
(def ^:const ^:private alignment-l
(letfn [(getter [state]
(let [{:keys [page flags]} (:workspace state)
{:keys [options]} (get-in state [:pages-by-id page])]
(and (contains? flags :alignment/indexed)
(contains? flags :grid)
(:grid/align options false))))]
(letfn [(getter [flags]
(and (contains? flags :grid/indexed)
(contains? flags :grid/alignment)
(contains? flags :grid)))]
(-> (l/getter getter)
(l/focus-atom st/state))))
(l/focus-atom wb/flags-l))))
;; --- Public Api
@ -121,5 +115,3 @@
[delta]
(doseq [shape delta]
(rs/emit! (uds/update-shape shape))))

View file

@ -46,7 +46,7 @@
(on-align-change [event]
(let [checked? (-> (dom/get-target event)
(dom/checked?))]
(swap! local assoc :grid/align checked?)))
(swap! local assoc :grid/alignment checked?)))
(on-submit [event]
(dom/prevent-default event)
(let [page (assoc page :options opts)]