From 53700e3cb6657c1c8a56a4bf397023f0ccc01536 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 11 Mar 2020 11:44:00 +0100 Subject: [PATCH 1/3] :construction: Comment worker code (temporary disabled). --- frontend/src/uxbox/main/data/workspace.cljs | 34 ++++----- frontend/src/uxbox/main/streams.cljs | 8 +- .../src/uxbox/main/ui/workspace/drawarea.cljs | 14 ++-- .../uxbox/main/ui/workspace/selection.cljs | 15 ++-- frontend/src/uxbox/main/workers.cljs | 46 ++++++------ frontend/src/uxbox/util/data.cljs | 2 +- frontend/tools.clj | 73 ++++++++++--------- 7 files changed, 97 insertions(+), 95 deletions(-) diff --git a/frontend/src/uxbox/main/data/workspace.cljs b/frontend/src/uxbox/main/data/workspace.cljs index ead4a6401..8af67981e 100644 --- a/frontend/src/uxbox/main/data/workspace.cljs +++ b/frontend/src/uxbox/main/data/workspace.cljs @@ -5,7 +5,7 @@ ;; This Source Code Form is "Incompatible With Secondary Licenses", as ;; defined by the Mozilla Public License, v. 2.0. ;; -;; Copyright (c) 2015-2019 Andrey Antukh +;; Copyright (c) 2015-2020 Andrey Antukh (ns uxbox.main.data.workspace (:require @@ -1779,23 +1779,23 @@ ;; --- Initial Path Point Alignment -;; TODO: revisit on alignemt refactor -(deftype InitialPathPointAlign [id index] - ptk/WatchEvent - (watch [_ state s] - (let [shape (get-in state [:workspace-data :objects id]) - point (get-in shape [:segments index])] - (->> (uwrk/align-point point) - (rx/map #(update-path id index %)))))) +;; ;; TODO: revisit on alignemt refactor +;; (deftype InitialPathPointAlign [id index] +;; ptk/WatchEvent +;; (watch [_ state s] +;; (let [shape (get-in state [:workspace-data :objects id]) +;; point (get-in shape [:segments index])] +;; (->> (uwrk/align-point point) +;; (rx/map #(update-path id index %)))))) -(defn initial-path-point-align - "Event responsible of align a specified point of the - shape by `index` with the grid." - [id index] - {:pre [(uuid? id) - (number? index) - (not (neg? index))]} - (InitialPathPointAlign. id index)) +;; (defn initial-path-point-align +;; "Event responsible of align a specified point of the +;; shape by `index` with the grid." +;; [id index] +;; {:pre [(uuid? id) +;; (number? index) +;; (not (neg? index))]} +;; (InitialPathPointAlign. id index)) ;; --- Shape Visibility diff --git a/frontend/src/uxbox/main/streams.cljs b/frontend/src/uxbox/main/streams.cljs index 9b4c41d80..27e5cbe95 100644 --- a/frontend/src/uxbox/main/streams.cljs +++ b/frontend/src/uxbox/main/streams.cljs @@ -79,10 +79,10 @@ (->> (rx/concat (rx/of current) (rx/sample 10 mouse-position)) (rx/map #(gpt/divide % (gpt/point @refs/selected-zoom))) - (rx/mapcat (fn [point] - (if @refs/selected-alignment - (uwrk/align-point point) - (rx/of point)))) + ;; (rx/mapcat (fn [point] + ;; (if @refs/selected-alignment + ;; (uwrk/align-point point) + ;; (rx/of point)))) (rx/buffer 2 1) (rx/map (fn [[old new]] (gpt/subtract new old))))) diff --git a/frontend/src/uxbox/main/ui/workspace/drawarea.cljs b/frontend/src/uxbox/main/ui/workspace/drawarea.cljs index c3f4beccc..d501d03b3 100644 --- a/frontend/src/uxbox/main/ui/workspace/drawarea.cljs +++ b/frontend/src/uxbox/main/ui/workspace/drawarea.cljs @@ -136,7 +136,7 @@ stoper (rx/filter stoper? stream) mouse (->> ms/mouse-position - (rx/mapcat #(conditional-align % align?)) + ;; (rx/mapcat #(conditional-align % align?)) (rx/map #(gpt/divide % (gpt/point zoom))))] (rx/concat (->> mouse @@ -187,7 +187,7 @@ (rx/share)) mouse (->> (rx/sample 10 ms/mouse-position) - (rx/mapcat #(conditional-align % align?)) + ;; (rx/mapcat #(conditional-align % align?)) (rx/map #(gpt/divide % (gpt/point zoom)))) points (->> stream @@ -256,7 +256,7 @@ align? (refs/alignment-activated? flags) stoper (rx/filter stoper-event? stream) mouse (->> (rx/sample 10 ms/mouse-position) - (rx/mapcat #(conditional-align % align?)) + ;; (rx/mapcat #(conditional-align % align?)) (rx/map #(gpt/divide % (gpt/point zoom))))] (rx/concat (rx/of initialize-drawing) @@ -349,7 +349,7 @@ :on-mouse-enter on-mouse-enter :on-mouse-leave on-mouse-leave}])]))) -(defn- conditional-align [point align?] - (if align? - (uwrk/align-point point) - (rx/of point))) +;; (defn- conditional-align [point align?] +;; (if align? +;; (uwrk/align-point point) +;; (rx/of point))) diff --git a/frontend/src/uxbox/main/ui/workspace/selection.cljs b/frontend/src/uxbox/main/ui/workspace/selection.cljs index 80c090715..68b97766f 100644 --- a/frontend/src/uxbox/main/ui/workspace/selection.cljs +++ b/frontend/src/uxbox/main/ui/workspace/selection.cljs @@ -46,10 +46,11 @@ ;; Applies alginment to point if it is currently ;; activated on the current workspace - (apply-grid-alignment [point] - (if @refs/selected-alignment - (uwrk/align-point point) - (rx/of point)))] + ;; (apply-grid-alignment [point] + ;; (if @refs/selected-alignment + ;; (uwrk/align-point point) + ;; (rx/of point))) + ] (reify ptk/WatchEvent (watch [_ state stream] @@ -59,7 +60,7 @@ (rx/concat (->> ms/mouse-position (rx/map apply-zoom) - (rx/mapcat apply-grid-alignment) + ;; (rx/mapcat apply-grid-alignment) (rx/with-latest vector ms/mouse-position-ctrl) (rx/map normalize-proportion-lock) (rx/mapcat (partial resize shape)) @@ -202,8 +203,8 @@ (let [stoper (get-edition-stream-stoper) stream (->> (ms/mouse-position-deltas @ms/mouse-position) (rx/take-until stoper))] - (when @refs/selected-alignment - (st/emit! (dw/initial-path-point-align (:id shape) index))) + ;; (when @refs/selected-alignment + ;; (st/emit! (dw/initial-path-point-align (:id shape) index))) (rx/subscribe stream #(on-handler-move % index)))) (get-edition-stream-stoper [] diff --git a/frontend/src/uxbox/main/workers.cljs b/frontend/src/uxbox/main/workers.cljs index 808f8f444..9b7d3ce2e 100644 --- a/frontend/src/uxbox/main/workers.cljs +++ b/frontend/src/uxbox/main/workers.cljs @@ -12,30 +12,30 @@ [uxbox.common.spec :as us] [uxbox.util.workers :as uw])) -(s/def ::width number?) -(s/def ::height number?) -(s/def ::x-axis number?) -(s/def ::y-axis number?) +;; (s/def ::width number?) +;; (s/def ::height number?) +;; (s/def ::x-axis number?) +;; (s/def ::y-axis number?) -(s/def ::initialize-alignment-params - (s/keys :req-un [::width - ::height - ::x-axis - ::y-axis])) +;; (s/def ::initialize-alignment-params +;; (s/keys :req-un [::width +;; ::height +;; ::x-axis +;; ::y-axis])) -;; This excludes webworker instantiation on nodejs where -;; the tests are run. -(when (not= *target* "nodejs") - (defonce worker (uw/init "js/worker.js"))) +;; ;; This excludes webworker instantiation on nodejs where +;; ;; the tests are run. +;; (when (not= *target* "nodejs") +;; (defonce worker (uw/init "js/worker.js"))) -(defn align-point - [point] - (let [message {:cmd :grid-align :point point}] - (->> (uw/ask! worker message) - (rx/map :point)))) +;; (defn align-point +;; [point] +;; (let [message {:cmd :grid-align :point point}] +;; (->> (uw/ask! worker message) +;; (rx/map :point)))) -(defn initialize-alignment - [params] - (us/verify ::initialize-alignment-params params) - (let [message (assoc params :cmd :grid-init)] - (uw/send! worker message))) +;; (defn initialize-alignment +;; [params] +;; (us/verify ::initialize-alignment-params params) +;; (let [message (assoc params :cmd :grid-init)] +;; (uw/send! worker message))) diff --git a/frontend/src/uxbox/util/data.cljs b/frontend/src/uxbox/util/data.cljs index a26fa54c4..0ea8ba097 100644 --- a/frontend/src/uxbox/util/data.cljs +++ b/frontend/src/uxbox/util/data.cljs @@ -9,7 +9,7 @@ (:require [cljs.reader :as r] [cuerdas.core :as str])) -;; TODO: partially move to uxbox.common.helpers +;; TODO: partially move to uxbox.common.data ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Data structure manipulation diff --git a/frontend/tools.clj b/frontend/tools.clj index 57c437747..0926483d3 100644 --- a/frontend/tools.clj +++ b/frontend/tools.clj @@ -60,12 +60,12 @@ ;; :output-to "resources/public/js/view.js"} }}) -(def worker-build-options - {:main 'uxbox.worker - :target :webworker - :output-to "resources/public/js/worker.js" - :output-dir "resources/public/js/worker" - :asset-path "/js/worker"}) +;; (def worker-build-options +;; {:main 'uxbox.worker +;; :target :webworker +;; :output-to "resources/public/js/worker.js" +;; :output-dir "resources/public/js/worker" +;; :asset-path "/js/worker"}) (def main-dist-build-options (-> (merge default-build-options @@ -84,22 +84,22 @@ (assoc-in [:modules :main :output-to] "target/dist/dbg/js/main.js") #_(assoc-in [:modules :view :output-to] "target/dist/dbg/js/view.js"))) -(def worker-dist-build-options - (merge default-build-options - worker-build-options - dist-build-options - {:output-to "target/dist/js/worker.js" - :output-dir "target/dist/js/worker" - :source-map "target/dist/js/worker.js.map"})) +;; (def worker-dist-build-options +;; (merge default-build-options +;; worker-build-options +;; dist-build-options +;; {:output-to "target/dist/js/worker.js" +;; :output-dir "target/dist/js/worker" +;; :source-map "target/dist/js/worker.js.map"})) -(def worker-dist-dbg-build-options - (merge worker-dist-build-options - {:optimizations :advanced - :pseudo-names true - :pretty-print true - :output-to "target/dist/dbg/js/worker.js" - :output-dir "target/dist/dbg/js/worker" - :source-map "target/dist/dbg/js/worker.js.map"})) +;; (def worker-dist-dbg-build-options +;; (merge worker-dist-build-options +;; {:optimizations :advanced +;; :pseudo-names true +;; :pretty-print true +;; :output-to "target/dist/dbg/js/worker.js" +;; :output-dir "target/dist/dbg/js/worker" +;; :source-map "target/dist/dbg/js/worker.js.map"})) ;; --- Tasks Definitions @@ -109,11 +109,11 @@ ;; (pprint cfg) (api/build (api/inputs "src") cfg))) -(defmethod task "dist:worker" - [args] - (let [cfg worker-dist-build-options] - ;; (pprint cfg) - (api/build (api/inputs "src") cfg))) +;; (defmethod task "dist:worker" +;; [args] +;; (let [cfg worker-dist-build-options] +;; ;; (pprint cfg) +;; (api/build (api/inputs "src") cfg))) (defmethod task "dist-dbg:main" [args] @@ -121,18 +121,18 @@ ;; (pprint cfg) (api/build (api/inputs "src") cfg))) -(defmethod task "dist-dbg:worker" - [args] - (let [cfg worker-dist-dbg-build-options] - ;; (pprint cfg) - (api/build (api/inputs "src") cfg))) +;; (defmethod task "dist-dbg:worker" +;; [args] +;; (let [cfg worker-dist-dbg-build-options] +;; ;; (pprint cfg) +;; (api/build (api/inputs "src") cfg))) (defmethod task "dist:all" [args] (task ["dist:main"]) - (task ["dist:worker"]) + #_(task ["dist:worker"]) (task ["dist-dbg:main"]) - (task ["dist-dbg:worker"])) + #_(task ["dist-dbg:worker"])) (defmethod task "repl:node" [args] @@ -189,8 +189,9 @@ (def figwheel-builds {:main {:id "main" :options (merge default-build-options main-build-options)} - :worker {:id "worker" - :options (merge default-build-options worker-build-options)}}) + ;; :worker {:id "worker" + ;; :options (merge default-build-options worker-build-options)} + }) (def figwheel-options {:open-url false @@ -208,7 +209,7 @@ (figwheel/start figwheel-options (:main figwheel-builds) - (:worker figwheel-builds))) + #_(:worker figwheel-builds))) ;;; Build script entrypoint. This should be the last expression. From 648dfdab80f155ad61d04efeb1248cce636b95af Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 11 Mar 2020 15:49:18 +0100 Subject: [PATCH 2/3] :fire: Remove unused Caddyfile. --- frontend/Caddyfile | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 frontend/Caddyfile diff --git a/frontend/Caddyfile b/frontend/Caddyfile deleted file mode 100644 index 4b9a29232..000000000 --- a/frontend/Caddyfile +++ /dev/null @@ -1,5 +0,0 @@ -:2015 { - gzip - root ./dist - proxy /api https://app.uxbox.io -} From 45290441debb284bc111ff082518e1242adc620d Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 11 Mar 2020 15:50:18 +0100 Subject: [PATCH 3/3] :fire: Remove view sub application. --- frontend/gulpfile.js | 5 +- frontend/resources/templates/index.mustache | 1 - frontend/resources/templates/view.mustache | 22 -- frontend/src/uxbox/view.cljs | 80 ------ frontend/src/uxbox/view/data/lightbox.cljs | 46 ---- frontend/src/uxbox/view/data/viewer.cljs | 144 ---------- frontend/src/uxbox/view/locales/en.cljs | 14 - frontend/src/uxbox/view/locales/fr.cljs | 14 - frontend/src/uxbox/view/store.cljs | 41 --- frontend/src/uxbox/view/ui.cljs | 68 ----- frontend/src/uxbox/view/ui/keyboard.cljs | 24 -- frontend/src/uxbox/view/ui/lightbox.cljs | 67 ----- frontend/src/uxbox/view/ui/loader.cljs | 19 -- frontend/src/uxbox/view/ui/notfound.cljs | 14 - frontend/src/uxbox/view/ui/viewer.cljs | 48 ---- frontend/src/uxbox/view/ui/viewer/frame.cljs | 40 --- .../uxbox/view/ui/viewer/interactions.cljs | 259 ------------------ frontend/src/uxbox/view/ui/viewer/nav.cljs | 43 --- frontend/src/uxbox/view/ui/viewer/shapes.cljs | 118 -------- .../src/uxbox/view/ui/viewer/sitemap.cljs | 31 --- frontend/tools.clj | 31 +-- 21 files changed, 18 insertions(+), 1111 deletions(-) delete mode 100644 frontend/resources/templates/view.mustache delete mode 100644 frontend/src/uxbox/view.cljs delete mode 100644 frontend/src/uxbox/view/data/lightbox.cljs delete mode 100644 frontend/src/uxbox/view/data/viewer.cljs delete mode 100644 frontend/src/uxbox/view/locales/en.cljs delete mode 100644 frontend/src/uxbox/view/locales/fr.cljs delete mode 100644 frontend/src/uxbox/view/store.cljs delete mode 100644 frontend/src/uxbox/view/ui.cljs delete mode 100644 frontend/src/uxbox/view/ui/keyboard.cljs delete mode 100644 frontend/src/uxbox/view/ui/lightbox.cljs delete mode 100644 frontend/src/uxbox/view/ui/loader.cljs delete mode 100644 frontend/src/uxbox/view/ui/notfound.cljs delete mode 100644 frontend/src/uxbox/view/ui/viewer.cljs delete mode 100644 frontend/src/uxbox/view/ui/viewer/frame.cljs delete mode 100644 frontend/src/uxbox/view/ui/viewer/interactions.cljs delete mode 100644 frontend/src/uxbox/view/ui/viewer/nav.cljs delete mode 100644 frontend/src/uxbox/view/ui/viewer/shapes.cljs delete mode 100644 frontend/src/uxbox/view/ui/viewer/sitemap.cljs diff --git a/frontend/gulpfile.js b/frontend/gulpfile.js index 968fe3717..41fd60fd0 100644 --- a/frontend/gulpfile.js +++ b/frontend/gulpfile.js @@ -211,7 +211,10 @@ gulp.task("watch:main", function() { gulp.watch([paths.resources + "templates/*.mustache", paths.resources + "locales.json", paths.resources + "images/**/*"], - gulp.series("templates", "dev:copy:images", "dev:copy:icons-sprite")); + gulp.series("templates", + "dev:copy:images", + "dev:copy:templates", + "dev:copy:icons-sprite")); }); gulp.task("watch", gulp.series( diff --git a/frontend/resources/templates/index.mustache b/frontend/resources/templates/index.mustache index 88c30382e..b98fb14a9 100644 --- a/frontend/resources/templates/index.mustache +++ b/frontend/resources/templates/index.mustache @@ -18,7 +18,6 @@ window.uxboxConfig = JSON.parse({{& config }}); window.uxboxTranslations = JSON.parse({{& translations }}); - diff --git a/frontend/resources/templates/view.mustache b/frontend/resources/templates/view.mustache deleted file mode 100644 index ef12f25a5..000000000 --- a/frontend/resources/templates/view.mustache +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - UXBOX-view - The Open-Source prototyping tool - - - - -
- - -
- - - - - - - diff --git a/frontend/src/uxbox/view.cljs b/frontend/src/uxbox/view.cljs deleted file mode 100644 index e91cff923..000000000 --- a/frontend/src/uxbox/view.cljs +++ /dev/null @@ -1,80 +0,0 @@ -;; 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-2017 Andrey Antukh - -(ns ^:figwheel-hooks uxbox.view - (:require - [rumext.core :as mx] - [rumext.alpha :as mf] - [uxbox.util.dom :as dom] - [uxbox.util.html.history :as html-history] - [uxbox.util.i18n :as i18n :refer [tr]] - [uxbox.util.router :as rt] - [uxbox.view.locales.en :as en] - [uxbox.view.locales.fr :as fr] - [uxbox.view.store :as st] - [uxbox.view.ui :as ui] - [uxbox.view.ui.lightbox :refer [lightbox]] - [uxbox.view.ui.loader :refer [loader]])) - -;; (i18n/update-locales! (fn [locales] -;; (-> locales -;; (assoc "en" en/locales) -;; (assoc "fr" fr/locales)))) - -(declare reinit) - -;; (i18n/on-locale-change! -;; (fn [new old] -;; (println "Locale changed from" old " to " new) -;; (reinit))) - -(defn- on-navigate - [router path] - (let [match (rt/match router path)] - (prn "view$on-navigate" path) - (cond - (nil? match) - (prn "TODO 404 view" match) - - :else - (st/emit! #(assoc % :route match))))) - -(defn init-ui - [] - (let [router (rt/init ui/routes) - cpath (deref html-history/path)] - - (st/emit! #(assoc % :router router)) - (add-watch html-history/path ::view #(on-navigate router %4)) - - (mf/mount (mf/element ui/app) (dom/get-element "app")) - (mf/mount (lightbox) (dom/get-element "lightbox")) - (mf/mount (loader) (dom/get-element "loader")) - - (on-navigate router cpath))) - -(def app-sym (.for js/Symbol "uxbox.app")) - -(defn ^:export init - [] - (unchecked-set js/window app-sym "view") - (st/init) - (init-ui)) - -(defn reinit - [] - (remove-watch html-history/path ::view) - (mf/unmount (dom/get-element "app")) - (mf/unmount (dom/get-element "lightbox")) - (mf/unmount (dom/get-element "loader")) - (init-ui)) - -(defn ^:after-load after-load - [] - (when (= "view" (unchecked-get js/window app-sym)) - (reinit))) - - diff --git a/frontend/src/uxbox/view/data/lightbox.cljs b/frontend/src/uxbox/view/data/lightbox.cljs deleted file mode 100644 index 5288cc9ee..000000000 --- a/frontend/src/uxbox/view/data/lightbox.cljs +++ /dev/null @@ -1,46 +0,0 @@ -;; 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.data.lightbox - (:require [beicon.core :as rx] - [lentes.core :as l] - [potok.core :as ptk] - [uxbox.view.store :as st])) - -;; --- Show Lightbox - -(defrecord ShowLightbox [name params] - ptk/UpdateEvent - (update [_ state] - (let [data (merge {:name name} params)] - (assoc state :lightbox data)))) - -(defn show-lightbox - ([name] - (ShowLightbox. name nil)) - ([name params] - (ShowLightbox. name params))) - -;; --- Hide Lightbox - -(defrecord HideLightbox [] - ptk/UpdateEvent - (update [_ state] - (dissoc state :lightbox))) - -(defn hide-lightbox - [] - (HideLightbox.)) - -;; --- Direct Call Api - -(defn open! - [& args] - (st/emit! (apply show-lightbox args))) - -(defn close! - [& args] - (st/emit! (apply hide-lightbox args))) diff --git a/frontend/src/uxbox/view/data/viewer.cljs b/frontend/src/uxbox/view/data/viewer.cljs deleted file mode 100644 index 4d564c9b7..000000000 --- a/frontend/src/uxbox/view/data/viewer.cljs +++ /dev/null @@ -1,144 +0,0 @@ -;; 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.data.viewer - (:require [beicon.core :as rx] - [potok.core :as ptk] - [uxbox.util.router :as rt] - [uxbox.util.data :refer (parse-int)] - [uxbox.main.repo :as rp] - [uxbox.main.data.projects :as udpj])) - -;; --- Initialize - -(declare load-data) - -(defrecord Initialize [token] - ptk/WatchEvent - (watch [_ state s] - (rx/of (load-data token)))) - -(defn initialize - "Initialize the viewer state." - [token] - (Initialize. token)) - -;; --- Data Loaded - -(defn- unpack-page - "Unpacks packed page object and assocs it to the - provided state." - [state {:keys [id data] :as page}] - (let [shapes (:shapes data) - shapes-map (:shapes-map data) - page (-> page - (dissoc :data) - (assoc :shapes shapes))] - (-> state - (update :shapes merge shapes-map) - (update :pages conj page)))) - -(defrecord DataLoaded [data] - ptk/UpdateEvent - (update [_ state] - (let [project (dissoc data :pages) - get-order #(get-in % [:metadata :order]) - pages (sort-by get-order (:pages data))] - (as-> state $ - (assoc $ :project project) - (assoc $ :pages []) - (reduce unpack-page $ pages))))) - -(defn data-loaded - [data] - (DataLoaded. data)) - -;; --- Load Data - -(defrecord LoadData [token] - ptk/WatchEvent - (watch [_ state stream] - #_(->> (rp/req :fetch/project-by-token token) - (rx/map :payload) - (rx/map data-loaded)))) - -(defn load-data - [token] - (LoadData. token)) - -;; --- Select Page - -(defrecord SelectPage [id] - ptk/WatchEvent - (watch [_ state stream] - (let [token (get-in state [:route :params :path :token])] - (rx/of (rt/nav :view/viewer {:token token :id id}))))) - -(defn select-page - [id] - (SelectPage. id)) - -;; --- Go to Page - -(defrecord GoToPage [id] - ptk/WatchEvent - (watch [_ state stream] - (let [token (get-in state [:route :params :path :token])] - (rx/of (rt/nav :view/viewer {:token token :id id}))))) - -(defn go-to-page - [id] - (GoToPage. id)) - -;; --- Toggle Flag - -(defrecord ToggleFlag [key] - ptk/UpdateEvent - (update [_ state] - (let [flags (:flags state #{})] - (if (contains? flags key) - (assoc state :flags (disj flags key)) - (assoc state :flags (conj flags key)))))) - -(defn toggle-flag - "Toggle the enabled flag of the specified tool." - [key] - {:pre [(keyword? key)]} - (ToggleFlag. key)) - -;; --- Fetch Image - -(declare image-fetched) - -(defrecord FetchImage [id] - ptk/WatchEvent - (watch [_ state stream] - (let [existing (get-in state [:images id])] - (if existing - (rx/empty) - #_(->> (rp/req :fetch/image {:id id}) - (rx/map :payload) - (rx/map image-fetched)))))) - -(defn fetch-image - "Conditionally fetch image by its id. If image - is already loaded, this event is noop." - [id] - {:pre [(uuid? id)]} - (FetchImage. id)) - -;; --- Image Fetched - -(defrecord ImageFetched [image] - ptk/UpdateEvent - (update [_ state] - (let [id (:id image)] - (update state :images assoc id image)))) - -(defn image-fetched - [image] - {:pre [(map? image)]} - (ImageFetched. image)) diff --git a/frontend/src/uxbox/view/locales/en.cljs b/frontend/src/uxbox/view/locales/en.cljs deleted file mode 100644 index bb47c3b55..000000000 --- a/frontend/src/uxbox/view/locales/en.cljs +++ /dev/null @@ -1,14 +0,0 @@ -;; 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) 2015-2016 Andrey Antukh -;; Copyright (c) 2015-2016 Juan de la Cruz - -(ns uxbox.view.locales.en) - -(defonce locales - {"viewer.sitemap" "sitemap" - "viewer.interactions" "view interactions" - "viewer.share" "share" - "viewer.save" "save SVG"}) diff --git a/frontend/src/uxbox/view/locales/fr.cljs b/frontend/src/uxbox/view/locales/fr.cljs deleted file mode 100644 index f381b4d30..000000000 --- a/frontend/src/uxbox/view/locales/fr.cljs +++ /dev/null @@ -1,14 +0,0 @@ -;; 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) 2015-2016 Andrey Antukh -;; Copyright (c) 2015-2016 Juan de la Cruz - -(ns uxbox.view.locales.fr) - -(defonce locales - {"viewer.sitemap" "plan du site" - "viewer.interactions" "voir les interactions" - "viewer.share" "partager" - "viewer.save" "sauvegarder en SVG"}) diff --git a/frontend/src/uxbox/view/store.cljs b/frontend/src/uxbox/view/store.cljs deleted file mode 100644 index a639f537f..000000000 --- a/frontend/src/uxbox/view/store.cljs +++ /dev/null @@ -1,41 +0,0 @@ -;; 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) 2015-2017 Andrey Antukh - -(ns uxbox.view.store - (:require [beicon.core :as rx] - [lentes.core :as l] - [potok.core :as ptk])) - -(def ^:dynamic *on-error* identity) - -(defonce state (atom {})) -(defonce loader (atom false)) -(defonce store (ptk/store {:on-error #(*on-error* %)})) -(defonce stream (ptk/input-stream store)) - -(def auth-ref - (-> (l/key :auth) - (l/derive state))) - -(defn emit! - ([event] - (ptk/emit! store event)) - ([event & events] - (apply ptk/emit! store (cons event events)))) - -(def initial-state - {:route nil - :project nil - :pages nil - :page nil - :flags #{:sitemap} - :shapes {}}) - -(defn init - "Initialize the state materialization." - [] - (emit! initial-state) - (rx/to-atom store state)) diff --git a/frontend/src/uxbox/view/ui.cljs b/frontend/src/uxbox/view/ui.cljs deleted file mode 100644 index 261903f5c..000000000 --- a/frontend/src/uxbox/view/ui.cljs +++ /dev/null @@ -1,68 +0,0 @@ -;; 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-2017 Andrey Antukh - -(ns uxbox.view.ui - (:require - [lentes.core :as l] - [potok.core :as ptk] - [rumext.core :as mx] - [rumext.alpha :as mf] - [uxbox.builtins.icons :as i] - [uxbox.util.data :refer [parse-int]] - [uxbox.util.dom :as dom] - [uxbox.util.i18n :refer [tr]] - [uxbox.util.messages :as uum] - [uxbox.util.router :as rt] - [uxbox.view.store :as st] - [uxbox.view.ui.lightbox :refer [lightbox]] - [uxbox.view.ui.loader :refer [loader]] - [uxbox.view.ui.notfound :refer [notfound-page]] - [uxbox.view.ui.viewer :refer [viewer-page]])) - -;; --- Error Handling - -(defn- on-error - "A default error handler." - [error] - (cond - ;; Network error - (= (:status error) 0) - (do - (st/emit! (uum/error (tr "errors.network"))) - (js/console.error "Stack:" (.-stack error))) - - ;; Something else - :else - (do - (st/emit! (uum/error (tr "errors.generic"))) - (js/console.error "Stack:" (.-stack error))))) - -(set! st/*on-error* on-error) - - -;; --- Routes - -(def routes - [["/preview/:token/:id" :view/viewer] - ["/not-found" :view/notfound]]) - -;; --- Main App (Component) - -(def route-ref - (-> (l/key :route) - (l/derive st/state))) - -(mf/defc app - [] - (let [route (mf/deref route-ref)] - (case (get-in route [:data :name]) - :view/notfound (notfound-page) - :view/viewer (let [{:keys [token id]} (get-in route [:params :path])] - (mf/element viewer-page {:token token - :id (uuid id) - :key [token id]})) - nil))) - diff --git a/frontend/src/uxbox/view/ui/keyboard.cljs b/frontend/src/uxbox/view/ui/keyboard.cljs deleted file mode 100644 index 00a3b33aa..000000000 --- a/frontend/src/uxbox/view/ui/keyboard.cljs +++ /dev/null @@ -1,24 +0,0 @@ -;; 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-2017 Andrey Antukh - -(ns uxbox.view.ui.keyboard) - -(defn is-keycode? - [keycode] - (fn [e] - (= (.-keyCode e) keycode))) - -(defn ctrl? - [event] - (.-ctrlKey event)) - -(defn shift? - [event] - (.-shiftKey event)) - -(def esc? (is-keycode? 27)) -(def enter? (is-keycode? 13)) -(def space? (is-keycode? 32)) diff --git a/frontend/src/uxbox/view/ui/lightbox.cljs b/frontend/src/uxbox/view/ui/lightbox.cljs deleted file mode 100644 index f13a4fb78..000000000 --- a/frontend/src/uxbox/view/ui/lightbox.cljs +++ /dev/null @@ -1,67 +0,0 @@ -;; 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-2017 Andrey Antukh - -(ns uxbox.view.ui.lightbox - (:require [lentes.core :as l] - [uxbox.view.store :as st] - [uxbox.view.data.lightbox :as udl] - [rumext.core :as mx :include-macros true] - [uxbox.view.ui.keyboard :as k] - [uxbox.util.dom :as dom] - [uxbox.util.data :refer [classnames]] - [goog.events :as events]) - (:import goog.events.EventType)) - -;; --- Lentes - -(def ^:private lightbox-ref - (-> (l/key :lightbox) - (l/derive st/state))) - -;; --- Lightbox (Component) - -(defmulti render-lightbox :name) -(defmethod render-lightbox :default [_] nil) - -(defn- on-esc-clicked - [event] - (when (k/esc? event) - (udl/close!) - (dom/stop-propagation event))) - -(defn- on-out-clicked - [own event] - (let [parent (mx/ref-node own "parent") - current (dom/get-target event)] - (when (dom/equals? parent current) - (udl/close!)))) - -(defn- lightbox-init - [own] - (let [key (events/listen js/document - EventType.KEYDOWN - on-esc-clicked)] - (assoc own ::key key))) - -(defn- lightbox-will-umount - [own] - (events/unlistenByKey (::key own)) - (dissoc own ::key)) - -(mx/defcs lightbox - {:mixins [mx/reactive] - :init lightbox-init - :will-unmount lightbox-will-umount} - [own] - (let [data (mx/react lightbox-ref) - classes (classnames - :hide (nil? data) - :transparent (:transparent? data))] - [:div.lightbox - {:class classes - :ref "parent" - :on-click (partial on-out-clicked own)} - (render-lightbox data)])) diff --git a/frontend/src/uxbox/view/ui/loader.cljs b/frontend/src/uxbox/view/ui/loader.cljs deleted file mode 100644 index 92b582bba..000000000 --- a/frontend/src/uxbox/view/ui/loader.cljs +++ /dev/null @@ -1,19 +0,0 @@ -;; 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-2017 Andrey Antukh - -(ns uxbox.view.ui.loader - (:require [uxbox.builtins.icons :as i] - [uxbox.view.store :as st] - [rumext.core :as mx :include-macros true])) - -;; --- Component - -(mx/defc loader - {:mixins [mx/reactive mx/static]} - [] - (when (mx/react st/loader) - [:div.loader-content i/loader])) - diff --git a/frontend/src/uxbox/view/ui/notfound.cljs b/frontend/src/uxbox/view/ui/notfound.cljs deleted file mode 100644 index ca85cef62..000000000 --- a/frontend/src/uxbox/view/ui/notfound.cljs +++ /dev/null @@ -1,14 +0,0 @@ -;; 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-2017 Andrey Antukh -;; Copyright (c) 2016-2017 Juan de la Cruz - -(ns uxbox.view.ui.notfound - (:require [rumext.core :as mx :include-macros true])) - -(mx/defc notfound-page - [] - [:div - [:strong "Not Found"]]) diff --git a/frontend/src/uxbox/view/ui/viewer.cljs b/frontend/src/uxbox/view/ui/viewer.cljs deleted file mode 100644 index 970c2367f..000000000 --- a/frontend/src/uxbox/view/ui/viewer.cljs +++ /dev/null @@ -1,48 +0,0 @@ -;; 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-2017 Andrey Antukh -;; Copyright (c) 2016-2017 Juan de la Cruz - -(ns uxbox.view.ui.viewer - (:require - [rumext.alpha :as mf] - [uxbox.builtins.icons :as i] - [uxbox.util.i18n :refer [tr]] - [uxbox.util.data :refer [seek]] - [uxbox.view.data.viewer :as dv] - [uxbox.view.store :as st] - [uxbox.view.ui.viewer.frame :refer [frame]] - [uxbox.view.ui.viewer.nav :refer [nav]] - [uxbox.view.ui.viewer.sitemap :refer [sitemap]] - [lentes.core :as l])) - -;; --- Refs - -(defn- sort-pages - [{:keys [pages] :as state}] - (let [get-order #(get-in % [:metadata :order])] - (assoc state :pages (->> (sort-by get-order pages) - (into []))))) - -(def state-ref - (-> (comp (l/select-keys [:flags :pages :project]) - (l/lens sort-pages)) - (l/derive st/state))) - -;; --- Component - -(mf/defc viewer-page - [{:keys [token id]}] - (let [{:keys [project pages flags]} (mf/deref state-ref)] - (mf/use-effect - {:fn #(st/emit! (dv/initialize token))}) - (when (seq pages) - [:section.view-content - (when (contains? flags :sitemap) - [:& sitemap {:project project - :pages pages - :selected id}]) - [:& nav {:flags flags}] - [:& frame {:page (seek #(= id (:id %)) pages)}]]))) diff --git a/frontend/src/uxbox/view/ui/viewer/frame.cljs b/frontend/src/uxbox/view/ui/viewer/frame.cljs deleted file mode 100644 index f08985734..000000000 --- a/frontend/src/uxbox/view/ui/viewer/frame.cljs +++ /dev/null @@ -1,40 +0,0 @@ -;; 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-2017 Andrey Antukh -;; Copyright (c) 2016-2017 Juan de la Cruz - -(ns uxbox.view.ui.viewer.frame - (:require - [rumext.alpha :as mf] - [uxbox.view.ui.viewer.shapes :as shapes])) - -;; --- Background (Component) - -(mf/defc background - {:wrap [mf/wrap-memo]} - [{:keys [background] :as metadata}] - #_[:rect - {:x 0 :y 0 - :width "100%" - :height "100%" - :fill (or background "#ffffff")}]) - -;; --- Canvas (Component) - -(declare shape) - -(mf/defc frame - {:wrap [mf/wrap-memo]} - [{:keys [page] :as props}] - #_(let [{:keys [metadata id]} page - {:keys [width height]} metadata] - [:div.view-frame - [:svg.page-layout {:width width - :height height} - [:& background metadata] - (for [id (reverse (:shapes page))] - (-> (shapes/shape id) - (mf/with-key (str id))))]])) - diff --git a/frontend/src/uxbox/view/ui/viewer/interactions.cljs b/frontend/src/uxbox/view/ui/viewer/interactions.cljs deleted file mode 100644 index a85453651..000000000 --- a/frontend/src/uxbox/view/ui/viewer/interactions.cljs +++ /dev/null @@ -1,259 +0,0 @@ -;; 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.ui.viewer.interactions - (:require [uxbox.util.dom :as dom] - [potok.core :as ptk] - [uxbox.util.geom.matrix :as gmt] - [uxbox.util.geom.point :as gpt] - [uxbox.util.timers :as ts] - [uxbox.main.geom :as geom] - [uxbox.view.store :as st] - [uxbox.view.data.viewer :as dv] - [vendor.snapsvg]) - ;; Documentation about available events: - ;; https://google.github.io/closure-library/api/goog.events.EventType.html - (:import goog.events.EventType)) - -(defn- translate-trigger - "Translates the interaction trigger name (keyword) into - approriate dom event name (keyword)." - [trigger] - {:pre [(keyword? trigger)]} - (case trigger - :click EventType.CLICK - :doubleclick EventType.DBLCLICK - :rightclick EventType.CONTEXTMENU - :mousein EventType.MOUSEENTER - :mouseout EventType.MOUSELEAVE - :hover ::hover - (throw (ex-info "not supported at this moment" {:trigger trigger})))) - -(defn- translate-ease - "Translates the uxbox ease settings to one - that are compatible with anime.js library." - [ease] - {:pre [(keyword? ease)]} - (case ease - :linear js/mina.linear - :easein js/mina.easin - :easeout js/mina.easout - :easeinout js/mina.easeinout - (throw (ex-info "invalid ease value" {:ease ease})))) - -(defn- animate - [& opts] - (js/anime (clj->js (apply hash-map opts)))) - -(defn- animate* - [dom {:keys [delay duration easing] :as opts}] - (let [props (dissoc opts :delay :duration :easing) - snap (js/Snap. dom)] - (ts/schedule delay #(.animate snap (clj->js props) duration easing)))) - -;; --- Interactions to Animation Compilation - -(defn- run-moveby-interaction - [{:keys [element moveby-x moveby-y easing delay duration direction]}] - (let [dom (dom/get-element (str "shape-" element))] - (if (= direction :reverse) - (animate* dom {:transform (str "translate(" (- moveby-x)" " (- moveby-y) ")") - :easing (translate-ease easing) - :delay delay - :duration duration}) - (animate* dom {:transform (str "translate(" moveby-x " " moveby-y ")") - :easing (translate-ease easing) - :delay delay - :duration duration})))) - -(declare run-hide-interaction) - -(defn- run-show-interaction - [{:keys [element easing delay duration - animation direction] :as itx}] - (let [dom (dom/get-element (str "shape-" element))] - (if (= direction :reverse) - (run-hide-interaction (dissoc itx :direction)) - (animate* dom {:fillOpacity "1" - :strokeOpacity "1" - :easing (translate-ease easing) - :delay delay - :duration duration})))) - -(defn- run-hide-interaction - [{:keys [element easing delay duration - animation direction] :as itx}] - (let [dom (dom/get-element (str "shape-" element))] - (if (= direction :reverse) - (run-show-interaction (dissoc itx :direction)) - (animate* dom {:fillOpacity "0" - :strokeOpacity "0" - :easing (translate-ease easing) - :delay delay - :duration duration})))) - -(defn- run-toggle-interaction - [{:keys [element easing delay duration - animation direction] :as itx}] - (let [dom (dom/get-element (str "shape-" element))] - (if (= direction :reverse) - (run-show-interaction itx) - (run-hide-interaction itx)))) - -(defn- run-opacity-interaction - [{:keys [element opacity easing delay - duration animation direction]}] - (let [shape (get-in @st/state [:shapes element]) - dom (dom/get-element (str "shape-" element))] - (if (= direction :reverse) - (animate* dom {:fillOpacity (:fill-opacity shape "1") - :strokeOpacity (:stroke-opacity shape "1") - :easing (translate-ease easing) - :delay delay - :duration duration}) - (animate* dom {:fillOpacity opacity - :strokeOpacity opacity - :easing (translate-ease easing) - :delay delay - :duration duration})))) - -(defn- run-size-interaction-rect - [{:keys [x1 y1 rotation] :as shape} - {:keys [resize-width resize-height easing - element delay duration direction] :as opts}] - (let [{:keys [width height]} (geom/size shape) - dom (dom/get-element (str "shape-" element))] - (if (= direction :reverse) - (animate* dom {:easing (translate-ease easing) - :delay delay - :duration duration - :width width - :height height}) - (animate* dom {:easing (translate-ease easing) - :delay delay - :duration duration - :width resize-width - :height resize-height})))) - -(defn- run-size-interaction-circle - [{:keys [x1 y1 rotation] :as shape} - {:keys [resize-width resize-height easing - element delay duration direction] :as opts}] - (let [{:keys [width height]} (geom/size shape) - dom (dom/get-element (str "shape-" element))] - (if (= direction :reverse) - (animate* dom {:easing (translate-ease easing) - :delay delay - :duration duration - :rx width - :ry height}) - (animate* dom {:easing (translate-ease easing) - :delay delay - :duration duration - :rx resize-width - :ry resize-height})))) - -(defn- run-size-interaction - [{:keys [element] :as opts}] - (let [shape (get-in @st/state [:shapes element])] - (case (:type shape) - :icon (run-size-interaction-rect shape opts) - :image (run-size-interaction-rect shape opts) - :rect (run-size-interaction-rect shape opts) - :circle (run-size-interaction-circle shape opts)))) - -(defn- run-gotourl-interaction - [{:keys [url]}] - (js/window.open url "_blank")) - -(defn- run-gotopage-interaction - [{:keys [page]}] - (st/emit! (dv/go-to-page page))) - -(defn- run-color-interaction - [{:keys [element fill-color stroke-color direction easing delay duration]}] - (let [shape (get-in @st/state [:shapes element]) - dom (dom/get-element (str "shape-" element))] - (if (= direction :reverse) - (animate* dom {:easing (translate-ease easing) - :delay delay - :duration duration - :fill (:fill shape "#000000") - :stroke (:stroke shape "#000000")}) - (animate* dom {:easing (translate-ease easing) - :delay delay - :duration duration - :fill fill-color - :stroke stroke-color})))) - -;; (defn- run-rotate-interaction -;; [{:keys [element rotation direction easing delay duration] :as opts}] -;; (let [shape (get-in @st/state [:shapes element]) -;; {:keys [x1 y1 width height]} (geom/size shape) -;; -;; dom (dom/get-element (str "shape-" element)) -;; mtx1 (geom/transformation-matrix (update shape :rotation + rotation)) -;; mtx2 (geom/transformation-matrix shape)] -;; (if (= direction :reverse) -;; (animate* dom {:easing (translate-ease easing) -;; :delay delay -;; :duration duration -;; :transform (str mtx2)}) -;; (animate* dom {:easing (translate-ease easing) -;; :delay delay -;; :duration duration -;; :transform (str mtx1)})))) - -(defn- run-interaction - "Given an interaction data structure return - a precompiled animation." - [{:keys [action] :as itx}] - (case action - :moveby (run-moveby-interaction itx) - :show (run-show-interaction itx) - :hide (run-hide-interaction itx) - :toggle (run-toggle-interaction itx) - :size (run-size-interaction itx) - :opacity (run-opacity-interaction itx) - :color (run-color-interaction itx) - ;; :rotate (run-rotate-interaction itx) - :gotourl (run-gotourl-interaction itx) - :gotopage (run-gotopage-interaction itx) - (throw (ex-info "undefined interaction" {:action action})))) - -;; --- Main Api - -(defn- build-hover-evt - "A special case for hover event." - [itx] - (letfn [(on-mouse-enter [event] - (dom/prevent-default event) - (run-interaction itx)) - (on-mouse-leave [event] - (dom/prevent-default event) - (run-interaction (assoc itx :direction :reverse)))] - [[EventType.MOUSEENTER on-mouse-enter] - [EventType.MOUSELEAVE on-mouse-leave]])) - -(defn- build-generic-evt - "A reducer function that compiles interaction data structures - into apropriate event handler attributes." - [evt itx] - (letfn [(on-event [event] - (dom/prevent-default event) - (run-interaction itx))] - [[evt on-event]])) - -(defn build-events - "Compile a sequence of interactions into a hash-map of event-handlers." - [shape] - (reduce (fn [acc itx] - (let [evt (translate-trigger (:trigger itx))] - (if (= evt ::hover) - (into acc (build-hover-evt itx)) - (into acc (build-generic-evt evt itx))))) - [] - (vals (:interactions shape)))) diff --git a/frontend/src/uxbox/view/ui/viewer/nav.cljs b/frontend/src/uxbox/view/ui/viewer/nav.cljs deleted file mode 100644 index 3e2b6974f..000000000 --- a/frontend/src/uxbox/view/ui/viewer/nav.cljs +++ /dev/null @@ -1,43 +0,0 @@ -;; 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-2017 Andrey Antukh -;; Copyright (c) 2016-2017 Juan de la Cruz - -(ns uxbox.view.ui.viewer.nav - (:require - [rumext.alpha :as mf] - [uxbox.builtins.icons :as i] - [uxbox.main.data.lightbox :as udl] - [uxbox.util.i18n :refer (tr)] - [uxbox.view.data.viewer :as dv] - [uxbox.view.store :as st])) - -(mf/defc nav - [{:keys [flags] :as props}] - (let [toggle-sitemap #(st/emit! (dv/toggle-flag :sitemap)) - toggle-interactions #(st/emit! (dv/toggle-flag :interactions)) - sitemap? (contains? flags :sitemap) - interactions? (contains? flags :interactions) - on-download #(udl/open! :download)] - [:div.view-nav - [:ul.view-options-btn - [:li.tooltip.tooltip-right - {:alt (tr "viewer.sitemap") - :class (when sitemap? "selected") - :on-click toggle-sitemap} - i/tree] - [:li.tooltip.tooltip-right - {:alt (tr "viewer.interactions") - :class (when interactions? "selected") - :on-click toggle-interactions} - i/action] - [:li.tooltip.tooltip-right - {:alt (tr "viewer.share") - :class "disabled" - :disabled true} i/export] - [:li.tooltip.tooltip-right - {:alt (tr "viewer.save") - :on-click on-download} - i/save]]])) diff --git a/frontend/src/uxbox/view/ui/viewer/shapes.cljs b/frontend/src/uxbox/view/ui/viewer/shapes.cljs deleted file mode 100644 index 9d8d1b1fb..000000000 --- a/frontend/src/uxbox/view/ui/viewer/shapes.cljs +++ /dev/null @@ -1,118 +0,0 @@ -;; 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.ui.viewer.shapes - #_(:require [goog.events :as events] - [lentes.core :as l] - [uxbox.builtins.icons :as i] - [uxbox.view.store :as st] - [uxbox.view.data.viewer :as udv] - [uxbox.view.ui.viewer.interactions :as itx] - [uxbox.main.geom :as geom] - [uxbox.main.ui.shapes.rect :refer [rect-shape]] - [uxbox.main.ui.shapes.icon :refer [icon-shape]] - [uxbox.main.ui.shapes.text :refer [text-shape]] - ;; [uxbox.main.ui.shapes.group :refer [group-shape]] - [uxbox.main.ui.shapes.path :refer [path-shape]] - [uxbox.main.ui.shapes.circle :refer [circle-shape]] - [uxbox.main.ui.shapes.image :refer [image-shape]] - [rumext.core :as mx :include-macros true]) - #_(:import goog.events.EventType)) - -;; (def itx-flag-ref -;; (-> (comp (l/key :flags) (l/lens :interactions)) -;; (l/derive st/state))) - -;; (defn image-ref -;; [id] -;; (-> (l/in [:images id]) -;; (l/derive st/state))) - -;; ;; --- Interactions Wrapper - -;; (defn- interactions-wrapper-did-mount -;; [own] -;; (let [dom (mx/dom-node own) -;; shape (first (::mx/args own)) -;; evnts (itx/build-events shape) -;; keys (reduce (fn [acc [evt callback]] -;; (conj acc (events/listen dom evt callback))) -;; [] -;; evnts)] -;; (assoc own ::keys keys))) - -;; (defn- interactions-wrapper-will-unmount -;; [own] -;; (let [keys (::keys own)] -;; (run! #(events/unlistenByKey %) keys) -;; (dissoc own ::keys))) - -;; (mx/defc interactions-wrapper -;; {:did-mount interactions-wrapper-did-mount -;; :will-unmount interactions-wrapper-will-unmount -;; :mixins [mx/reactive mx/static]} -;; [shape factory] -;; {:pre [(map? shape)]} -;; (let [show-itx? (and (mx/react itx-flag-ref) -;; (not (empty? (:interactions shape)))) -;; rect (geom/shape->rect-shape shape)] -;; [:g {:id (str "itx-" (:id shape)) -;; :style {:cursor "pointer"}} -;; (factory shape) -;; (when show-itx? -;; [:circle {:class "interaction-bullet" -;; :cx (:x1 rect) -;; :cy (:y1 rect) -;; :r 5}])])) - -;; ;; [:rect {:class "interaction-hightlight" -;; ;; :x (:x1 rect) -;; ;; :y (:y1 rect) -;; ;; :width (:width rect) -;; ;; :height (:height rect)}] - -;; ;; --- Image Shape Wrapper -;; ;; -;; ;; NOTE: This wrapper is needed for preload the referenced -;; ;; image object which is need for properly show the shape. - -;; (mx/defc image-shape-wrapper -;; {:mixins [mx/static mx/reactive] -;; :init (fn [own] -;; (when-let [image-id (-> own ::mx/args first :image)] -;; (st/emit! (udv/fetch-image image-id))) -;; own)} -;; [{:keys [image] :as item}] -;; (when-let [image (mx/react (image-ref image))] -;; (image-shape (assoc item :image image)))) - -;; ;; --- Text Shape Wrapper - -;; (mx/defc text-shape-wrapper -;; {:mixins [mx/static]} -;; [item] -;; (text-shape (assoc item :user-select true))) - -;; ;; --- Shapes - -;; (declare shape) - -;; (mx/defc shape* -;; [{:keys [type] :as item}] -;; (case type -;; ;; :group (group-shape item shape) -;; :image (image-shape-wrapper item) -;; :text (text-shape-wrapper item) -;; :icon (icon-shape item) -;; :rect (rect-shape item) -;; :path (path-shape item) -;; :circle (circle-shape item))) - -;; (mx/defc shape -;; [sid] -;; {:pre [(uuid? sid)]} -;; (let [item (get-in @st/state [:shapes sid])] -;; (interactions-wrapper item shape*))) diff --git a/frontend/src/uxbox/view/ui/viewer/sitemap.cljs b/frontend/src/uxbox/view/ui/viewer/sitemap.cljs deleted file mode 100644 index 235854ed2..000000000 --- a/frontend/src/uxbox/view/ui/viewer/sitemap.cljs +++ /dev/null @@ -1,31 +0,0 @@ -;; 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 Juan de la Cruz -;; Copyright (c) 2016-2019 Andrey Antukh - -(ns uxbox.view.ui.viewer.sitemap - (:require - [lentes.core :as l] - [rumext.alpha :as mf] - [uxbox.builtins.icons :as i] - [uxbox.view.data.viewer :as dv] - [uxbox.view.store :as st])) - -(mf/defc sitemap - [{:keys [project pages selected] :as props}] - (let [project-name (:name project) - on-click #(st/emit! (dv/select-page %))] - [:div.view-sitemap - [:span.sitemap-title project-name] - [:ul.sitemap-list - (for [page pages] - (let [selected? (= (:id page) selected) - page-id (:id page)] - [:li {:class (when selected? "selected") - :on-click (partial on-click page-id) - :id (str "page-" page-id) - :key page-id} - [:div.page-icon i/file-html] - [:span (:name page)]]))]])) diff --git a/frontend/tools.clj b/frontend/tools.clj index 0926483d3..24d49b9fe 100644 --- a/frontend/tools.clj +++ b/frontend/tools.clj @@ -52,13 +52,10 @@ ;; --- Specific Build Options (def main-build-options - {:output-dir "resources/public/js" - :asset-path "/js" - :modules {:main {:entries #{"uxbox.main"} - :output-to "resources/public/js/main.js"} - ;; :view {:entries #{"uxbox.view"} - ;; :output-to "resources/public/js/view.js"} - }}) + {:output-dir "resources/public/js/main/" + :output-to "resources/public/js/main.js" + :main 'uxbox.main + :asset-path "/js/main"}) ;; (def worker-build-options ;; {:main 'uxbox.worker @@ -71,18 +68,18 @@ (-> (merge default-build-options main-build-options dist-build-options) - (assoc :output-dir "target/dist/js/") - (assoc-in [:modules :main :output-to] "target/dist/js/main.js") - #_(assoc-in [:modules :view :output-to] "target/dist/js/view.js"))) + (assoc :output-dir "target/dist/js/main/" + :source-map "target/dist/js/main.js.map" + :output-to "target/dist/js/main.js"))) (def main-dist-dbg-build-options - (-> (merge main-dist-build-options - {:optimizations :advanced - :pseudo-names true - :pretty-print true}) - (assoc :output-dir "target/dist/dbg/js/") - (assoc-in [:modules :main :output-to] "target/dist/dbg/js/main.js") - #_(assoc-in [:modules :view :output-to] "target/dist/dbg/js/view.js"))) + (assoc main-dist-build-options + :optimizations :advanced + :pseudo-names true + :pretty-print true + :output-dir "target/dist/dbg/js/main/" + :source-map "target/dist/dbg/js/main.js.map" + :output-to "target/dist/dbg/js/main.js")) ;; (def worker-dist-build-options ;; (merge default-build-options