0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 15:09:10 -05:00
penpot/frontend/uxbox/ui/workspace.cljs

98 lines
2.9 KiB
Text
Raw Normal View History

2015-12-14 20:31:21 +02:00
(ns uxbox.ui.workspace
(:require [sablono.core :as html :refer-macros [html]]
[rum.core :as rum]
[uxbox.router :as r]
[uxbox.rstore :as rs]
[uxbox.state :as s]
[uxbox.data.workspace :as dw]
2015-12-17 16:43:58 +02:00
[uxbox.ui.util :as util]
[uxbox.ui.mixins :as mx]
2015-12-17 12:51:36 +02:00
[uxbox.ui.workspace.base :as wb]
[uxbox.ui.workspace.shortcuts :as wshortcuts]
2015-12-18 17:42:42 +02:00
[uxbox.ui.workspace.lateralmenu :refer (lateralmenu)]
[uxbox.ui.workspace.pagesmngr :refer (pagesmngr)]
[uxbox.ui.workspace.header :refer (header)]
[uxbox.ui.workspace.rules :refer (h-rule v-rule)]
2015-12-28 15:20:16 +02:00
[uxbox.ui.workspace.sidebar :refer (aside)]
[uxbox.ui.workspace.workarea :refer (viewport)]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Coordinates Debug
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn- coordenates-render
[own]
(let [[x y] (rum/react wb/mouse-position)]
(html
[:div {:style {:position "absolute" :left "80px" :top "20px"}}
[:table
[:tbody
[:tr [:td "X:"] [:td x]]
[:tr [:td "Y:"] [:td y]]]]])))
(def coordinates
(util/component
{:render coordenates-render
:name "coordenates"
:mixins [rum/reactive]}))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Workspace
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2015-12-14 20:31:21 +02:00
2015-12-22 20:25:38 +02:00
(defn- workspace-render
2015-12-14 20:31:21 +02:00
[own projectid]
2015-12-28 15:20:16 +02:00
(let [workspace (rum/react wb/workspace-state)
no-toolbars? (empty? (:toolboxes workspace))]
(html
[:div
(header)
[:main.main-content
[:section.workspace-content
;; Lateral Menu (left side)
(lateralmenu)
;; Pages management lightbox
(pagesmngr)
;; Rules
(h-rule)
(v-rule)
;; Canvas
2015-12-28 15:20:16 +02:00
[:section.workspace-canvas {:class (when no-toolbars? "no-tool-bar")
:on-scroll (constantly nil)}
#_(when (:selected page)
(element-options conn
page-cursor
project-cursor
zoom-cursor
shapes-cursor))
(coordinates)
(viewport)]]
;; Aside
2015-12-28 15:20:16 +02:00
(when-not no-toolbars?
(aside))]])))
2015-12-22 20:25:38 +02:00
(defn- workspace-will-mount
[own]
(let [[projectid pageid] (:rum/props own)]
(rs/emit! (dw/initialize projectid pageid))
own))
2015-12-14 20:31:21 +02:00
2015-12-22 20:25:38 +02:00
(defn- workspace-transfer-state
2015-12-16 00:40:14 +02:00
[old-state state]
(let [[projectid pageid] (:rum/props state)]
(rs/emit! (dw/initialize projectid pageid))
state))
2015-12-16 00:40:14 +02:00
2015-12-14 20:31:21 +02:00
(def ^:static workspace
(util/component
{:render workspace-render
:will-mount workspace-will-mount
2015-12-16 00:40:14 +02:00
:transfer-state workspace-transfer-state
2015-12-14 20:31:21 +02:00
:name "workspace"
:mixins [mx/static rum/reactive wshortcuts/mixin]}))
2015-12-14 20:31:21 +02:00