mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 17:46:39 +02:00
Minor code reorganization and wip of colors page.
This commit is contained in:
parent
a93c6bfa45
commit
9c2c7f40ba
13 changed files with 221 additions and 56 deletions
60
frontend/uxbox/data/dashboard.cljs
Normal file
60
frontend/uxbox/data/dashboard.cljs
Normal file
|
@ -0,0 +1,60 @@
|
|||
(ns uxbox.data.dashboard
|
||||
(: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]))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Helpers
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn assoc-page
|
||||
"A reduce function for assoc the page
|
||||
to the state map."
|
||||
[state page]
|
||||
(let [uuid (:id page)]
|
||||
(update-in state [:pages-by-id] assoc uuid page)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Events
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn initialize
|
||||
[section]
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(assoc state :dashboard {:section section
|
||||
:collection-type :builtin
|
||||
:collection-id nil}))
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.d.d/initialize>"))))
|
||||
|
||||
(defn set-collection-type
|
||||
[type]
|
||||
{:pre [(contains? #{:builtin :own} type)]}
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(as-> state $
|
||||
(assoc-in $ [:dashboard :collection-type] type)
|
||||
(assoc-in $ [:dashboard :collection-id] nil)))
|
||||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.d.d/set-collection-type>"))))
|
||||
|
||||
(defn set-collection
|
||||
[id]
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(println "set-collection" id)
|
||||
(assoc-in state [:dashboard :collection-id] id))
|
||||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.d.d/set-collection>"))))
|
Loading…
Add table
Add a link
Reference in a new issue