aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorafc163 <afc163@gmail.com>2015-12-08 16:39:16 +0800
committerafc163 <afc163@gmail.com>2015-12-08 16:39:16 +0800
commitd360614938e1f73d1a564ca5c1d243e58ec6c187 (patch)
tree5b0e52b64eff01ccbed00b798cf054dbb4e1bbc9 /examples
parent1c9a59341f2ad8f90aba0f9737d0dce9fce7ce5d (diff)
downloadtime-picker-d360614938e1f73d1a564ca5c1d243e58ec6c187.tar.gz
time-picker-d360614938e1f73d1a564ca5c1d243e58ec6c187.tar.zst
time-picker-d360614938e1f73d1a564ca5c1d243e58ec6c187.zip
Add demo
Diffstat (limited to 'examples')
-rw-r--r--examples/value-and-defaultValue.html1
-rw-r--r--examples/value-and-defaultValue.js46
2 files changed, 47 insertions, 0 deletions
diff --git a/examples/value-and-defaultValue.html b/examples/value-and-defaultValue.html
new file mode 100644
index 0000000..48cdce8
--- /dev/null
+++ b/examples/value-and-defaultValue.html
@@ -0,0 +1 @@
placeholder
diff --git a/examples/value-and-defaultValue.js b/examples/value-and-defaultValue.js
new file mode 100644
index 0000000..67771c0
--- /dev/null
+++ b/examples/value-and-defaultValue.js
@@ -0,0 +1,46 @@
1/* eslint no-console:0 */
2
3import 'rc-time-picker/assets/index.less';
4
5import React from 'react';
6import ReactDom from 'react-dom';
7
8import GregorianCalendar from 'gregorian-calendar';
9import DateTimeFormat from 'gregorian-calendar-format';
10import zhCn from 'gregorian-calendar/lib/locale/zh_CN';
11
12import TimePicker from 'rc-time-picker';
13import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN';
14
15const formatter = new DateTimeFormat('HH:mm:ss');
16
17const now = new GregorianCalendar(zhCn);
18now.setTime(Date.now());
19
20const App = React.createClass({
21 getInitialState() {
22 return {
23 value: now,
24 };
25 },
26 handleValueChange(value) {
27 console.log(value && formatter.format(value));
28 this.setState({ value });
29 },
30 render() {
31 return (
32 <div>
33 <TimePicker formatter={formatter} locale={TimePickerLocale}
34 defaultValue={now} />
35 <TimePicker formatter={formatter} locale={TimePickerLocale}
36 value={this.state.value}
37 onChange={this.handleValueChange}/>
38 </div>
39 );
40 }
41});
42
43ReactDom.render(
44 <App />,
45 document.getElementById('__react-content')
46);