0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-10 00:58:26 -05:00

Move pages-l lense to sitemap ns and add small optimizations to base lenses.

This commit is contained in:
Andrey Antukh 2016-03-19 19:10:11 +02:00
parent 289ac74553
commit 2201339887
2 changed files with 28 additions and 22 deletions

View file

@ -22,42 +22,35 @@
;; Lenses
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:static project-l
(def ^:const workspace-l
(as-> (l/in [:workspace]) $
(l/focus-atom $ st/state)))
(def ^:const project-l
(letfn [(getter [state]
(let [project (get-in state [:workspace :project])]
(get-in state [:projects-by-id project])))]
(as-> (ul/getter getter) $
(l/focus-atom $ st/state))))
(def ^:static page-l
(def ^:const page-l
(letfn [(getter [state]
(let [page (get-in state [:workspace :page])]
(get-in state [:pages-by-id page])))]
(as-> (ul/getter getter) $
(l/focus-atom $ st/state))))
(def ^:static pages-l
(letfn [(getter [state]
(let [project (get-in state [:workspace :project])]
(stpr/project-pages state project)))]
(as-> (ul/getter getter) $
(l/focus-atom $ st/state))))
(def ^:static workspace-l
(as-> (l/in [:workspace]) $
(l/focus-atom $ st/state)))
(def ^:static selected-shapes-l
(as-> (l/in [:workspace :selected]) $
(l/focus-atom $ st/state)))
(as-> (l/in [:selected]) $
(l/focus-atom $ workspace-l)))
(def ^:static toolboxes-l
(as-> (l/in [:workspace :toolboxes]) $
(l/focus-atom $ st/state)))
(as-> (l/in [:toolboxes]) $
(l/focus-atom $ workspace-l)))
(def ^:static flags-l
(as-> (l/in [:workspace :flags]) $
(l/focus-atom $ st/state)))
(as-> (l/in [:flags]) $
(l/focus-atom $ workspace-l)))
(def ^:static shapes-by-id-l
(as-> (l/key :shapes-by-id) $

View file

@ -14,6 +14,7 @@
[uxbox.router :as r]
[uxbox.rstore :as rs]
[uxbox.state :as st]
[uxbox.state.project :as stpr]
[uxbox.shapes :as shapes]
[uxbox.library :as library]
[uxbox.data.projects :as dp]
@ -24,12 +25,24 @@
[uxbox.ui.icons :as i]
[uxbox.ui.mixins :as mx]
[uxbox.ui.lightbox :as lightbox]
[uxbox.util.lens :as ul]
[uxbox.util.data :refer (read-string parse-int)]
[uxbox.util.dom :as dom]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Lenses
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:static pages-l
(letfn [(getter [state]
(let [project (get-in state [:workspace :project])]
(stpr/project-pages state project)))]
(as-> (ul/getter getter) $
(l/focus-atom $ st/state))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Component
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn page-item-render
[own page total active?]
@ -60,7 +73,7 @@
(defn sitemap-toolbox-render
[own]
(let [project (rum/react wb/project-l)
pages (rum/react wb/pages-l)
pages (rum/react pages-l)
current (rum/react wb/page-l)
create #(lightbox/open! :page-form {:page {:project (:id project)}})
close #(rs/emit! (dw/toggle-flag :sitemap))]