mirror of
https://github.com/penpot/penpot.git
synced 2025-01-23 06:58:58 -05:00
Implement pagesbar toggle.
This commit is contained in:
parent
9e0edbc082
commit
ede2d4becd
5 changed files with 42 additions and 12 deletions
|
@ -124,9 +124,10 @@
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
rs/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(-apply-update [_ state]
|
||||||
(assoc state :workspace {:project projectid
|
(let [s {:project projectid
|
||||||
:page pageid
|
:page pageid
|
||||||
:toolboxes {}}))
|
:toolboxes {}}]
|
||||||
|
(update state :workspace merge s)))
|
||||||
|
|
||||||
IPrintWithWriter
|
IPrintWithWriter
|
||||||
(-pr-writer [mv writer _]
|
(-pr-writer [mv writer _]
|
||||||
|
|
25
frontend/uxbox/data/workspace.cljs
Normal file
25
frontend/uxbox/data/workspace.cljs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
(ns uxbox.data.workspace
|
||||||
|
(:require [uxbox.rstore :as rs]
|
||||||
|
[uxbox.router :as r]
|
||||||
|
[uxbox.state :as st]
|
||||||
|
[uxbox.schema :as sc]
|
||||||
|
[uxbox.time :as time]
|
||||||
|
[bouncer.validators :as v]))
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Events
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(defn toggle-pagesbar
|
||||||
|
[]
|
||||||
|
(reify
|
||||||
|
rs/UpdateEvent
|
||||||
|
(-apply-update [_ state]
|
||||||
|
(println "KAKAKA" (get-in state [:workspace :visible-pagebar]))
|
||||||
|
(update-in state [:workspace :visible-pagebar] (fnil not false)))
|
||||||
|
|
||||||
|
IPrintWithWriter
|
||||||
|
(-pr-writer [mv writer _]
|
||||||
|
(-write writer "#<event:u.s.p/toggle-pagebar>"))))
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
(rs/init {:user {:fullname "Cirilla"
|
(rs/init {:user {:fullname "Cirilla"
|
||||||
:avatar "http://lorempixel.com/50/50/"}
|
:avatar "http://lorempixel.com/50/50/"}
|
||||||
:dashboard {:section :dashboard/projects}
|
:dashboard {:section :dashboard/projects}
|
||||||
|
:workspace {}
|
||||||
:projects-by-id {}
|
:projects-by-id {}
|
||||||
:pages-by-id {}}))
|
:pages-by-id {}}))
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
[uxbox.rstore :as rs]
|
[uxbox.rstore :as rs]
|
||||||
[uxbox.state :as s]
|
[uxbox.state :as s]
|
||||||
[uxbox.data.projects :as dp]
|
[uxbox.data.projects :as dp]
|
||||||
|
[uxbox.data.workspace :as dw]
|
||||||
[uxbox.ui.icons.dashboard :as icons]
|
[uxbox.ui.icons.dashboard :as icons]
|
||||||
[uxbox.ui.icons :as i]
|
[uxbox.ui.icons :as i]
|
||||||
[uxbox.ui.lightbox :as lightbox]
|
[uxbox.ui.lightbox :as lightbox]
|
||||||
|
@ -29,6 +30,10 @@
|
||||||
(dp/project-pages % pid))) $
|
(dp/project-pages % pid))) $
|
||||||
(l/focus-atom $ s/state)))
|
(l/focus-atom $ s/state)))
|
||||||
|
|
||||||
|
(def ^:static workspace-state
|
||||||
|
(as-> (l/in [:workspace]) $
|
||||||
|
(l/focus-atom $ s/state)))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Header
|
;; Header
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -45,13 +50,14 @@
|
||||||
|
|
||||||
(defn header-render
|
(defn header-render
|
||||||
[own]
|
[own]
|
||||||
(let [page (rum/react page-state)]
|
(let [page (rum/react page-state)
|
||||||
|
toggle #(rs/emit! (dw/toggle-pagesbar))]
|
||||||
(html
|
(html
|
||||||
[:header#workspace-bar.workspace-bar
|
[:header#workspace-bar.workspace-bar
|
||||||
[:div.main-icon
|
[:div.main-icon
|
||||||
(nav/link (r/route-for :dashboard/projects) i/logo-icon)]
|
(nav/link (r/route-for :dashboard/projects) i/logo-icon)]
|
||||||
[:div.project-tree-btn
|
[:div.project-tree-btn
|
||||||
{:on-click (constantly nil)}
|
{:on-click toggle}
|
||||||
i/project-tree
|
i/project-tree
|
||||||
[:span (:name page)]]
|
[:span (:name page)]]
|
||||||
[:div.workspace-options
|
[:div.workspace-options
|
||||||
|
@ -145,7 +151,6 @@
|
||||||
|
|
||||||
(defn- project-sidebar-pageitem-render
|
(defn- project-sidebar-pageitem-render
|
||||||
[own parent page numpages]
|
[own parent page numpages]
|
||||||
(println "pageitem-render" (:id page))
|
|
||||||
(letfn [(on-edit [e]
|
(letfn [(on-edit [e]
|
||||||
(let [data {:edit true :form page}]
|
(let [data {:edit true :form page}]
|
||||||
(reset! parent data)))]
|
(reset! parent data)))]
|
||||||
|
@ -228,8 +233,7 @@
|
||||||
:type "text"
|
:type "text"
|
||||||
:value (get-in @parent [:form :name] "")
|
:value (get-in @parent [:form :name] "")
|
||||||
:on-change on-change
|
:on-change on-change
|
||||||
:on-key-up on-key-up
|
:on-key-up on-key-up}]
|
||||||
}]
|
|
||||||
[:button.btn-primary.btn-small
|
[:button.btn-primary.btn-small
|
||||||
{:disabled (str/empty? (str/trim (get-in @parent [:form :name] "")))
|
{:disabled (str/empty? (str/trim (get-in @parent [:form :name] "")))
|
||||||
:on-click on-save}
|
:on-click on-save}
|
||||||
|
@ -247,11 +251,11 @@
|
||||||
(defn project-sidebar-render
|
(defn project-sidebar-render
|
||||||
[own]
|
[own]
|
||||||
(let [local (:rum/local own)
|
(let [local (:rum/local own)
|
||||||
page (rum/react page-state)
|
workspace (rum/react workspace-state)
|
||||||
project (rum/react project-state)]
|
project (rum/react project-state)]
|
||||||
(html
|
(html
|
||||||
[:div#project-bar.project-bar
|
[:div#project-bar.project-bar
|
||||||
(when-not (:visible project true)
|
(when-not (:visible-pagebar workspace false)
|
||||||
{:class "toggle"})
|
{:class "toggle"})
|
||||||
(if (:edit @local)
|
(if (:edit @local)
|
||||||
(project-sidebar-form local)
|
(project-sidebar-form local)
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
:common
|
:common
|
||||||
{:dependencies [[org.clojure/clojure "1.7.0"]
|
{:dependencies [[org.clojure/clojure "1.7.0"]
|
||||||
[funcool/cats "1.2.0"]]}
|
[funcool/cats "1.2.1"]]}
|
||||||
|
|
||||||
;; Backend profile
|
;; Backend profile
|
||||||
|
|
||||||
|
@ -44,7 +44,6 @@
|
||||||
[bouncer "0.3.3"]
|
[bouncer "0.3.3"]
|
||||||
[funcool/promesa "0.6.0"]
|
[funcool/promesa "0.6.0"]
|
||||||
[funcool/beicon "0.3.0"]
|
[funcool/beicon "0.3.0"]
|
||||||
[funcool/cats "1.2.0"]
|
|
||||||
[cljsjs/moment "2.10.6-0"]
|
[cljsjs/moment "2.10.6-0"]
|
||||||
[figwheel-sidecar "0.5.0-2" :scope "test"]
|
[figwheel-sidecar "0.5.0-2" :scope "test"]
|
||||||
[bidi "1.21.0"]
|
[bidi "1.21.0"]
|
||||||
|
|
Loading…
Add table
Reference in a new issue