From 8880287acbed357383545683e99a09a2542bbe5a Mon Sep 17 00:00:00 2001 From: Javi Velasco Date: Fri, 4 Sep 2015 22:09:16 +0200 Subject: [PATCH] Add documentation and fixes for date picker --- components/calendar/index.cjsx | 3 +-- components/date_picker/date_picker.md | 25 +++++++++++++++++++++++++ components/date_picker/index.cjsx | 10 ++++++++-- spec/components/date_picker.cjsx | 7 ------- spec/components/pickers.cjsx | 9 +++++---- 5 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 components/date_picker/date_picker.md delete mode 100644 spec/components/date_picker.cjsx diff --git a/components/calendar/index.cjsx b/components/calendar/index.cjsx index f39b897a..d2b06ce6 100644 --- a/components/calendar/index.cjsx +++ b/components/calendar/index.cjsx @@ -17,11 +17,10 @@ module.exports = React.createClass getDefaultProps: -> display : 'months' selectedDate : new Date() - viewDate : new Date() getInitialState: -> selectedDate : @props.selectedDate - viewDate : @props.viewDate + viewDate : @props.selectedDate # -- Lifecycle componentDidUpdate: (prevProps, prevState) -> diff --git a/components/date_picker/date_picker.md b/components/date_picker/date_picker.md new file mode 100644 index 00000000..29b8abfc --- /dev/null +++ b/components/date_picker/date_picker.md @@ -0,0 +1,25 @@ +# DatePicker + +```javascript +var DatePicker = require('react-toolbox/components/date_picker'); + +var date = new Date(1995,11,17); + +// Initialized date picker + +``` + +## Properties + +| Name | Type | Default | Description| +| ------------- |:-------:|:--------------- |:---------- | +| **value** | Date | `new Date()` | Date object with currrent date by default | + +## Methods + +#### getValue +Returns the value of the picker. + +``` +input_instance.getValue(); +``` diff --git a/components/date_picker/index.cjsx b/components/date_picker/index.cjsx index 214a07b2..6277506a 100644 --- a/components/date_picker/index.cjsx +++ b/components/date_picker/index.cjsx @@ -1,6 +1,5 @@ css = require './style' dateUtils = require '../date_utils' - Input = require '../input' CalendarDialog = require './dialog' @@ -32,6 +31,10 @@ module.exports = React.createClass year = date.getFullYear() "#{day} #{month} #{year}" + # -- Public methods + getValue: -> + @state.value + # -- Render render: ->
@@ -42,5 +45,8 @@ module.exports = React.createClass onClick={@openCalendarDialog} placeholder="Pick up date" value={@formatDate(@state.value) if @state.value} /> - +
diff --git a/spec/components/date_picker.cjsx b/spec/components/date_picker.cjsx deleted file mode 100644 index 4836577d..00000000 --- a/spec/components/date_picker.cjsx +++ /dev/null @@ -1,7 +0,0 @@ -DatePicker = require '../../components/date_picker' - -module.exports = React.createClass - displayName: 'DatePickerTest' - - render: -> - diff --git a/spec/components/pickers.cjsx b/spec/components/pickers.cjsx index 00525699..cf8724c6 100644 --- a/spec/components/pickers.cjsx +++ b/spec/components/pickers.cjsx @@ -5,12 +5,13 @@ module.exports = React.createClass displayName: 'PickersTest' render: -> - time = new Date(1995,11,17); - time.setHours(17) - time.setMinutes(28) + datetime = new Date(1995,11,17) + datetime.setHours(17) + datetime.setMinutes(28)
- + +