项目作者: Zaid-Ajaj

项目描述 :
Fable binding for react-flatpickr that is ready to use within Elmish applications
高级语言: F#
项目地址: git://github.com/Zaid-Ajaj/Fable.React.Flatpickr.git
创建时间: 2018-04-11T07:30:01Z
项目社区:https://github.com/Zaid-Ajaj/Fable.React.Flatpickr

开源协议:MIT License

下载


Fable.React.Flatpickr Build Status Build status Nuget

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

Installation

  • Install this library from nuget
    1. paket add Fable.React.Flatpickr --project /path/to/Project.fsproj
  • Install the actual Flatpickr library from npm
    1. npm install flatpickr react-flatpickr --save
  • You will also need css module loaders for Webpack because we are going to import the styles directly from npm css-loader and style-loader, install them :
    1. npm install css-loader style-loader --save-dev
  • Now from your Webpack, use the loaders:
    1. {
    2. test: /\.(sa|c)ss$/,
    3. use: [
    4. "style-loader",
    5. "css-loader"
    6. ]
    7. }

Usage

Live Demo with examples

  1. type State = { SelectedTime : DateTime }
  2. type Msg = UpdateSelectedTime of DateTime
  3. let init() = { SelectedTime = DateTime.Now }, Cmd.none
  4. let update msg state =
  5. match msg with
  6. | UpdateSelectedTime time ->
  7. let nextState = { state with SelectedTime = time }
  8. nextState, Cmd.none
  9. let render state dispatch =
  10. Flatpickr.flatpickr
  11. [ Flatpickr.Value state.SelectedTime
  12. Flatpickr.OnChange (UpdateSelectedTime >> dispatch)
  13. Flatpickr.ClassName "input" ]
  14. // Somewhere before you app starts
  15. // you must import the CSS theme
  16. importAll "flatpickr/dist/themes/material_green.css"
  17. // or any of the other themes in the dist directory of flatpickr