mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 23:18:48 -05:00
Convert workspace component to use new defc macro.
This commit is contained in:
parent
30ae7a4deb
commit
09b3017874
1 changed files with 41 additions and 48 deletions
|
@ -2,13 +2,11 @@
|
|||
;; 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 <niwi@niwi.nz>
|
||||
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
||||
;; Copyright (c) 2015-2017 Andrey Antukh <niwi@niwi.nz>
|
||||
;; Copyright (c) 2015-2017 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
||||
|
||||
(ns uxbox.main.ui.workspace
|
||||
(:require [sablono.core :as html :refer-macros [html]]
|
||||
[rum.core :as rum]
|
||||
[beicon.core :as rx]
|
||||
(:require [beicon.core :as rx]
|
||||
[uxbox.main.constants :as c]
|
||||
[potok.core :as ptk]
|
||||
[uxbox.store :as st]
|
||||
|
@ -16,10 +14,6 @@
|
|||
[uxbox.main.data.pages :as udp]
|
||||
[uxbox.main.data.history :as udh]
|
||||
[uxbox.main.data.undo :as udu]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.geom.point :as gpt]
|
||||
[uxbox.util.data :refer (classnames)]
|
||||
[uxbox.util.mixins :as mx :include-macros true]
|
||||
[uxbox.main.ui.messages :as uum]
|
||||
[uxbox.main.ui.confirm]
|
||||
[uxbox.main.ui.workspace.images]
|
||||
|
@ -33,7 +27,11 @@
|
|||
[uxbox.main.ui.workspace.sidebar.history :refer (history-dialog)]
|
||||
[uxbox.main.ui.workspace.sidebar :refer (left-sidebar right-sidebar)]
|
||||
[uxbox.main.ui.workspace.colorpalette :refer (colorpalette)]
|
||||
[uxbox.main.ui.workspace.canvas :refer (viewport)]))
|
||||
[uxbox.main.ui.workspace.canvas :refer (viewport)]
|
||||
[uxbox.util.dom :as dom]
|
||||
[uxbox.util.geom.point :as gpt]
|
||||
[uxbox.util.data :refer (classnames)]
|
||||
[uxbox.util.mixins :as mx :include-macros true]))
|
||||
|
||||
;; --- Workspace
|
||||
|
||||
|
@ -99,7 +97,15 @@
|
|||
(st/emit! (dw/decrease-zoom)))
|
||||
(scroll/scroll-to-point dom mouse-point scroll-position))))
|
||||
|
||||
(defn- workspace-render
|
||||
(mx/defcs workspace
|
||||
{:did-remount workspace-did-remount
|
||||
:will-mount workspace-will-mount
|
||||
:will-unmount workspace-will-unmount
|
||||
:did-mount workspace-did-mount
|
||||
:mixins [mx/static
|
||||
mx/reactive
|
||||
shortcuts-mixin
|
||||
(mx/local)]}
|
||||
[own]
|
||||
(let [{:keys [flags zoom page] :as workspace} (mx/react wb/workspace-ref)
|
||||
left-sidebar? (not (empty? (keep flags [:layers :sitemap
|
||||
|
@ -110,47 +116,34 @@
|
|||
classes (classnames
|
||||
:no-tool-bar-right (not right-sidebar?)
|
||||
:no-tool-bar-left (not left-sidebar?)
|
||||
:scrolling (:scrolling @local false))]
|
||||
(html
|
||||
[:div
|
||||
(header)
|
||||
(colorpalette)
|
||||
(uum/messages)
|
||||
:scrolling (:viewport-positionig workspace))]
|
||||
[:div
|
||||
(header)
|
||||
(colorpalette)
|
||||
(uum/messages)
|
||||
|
||||
[:main.main-content
|
||||
[:main.main-content
|
||||
|
||||
[:section.workspace-content
|
||||
{:class classes
|
||||
:on-scroll on-scroll
|
||||
:on-wheel (partial on-wheel own)}
|
||||
[:section.workspace-content
|
||||
{:class classes
|
||||
:on-scroll on-scroll
|
||||
:on-wheel (partial on-wheel own)}
|
||||
|
||||
|
||||
(history-dialog page)
|
||||
(history-dialog page)
|
||||
|
||||
;; Rules
|
||||
(horizontal-rule zoom)
|
||||
(vertical-rule zoom)
|
||||
;; Rules
|
||||
(horizontal-rule zoom)
|
||||
(vertical-rule zoom)
|
||||
|
||||
;; Canvas
|
||||
[:section.workspace-canvas
|
||||
{:ref "workspace-canvas"}
|
||||
(viewport)]]
|
||||
;; Canvas
|
||||
[:section.workspace-canvas
|
||||
{:id "workspace-canvas"
|
||||
:ref "workspace-canvas"}
|
||||
(viewport)]]
|
||||
|
||||
;; Aside
|
||||
(when left-sidebar?
|
||||
(left-sidebar))
|
||||
(when right-sidebar?
|
||||
(right-sidebar))]])))
|
||||
|
||||
(def workspace
|
||||
(mx/component
|
||||
{:render workspace-render
|
||||
:did-remount workspace-did-remount
|
||||
:will-mount workspace-will-mount
|
||||
:will-unmount workspace-will-unmount
|
||||
:did-mount workspace-did-mount
|
||||
:name "workspace"
|
||||
:mixins [mx/static
|
||||
mx/reactive
|
||||
shortcuts-mixin
|
||||
(mx/local)]}))
|
||||
;; Aside
|
||||
(when left-sidebar?
|
||||
(left-sidebar))
|
||||
(when right-sidebar?
|
||||
(right-sidebar))]]))
|
||||
|
|
Loading…
Add table
Reference in a new issue