mirror of
https://github.com/penpot/penpot.git
synced 2025-05-24 13:56:12 +02:00
Minor project structure improvement.
This commit is contained in:
parent
a2c313dfc0
commit
b317ee4904
17 changed files with 106 additions and 115 deletions
|
@ -1,19 +1,15 @@
|
||||||
(ns uxbox.core
|
(ns uxbox.core
|
||||||
(:require [uxbox.ui :as ui]
|
(:require [beicon.core :as rx]
|
||||||
[uxbox.router]
|
[uxbox.router]
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.data.projects :as dp]
|
[uxbox.ui :as ui]
|
||||||
[uxbox.data.load :as dl]
|
[uxbox.data.load :as dl]))
|
||||||
[goog.dom :as dom]
|
|
||||||
[beicon.core :as rx]))
|
|
||||||
|
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
|
|
||||||
(defonce +setup+
|
(defonce +setup+
|
||||||
(do
|
(do
|
||||||
(println "BOOTSTRAP")
|
|
||||||
(ui/init)
|
(ui/init)
|
||||||
(rs/emit! (dl/load-data))
|
(rs/emit! (dl/load-data))
|
||||||
(rx/on-value s/stream #(dl/persist-state %))
|
(rx/on-value s/stream #(dl/persist-state %))
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
(:require [bidi.router]
|
(:require [bidi.router]
|
||||||
[bidi.bidi :as bidi]
|
[bidi.bidi :as bidi]
|
||||||
[goog.events :as events]
|
[goog.events :as events]
|
||||||
[uxbox.state]
|
|
||||||
[uxbox.rstore :as rs]))
|
[uxbox.rstore :as rs]))
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
(ns uxbox.state
|
(ns uxbox.state
|
||||||
(:require [uxbox.rstore :as rs]
|
(:require [beicon.core :as rx]
|
||||||
[beicon.core :as rx]))
|
[uxbox.rstore :as rs]))
|
||||||
|
|
||||||
(enable-console-print!)
|
(enable-console-print!)
|
||||||
|
|
||||||
|
|
|
@ -5,13 +5,15 @@
|
||||||
[cats.labs.lens :as l]
|
[cats.labs.lens :as l]
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.util :as util]
|
|
||||||
[uxbox.data.projects :as dp]
|
[uxbox.data.projects :as dp]
|
||||||
[uxbox.ui.lightbox :as ui.lb]
|
[uxbox.ui.lightbox :as ui.lb]
|
||||||
[uxbox.ui.users :as ui.users]
|
[uxbox.ui.users :as ui.users]
|
||||||
[uxbox.ui.dashboard.projects :as ui.dashboard.projects]
|
[uxbox.ui.dashboard.projects :as ui.dashboard.projects]
|
||||||
[uxbox.ui.dashboard.elements :as ui.dashboard.elements]
|
[uxbox.ui.dashboard.elements :as ui.dashboard.elements]
|
||||||
[uxbox.ui.workspace :as ui.w]))
|
[uxbox.ui.workspace :as ui.w]
|
||||||
|
[uxbox.ui.util :as util]
|
||||||
|
[uxbox.ui.mixins :as mx]))
|
||||||
|
|
||||||
|
|
||||||
(def ^:static state
|
(def ^:static state
|
||||||
(as-> (l/select-keys [:location :location-params]) $
|
(as-> (l/select-keys [:location :location-params]) $
|
||||||
|
@ -40,5 +42,5 @@
|
||||||
[]
|
[]
|
||||||
(let [app-dom (gdom/getElement "app")
|
(let [app-dom (gdom/getElement "app")
|
||||||
lb-dom (gdom/getElement "lightbox")]
|
lb-dom (gdom/getElement "lightbox")]
|
||||||
(rum/mount (app) app-dom)
|
(util/mount (app) app-dom)
|
||||||
(rum/mount (ui.lb/lightbox) lb-dom)))
|
(util/mount (ui.lb/lightbox) lb-dom)))
|
||||||
|
|
|
@ -6,7 +6,8 @@
|
||||||
[uxbox.ui.icons :as i]
|
[uxbox.ui.icons :as i]
|
||||||
[uxbox.ui.lightbox :as lightbox]
|
[uxbox.ui.lightbox :as lightbox]
|
||||||
[uxbox.ui.dom :as dom]
|
[uxbox.ui.dom :as dom]
|
||||||
[uxbox.util :as util]))
|
[uxbox.ui.mixins :as mx]
|
||||||
|
[uxbox.ui.util :as util]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Elements
|
;; Elements
|
||||||
|
@ -125,7 +126,7 @@
|
||||||
(util/component
|
(util/component
|
||||||
{:render elements-render
|
{:render elements-render
|
||||||
:name "elements"
|
:name "elements"
|
||||||
:mixins [rum/static]}))
|
:mixins [mx/static]}))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Icons
|
;; Icons
|
||||||
|
@ -279,7 +280,7 @@
|
||||||
(util/component
|
(util/component
|
||||||
{:render icons-render
|
{:render icons-render
|
||||||
:name "icons"
|
:name "icons"
|
||||||
:mixins [rum/static]}))
|
:mixins [mx/static]}))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Colors
|
;; Colors
|
||||||
|
@ -411,7 +412,7 @@
|
||||||
(util/component
|
(util/component
|
||||||
{:render colors-render
|
{:render colors-render
|
||||||
:name "colors"
|
:name "colors"
|
||||||
:mixins [rum/static]}))
|
:mixins [mx/static]}))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Lightbox
|
;; Lightbox
|
||||||
|
|
|
@ -2,20 +2,19 @@
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require [sablono.core :as html :refer-macros [html]]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[cats.labs.lens :as l]
|
[cats.labs.lens :as l]
|
||||||
[uxbox.util :as util]
|
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
[uxbox.data.projects :as dp]
|
[uxbox.data.projects :as dp]
|
||||||
[uxbox.ui.navigation :as nav]
|
[uxbox.ui.navigation :as nav]
|
||||||
[uxbox.ui.icons :as i]
|
[uxbox.ui.icons :as i]
|
||||||
[uxbox.ui.users :as ui.u]))
|
[uxbox.ui.users :as ui.u]
|
||||||
|
[uxbox.ui.util :as util]))
|
||||||
|
|
||||||
(def ^:static header-state
|
(def ^:static header-state
|
||||||
(as-> (l/in [:dashboard]) $
|
(as-> (l/in [:dashboard]) $
|
||||||
(l/focus-atom $ s/state)))
|
(l/focus-atom $ s/state)))
|
||||||
|
|
||||||
|
|
||||||
(defn- header-link
|
(defn- header-link
|
||||||
[section content]
|
[section content]
|
||||||
(let [link (r/route-for section)
|
(let [link (r/route-for section)
|
||||||
|
|
|
@ -3,17 +3,17 @@
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[cats.labs.lens :as l]
|
[cats.labs.lens :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.util :as util]
|
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
|
[uxbox.time :as time]
|
||||||
[uxbox.data.projects :as dp]
|
[uxbox.data.projects :as dp]
|
||||||
[uxbox.ui.icons.dashboard :as icons]
|
[uxbox.ui.icons.dashboard :as icons]
|
||||||
[uxbox.ui.icons :as i]
|
[uxbox.ui.icons :as i]
|
||||||
[uxbox.ui.dom :as dom]
|
[uxbox.ui.dom :as dom]
|
||||||
[uxbox.ui.dashboard.header :as dsh.header]
|
[uxbox.ui.dashboard.header :as dsh.header]
|
||||||
[uxbox.ui.lightbox :as lightbox]
|
[uxbox.ui.lightbox :as lightbox]
|
||||||
[uxbox.time :refer [ago]]))
|
[uxbox.ui.util :as util]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Helpers & Constants
|
;; Helpers & Constants
|
||||||
|
@ -195,7 +195,7 @@
|
||||||
:key (:id project)}
|
:key (:id project)}
|
||||||
[:h3 (:name project)]
|
[:h3 (:name project)]
|
||||||
[:span.project-th-update
|
[:span.project-th-update
|
||||||
(str "Updated " (ago (:last-update project)))]
|
(str "Updated " (time/ago (:last-update project)))]
|
||||||
[:div.project-th-actions
|
[:div.project-th-actions
|
||||||
[:div.project-th-icon.pages
|
[:div.project-th-icon.pages
|
||||||
icons/page
|
icons/page
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
(ns uxbox.ui.library-bar
|
(ns uxbox.ui.library-bar
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require [sablono.core :as html :refer-macros [html]]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.util :as util]
|
[uxbox.ui.util :as ui]
|
||||||
|
[uxbox.ui.mixins :as mx]
|
||||||
[uxbox.ui.icons :as i]))
|
[uxbox.ui.icons :as i]))
|
||||||
|
|
||||||
(defn library-bar-render
|
(defn library-bar-render
|
||||||
|
@ -78,7 +79,7 @@
|
||||||
]))
|
]))
|
||||||
|
|
||||||
(def ^:static library-bar
|
(def ^:static library-bar
|
||||||
(util/component
|
(ui/component
|
||||||
{:render library-bar-render
|
{:render library-bar-render
|
||||||
:name "library-bar"
|
:name "library-bar"
|
||||||
:mixins [rum/static]}))
|
:mixins [mx/static]}))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(ns uxbox.ui.lightbox
|
(ns uxbox.ui.lightbox
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require [sablono.core :as html :refer-macros [html]]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.util :as util]
|
[uxbox.ui.util :as util]
|
||||||
[uxbox.ui.keyboard :as k]
|
[uxbox.ui.keyboard :as k]
|
||||||
[goog.events :as events])
|
[goog.events :as events])
|
||||||
(:import goog.events.EventType))
|
(:import goog.events.EventType))
|
||||||
|
|
|
@ -1,38 +1,9 @@
|
||||||
(ns uxbox.util
|
(ns uxbox.ui.mixins
|
||||||
(:refer-clojure :exclude [derive])
|
(:refer-clojure :exclude [derive])
|
||||||
(:require [rum.core :as rum]
|
(:require [rum.core :as rum]
|
||||||
[cats.labs.lens :as l]
|
[cats.labs.lens :as l]
|
||||||
[goog.dom.forms :as gforms]))
|
[goog.dom.forms :as gforms]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; Sugar for define rum components
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
(defn component
|
|
||||||
[spec]
|
|
||||||
(let [name (or (:name spec)
|
|
||||||
(str (gensym "rum-")))
|
|
||||||
mixins (or (:mixins spec)
|
|
||||||
[])
|
|
||||||
spec (merge (dissoc spec :name :mixins)
|
|
||||||
(when-let [rfn (:render spec)]
|
|
||||||
{:render (fn [state]
|
|
||||||
[(apply rfn state (:rum/props state)) state])}))
|
|
||||||
cls (rum/build-class (conj mixins spec) name)
|
|
||||||
ctr (fn self
|
|
||||||
([] (self {}))
|
|
||||||
([& props]
|
|
||||||
(let [state {:rum/props props}]
|
|
||||||
(rum/element cls state nil))))]
|
|
||||||
(with-meta ctr {:rum/class cls})))
|
|
||||||
|
|
||||||
(defn ref-value
|
|
||||||
[own ref]
|
|
||||||
(let [component (-> own :rum/react-component)
|
|
||||||
ref-node (aget (.-refs component) ref)
|
|
||||||
dom-node (.findDOMNode js/ReactDOM ref-node)]
|
|
||||||
(.-value dom-node)))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Cursored & Lenses
|
;; Cursored & Lenses
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -116,44 +87,3 @@
|
||||||
{:should-update
|
{:should-update
|
||||||
(fn [old-state new-state]
|
(fn [old-state new-state]
|
||||||
(not= (:rum/props old-state) (:rum/props new-state)))})
|
(not= (:rum/props old-state) (:rum/props new-state)))})
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; Lenses & Helpers
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
(defn dep-in
|
|
||||||
[where link]
|
|
||||||
{:pre [(vector? where) (vector? link)]}
|
|
||||||
(l/lens
|
|
||||||
(fn [s]
|
|
||||||
(let [value (get-in s link)
|
|
||||||
path (conj where value)]
|
|
||||||
(get-in s path)))
|
|
||||||
(fn [s f]
|
|
||||||
(throw (ex-info "Not implemented" {})))))
|
|
||||||
|
|
||||||
(defn getter
|
|
||||||
[f]
|
|
||||||
(l/lens f #(throw (ex-info "Not implemented" {}))))
|
|
||||||
|
|
||||||
(defn derive
|
|
||||||
[a path]
|
|
||||||
(l/focus-atom (l/in path) a))
|
|
||||||
|
|
||||||
(defn focus
|
|
||||||
([state]
|
|
||||||
(l/focus-atom l/id state))
|
|
||||||
([lens state]
|
|
||||||
(l/focus-atom lens state)))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
;; Dom Helpers
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
||||||
|
|
||||||
(defn prevent-default
|
|
||||||
[e]
|
|
||||||
(.preventDefault e))
|
|
||||||
|
|
||||||
(defn get-value
|
|
||||||
[el]
|
|
||||||
(gforms/getValue el))
|
|
|
@ -4,9 +4,9 @@
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
[uxbox.util :as util]
|
|
||||||
[uxbox.ui.icons :as icons]
|
[uxbox.ui.icons :as icons]
|
||||||
[uxbox.ui.navigation :as nav]))
|
[uxbox.ui.navigation :as nav]
|
||||||
|
[uxbox.ui.util :as util]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Menu
|
;; Menu
|
||||||
|
|
33
frontend/uxbox/ui/util.cljs
Normal file
33
frontend/uxbox/ui/util.cljs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
(ns uxbox.ui.util
|
||||||
|
"A collection of sugar syntax for define react
|
||||||
|
components using rum libary."
|
||||||
|
(:refer-clojure :exclude [derive])
|
||||||
|
(:require [rum.core :as rum]))
|
||||||
|
|
||||||
|
(defn component
|
||||||
|
[spec]
|
||||||
|
(let [name (or (:name spec)
|
||||||
|
(str (gensym "rum-")))
|
||||||
|
mixins (or (:mixins spec)
|
||||||
|
[])
|
||||||
|
spec (merge (dissoc spec :name :mixins)
|
||||||
|
(when-let [rfn (:render spec)]
|
||||||
|
{:render (fn [state]
|
||||||
|
[(apply rfn state (:rum/props state)) state])}))
|
||||||
|
cls (rum/build-class (conj mixins spec) name)
|
||||||
|
ctr (fn self
|
||||||
|
([] (self {}))
|
||||||
|
([& props]
|
||||||
|
(let [state {:rum/props props}]
|
||||||
|
(rum/element cls state nil))))]
|
||||||
|
(with-meta ctr {:rum/class cls})))
|
||||||
|
|
||||||
|
(defn ref-value
|
||||||
|
[own ref]
|
||||||
|
(let [component (-> own :rum/react-component)
|
||||||
|
ref-node (aget (.-refs component) ref)
|
||||||
|
dom-node (.findDOMNode js/ReactDOM ref-node)]
|
||||||
|
(.-value dom-node)))
|
||||||
|
|
||||||
|
|
||||||
|
(def mount rum/mount)
|
|
@ -1,11 +1,11 @@
|
||||||
(ns uxbox.ui.workspace
|
(ns uxbox.ui.workspace
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require [sablono.core :as html :refer-macros [html]]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.util :as util]
|
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
[uxbox.data.projects :as dp]
|
[uxbox.data.projects :as dp]
|
||||||
|
[uxbox.ui.util :as util]
|
||||||
[uxbox.ui.workspace.base :as wb]
|
[uxbox.ui.workspace.base :as wb]
|
||||||
[uxbox.ui.workspace.rules :as wr]
|
[uxbox.ui.workspace.rules :as wr]
|
||||||
[uxbox.ui.workspace.workarea :as wa]))
|
[uxbox.ui.workspace.workarea :as wa]))
|
||||||
|
|
|
@ -4,34 +4,35 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[cats.labs.lens :as l]
|
[cats.labs.lens :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.util :as util]
|
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
[uxbox.data.projects :as dp]
|
[uxbox.data.projects :as dp]
|
||||||
[uxbox.data.workspace :as dw]
|
[uxbox.data.workspace :as dw]
|
||||||
|
[uxbox.util.lens :as ul]
|
||||||
[uxbox.ui.icons.dashboard :as icons]
|
[uxbox.ui.icons.dashboard :as icons]
|
||||||
[uxbox.ui.icons :as i]
|
[uxbox.ui.icons :as i]
|
||||||
[uxbox.ui.lightbox :as lightbox]
|
[uxbox.ui.lightbox :as lightbox]
|
||||||
[uxbox.ui.keyboard :as k]
|
[uxbox.ui.keyboard :as k]
|
||||||
[uxbox.ui.users :as ui.u]
|
[uxbox.ui.users :as ui.u]
|
||||||
[uxbox.ui.navigation :as nav]
|
[uxbox.ui.navigation :as nav]
|
||||||
[uxbox.ui.dom :as dom]))
|
[uxbox.ui.dom :as dom]
|
||||||
|
[uxbox.ui.util :as util]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Lenses
|
;; Lenses
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(def ^:static project-state
|
(def ^:static project-state
|
||||||
(as-> (util/dep-in [:projects-by-id] [:workspace :project]) $
|
(as-> (ul/dep-in [:projects-by-id] [:workspace :project]) $
|
||||||
(l/focus-atom $ s/state)))
|
(l/focus-atom $ s/state)))
|
||||||
|
|
||||||
(def ^:static page-state
|
(def ^:static page-state
|
||||||
(as-> (util/dep-in [:pages-by-id] [:workspace :page]) $
|
(as-> (ul/dep-in [:pages-by-id] [:workspace :page]) $
|
||||||
(l/focus-atom $ s/state)))
|
(l/focus-atom $ s/state)))
|
||||||
|
|
||||||
(def ^:static pages-state
|
(def ^:static pages-state
|
||||||
(as-> (util/getter #(let [pid (get-in % [:workspace :project])]
|
(as-> (ul/getter #(let [pid (get-in % [:workspace :project])]
|
||||||
(dp/project-pages % pid))) $
|
(dp/project-pages % pid))) $
|
||||||
(l/focus-atom $ s/state)))
|
(l/focus-atom $ s/state)))
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[uxbox.util :as util]
|
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
[uxbox.ui.dom :as dom]
|
[uxbox.ui.dom :as dom]
|
||||||
[uxbox.ui.workspace.base :as wd]))
|
[uxbox.ui.workspace.base :as wd]
|
||||||
|
[uxbox.ui.util :as util]))
|
||||||
|
|
||||||
|
|
||||||
(def viewport-height 3000)
|
(def viewport-height 3000)
|
||||||
(def viewport-width 3000)
|
(def viewport-width 3000)
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
(ns uxbox.ui.workspace.workarea
|
(ns uxbox.ui.workspace.workarea
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require [sablono.core :as html :refer-macros [html]]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.util :as util]
|
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
[uxbox.data.projects :as dp]
|
[uxbox.data.projects :as dp]
|
||||||
[uxbox.ui.workspace.base :as wb]
|
[uxbox.ui.workspace.base :as wb]
|
||||||
[uxbox.ui.workspace.rules :as wr]))
|
[uxbox.ui.workspace.rules :as wr]
|
||||||
|
[uxbox.ui.mixins :as mx]
|
||||||
|
[uxbox.ui.util :as util]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Coordinates Debug
|
;; Coordinates Debug
|
||||||
|
@ -47,7 +47,7 @@
|
||||||
(util/component
|
(util/component
|
||||||
{:render background-render
|
{:render background-render
|
||||||
:name "background"
|
:name "background"
|
||||||
:mixins [util/static]}))
|
:mixins [mx/static]}))
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
(util/component
|
(util/component
|
||||||
{:render grid-render
|
{:render grid-render
|
||||||
:name "grid"
|
:name "grid"
|
||||||
:mixins [util/static]}))
|
:mixins [mx/static]}))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Canvas
|
;; Canvas
|
||||||
|
|
28
frontend/uxbox/util/lens.cljs
Normal file
28
frontend/uxbox/util/lens.cljs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
(ns uxbox.util.lens
|
||||||
|
(:refer-clojure :exclude [derive])
|
||||||
|
(:require [cats.labs.lens :as l]))
|
||||||
|
|
||||||
|
(defn dep-in
|
||||||
|
[where link]
|
||||||
|
{:pre [(vector? where) (vector? link)]}
|
||||||
|
(l/lens
|
||||||
|
(fn [s]
|
||||||
|
(let [value (get-in s link)
|
||||||
|
path (conj where value)]
|
||||||
|
(get-in s path)))
|
||||||
|
(fn [s f]
|
||||||
|
(throw (ex-info "Not implemented" {})))))
|
||||||
|
|
||||||
|
(defn getter
|
||||||
|
[f]
|
||||||
|
(l/lens f #(throw (ex-info "Not implemented" {}))))
|
||||||
|
|
||||||
|
(defn derive
|
||||||
|
[a path]
|
||||||
|
(l/focus-atom (l/in path) a))
|
||||||
|
|
||||||
|
(defn focus
|
||||||
|
([state]
|
||||||
|
(l/focus-atom l/id state))
|
||||||
|
([lens state]
|
||||||
|
(l/focus-atom lens state)))
|
Loading…
Add table
Add a link
Reference in a new issue