Skip to content

Commit ea210a8

Browse files
committed
no more empty states, fixes #103
1 parent bc229f8 commit ea210a8

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

public/css/style.css

+3
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ input, textarea {
339339
list-style-type: none;
340340
}
341341

342+
#mosaic_libman .empty {
343+
margin: 1em 0;
344+
}
342345
/* editor */
343346
#mosaic_editor * {
344347
margin: 0;

src/main/nyancad/mosaic/libman.cljs

+26-20
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@
109109

110110
(defn database-selector []
111111
[:div.cellsel
112-
[categories [] (category-trie @modeldb)]])
112+
(if (seq @modeldb)
113+
[categories [] (category-trie @modeldb)]
114+
[:div.empty "There aren't any interfaces yet. Open a different workspace or click \"Add interface\" to get started."])])
113115

114116
(defn edit-url [cell mod]
115117
(let [mname (str cell "$" mod)]
@@ -130,21 +132,23 @@
130132
(let [cellname @selcell
131133
cell (get @db cellname)]
132134
[:div.schematics
133-
[cm/radiobuttons selmod
134-
(doall (for [[key mod] (:models cell)
135-
:when (or (= @selcat ["Everything"])
136-
(some (partial = (apply str (interpose "/" @selcat))) (:categories mod)))
137-
:let [schem? (= (get-in cell [:models key :type]) "schematic")
138-
icon (if schem? cm/schemmodel cm/codemodel)]]
139-
; inactive, active, key, title
140-
[[:span [icon] " " (get mod :name key)]
141-
[:span [icon] " " [cm/renamable (r/cursor db [cellname :models key :name])]]
142-
key key]))
143-
(fn [key]
144-
(when (= (get-in cell [:models key :type]) "schematic")
145-
#(js/window.open (edit-url (second (.split cellname ":")) (name key)), cellname)))
146-
(fn [key]
147-
#(schem-context-menu % db cellname key))]]))
135+
(if @selcell
136+
[cm/radiobuttons selmod
137+
(doall (for [[key mod] (:models cell)
138+
:when (or (= @selcat ["Everything"])
139+
(some (partial = (apply str (interpose "/" @selcat))) (:categories mod)))
140+
:let [schem? (= (get-in cell [:models key :type]) "schematic")
141+
icon (if schem? cm/schemmodel cm/codemodel)]]
142+
; inactive, active, key, title
143+
[[:span [icon] " " (get mod :name key)]
144+
[:span [icon] " " [cm/renamable (r/cursor db [cellname :models key :name])]]
145+
key key]))
146+
(fn [key]
147+
(when (= (get-in cell [:models key :type]) "schematic")
148+
#(js/window.open (edit-url (second (.split cellname ":")) (name key)), cellname)))
149+
(fn [key]
150+
#(schem-context-menu % db cellname key))]
151+
[:div.empty "There are no implementations to show. Select an interface to edit its schematics and SPICE models."])]))
148152

149153

150154
(defn db-properties []
@@ -207,7 +211,7 @@
207211
(defn cell-properties [db]
208212
(let [cell @selcell
209213
sc (r/cursor db [cell])]
210-
(when cell
214+
(if cell
211215
[:<>
212216
[:div.properties
213217
[background-selector sc]
@@ -217,7 +221,8 @@
217221
[:label {:for "symurl" :title "image url for this component"} "url"]
218222
[:input {:id "symurl" :type "text"
219223
:default-value (get-in @db [cell :sym])
220-
:on-blur #(swap! db assoc-in [cell :sym] (.. % -target -value))}]]])))
224+
:on-blur #(swap! db assoc-in [cell :sym] (.. % -target -value))}]]]
225+
[:div.empty "Select an interface to edit its properties."])))
221226

222227
(def dialect (r/atom "NgSpice"))
223228

@@ -256,12 +261,13 @@
256261
[:<>
257262
[:a {:href (edit-url (second (.split @selcell ":")) (name @selmod))
258263
:target @selcell} "Edit"]]))
259-
(when (and @selcell @selmod)
264+
(if (and @selcell @selmod)
260265
[:<>
261266
[:label {:for "categories" :title "Comma-seperated device categories"} "Categories"]
262267
[cm/dbfield :input {:id "categories"} mod
263268
#(apply str (interpose ", " (:categories %)))
264-
#(swap! %1 assoc :categories (clojure.string/split %2 #", " -1))]])]))
269+
#(swap! %1 assoc :categories (clojure.string/split %2 #", " -1))]]
270+
[:div.empty "Select a schematic or SPICE model to edit its properties."])]))
265271

266272
(defn cell-view []
267273
(let [add-cell #(prompt "Enter the name of the new interface"

0 commit comments

Comments
 (0)