JuliaPluto / PlutoUI.jl

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

Add DateRangePicker #256

Open swt30 opened 1 year ago

swt30 commented 1 year ago

This is a first pass at a DateRangePicker as described in #255.

image

To see it in action, open the src/DateRangePicker.jl notebook.

I wanted something that behaved like this:

It's not fully working yet. I have used transformed_value, as in ScrubbableMatrix, to build a DateRangePicker out of two DatePickers. But this causes problems when the range isn't valid (e.g. if no default range is set). There are some assertions for validation in the inner function of transformed_value, but transformed_value turns these into its own error tuple, which bubbles up to the bound value itself. So a default DateRangePicker() returns an error tuple instead of nothing, which doesn't feel right to me:

image

The error logging above also doesn't disappear when a correct range is entered. I'll experiment; maybe I need to log an @error and return nothing instead of using @assert in the inner function.

Addresses #255

github-actions[bot] commented 1 year ago

Try this Pull Request!

Open Julia and type:

  julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/swt30/PlutoUI.jl", rev="date-range-picker")
julia> using PlutoUI

Or run this code in your browser: Run with binder