0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-06 14:28:30 -05:00
penpot/frontend/uxbox/ui/workspace/base.cljs

51 lines
1.6 KiB
Text
Raw Normal View History

2015-12-17 12:51:36 +02:00
(ns uxbox.ui.workspace.base
2015-12-17 17:32:06 +02:00
(:require [beicon.core :as rx]
2015-12-17 12:51:36 +02:00
[cats.labs.lens :as l]
[uxbox.rstore :as rs]
[uxbox.state :as s]
[uxbox.data.projects :as dp]
2015-12-17 17:32:06 +02:00
[uxbox.util.lens :as ul]))
2015-12-17 12:51:36 +02:00
2015-12-17 16:43:58 +02:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2015-12-17 12:51:36 +02:00
;; Lenses
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:static project-state
2015-12-17 16:43:58 +02:00
(as-> (ul/dep-in [:projects-by-id] [:workspace :project]) $
2015-12-17 12:51:36 +02:00
(l/focus-atom $ s/state)))
(def ^:static page-state
2015-12-17 16:43:58 +02:00
(as-> (ul/dep-in [:pages-by-id] [:workspace :page]) $
2015-12-17 12:51:36 +02:00
(l/focus-atom $ s/state)))
(def ^:static pages-state
2015-12-17 16:43:58 +02:00
(as-> (ul/getter #(let [pid (get-in % [:workspace :project])]
2015-12-17 12:51:36 +02:00
(dp/project-pages % pid))) $
(l/focus-atom $ s/state)))
(def ^:static workspace-state
(as-> (l/in [:workspace]) $
(l/focus-atom $ s/state)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Streams
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defonce scroll-bus (rx/bus))
(defonce top-scroll-s (rx/dedupe (rx/map :top scroll-bus)))
(defonce left-scroll-s (rx/dedupe (rx/map :left scroll-bus)))
(defonce top-scroll (rx/to-atom top-scroll-s))
(defonce left-scroll (rx/to-atom left-scroll-s))
2015-12-17 15:44:05 +02:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Constants
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def viewport-height 3000)
(def viewport-width 3000)
(def document-start-x 50)
(def document-start-y 50)