0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-18 02:32:13 -05:00

Move dashboard builtints to library.

This commit is contained in:
Andrey Antukh 2015-12-25 15:33:58 +02:00
parent d8e7087af6
commit 11bb081c7c
3 changed files with 18 additions and 15 deletions

View file

@ -0,0 +1,9 @@
(ns uxbox.library
(:require [uxbox.library.colors :as colors]
[uxbox.util.data :refer (index-by-id)]))
(def ^:static +color-collections+
colors/+collections+)
(def ^:static +color-collections-by-id+
(index-by-id colors/+collections+))

View file

@ -1,6 +1,6 @@
(ns uxbox.ui.dashboard.builtins)
(ns uxbox.library.colors)
(def ^:static +color-collections+
(def ^:static +collections+
[{:name "Generic 1"
:id 1
:builtin true
@ -12,8 +12,8 @@
"#7502f1"
"#ffe705"
"#00ffab"
"#f52105"
}}
"#f52105"}}
{:name "Generic 2"
:id 2
:builtin true
@ -34,10 +34,4 @@
"#3fe720"
"#30ff20"
"#352120"
"#352140"
}}])
(def ^:static +color-collections-by-id+
(let [data (transient {})]
(run! #(assoc! data (:id %) %) +color-collections+)
(persistent! data)))
"#352140"}}])

View file

@ -6,11 +6,11 @@
[uxbox.state :as st]
[uxbox.rstore :as rs]
[uxbox.schema :as sc]
[uxbox.library :as library]
[uxbox.data.dashboard :as dd]
[uxbox.util.lens :as ul]
[uxbox.ui.icons :as i]
[uxbox.ui.form :as form]
[uxbox.ui.dashboard.builtins :as builtins]
[uxbox.ui.lightbox :as lightbox]
[uxbox.ui.colorpicker :refer (colorpicker)]
[uxbox.ui.dom :as dom]
@ -40,7 +40,7 @@
(defn- get-collection
[type id]
(case type
:builtin (get builtins/+color-collections-by-id+ id)
:builtin (get library/+color-collections-by-id+ id)
:own (get-in @st/state [:colors-by-id id])))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -110,7 +110,7 @@
builtin? (= (:collection-type dashboard) :builtin)
collections (if own?
(sort-by :id (vals colors))
builtins/+color-collections+)]
library/+color-collections+)]
(html
[:div.library-bar
[:div.library-bar-inside
@ -152,7 +152,7 @@
coll-id (:collection-id dashboard)
own? (= coll-type :own)
coll (case coll-type
:builtin (get builtins/+color-collections-by-id+ coll-id)
:builtin (get library/+color-collections-by-id+ coll-id)
:own (rum/react collection-state))
edit-cb #(lightbox/open! :color-form {:coll coll :color %})
remove-cb #(rs/emit! (dd/remove-color {:id (:id coll) :color %}))]