mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 09:46:38 +02:00
♻️ Replace lentes with okulary (performance).
This commit is contained in:
parent
9649d67883
commit
cd61269cd5
28 changed files with 162 additions and 300 deletions
|
@ -13,9 +13,11 @@
|
||||||
funcool/beicon {:mvn/version "2020.03.29-1"}
|
funcool/beicon {:mvn/version "2020.03.29-1"}
|
||||||
funcool/cuerdas {:mvn/version "2020.03.26-3"}
|
funcool/cuerdas {:mvn/version "2020.03.26-3"}
|
||||||
funcool/lentes {:mvn/version "1.4.0-SNAPSHOT"}
|
funcool/lentes {:mvn/version "1.4.0-SNAPSHOT"}
|
||||||
|
|
||||||
|
funcool/okulary {:mvn/version "2020.04.11-0"}
|
||||||
funcool/potok {:mvn/version "2.8.0-SNAPSHOT"}
|
funcool/potok {:mvn/version "2.8.0-SNAPSHOT"}
|
||||||
funcool/promesa {:mvn/version "5.1.0"}
|
funcool/promesa {:mvn/version "5.1.0"}
|
||||||
funcool/rumext {:mvn/version "2020.04.08-1"}
|
funcool/rumext {:mvn/version "2020.04.11-0"}
|
||||||
}
|
}
|
||||||
:aliases
|
:aliases
|
||||||
{:dev
|
{:dev
|
||||||
|
|
|
@ -9,68 +9,61 @@
|
||||||
|
|
||||||
(ns uxbox.main.refs
|
(ns uxbox.main.refs
|
||||||
"A collection of derived refs."
|
"A collection of derived refs."
|
||||||
(:require [lentes.core :as l]
|
(:require
|
||||||
[beicon.core :as rx]
|
[okulary.core :as l]
|
||||||
[uxbox.main.constants :as c]
|
[beicon.core :as rx]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.constants :as c]
|
||||||
[uxbox.main.data.helpers :as helpers]))
|
[uxbox.main.store :as st]
|
||||||
|
[uxbox.main.data.helpers :as helpers]))
|
||||||
|
|
||||||
|
(def route
|
||||||
|
(l/derived :route st/state))
|
||||||
|
|
||||||
|
(def router
|
||||||
|
(l/derived :router st/state))
|
||||||
|
|
||||||
|
(def message
|
||||||
|
(l/derived :message st/state))
|
||||||
|
|
||||||
(def profile
|
(def profile
|
||||||
(-> (l/key :profile)
|
(l/derived :profile st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def workspace
|
|
||||||
(-> (l/key :workspace-local)
|
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def workspace-local
|
(def workspace-local
|
||||||
(-> (l/key :workspace-local)
|
(l/derived :workspace-local st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def workspace-layout
|
(def workspace-layout
|
||||||
(-> (l/key :workspace-layout)
|
(l/derived :workspace-layout st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def workspace-page
|
(def workspace-page
|
||||||
(-> (l/key :workspace-page)
|
(l/derived :workspace-page st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def workspace-file
|
(def workspace-file
|
||||||
(-> (l/key :workspace-file)
|
(l/derived :workspace-file st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def workspace-project
|
(def workspace-project
|
||||||
(-> (l/key :workspace-project)
|
(l/derived :workspace-project st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def workspace-images
|
(def workspace-images
|
||||||
(-> (l/key :workspace-images)
|
(l/derived :workspace-images st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def workspace-users
|
(def workspace-users
|
||||||
(-> (l/key :workspace-users)
|
(l/derived :workspace-users st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def workspace-data
|
(def workspace-data
|
||||||
(-> (l/lens #(let [page-id (get-in % [:workspace-page :id])]
|
(-> #(let [page-id (get-in % [:workspace-page :id])]
|
||||||
(get-in % [:workspace-data page-id])))
|
(get-in % [:workspace-data page-id]))
|
||||||
(l/derive st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(def objects
|
|
||||||
(-> (l/lens #(let [page-id (get-in % [:workspace-page :id])]
|
|
||||||
(get-in % [:workspace-data page-id :objects])))
|
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(defn objects-by-id
|
(defn objects-by-id
|
||||||
[ids]
|
[ids]
|
||||||
(-> (l/lens (fn [state]
|
(letfn [(selector [state]
|
||||||
(let [page-id (get-in state [:workspace-page :id])
|
(let [page-id (get-in state [:workspace-page :id])
|
||||||
objects (get-in state [:workspace-data page-id :objects])]
|
objects (get-in state [:workspace-data page-id :objects])]
|
||||||
(->> (set ids)
|
(->> (set ids)
|
||||||
(map #(get objects %))
|
(map #(get objects %))
|
||||||
(filter identity)
|
(filter identity)
|
||||||
(vec)))))
|
(vec))))]
|
||||||
(l/derive st/state {:equals? =})))
|
(l/derived selector st/state =)))
|
||||||
|
|
||||||
(defn is-child-selected?
|
(defn is-child-selected?
|
||||||
[id]
|
[id]
|
||||||
|
@ -81,71 +74,20 @@
|
||||||
shape (get objects id)
|
shape (get objects id)
|
||||||
children (helpers/get-children id objects)]
|
children (helpers/get-children id objects)]
|
||||||
(some selected children)))]
|
(some selected children)))]
|
||||||
(-> (l/lens selector)
|
(l/derived selector st/state)))
|
||||||
(l/derive st/state))))
|
|
||||||
|
|
||||||
(def selected-shapes
|
(def selected-shapes
|
||||||
(-> (l/key :selected)
|
(l/derived :selected workspace-local))
|
||||||
(l/derive workspace-local)))
|
|
||||||
|
|
||||||
(defn make-selected
|
(defn make-selected
|
||||||
[id]
|
[id]
|
||||||
(-> (l/lens #(contains? % id))
|
(l/derived #(contains? % id) selected-shapes))
|
||||||
(l/derive selected-shapes)))
|
|
||||||
|
|
||||||
(def selected-frame
|
|
||||||
(-> (l/key :selected-frame)
|
|
||||||
(l/derive workspace-local)))
|
|
||||||
|
|
||||||
(def toolboxes
|
|
||||||
(-> (l/key :toolboxes)
|
|
||||||
(l/derive workspace-local)))
|
|
||||||
|
|
||||||
;; DEPRECATED
|
|
||||||
(def selected-zoom
|
(def selected-zoom
|
||||||
(-> (l/key :zoom)
|
(l/derived :zoom workspace-local))
|
||||||
(l/derive workspace-local)))
|
|
||||||
|
|
||||||
(def selected-tooltip
|
|
||||||
(-> (l/key :tooltip)
|
|
||||||
(l/derive workspace-local)))
|
|
||||||
|
|
||||||
(def selected-drawing-shape
|
|
||||||
(-> (l/key :drawing)
|
|
||||||
(l/derive workspace-local)))
|
|
||||||
|
|
||||||
(def selected-drawing-tool
|
(def selected-drawing-tool
|
||||||
(-> (l/key :drawing-tool)
|
(l/derived :drawing-tool workspace-local))
|
||||||
(l/derive workspace)))
|
|
||||||
|
|
||||||
(def selected-edition
|
(def selected-edition
|
||||||
(-> (l/key :edition)
|
(l/derived :edition workspace-local))
|
||||||
(l/derive workspace)))
|
|
||||||
|
|
||||||
(def history
|
|
||||||
(-> (l/key :history)
|
|
||||||
(l/derive workspace)))
|
|
||||||
|
|
||||||
(defn selected-modifiers
|
|
||||||
[id]
|
|
||||||
{:pre [(uuid? id)]}
|
|
||||||
(-> (l/in [:modifiers id])
|
|
||||||
(l/derive workspace)))
|
|
||||||
|
|
||||||
(defn alignment-activated?
|
|
||||||
[flags]
|
|
||||||
(and (contains? flags :grid-indexed)
|
|
||||||
(contains? flags :grid-snap)))
|
|
||||||
|
|
||||||
(def selected-alignment
|
|
||||||
(-> (comp (l/key :flags)
|
|
||||||
(l/lens alignment-activated?))
|
|
||||||
(l/derive workspace)))
|
|
||||||
|
|
||||||
(def shapes-by-id
|
|
||||||
(-> (l/key :shapes)
|
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,15 @@
|
||||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
;; 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/.
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2015-2017 Andrey Antukh <niwi@niwi.nz>
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns uxbox.main.store
|
(ns uxbox.main.store
|
||||||
(:require [beicon.core :as rx]
|
(:require
|
||||||
[lentes.core :as l]
|
[beicon.core :as rx]
|
||||||
[potok.core :as ptk]
|
[okulary.core :as l]
|
||||||
[uxbox.common.uuid :as uuid]
|
[potok.core :as ptk]
|
||||||
[uxbox.util.storage :refer [storage]]))
|
[uxbox.common.uuid :as uuid]
|
||||||
|
[uxbox.util.storage :refer [storage]]))
|
||||||
|
|
||||||
;; TODO: move outside uxbox.main
|
;; TODO: move outside uxbox.main
|
||||||
|
|
||||||
|
@ -17,8 +18,8 @@
|
||||||
|
|
||||||
(def ^:dynamic *on-error* identity)
|
(def ^:dynamic *on-error* identity)
|
||||||
|
|
||||||
(defonce state (atom {}))
|
(defonce state (l/atom {}))
|
||||||
(defonce loader (atom false))
|
(defonce loader (l/atom false))
|
||||||
(defonce store (ptk/store {:on-error #(*on-error* %)}))
|
(defonce store (ptk/store {:on-error #(*on-error* %)}))
|
||||||
(defonce stream (ptk/input-stream store))
|
(defonce stream (ptk/input-stream store))
|
||||||
|
|
||||||
|
@ -44,10 +45,6 @@
|
||||||
(rx/filter (fn [s] (deref *debug*)) $)
|
(rx/filter (fn [s] (deref *debug*)) $)
|
||||||
(rx/subscribe $ (fn [event]
|
(rx/subscribe $ (fn [event]
|
||||||
(println "[stream]: " (repr-event event)))))))
|
(println "[stream]: " (repr-event event)))))))
|
||||||
(def auth-ref
|
|
||||||
(-> (l/key :auth)
|
|
||||||
(l/derive state)))
|
|
||||||
|
|
||||||
(defn emit!
|
(defn emit!
|
||||||
([] nil)
|
([] nil)
|
||||||
([event]
|
([event]
|
||||||
|
|
|
@ -11,33 +11,28 @@
|
||||||
(:require
|
(:require
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[lentes.core :as l]
|
|
||||||
[potok.core :as ptk]
|
[potok.core :as ptk]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.common.exceptions :as ex]
|
|
||||||
[uxbox.common.data :as d]
|
[uxbox.common.data :as d]
|
||||||
|
[uxbox.common.exceptions :as ex]
|
||||||
[uxbox.main.data.auth :refer [logout]]
|
[uxbox.main.data.auth :refer [logout]]
|
||||||
[uxbox.main.data.messages :as dm]
|
[uxbox.main.data.messages :as dm]
|
||||||
[uxbox.main.refs :as refs]
|
[uxbox.main.refs :as refs]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
[uxbox.main.ui.dashboard :refer [dashboard]]
|
[uxbox.main.ui.dashboard :refer [dashboard]]
|
||||||
[uxbox.main.ui.login :refer [login-page]]
|
[uxbox.main.ui.login :refer [login-page]]
|
||||||
|
[uxbox.main.ui.not-found :refer [not-found-page]]
|
||||||
[uxbox.main.ui.profile.recovery :refer [profile-recovery-page]]
|
[uxbox.main.ui.profile.recovery :refer [profile-recovery-page]]
|
||||||
[uxbox.main.ui.profile.recovery-request :refer [profile-recovery-request-page]]
|
[uxbox.main.ui.profile.recovery-request :refer [profile-recovery-request-page]]
|
||||||
[uxbox.main.ui.profile.register :refer [profile-register-page]]
|
[uxbox.main.ui.profile.register :refer [profile-register-page]]
|
||||||
[uxbox.main.ui.viewer :refer [viewer-page]]
|
|
||||||
[uxbox.main.ui.settings :as settings]
|
[uxbox.main.ui.settings :as settings]
|
||||||
[uxbox.main.ui.not-found :refer [not-found-page]]
|
|
||||||
[uxbox.main.ui.shapes]
|
[uxbox.main.ui.shapes]
|
||||||
|
[uxbox.main.ui.viewer :refer [viewer-page]]
|
||||||
[uxbox.main.ui.workspace :as workspace]
|
[uxbox.main.ui.workspace :as workspace]
|
||||||
[uxbox.util.i18n :refer [tr]]
|
[uxbox.util.i18n :refer [tr]]
|
||||||
[uxbox.util.timers :as ts]))
|
[uxbox.util.timers :as ts]))
|
||||||
|
|
||||||
(def route-iref
|
|
||||||
(-> (l/key :route)
|
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
;; --- Routes
|
;; --- Routes
|
||||||
|
|
||||||
(def routes
|
(def routes
|
||||||
|
@ -142,7 +137,7 @@
|
||||||
|
|
||||||
(mf/defc app
|
(mf/defc app
|
||||||
[]
|
[]
|
||||||
(let [route (mf/deref route-iref)]
|
(let [route (mf/deref refs/route)]
|
||||||
(when route
|
(when route
|
||||||
[:& app-container {:route route :key (get-in route [:data :name])}])))
|
[:& app-container {:route route :key (get-in route [:data :name])}])))
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.colorpicker
|
(ns uxbox.main.ui.colorpicker
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
[goog.object :as gobj]
|
[goog.object :as gobj]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
|
@ -15,7 +15,6 @@
|
||||||
(mf/defc colorpicker
|
(mf/defc colorpicker
|
||||||
[{:keys [on-change value colors] :as props}]
|
[{:keys [on-change value colors] :as props}]
|
||||||
(let [local-value (mf/use-state value)
|
(let [local-value (mf/use-state value)
|
||||||
|
|
||||||
on-change-complete #(do
|
on-change-complete #(do
|
||||||
(reset! local-value %)
|
(reset! local-value %)
|
||||||
(on-change (gobj/get % "hex")))]
|
(on-change (gobj/get % "hex")))]
|
||||||
|
@ -26,18 +25,16 @@
|
||||||
:onChangeComplete on-change-complete
|
:onChangeComplete on-change-complete
|
||||||
:style {:box-shadow "none"}}]))
|
:style {:box-shadow "none"}}]))
|
||||||
|
|
||||||
(defn- lookup-colors
|
|
||||||
[state]
|
|
||||||
(as-> {} $
|
|
||||||
(reduce (fn [acc shape]
|
|
||||||
(-> acc
|
|
||||||
(update (:fill-color shape) (fnil inc 0))
|
|
||||||
(update (:stroke-color shape) (fnil inc 0))))
|
|
||||||
$ (vals (:shapes state)))
|
|
||||||
(reverse (sort-by second $))
|
|
||||||
(map first $)
|
|
||||||
(remove nil? $)))
|
|
||||||
|
|
||||||
(def most-used-colors
|
(def most-used-colors
|
||||||
(-> (l/lens lookup-colors)
|
(letfn [(selector [{:keys [objects]}]
|
||||||
(l/derive st/state)))
|
(as-> {} $
|
||||||
|
(reduce (fn [acc shape]
|
||||||
|
(-> acc
|
||||||
|
(update (:fill-color shape) (fnil inc 0))
|
||||||
|
(update (:stroke-color shape) (fnil inc 0))))
|
||||||
|
$ (vals objects))
|
||||||
|
(reverse (sort-by second $))
|
||||||
|
(map first $)
|
||||||
|
(remove nil? $)))]
|
||||||
|
(l/derived selector st/state)))
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.dashboard.library
|
(ns uxbox.main.ui.dashboard.library
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[uxbox.util.router :as rt]
|
[uxbox.util.router :as rt]
|
||||||
|
@ -302,16 +302,16 @@
|
||||||
:accept-text "Delete"}))]]}]]])))
|
:accept-text "Delete"}))]]}]]])))
|
||||||
|
|
||||||
(defn libraries-ref [section team-id]
|
(defn libraries-ref [section team-id]
|
||||||
(-> (comp (l/key :library) (l/key section) (l/key team-id))
|
(-> (l/in [:library section team-id])
|
||||||
(l/derive st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(defn selected-items-ref [section library-id]
|
(defn selected-items-ref [section library-id]
|
||||||
(-> (comp (l/key :library-items) (l/key section) (l/key library-id))
|
(-> (l/in [:library-items section library-id])
|
||||||
(l/derive st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(def last-deleted-library-ref
|
(def last-deleted-library-ref
|
||||||
(-> (comp (l/key :library) (l/key :last-deleted-library))
|
(-> (l/in [:library :last-deleted-library])
|
||||||
(l/derive st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(mf/defc library-page
|
(mf/defc library-page
|
||||||
[{:keys [team-id library-id section]}]
|
[{:keys [team-id library-id section]}]
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.dashboard.project
|
(ns uxbox.main.ui.dashboard.project
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.util.i18n :as i18n :refer [t]]
|
[uxbox.util.i18n :as i18n :refer [t]]
|
||||||
|
@ -24,13 +24,11 @@
|
||||||
[uxbox.main.ui.dashboard.grid :refer [grid]]))
|
[uxbox.main.ui.dashboard.grid :refer [grid]]))
|
||||||
|
|
||||||
(def projects-ref
|
(def projects-ref
|
||||||
(-> (l/key :projects)
|
(l/derived :projects st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def files-ref
|
(def files-ref
|
||||||
(-> (comp (l/key :files)
|
(-> (comp vals :files)
|
||||||
(l/lens vals))
|
(l/derived st/state)))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(mf/defc project-header
|
(mf/defc project-header
|
||||||
[{:keys [team-id project-id] :as props}]
|
[{:keys [team-id project-id] :as props}]
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.dashboard.recent-files
|
(ns uxbox.main.ui.dashboard.recent-files
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.common.exceptions :as ex]
|
[uxbox.common.exceptions :as ex]
|
||||||
|
@ -31,16 +31,13 @@
|
||||||
;; --- Component: Content
|
;; --- Component: Content
|
||||||
|
|
||||||
(def projects-ref
|
(def projects-ref
|
||||||
(-> (l/key :projects)
|
(l/derived :projects st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def recent-file-ids-ref
|
(def recent-file-ids-ref
|
||||||
(-> (l/key :recent-file-ids)
|
(l/derived :recent-file-ids st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def files-ref
|
(def files-ref
|
||||||
(-> (l/key :files)
|
(l/derived :files st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
;; --- Component: Recent files
|
;; --- Component: Recent files
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.dashboard.search
|
(ns uxbox.main.ui.dashboard.search
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
[uxbox.main.data.dashboard :as dsh]
|
[uxbox.main.data.dashboard :as dsh]
|
||||||
|
@ -20,8 +20,8 @@
|
||||||
;; --- Component: Search
|
;; --- Component: Search
|
||||||
|
|
||||||
(def search-result-ref
|
(def search-result-ref
|
||||||
(-> (l/in [:dashboard-local :search-result])
|
(-> #(get-in % [:dashboard-local :search-result])
|
||||||
(l/derive st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(mf/defc search-page
|
(mf/defc search-page
|
||||||
[{:keys [team-id search-term] :as props}]
|
[{:keys [team-id search-term] :as props}]
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
(ns uxbox.main.ui.dashboard.sidebar
|
(ns uxbox.main.ui.dashboard.sidebar
|
||||||
(:require
|
(:require
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[goog.functions :as f]
|
[goog.functions :as f]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
|
@ -65,8 +65,7 @@
|
||||||
[:span.element-title name]])]))
|
[:span.element-title name]])]))
|
||||||
|
|
||||||
(def projects-iref
|
(def projects-iref
|
||||||
(-> (l/key :projects)
|
(l/derived :projects st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(mf/defc sidebar-projects
|
(mf/defc sidebar-projects
|
||||||
[{:keys [team-id selected-project-id] :as props}]
|
[{:keys [team-id selected-project-id] :as props}]
|
||||||
|
|
|
@ -1,29 +1,22 @@
|
||||||
(ns uxbox.main.ui.messages
|
(ns uxbox.main.ui.messages
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.main.data.messages :as dm]
|
[uxbox.main.data.messages :as dm]
|
||||||
|
[uxbox.main.refs :as refs]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
|
[uxbox.util.data :refer [classnames]]
|
||||||
[uxbox.util.dom :as dom]
|
[uxbox.util.dom :as dom]
|
||||||
[uxbox.util.timers :as ts]
|
|
||||||
[uxbox.util.i18n :as i18n :refer [t]]
|
[uxbox.util.i18n :as i18n :refer [t]]
|
||||||
[uxbox.util.data :refer [classnames]]))
|
[uxbox.util.timers :as ts]))
|
||||||
|
|
||||||
;; --- Main Component (entry point)
|
;; --- Main Component (entry point)
|
||||||
|
|
||||||
(declare notification)
|
(declare notification)
|
||||||
|
|
||||||
(def ^:private message-iref
|
|
||||||
(-> (l/key :message)
|
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(mf/defc messages
|
(mf/defc messages
|
||||||
[]
|
[]
|
||||||
(let [message (mf/deref message-iref)
|
(let [message (mf/deref refs/message)]
|
||||||
;; message {:type :error
|
|
||||||
;; :content "Hello world!"}
|
|
||||||
]
|
|
||||||
(when message
|
(when message
|
||||||
[:& notification {:type (:type message)
|
[:& notification {:type (:type message)
|
||||||
:status (:status message)
|
:status (:status message)
|
||||||
|
@ -31,7 +24,7 @@
|
||||||
|
|
||||||
(mf/defc messages-widget
|
(mf/defc messages-widget
|
||||||
[]
|
[]
|
||||||
(let [message (mf/deref message-iref)
|
(let [message (mf/deref refs/message)
|
||||||
message {:type :error
|
message {:type :error
|
||||||
:content "Hello world!"}]
|
:content "Hello world!"}]
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[goog.events :as events]
|
[goog.events :as events]
|
||||||
[goog.object :as gobj]
|
[goog.object :as gobj]
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.common.exceptions :as ex]
|
[uxbox.common.exceptions :as ex]
|
||||||
|
@ -93,12 +93,10 @@
|
||||||
;; --- Component: Viewer Page
|
;; --- Component: Viewer Page
|
||||||
|
|
||||||
(def viewer-data-ref
|
(def viewer-data-ref
|
||||||
(-> (l/key :viewer-data)
|
(l/derived :viewer-data st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def viewer-local-ref
|
(def viewer-local-ref
|
||||||
(-> (l/key :viewer-local)
|
(l/derived :viewer-local st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(mf/defc viewer-page
|
(mf/defc viewer-page
|
||||||
[{:keys [page-id index token] :as props}]
|
[{:keys [page-id index token] :as props}]
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
[:& colorpalette {:left-sidebar? left-sidebar?}])
|
[:& colorpalette {:left-sidebar? left-sidebar?}])
|
||||||
|
|
||||||
[:& messages]
|
[:& messages]
|
||||||
[:& context-menu {}]
|
[:& context-menu]
|
||||||
|
|
||||||
[:section.workspace-content
|
[:section.workspace-content
|
||||||
{:class classes
|
{:class classes
|
||||||
|
|
|
@ -2,42 +2,40 @@
|
||||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
;; 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/.
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2015-2017 Andrey Antukh <niwi@niwi.nz>
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; Copyright (c) 2015-2017 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns uxbox.main.ui.workspace.colorpalette
|
(ns uxbox.main.ui.workspace.colorpalette
|
||||||
(:require
|
(:require
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.main.data.colors :as udc]
|
[uxbox.main.data.colors :as udc]
|
||||||
[uxbox.main.data.workspace :as udw]
|
|
||||||
[uxbox.main.data.library :as dlib]
|
[uxbox.main.data.library :as dlib]
|
||||||
|
[uxbox.main.data.workspace :as udw]
|
||||||
|
[uxbox.main.refs :as refs]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
|
[uxbox.main.ui.components.context-menu :refer [context-menu]]
|
||||||
[uxbox.main.ui.keyboard :as kbd]
|
[uxbox.main.ui.keyboard :as kbd]
|
||||||
[uxbox.util.color :refer [hex->rgb]]
|
[uxbox.util.color :refer [hex->rgb]]
|
||||||
[uxbox.util.data :refer [read-string seek]]
|
[uxbox.util.dom :as dom]))
|
||||||
[uxbox.util.dom :as dom]
|
|
||||||
[uxbox.main.ui.components.context-menu :refer [context-menu]]))
|
|
||||||
|
|
||||||
;; --- Refs
|
;; --- Refs
|
||||||
|
|
||||||
(def project-ref
|
|
||||||
(-> (l/key :workspace-project)
|
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(def libraries-ref
|
(def libraries-ref
|
||||||
(-> (comp (l/key :library) (l/key :palettes))
|
(l/derived #(get-in % [:library :palettes]) st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(defn selected-items-ref [library-id]
|
(defn selected-items-ref
|
||||||
(-> (comp (l/key :library-items) (l/key :palettes) (l/key library-id))
|
[library-id]
|
||||||
(l/derive st/state)))
|
(->> #(get-in % [:library-items :palettes library-id])
|
||||||
|
(l/derived st/state)))
|
||||||
|
|
||||||
(def selected-library-ref
|
(def selected-library-ref
|
||||||
(-> (comp (l/key :library-selected) (l/key :palettes))
|
(-> #(get-in % [:library-selected :palettes])
|
||||||
(l/derive st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
;; --- Components
|
;; --- Components
|
||||||
|
|
||||||
|
@ -64,7 +62,7 @@
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(mf/deps current-selection)
|
(mf/deps current-selection)
|
||||||
#(st/emit! (dlib/retrieve-library-data :palettes current-selection)))
|
#(st/emit! (dlib/retrieve-library-data :palettes current-selection)))
|
||||||
|
|
||||||
(let [items (-> current-selection selected-items-ref mf/deref)
|
(let [items (-> current-selection selected-items-ref mf/deref)
|
||||||
doc-width (.. js/document -documentElement -clientWidth)
|
doc-width (.. js/document -documentElement -clientWidth)
|
||||||
width (:width @state (* doc-width 0.84))
|
width (:width @state (* doc-width 0.84))
|
||||||
|
@ -108,7 +106,7 @@
|
||||||
|
|
||||||
[:div.color-palette {:class (when left-sidebar? "left-sidebar-open")}
|
[:div.color-palette {:class (when left-sidebar? "left-sidebar-open")}
|
||||||
[:& context-menu {:selectable true
|
[:& context-menu {:selectable true
|
||||||
:selected (->> libraries (filter #(= (:id %) current-selection)) first :name)
|
:selected (->> libraries (filter #(= (:id %) current-selection)) first :name)
|
||||||
:show (:show-menu @state)
|
:show (:show-menu @state)
|
||||||
:on-close #(swap! state assoc :show-menu false)
|
:on-close #(swap! state assoc :show-menu false)
|
||||||
:options (mapv #(vector (:name %) (partial handle-click %)) libraries)} ]
|
:options (mapv #(vector (:name %) (partial handle-click %)) libraries)} ]
|
||||||
|
@ -130,7 +128,7 @@
|
||||||
|
|
||||||
(mf/defc colorpalette
|
(mf/defc colorpalette
|
||||||
[{:keys [left-sidebar?]}]
|
[{:keys [left-sidebar?]}]
|
||||||
(let [team-id (-> project-ref mf/deref :team-id)
|
(let [team-id (-> refs/workspace-project mf/deref :team-id)
|
||||||
libraries (-> libraries-ref mf/deref vals flatten)]
|
libraries (-> libraries-ref mf/deref vals flatten)]
|
||||||
(mf/use-effect #(st/emit! (dlib/retrieve-libraries :palettes)
|
(mf/use-effect #(st/emit! (dlib/retrieve-libraries :palettes)
|
||||||
(dlib/retrieve-libraries :palettes team-id)))
|
(dlib/retrieve-libraries :palettes team-id)))
|
||||||
|
|
|
@ -7,29 +7,10 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.workspace.colorpicker
|
(ns uxbox.main.ui.workspace.colorpicker
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
[uxbox.main.ui.colorpicker :as cp]))
|
[uxbox.main.ui.colorpicker :as cp]))
|
||||||
|
|
||||||
;; --- Recent Colors Calc. Algorithm
|
|
||||||
|
|
||||||
(defn- lookup-colors
|
|
||||||
[state]
|
|
||||||
(as-> {} $
|
|
||||||
(reduce (fn [acc shape]
|
|
||||||
(-> acc
|
|
||||||
(update (:fill-color shape) (fnil inc 0))
|
|
||||||
(update (:stroke-color shape) (fnil inc 0))))
|
|
||||||
$ (vals (:shapes state)))
|
|
||||||
(reverse (sort-by second $))
|
|
||||||
(map first $)
|
|
||||||
(remove nil? $)))
|
|
||||||
|
|
||||||
(def most-used-colors
|
|
||||||
(-> (l/lens lookup-colors)
|
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
;; --- Color Picker Modal
|
;; --- Color Picker Modal
|
||||||
|
|
||||||
(mf/defc colorpicker-modal
|
(mf/defc colorpicker-modal
|
||||||
|
@ -38,7 +19,7 @@
|
||||||
{:style {:left (str (- x 260) "px")
|
{:style {:left (str (- x 260) "px")
|
||||||
:top (str (- y 50) "px")}}
|
:top (str (- y 50) "px")}}
|
||||||
[:& cp/colorpicker {:value (or value default)
|
[:& cp/colorpicker {:value (or value default)
|
||||||
:colors (into-array @most-used-colors)
|
:colors (into-array @cp/most-used-colors)
|
||||||
:on-change on-change}]])
|
:on-change on-change}]])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
"A workspace specific context menu (mouse right click)."
|
"A workspace specific context menu (mouse right click)."
|
||||||
(:require
|
(:require
|
||||||
[beicon.core :as rx]
|
[beicon.core :as rx]
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[potok.core :as ptk]
|
[potok.core :as ptk]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.main.store :as st]
|
[uxbox.main.store :as st]
|
||||||
|
@ -24,8 +24,7 @@
|
||||||
[uxbox.main.ui.components.dropdown :refer [dropdown]]))
|
[uxbox.main.ui.components.dropdown :refer [dropdown]]))
|
||||||
|
|
||||||
(def menu-ref
|
(def menu-ref
|
||||||
(-> (l/key :context-menu)
|
(l/derived :context-menu refs/workspace-local))
|
||||||
(l/derive refs/workspace-local)))
|
|
||||||
|
|
||||||
(defn- prevent-default
|
(defn- prevent-default
|
||||||
[event]
|
[event]
|
||||||
|
@ -102,8 +101,8 @@
|
||||||
[:& menu-entry {:title "Hide"
|
[:& menu-entry {:title "Hide"
|
||||||
:on-click do-hide-shape}])
|
:on-click do-hide-shape}])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(if (:blocked shape)
|
(if (:blocked shape)
|
||||||
[:& menu-entry {:title "Unlock"
|
[:& menu-entry {:title "Unlock"
|
||||||
:on-click do-unlock-shape}]
|
:on-click do-unlock-shape}]
|
||||||
|
|
|
@ -131,13 +131,10 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [{:keys [zoom flags]} (:workspace-local state)
|
(let [{:keys [zoom flags]} (:workspace-local state)
|
||||||
align? (refs/alignment-activated? flags)
|
|
||||||
|
|
||||||
stoper? #(or (ms/mouse-up? %) (= % :interrupt))
|
stoper? #(or (ms/mouse-up? %) (= % :interrupt))
|
||||||
stoper (rx/filter stoper? stream)
|
stoper (rx/filter stoper? stream)
|
||||||
|
|
||||||
mouse (->> ms/mouse-position
|
mouse (->> ms/mouse-position
|
||||||
;; (rx/mapcat #(conditional-align % align?))
|
|
||||||
(rx/map #(gpt/divide % (gpt/point zoom))))]
|
(rx/map #(gpt/divide % (gpt/point zoom))))]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(->> mouse
|
(->> mouse
|
||||||
|
@ -181,14 +178,12 @@
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [{:keys [zoom flags]} (:workspace-local state)
|
(let [{:keys [zoom flags]} (:workspace-local state)
|
||||||
|
|
||||||
align? (refs/alignment-activated? flags)
|
|
||||||
last-point (volatile! (gpt/divide @ms/mouse-position (gpt/point zoom)))
|
last-point (volatile! (gpt/divide @ms/mouse-position (gpt/point zoom)))
|
||||||
|
|
||||||
stoper (->> (rx/filter stoper-event? stream)
|
stoper (->> (rx/filter stoper-event? stream)
|
||||||
(rx/share))
|
(rx/share))
|
||||||
|
|
||||||
mouse (->> (rx/sample 10 ms/mouse-position)
|
mouse (->> (rx/sample 10 ms/mouse-position)
|
||||||
;; (rx/mapcat #(conditional-align % align?))
|
|
||||||
(rx/map #(gpt/divide % (gpt/point zoom))))
|
(rx/map #(gpt/divide % (gpt/point zoom))))
|
||||||
|
|
||||||
points (->> stream
|
points (->> stream
|
||||||
|
@ -255,10 +250,8 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state stream]
|
(watch [_ state stream]
|
||||||
(let [{:keys [zoom flags]} (:workspace-local state)
|
(let [{:keys [zoom flags]} (:workspace-local state)
|
||||||
align? (refs/alignment-activated? flags)
|
|
||||||
stoper (rx/filter stoper-event? stream)
|
stoper (rx/filter stoper-event? stream)
|
||||||
mouse (->> (rx/sample 10 ms/mouse-position)
|
mouse (->> (rx/sample 10 ms/mouse-position)
|
||||||
;; (rx/mapcat #(conditional-align % align?))
|
|
||||||
(rx/map #(gpt/divide % (gpt/point zoom))))]
|
(rx/map #(gpt/divide % (gpt/point zoom))))]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of initialize-drawing)
|
(rx/of initialize-drawing)
|
||||||
|
@ -350,8 +343,3 @@
|
||||||
:on-click on-click
|
:on-click on-click
|
||||||
:on-mouse-enter on-mouse-enter
|
:on-mouse-enter on-mouse-enter
|
||||||
:on-mouse-leave on-mouse-leave}])])))
|
:on-mouse-leave on-mouse-leave}])])))
|
||||||
|
|
||||||
;; (defn- conditional-align [point align?]
|
|
||||||
;; (if align?
|
|
||||||
;; (uwrk/align-point point)
|
|
||||||
;; (rx/of point)))
|
|
||||||
|
|
|
@ -2,27 +2,27 @@
|
||||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
;; 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/.
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2015-2017 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; Copyright (c) 2015-2019 Andrey Antukh <niwi@niwi.nz>
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns uxbox.main.ui.workspace.grid
|
(ns uxbox.main.ui.workspace.grid
|
||||||
(:require
|
(:require
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.main.refs :as refs]
|
[uxbox.main.constants :as c]
|
||||||
[uxbox.main.constants :as c]))
|
[uxbox.main.refs :as refs]))
|
||||||
|
|
||||||
;; --- Grid (Component)
|
;; --- Grid (Component)
|
||||||
|
|
||||||
(def options-iref
|
(def options-iref
|
||||||
(-> (l/key :options)
|
(l/derived :options refs/workspace-data))
|
||||||
(l/derive refs/workspace-data)))
|
|
||||||
|
|
||||||
(mf/defc grid
|
(mf/defc grid
|
||||||
{:wrap [mf/memo]}
|
{:wrap [mf/memo]}
|
||||||
[props]
|
[props]
|
||||||
(prn "grid$render")
|
|
||||||
(let [options (mf/deref options-iref)
|
(let [options (mf/deref options-iref)
|
||||||
width (:grid-x options 10)
|
width (:grid-x options 10)
|
||||||
height (:grid-y options 10)
|
height (:grid-y options 10)
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.workspace.header
|
(ns uxbox.main.ui.workspace.header
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.builtins.icons :as i :include-macros true]
|
[uxbox.builtins.icons :as i :include-macros true]
|
||||||
[uxbox.config :as cfg]
|
[uxbox.config :as cfg]
|
||||||
|
@ -144,17 +143,13 @@
|
||||||
|
|
||||||
;; --- Header Component
|
;; --- Header Component
|
||||||
|
|
||||||
(def router-ref
|
|
||||||
(-> (l/key :router)
|
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(mf/defc header
|
(mf/defc header
|
||||||
[{:keys [page file layout project] :as props}]
|
[{:keys [page file layout project] :as props}]
|
||||||
(let [locale (i18n/use-locale)
|
(let [locale (i18n/use-locale)
|
||||||
go-to-dashboard #(st/emit! (rt/nav :dashboard-team {:team-id "self"}))
|
go-to-dashboard #(st/emit! (rt/nav :dashboard-team {:team-id "self"}))
|
||||||
zoom (mf/deref refs/selected-zoom)
|
zoom (mf/deref refs/selected-zoom)
|
||||||
locale (i18n/use-locale)
|
locale (i18n/use-locale)
|
||||||
router (mf/deref router-ref)
|
router (mf/deref refs/router)
|
||||||
view-url (rt/resolve router :viewer {:page-id (:id page)} {:index 0})]
|
view-url (rt/resolve router :viewer {:page-id (:id page)} {:index 0})]
|
||||||
[:header.workspace-header
|
[:header.workspace-header
|
||||||
[:div.main-icon
|
[:div.main-icon
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
[uxbox.common.uuid :as uuid]))
|
[uxbox.common.uuid :as uuid]))
|
||||||
|
|
||||||
;; --- Refs
|
;; --- Refs
|
||||||
|
;; TODO: pending refactor
|
||||||
|
|
||||||
(def ^:private collections-iref
|
(def ^:private collections-iref
|
||||||
(-> (l/key :images-collections)
|
(-> (l/key :images-collections)
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
(mf/defc align-options
|
(mf/defc align-options
|
||||||
[]
|
[]
|
||||||
(let [selected (mf/deref refs/selected-shapes)
|
(let [selected (mf/deref refs/selected-shapes)
|
||||||
objects (deref refs/objects) ; don't need to watch objects, only read the value
|
|
||||||
|
;; don't need to watch objects, only read the value
|
||||||
|
objects (:objects (deref refs/workspace-data))
|
||||||
|
|
||||||
disabled (cond
|
disabled (cond
|
||||||
(empty? selected) true
|
(empty? selected) true
|
||||||
|
|
|
@ -73,7 +73,7 @@
|
||||||
|
|
||||||
(mf/defc history-toolbox
|
(mf/defc history-toolbox
|
||||||
[props]
|
[props]
|
||||||
(let [history (mf/deref refs/history)
|
(let [history nil #_(mf/deref refs/history)
|
||||||
section (mf/use-state :main)
|
section (mf/use-state :main)
|
||||||
;; close #(st/emit! (dw/toggle-flag :history))
|
;; close #(st/emit! (dw/toggle-flag :history))
|
||||||
close (constantly nil)
|
close (constantly nil)
|
||||||
|
@ -102,7 +102,7 @@
|
||||||
|
|
||||||
(mf/defc history-dialog
|
(mf/defc history-dialog
|
||||||
[props]
|
[props]
|
||||||
(let [history (mf/deref refs/history)
|
(let [history nil #_(mf/deref refs/history)
|
||||||
version (:selected history)
|
version (:selected history)
|
||||||
on-accept #(st/emit! udh/apply-selected)
|
on-accept #(st/emit! udh/apply-selected)
|
||||||
on-cancel #(st/emit! udh/deselect)]
|
on-cancel #(st/emit! udh/deselect)]
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.workspace.sidebar.layers
|
(ns uxbox.main.ui.workspace.sidebar.layers
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.common.data :as d]
|
[uxbox.common.data :as d]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
|
@ -26,10 +25,6 @@
|
||||||
[uxbox.common.uuid :as uuid]
|
[uxbox.common.uuid :as uuid]
|
||||||
[uxbox.util.i18n :as i18n :refer [t]]))
|
[uxbox.util.i18n :as i18n :refer [t]]))
|
||||||
|
|
||||||
(def ^:private shapes-iref
|
|
||||||
(-> (l/key :shapes)
|
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
;; --- Helpers
|
;; --- Helpers
|
||||||
|
|
||||||
(mf/defc element-icon
|
(mf/defc element-icon
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
(ns uxbox.main.ui.workspace.sidebar.libraries
|
(ns uxbox.main.ui.workspace.sidebar.libraries
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.common.data :as d]
|
[uxbox.common.data :as d]
|
||||||
|
@ -31,25 +31,21 @@
|
||||||
|
|
||||||
;; --- Refs
|
;; --- Refs
|
||||||
|
|
||||||
(def project-ref
|
|
||||||
(-> (l/key :workspace-project)
|
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(defn libraries-ref [section]
|
(defn libraries-ref [section]
|
||||||
(-> (comp (l/key :library) (l/key section))
|
(-> (l/in [:library section])
|
||||||
(l/derive st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(defn selected-items-ref [section library-id]
|
(defn selected-items-ref [section library-id]
|
||||||
(-> (comp (l/key :library-items) (l/key section) (l/key library-id))
|
(-> (l/in [:library-items section library-id])
|
||||||
(l/derive st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(defn selected-library-ref [section]
|
(defn selected-library-ref [section]
|
||||||
(-> (comp (l/key :library-selected) (l/key section))
|
(-> (l/in [:library-selected section])
|
||||||
(l/derive st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(defn selected-filter-ref [section]
|
(defn selected-filter-ref [section]
|
||||||
(-> (comp (l/key :library-filter) (l/key section))
|
(-> (l/in [:library-filter section])
|
||||||
(l/derive st/state)))
|
(l/derived st/state)))
|
||||||
|
|
||||||
(defmulti shape-from-item (fn [type _] type))
|
(defmulti shape-from-item (fn [type _] type))
|
||||||
|
|
||||||
|
@ -111,7 +107,7 @@
|
||||||
(if (= section :icons)
|
(if (= section :icons)
|
||||||
[:svg {:view-box (->> item :metadata :view-box (str/join " "))
|
[:svg {:view-box (->> item :metadata :view-box (str/join " "))
|
||||||
:width (-> item :metadata :width)
|
:width (-> item :metadata :width)
|
||||||
:height (-> item :metadat :height)
|
:height (-> item :metadat :height)
|
||||||
:dangerouslySetInnerHTML {:__html (:content item)}}]
|
:dangerouslySetInnerHTML {:__html (:content item)}}]
|
||||||
[:img {:draggable false
|
[:img {:draggable false
|
||||||
:src (:thumb-uri item)}])
|
:src (:thumb-uri item)}])
|
||||||
|
@ -121,7 +117,7 @@
|
||||||
[{:keys [key]}]
|
[{:keys [key]}]
|
||||||
(let [state (mf/use-state {:menu-open false})
|
(let [state (mf/use-state {:menu-open false})
|
||||||
selected-filter (fn [section] (or (mf/deref (selected-filter-ref section)) :all))
|
selected-filter (fn [section] (or (mf/deref (selected-filter-ref section)) :all))
|
||||||
team-id (-> project-ref mf/deref :team-id)
|
team-id (-> refs/workspace-project mf/deref :team-id)
|
||||||
|
|
||||||
filter-to-str {:all (tr "workspace.library.all")
|
filter-to-str {:all (tr "workspace.library.all")
|
||||||
:own (tr "workspace.library.own")
|
:own (tr "workspace.library.own")
|
||||||
|
|
|
@ -2,12 +2,14 @@
|
||||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
;; 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/.
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) 2015-2016 Andrey Antukh <niwi@niwi.nz>
|
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||||
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
;; defined by the Mozilla Public License, v. 2.0.
|
||||||
|
;;
|
||||||
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns uxbox.main.ui.workspace.sidebar.options
|
(ns uxbox.main.ui.workspace.sidebar.options
|
||||||
(:require
|
(:require
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.main.data.workspace :as udw]
|
[uxbox.main.data.workspace :as udw]
|
||||||
|
@ -46,8 +48,8 @@
|
||||||
[{:keys [shape-id page-id] :as props}]
|
[{:keys [shape-id page-id] :as props}]
|
||||||
(let [shape-iref (-> (mf/deps shape-id page-id)
|
(let [shape-iref (-> (mf/deps shape-id page-id)
|
||||||
(mf/use-memo
|
(mf/use-memo
|
||||||
#(-> (l/in [:workspace-data page-id :objects shape-id])
|
#(-> (l/in [:objects shape-id])
|
||||||
(l/derive st/state))))
|
(l/derived refs/workspace-data))))
|
||||||
shape (mf/deref shape-iref)]
|
shape (mf/deref shape-iref)]
|
||||||
[:& shape-options {:shape shape}]))
|
[:& shape-options {:shape shape}]))
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
(:require
|
(:require
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[uxbox.common.data :as d]
|
[uxbox.common.data :as d]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.main.constants :as c]
|
[uxbox.main.constants :as c]
|
||||||
|
@ -66,8 +66,7 @@
|
||||||
:grid-color "#cccccc"})
|
:grid-color "#cccccc"})
|
||||||
|
|
||||||
(def options-iref
|
(def options-iref
|
||||||
(-> (l/key :options)
|
(l/derived :options refs/workspace-data))
|
||||||
(l/derive refs/workspace-data)))
|
|
||||||
|
|
||||||
(mf/defc grid-options
|
(mf/defc grid-options
|
||||||
{:wrap [mf/memo]}
|
{:wrap [mf/memo]}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(ns uxbox.main.ui.workspace.sidebar.sitemap
|
(ns uxbox.main.ui.workspace.sidebar.sitemap
|
||||||
(:require
|
(:require
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[lentes.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.alpha :as mf]
|
[rumext.alpha :as mf]
|
||||||
[uxbox.builtins.icons :as i]
|
[uxbox.builtins.icons :as i]
|
||||||
[uxbox.main.data.workspace :as dw]
|
[uxbox.main.data.workspace :as dw]
|
||||||
|
@ -92,8 +92,7 @@
|
||||||
|
|
||||||
(defn- make-page-ref
|
(defn- make-page-ref
|
||||||
[page-id]
|
[page-id]
|
||||||
(-> (l/in [:pages page-id])
|
(l/derived #(get-in % [:pages page-id]) st/state))
|
||||||
(l/derive st/state)))
|
|
||||||
|
|
||||||
(mf/defc page-item-wrapper
|
(mf/defc page-item-wrapper
|
||||||
[{:keys [page-id index deletable? selected?] :as props}]
|
[{:keys [page-id index deletable? selected?] :as props}]
|
||||||
|
|
|
@ -102,23 +102,12 @@
|
||||||
;; --- Viewport
|
;; --- Viewport
|
||||||
|
|
||||||
(declare remote-user-cursors)
|
(declare remote-user-cursors)
|
||||||
(declare frames)
|
|
||||||
|
|
||||||
(mf/defc frames-wrapper
|
|
||||||
{::mf/wrap-props false}
|
|
||||||
[props]
|
|
||||||
(let [page (unchecked-get props "page")
|
|
||||||
page-id (:id page)
|
|
||||||
data-ref (-> (mf/deps page-id)
|
|
||||||
(mf/use-memo #(-> (l/in [:workspace-data page-id])
|
|
||||||
(l/derive st/state))))
|
|
||||||
data (mf/deref data-ref)]
|
|
||||||
[:& frames {:data data}]))
|
|
||||||
|
|
||||||
(mf/defc frames
|
(mf/defc frames
|
||||||
{:wrap [mf/memo]}
|
{:wrap [mf/memo]}
|
||||||
[{:keys [data] :as props}]
|
[]
|
||||||
(let [objects (:objects data)
|
(let [data (mf/deref refs/workspace-data)
|
||||||
|
objects (:objects data)
|
||||||
root (get objects uuid/zero)
|
root (get objects uuid/zero)
|
||||||
shapes (->> (:shapes root)
|
shapes (->> (:shapes root)
|
||||||
(map #(get objects %)))]
|
(map #(get objects %)))]
|
||||||
|
@ -304,7 +293,7 @@
|
||||||
:on-drop on-drop}
|
:on-drop on-drop}
|
||||||
[:g.zoom {:transform (str "scale(" zoom ", " zoom ")")}
|
[:g.zoom {:transform (str "scale(" zoom ", " zoom ")")}
|
||||||
;; [:& perf/profiler {:label "viewport-frames"}
|
;; [:& perf/profiler {:label "viewport-frames"}
|
||||||
[:& frames-wrapper {:page page}]
|
[:& frames]
|
||||||
|
|
||||||
(when (seq selected)
|
(when (seq selected)
|
||||||
[:& selection-handlers {:selected selected
|
[:& selection-handlers {:selected selected
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue