Zaid-Ajaj / Fable.React.Flatpickr

Fable binding for react-flatpickr that is ready to use within Elmish applications
https://zaid-ajaj.github.io/Fable.React.Flatpickr/
MIT License
14 stars 6 forks source link
fable flatpak react

Fable.React.Flatpickr Build Status Build status Nuget

A complete binding for react-flatpickr that is ready to use within Elmish applications

Installation

Usage

Live Demo with examples

type State = { SelectedTime : DateTime }

type Msg = UpdateSelectedTime of DateTime 

let init() = { SelectedTime = DateTime.Now }, Cmd.none

let update msg state = 
    match msg with 
    | UpdateSelectedTime time ->
        let nextState = { state with SelectedTime = time }
        nextState, Cmd.none

let render state dispatch = 
    Flatpickr.flatpickr 
        [ Flatpickr.Value state.SelectedTime 
          Flatpickr.OnChange (UpdateSelectedTime >> dispatch)
          Flatpickr.ClassName "input" ]

// Somewhere before you app starts
// you must import the CSS theme

importAll "flatpickr/dist/themes/material_green.css"

// or any of the other themes in the dist directory of flatpickr