Skip to content

Commit

Permalink
modularize tabulator
Browse files Browse the repository at this point in the history
  • Loading branch information
Pietro Vertechi committed May 29, 2018
1 parent 1f0c91c commit 1b1d74a
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/optioninput.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,7 @@ function entry(::WidgetTheme, style, idx, label, sel; typ=typ, class="interact-w
)
end


function tabulator(options, values; value=1, display = "block", vskip = 1em)

buttons = togglebuttons(options; value=value)
key = observe(buttons, "index")
keyvals = 1:length(options)

function _mask(key, keyvals, values; display = "block")
s = string(gensym())
onjs(key, js"""
function (k) {
Expand All @@ -207,9 +201,19 @@ function tabulator(options, values; value=1, display = "block", vskip = 1em)

displays = [(keyval == key[]) ? "display:$display" : "display:none" for keyval in keyvals]

content = dom"div[id=$s]"(
dom"div[id=$s]"(
(dom"div[key=$keyval, style=$displaystyle;]"(value) for (displaystyle, keyval, value) in zip(displays, keyvals, values))...
)
end

function tabulator(options, values; value=1, display = "block", vskip = 1em)

buttons = togglebuttons(options; value=value)
key = observe(buttons, "index")
keyvals = 1:length(options)

content = _mask(key, keyvals, values; display=display)

ui = vbox(buttons, CSSUtil.vskip(vskip), content)
primary_obs!(ui, key)
ui
Expand Down

0 comments on commit 1b1d74a

Please sign in to comment.