Toggling data structures with arrows only, not body

This commit is contained in:
chris (daiyi) 2017-09-20 10:46:10 +02:00 committed by Daniel Compton
parent 49095dcfe3
commit 910483dd53
3 changed files with 21 additions and 14 deletions

View File

@ -456,13 +456,9 @@
color: #8f8f8f;
content: "}";
}
#--re-frame-trace-- .re-frame-trace--object:before {
#--re-frame-trace-- .re-frame-trace--object .toggle {
color: #8f8f8f;
content: "▶ ";
}
#--re-frame-trace-- .re-frame-trace--object.expanded:before {
color: #8f8f8f;
content: "▼ ";
cursor: pointer;
}
#--re-frame-trace-- .re-frame-trace--object > span {
vertical-align: text-top;

View File

@ -575,14 +575,23 @@
}
}
.re-frame-trace--object {
&:before {
.toggle {
color: @text-color-muted;
content: "▶ ";
cursor: pointer;
}
&.expanded {
&>span {
vertical-align: text-top;
}
}
.data-structure-editable {
&.string {
&:before {
color: @text-color-muted;
content: "▼ ";
content: "\"";
}
&:after {
color: @text-color-muted;
content: "\"";
}
}

View File

@ -22,13 +22,15 @@
(defn data-structure
[jsonml]
(let [expand? (r/atom true)]
(let [expanded? (r/atom true)]
(fn [jsonml]
[:span
{:class (str/join " " ["re-frame-trace--object"
(when @expand? "expanded")])
:on-click #(swap! expand? not)}
(jsonml->hiccup (if @expand?
(when @expanded? "expanded")])}
[:span {:class "toggle"
:on-click #(swap! expanded? not)}
(if @expanded? "▼" "▶")]
(jsonml->hiccup (if @expanded?
(cljs-devtools/body-api-call
(.-object (get jsonml 1))
(.-config (get jsonml 1)))