JuliaGizmos / InteractBase.jl

Build interactive HTML5 widgets in Julia
Other
27 stars 23 forks source link

Have `filepicker` accept default observables #36

Closed ranjanan closed 6 years ago

ranjanan commented 6 years ago

Firstly, thank you for such a useful package! This package greatly simplifies writing Web-based UIs . πŸ˜„

I was hoping to make a simple contribution. This PR modifies filepicker to take in a default observable, much like checkbox, for example.

piever commented 6 years ago

Thanks! This was something I had forgotten to do. I left a few comments, in particular:

piever commented 6 years ago

I actually like the idea of having the observable start at nothing and in the @manipulate the @manipulate for x = nothing could create a file selection widget. Say:

@manipulate for x = nothing
  x != nothing && histogram(column(loadtable(x), 1))
end
codecov-io commented 6 years ago

Codecov Report

Merging #36 into master will decrease coverage by 0.85%. The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #36      +/-   ##
==========================================
- Coverage   68.11%   67.25%   -0.86%     
==========================================
  Files          13       13              
  Lines         276      281       +5     
==========================================
+ Hits          188      189       +1     
- Misses         88       92       +4
Impacted Files Coverage Ξ”
src/input.jl 86.32% <33.33%> (-2.97%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data Powered by Codecov. Last update e77483e...c0e127d. Read the comment docs.

ranjanan commented 6 years ago

The tests pass and it works for all sensible inputs:

julia> using InteractBase

julia> filepicker(value = "hello")
(div { className="interact-widget" }
    (input { attributes=Dict{Any,Any}(Pair{Any,Any}("class", "interact-widget "),Pair{Any,Any}("type", "file"),Pair{Any,Any}("v-on:change", "onFileChange"),Pair{Any,Any}("ref", "data")) }))

julia> filepicker()
(div { className="interact-widget" }
    (input { attributes=Dict{Any,Any}(Pair{Any,Any}("class", "interact-widget "),Pair{Any,Any}("type", "file"),Pair{Any,Any}("v-on:change", "onFileChange"),Pair{Any,Any}("ref", "data")) }))

julia> using Observables

julia> filepicker(value = Observable{Any}("hello"))
(div { className="interact-widget" }
    (input { attributes=Dict{Any,Any}(Pair{Any,Any}("class", "interact-widget "),Pair{Any,Any}("type", "file"),Pair{Any,Any}("v-on:change", "onFileChange"),Pair{Any,Any}("ref", "data")) }))
piever commented 6 years ago

Nice job!