mirror of
https://github.com/penpot/penpot.git
synced 2025-06-07 13:51:37 +02:00
Additional work on colors page.
This commit is contained in:
parent
5d7379ec32
commit
5fb93ad5fd
5 changed files with 66 additions and 130 deletions
|
@ -21,14 +21,30 @@
|
|||
;; Events
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn merge-if-not-exists
|
||||
[map & maps]
|
||||
(let [result (transient map)]
|
||||
(loop [maps maps]
|
||||
(if-let [nextval (first maps)]
|
||||
(do
|
||||
(run! (fn [[key value]]
|
||||
(when-not (contains? result key)
|
||||
(assoc! result key value)))
|
||||
nextval)
|
||||
(recur (rest maps)))
|
||||
(persistent! result)))))
|
||||
|
||||
(defn initialize
|
||||
[section]
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(assoc state :dashboard {:section section
|
||||
:collection-type :builtin
|
||||
:collection-id nil}))
|
||||
(as-> state $
|
||||
(assoc-in $ [:dashboard :section] section)
|
||||
(update $ :dashboard merge-if-not-exists
|
||||
{:collection-type :builtin
|
||||
:collection-id 1})))
|
||||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.d.d/initialize>"))))
|
||||
|
@ -36,16 +52,21 @@
|
|||
(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)))
|
||||
(letfn [(select-first [state]
|
||||
(if (= type :builtin)
|
||||
(assoc-in state [:dashboard :collection-id] 1)
|
||||
(let [coll (sort-by :id (vals (:colors-by-id state)))]
|
||||
(assoc-in state [:dashboard :collection-id] (:id (first coll))))))]
|
||||
(reify
|
||||
rs/UpdateEvent
|
||||
(-apply-update [_ state]
|
||||
(as-> state $
|
||||
(assoc-in $ [:dashboard :collection-type] type)
|
||||
(select-first $)))
|
||||
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.d.d/set-collection-type>"))))
|
||||
IPrintWithWriter
|
||||
(-pr-writer [mv writer _]
|
||||
(-write writer "#<event:u.d.d/set-collection-type>")))))
|
||||
|
||||
(defn set-collection
|
||||
[id]
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
(defonce state (atom {}))
|
||||
|
||||
(defonce stream
|
||||
(rs/init {:user {:fullname "Cirilla"
|
||||
(rs/init {:user {:fullname "Cirilla Fiona"
|
||||
:avatar "http://lorempixel.com/50/50/"}
|
||||
:dashboard {}
|
||||
:workspace {}
|
||||
|
|
|
@ -1,36 +1,32 @@
|
|||
(ns uxbox.ui.dashboard.builtins)
|
||||
|
||||
(def ^:static +colors+
|
||||
(def ^:static +color-collections+
|
||||
[{:name "Generic 1"
|
||||
:id 1
|
||||
:colors
|
||||
[{:hex "00f9ff"}
|
||||
{:hex "009fff"}
|
||||
{:hex "0078ff"}
|
||||
{:hex "005eff"}
|
||||
{:hex "0900ff"}
|
||||
{:hex "7502f1"}
|
||||
{:hex "ffe705"}
|
||||
{:hex "00ffab"}
|
||||
{:hex "f52105"}
|
||||
{:hex "7502f1"}
|
||||
{:hex "ffe705"}
|
||||
{:hex "00ffab"}
|
||||
{:hex "f52105"}]}
|
||||
:colors #{:00f9ff
|
||||
:009fff
|
||||
:0078ff
|
||||
:005eff
|
||||
:0900ff
|
||||
:7502f1
|
||||
:ffe705
|
||||
:00ffab
|
||||
:f52105
|
||||
}}
|
||||
{:name "Generic 2"
|
||||
:id 2
|
||||
:colors
|
||||
[{:hex "00f9ff"}
|
||||
{:hex "009fff"}
|
||||
{:hex "0078ff"}
|
||||
{:hex "005eff"}
|
||||
{:hex "0900ff"}
|
||||
{:hex "7502f1"}
|
||||
{:hex "ffe705"}
|
||||
{:hex "00ffab"}
|
||||
{:hex "f52105"}
|
||||
{:hex "7502f1"}
|
||||
{:hex "ffe705"}
|
||||
{:hex "00ffab"}
|
||||
{:hex "f52105"}]}])
|
||||
:colors #{:00f9ff
|
||||
:009fff
|
||||
:0078ff
|
||||
:005eff
|
||||
:0900ff
|
||||
:7502f1
|
||||
:ffe705
|
||||
:00ffab
|
||||
:f52105
|
||||
}}])
|
||||
|
||||
(def ^:static +color-collections-by-id+
|
||||
(let [data (transient {})]
|
||||
(run! #(assoc! data (:id %) %) +color-collections+)
|
||||
(persistent! data)))
|
||||
|
|
|
@ -77,14 +77,16 @@
|
|||
builtin? (= (:collection-type dashboard) :builtin)
|
||||
collections (if own?
|
||||
(sort-by :id (vals colors))
|
||||
builtins/+colors+)]
|
||||
builtins/+color-collections+)]
|
||||
(html
|
||||
[:div.library-bar
|
||||
[:div.library-bar-inside
|
||||
[:ul.library-tabs
|
||||
[:li (when builtin? {:class-name "current"})
|
||||
[:li {:class-name (when builtin? "current")
|
||||
:on-click #(rs/emit! (dd/set-collection-type :builtin))}
|
||||
"STANDARD"]
|
||||
[:li (when own? {:class-name "current"})
|
||||
[:li {:class-name (when own? "current")
|
||||
:on-click #(rs/emit! (dd/set-collection-type :own))}
|
||||
"YOUR LIBRARIES"]]
|
||||
[:ul.library-elements
|
||||
;; (when own?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue