JuliaPluto / PlutoUI.jl

https://featured.plutojl.org/basic/plutoui.jl
The Unlicense
302 stars 55 forks source link

Enable unbounded intervals to NumberField and maintained default type #188

Closed ghaetinger closed 2 years ago

ghaetinger commented 2 years ago

~Number fields should have an "unbounded" option. I used Intervals.jl to make sure we can easily define a NumberField widget with no upper and/or lower limits.~

I also realized that there was no type-persistence between the NumberField's returning value and the default value.

~I am not sure whether this is expected, but, as Intervals.jl doesn't provide us with step, we need to keep track of the desired type as the step will always be 1. Thus, I added another step, which converts what we receive from the widget to the NumberField.default type.~

PS.: I think we could remove the numeric_type argument and just get it from default, but this would be very implicit.

EDIT I added a step field to the constructor, which is only accessed when creating an Interval based NumberField.

EDIT 2 I moved on from interval as it was consensus that string intervals weren't a good parameter. I created an unlisted package UnboundRanges.jl to allow the use of things like (1:10:unbounded) which goes from 1 to infinity with a step of 10.

Here is a preview 😄

image

github-actions[bot] commented 2 years ago

Try this Pull Request!

Open Julia and type:

  julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/JuliaPluto/PlutoUI.jl", rev="new-numeric-field-parameters")
julia> using PlutoUI

Or run this code in your browser: Run with binder