mirror of
https://github.com/penpot/penpot.git
synced 2025-01-07 15:39:42 -05:00
Add draw toolbox rendering on workarea.
This commit is contained in:
parent
2742db8dfd
commit
5fddf7ca4d
5 changed files with 108 additions and 39 deletions
|
@ -27,7 +27,7 @@
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
rs/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(-apply-update [_ state]
|
||||||
(let [key (keyword (str (name toolname) "-enabled"))
|
(let [key (keyword (str (name toolname) "-toolbox-enabled"))
|
||||||
val (get-in state [:workspace key] false)
|
val (get-in state [:workspace key] false)
|
||||||
state (assoc-in state [:workspace key] (not val))]
|
state (assoc-in state [:workspace key] (not val))]
|
||||||
(if val
|
(if val
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
[uxbox.ui.workspace.pagesmngr :refer (pagesmngr)]
|
[uxbox.ui.workspace.pagesmngr :refer (pagesmngr)]
|
||||||
[uxbox.ui.workspace.header :refer (header)]
|
[uxbox.ui.workspace.header :refer (header)]
|
||||||
[uxbox.ui.workspace.rules :refer (h-rule v-rule)]
|
[uxbox.ui.workspace.rules :refer (h-rule v-rule)]
|
||||||
[uxbox.ui.workspace.workarea :refer (workarea)]))
|
[uxbox.ui.workspace.workarea :refer (workarea aside)]))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Workspace
|
;; Workspace
|
||||||
|
@ -20,27 +20,29 @@
|
||||||
|
|
||||||
(defn workspace-render
|
(defn workspace-render
|
||||||
[own projectid]
|
[own projectid]
|
||||||
(html
|
(let [workspace (rum/react wb/workspace-state )]
|
||||||
[:div
|
(html
|
||||||
(header)
|
[:div
|
||||||
[:main.main-content
|
(header)
|
||||||
[:section.workspace-content
|
[:main.main-content
|
||||||
;; Lateral Menu (left side)
|
[:section.workspace-content
|
||||||
(lateralmenu)
|
;; Lateral Menu (left side)
|
||||||
|
(lateralmenu)
|
||||||
|
|
||||||
;; Pages management lightbox
|
;; Pages management lightbox
|
||||||
(pagesmngr)
|
(pagesmngr)
|
||||||
|
|
||||||
;; Rules
|
;; Rules
|
||||||
(h-rule)
|
(h-rule)
|
||||||
(v-rule)
|
(v-rule)
|
||||||
|
|
||||||
;; Canvas
|
;; Canvas
|
||||||
(workarea)
|
(workarea)]
|
||||||
|
|
||||||
|
;; Aside
|
||||||
|
(when-not (empty? (:toolboxes workspace))
|
||||||
|
(aside))]])))
|
||||||
|
|
||||||
;; Aside
|
|
||||||
;; (wa/aside)
|
|
||||||
]]]))
|
|
||||||
|
|
||||||
(defn workspace-will-mount
|
(defn workspace-will-mount
|
||||||
[own]
|
[own]
|
||||||
|
|
|
@ -27,17 +27,17 @@
|
||||||
[:ul.main-tools
|
[:ul.main-tools
|
||||||
[:li.tooltip
|
[:li.tooltip
|
||||||
{:alt "Shapes (Ctrl + Shift + F)"
|
{:alt "Shapes (Ctrl + Shift + F)"
|
||||||
:class (when (:tools-enabled workspace false) "current")
|
:class (when (:draw-toolbox-enabled workspace false) "current")
|
||||||
:on-click (partial toggle :tools)}
|
:on-click (partial toggle :draw)}
|
||||||
i/shapes]
|
i/shapes]
|
||||||
[:li.tooltip
|
[:li.tooltip
|
||||||
{:alt "Icons (Ctrl + Shift + I)"
|
{:alt "Icons (Ctrl + Shift + I)"
|
||||||
:class (when (:icons-enabled workspace false) "current")
|
:class (when (:icons-toolbox-enabled workspace false) "current")
|
||||||
:on-click (partial toggle :icons)}
|
:on-click (partial toggle :icons)}
|
||||||
i/icon-set]
|
i/icon-set]
|
||||||
[:li.tooltip
|
[:li.tooltip
|
||||||
{:alt "Elements (Ctrl + Shift + L)"
|
{:alt "Elements (Ctrl + Shift + L)"
|
||||||
:class (when (:layers-enabled workspace false) "current")
|
:class (when (:layers-toolbox-enabled workspace false) "current")
|
||||||
:on-click (partial toggle :layers)}
|
:on-click (partial toggle :layers)}
|
||||||
i/layers]
|
i/layers]
|
||||||
[:li.tooltip
|
[:li.tooltip
|
||||||
|
|
69
frontend/uxbox/ui/workspace/toolboxes.cljs
Normal file
69
frontend/uxbox/ui/workspace/toolboxes.cljs
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
(ns uxbox.ui.workspace.toolboxes
|
||||||
|
(: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]
|
||||||
|
[uxbox.ui.workspace.base :as wb]
|
||||||
|
[uxbox.ui.icons :as i]
|
||||||
|
[uxbox.ui.mixins :as mx]
|
||||||
|
[uxbox.ui.util :as util]))
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Draw Tools
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(def ^:staric draw-tools
|
||||||
|
{:rect
|
||||||
|
{:icon i/box
|
||||||
|
:help "Box (Ctrl + B)"
|
||||||
|
:priority 10}
|
||||||
|
:circle
|
||||||
|
{:icon i/circle
|
||||||
|
:help "Circle (Ctrl + E)"
|
||||||
|
:priority 20}
|
||||||
|
:line
|
||||||
|
{:icon i/line
|
||||||
|
:help "Line (Ctrl + L)"
|
||||||
|
:priority 30}})
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Draw Tool Box
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(defn draw-toolbox-render
|
||||||
|
[open-toolboxes]
|
||||||
|
(let [workspace (rum/react wb/workspace-state)
|
||||||
|
close #(rs/emit! (dw/toggle-toolbox :draw))
|
||||||
|
tools (->> (into [] draw-tools)
|
||||||
|
(sort-by (comp :priority second)))]
|
||||||
|
(html
|
||||||
|
[:div#form-tools.tool-window
|
||||||
|
[:div.tool-window-bar
|
||||||
|
[:div.tool-window-icon i/window]
|
||||||
|
[:span "Tools"]
|
||||||
|
[:div.tool-window-close {:on-click close} i/close]]
|
||||||
|
[:div.tool-window-content
|
||||||
|
(for [[key props] tools]
|
||||||
|
[:div.tool-btn.tooltip.tooltip-hover
|
||||||
|
{:alt (:help props)
|
||||||
|
:key (name key)
|
||||||
|
:on-click (constantly nil)}
|
||||||
|
(:icon props)])]])))
|
||||||
|
|
||||||
|
;; #_(for [tool (t/sorted-tools (rum/react t/drawing-tools))]
|
||||||
|
;; [:div.tool-btn.tooltip.tooltip-hover
|
||||||
|
;; {:alt (:text tool)
|
||||||
|
;; :class (when (= (rum/react ws/selected-tool)
|
||||||
|
;; [(:key tool)])
|
||||||
|
;; "selected")
|
||||||
|
;; :key (:key tool)
|
||||||
|
;; :on-click #(ws/toggle-tool! [(:key tool)])}
|
||||||
|
;; (:icon tool)])]])))
|
||||||
|
|
||||||
|
(def ^:static draw-toolbox
|
||||||
|
(util/component
|
||||||
|
{:render draw-toolbox-render
|
||||||
|
:name "draw-toolbox"
|
||||||
|
:mixins [mx/static rum/reactive]}))
|
|
@ -4,11 +4,12 @@
|
||||||
[uxbox.router :as r]
|
[uxbox.router :as r]
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
|
[uxbox.ui.mixins :as mx]
|
||||||
|
[uxbox.ui.util :as util]
|
||||||
[uxbox.data.projects :as dp]
|
[uxbox.data.projects :as dp]
|
||||||
[uxbox.ui.workspace.base :as wb]
|
[uxbox.ui.workspace.base :as wb]
|
||||||
[uxbox.ui.workspace.rules :as wr]
|
[uxbox.ui.workspace.rules :as wr]
|
||||||
[uxbox.ui.mixins :as mx]
|
[uxbox.ui.workspace.toolboxes :refer (draw-toolbox)]))
|
||||||
[uxbox.ui.util :as util]))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Coordinates Debug
|
;; Coordinates Debug
|
||||||
|
@ -214,20 +215,17 @@
|
||||||
(defn aside-render
|
(defn aside-render
|
||||||
[own]
|
[own]
|
||||||
(let [workspace (rum/react wb/workspace-state)]
|
(let [workspace (rum/react wb/workspace-state)]
|
||||||
[:aside#settings-bar.settings-bar
|
(html
|
||||||
[:div.settings-bar-inside
|
[:aside#settings-bar.settings-bar
|
||||||
[:p "foo bar"]
|
[:div.settings-bar-inside
|
||||||
#_(when (:tools open-setting-boxes)
|
(when (:draw-toolbox-enabled workspace false)
|
||||||
(tools open-toolboxes))
|
(draw-toolbox))
|
||||||
|
#_(when (:icons open-setting-boxes)
|
||||||
#_(when (:icons open-setting-boxes)
|
(icon-sets open-toolboxes))
|
||||||
(icon-sets open-toolboxes))
|
#_(when (:components open-setting-boxes)
|
||||||
|
(components open-toolboxes components))
|
||||||
#_(when (:components open-setting-boxes)
|
#_(when (:layers open-setting-boxes)
|
||||||
(components open-toolboxes components))
|
(layers conn open-toolboxes page shapes))]])))
|
||||||
|
|
||||||
#_(when (:layers open-setting-boxes)
|
|
||||||
(layers conn open-toolboxes page shapes))]]))
|
|
||||||
|
|
||||||
(def aside
|
(def aside
|
||||||
(util/component
|
(util/component
|
||||||
|
|
Loading…
Reference in a new issue