From 3d72c53f029a3879b06750cf57fa6ef518e48d6e Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 15 Jun 2016 20:23:08 +0300 Subject: [PATCH] Add initial dummy placeholder for view application. --- resources/view.mustache | 1 + src/uxbox/view.cljs | 17 +++++++++++++++++ src/uxbox/view/state.cljs | 37 +++++++++++++++++++++++++++++++++++++ src/uxbox/view/ui.cljs | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 src/uxbox/view.cljs create mode 100644 src/uxbox/view/state.cljs create mode 100644 src/uxbox/view/ui.cljs diff --git a/resources/view.mustache b/resources/view.mustache index 9cfcbc812b..ca9b7dac98 100644 --- a/resources/view.mustache +++ b/resources/view.mustache @@ -12,5 +12,6 @@
+ diff --git a/src/uxbox/view.cljs b/src/uxbox/view.cljs new file mode 100644 index 0000000000..4315201ef8 --- /dev/null +++ b/src/uxbox/view.cljs @@ -0,0 +1,17 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) 2016 Andrey Antukh + +(ns uxbox.view + (:require [uxbox.view.state :as st] + #_[uxbox.view.locales :as lc] + [uxbox.view.ui :as ui])) + +(defn ^:export init + [] + ;; (lc/init) + (st/init) + ;; (ui/init-routes) + (ui/init)) diff --git a/src/uxbox/view/state.cljs b/src/uxbox/view/state.cljs new file mode 100644 index 0000000000..da36a2f315 --- /dev/null +++ b/src/uxbox/view/state.cljs @@ -0,0 +1,37 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) 2016 Andrey Antukh + +(ns uxbox.view.state + (:require [beicon.core :as rx] + [lentes.core :as l] + [uxbox.common.rstore :as rs] + [uxbox.common.i18n :refer (tr)] + [uxbox.util.storage :refer (storage)])) + +(enable-console-print!) + +(defonce state (atom {})) +(defonce loader (atom false)) + +(def auth-l + (-> (l/key :auth) + (l/focus-atom state))) + +(defn initial-state + [] + {:route nil + :project nil + :auth (:uxbox/auth storage nil) + :shapes-by-id {} + :pages-by-id {}}) + +(defn init + "Initialize the state materialization." + ([] (init initial-state)) + ([& callbacks] + (-> (reduce #(merge %1 (%2)) nil callbacks) + (rs/init) + (rx/to-atom state)))) diff --git a/src/uxbox/view/ui.cljs b/src/uxbox/view/ui.cljs new file mode 100644 index 0000000000..68f691152f --- /dev/null +++ b/src/uxbox/view/ui.cljs @@ -0,0 +1,38 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) 2016 Andrey Antukh +;; Copyright (c) 2016 Juan de la Cruz + +(ns uxbox.view.ui + (:require [sablono.core :refer-macros [html]] + [goog.dom :as gdom] + [rum.core :as rum] + [uxbox.common.i18n :refer (tr)] + ;; [uxbox.view.ui.loader :refer (loader)] + ;; [uxbox.view.ui.lightbox :refer (lightbox)] + [uxbox.common.ui.mixins :as mx])) + +;; --- Main App (Component) + +(defn app-render + [own] + (html [:p "hello world!!"])) + +(def app + (mx/component + {:render app-render + :mixins [mx/static] + :name "app"})) + +;; --- Main Entry Point + +(defn init + [] + (let [app-dom (gdom/getElement "app") + lightbox-dom (gdom/getElement "lightbox") + loader-dom (gdom/getElement "loader")] + (rum/mount (app) app-dom) + #_(rum/mount (lightbox) lightbox-dom) + #_(rum/mount (loader) loader-dom)))