diff options
author | MG12 <wuzhao.mail@gmail.com> | 2015-12-13 00:03:19 +0800 |
---|---|---|
committer | MG12 <wuzhao.mail@gmail.com> | 2015-12-13 00:03:19 +0800 |
commit | 0e62bf0b7bdc260e882fd185492939cbaed04d56 (patch) | |
tree | 84f678a775ead7577fdcac9089ca918b4febcf39 /examples | |
parent | 518b852e8bd9c50a6c5c7e84cddecb5c94ebb5b6 (diff) | |
download | time-picker-0e62bf0b7bdc260e882fd185492939cbaed04d56.tar.gz time-picker-0e62bf0b7bdc260e882fd185492939cbaed04d56.tar.zst time-picker-0e62bf0b7bdc260e882fd185492939cbaed04d56.zip |
update test case and fix bugs
Diffstat (limited to 'examples')
-rw-r--r-- | examples/disabled.html | 1 | ||||
-rw-r--r-- | examples/disabled.js | 36 | ||||
-rw-r--r-- | examples/hidden.html | 1 | ||||
-rw-r--r-- | examples/hidden.js | 37 | ||||
-rw-r--r-- | examples/pick-time.js | 18 |
5 files changed, 76 insertions, 17 deletions
diff --git a/examples/disabled.html b/examples/disabled.html new file mode 100644 index 0000000..48cdce8 --- /dev/null +++ b/examples/disabled.html | |||
@@ -0,0 +1 @@ | |||
placeholder | |||
diff --git a/examples/disabled.js b/examples/disabled.js new file mode 100644 index 0000000..24d0068 --- /dev/null +++ b/examples/disabled.js | |||
@@ -0,0 +1,36 @@ | |||
1 | /* eslint no-console:0 */ | ||
2 | |||
3 | import 'rc-time-picker/assets/index.less'; | ||
4 | |||
5 | import React from 'react'; | ||
6 | import ReactDom from 'react-dom'; | ||
7 | |||
8 | import GregorianCalendar from 'gregorian-calendar'; | ||
9 | import DateTimeFormat from 'gregorian-calendar-format'; | ||
10 | import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; | ||
11 | |||
12 | import TimePicker from 'rc-time-picker'; | ||
13 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; | ||
14 | |||
15 | const showSecond = true; | ||
16 | const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; | ||
17 | |||
18 | const formatter = new DateTimeFormat(str); | ||
19 | |||
20 | const now = new GregorianCalendar(zhCn); | ||
21 | now.setTime(Date.now()); | ||
22 | |||
23 | function onChange(value) { | ||
24 | console.log(value && formatter.format(value)); | ||
25 | } | ||
26 | |||
27 | ReactDom.render( | ||
28 | <TimePicker formatter={formatter} locale={TimePickerLocale} | ||
29 | showSecond={showSecond} | ||
30 | defaultValue={now} | ||
31 | className="xxx" | ||
32 | onChange={onChange} | ||
33 | disabledHours={[0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]} | ||
34 | disabledMinutes={[0, 2, 4, 6, 8]} />, | ||
35 | document.getElementById('__react-content') | ||
36 | ); | ||
diff --git a/examples/hidden.html b/examples/hidden.html new file mode 100644 index 0000000..48cdce8 --- /dev/null +++ b/examples/hidden.html | |||
@@ -0,0 +1 @@ | |||
placeholder | |||
diff --git a/examples/hidden.js b/examples/hidden.js new file mode 100644 index 0000000..1084236 --- /dev/null +++ b/examples/hidden.js | |||
@@ -0,0 +1,37 @@ | |||
1 | /* eslint no-console:0 */ | ||
2 | |||
3 | import 'rc-time-picker/assets/index.less'; | ||
4 | |||
5 | import React from 'react'; | ||
6 | import ReactDom from 'react-dom'; | ||
7 | |||
8 | import GregorianCalendar from 'gregorian-calendar'; | ||
9 | import DateTimeFormat from 'gregorian-calendar-format'; | ||
10 | import zhCn from 'gregorian-calendar/lib/locale/zh_CN'; | ||
11 | |||
12 | import TimePicker from 'rc-time-picker'; | ||
13 | import TimePickerLocale from 'rc-time-picker/src/locale/zh_CN'; | ||
14 | |||
15 | const showSecond = true; | ||
16 | const str = showSecond ? 'HH:mm:ss' : 'HH:mm'; | ||
17 | |||
18 | const formatter = new DateTimeFormat(str); | ||
19 | |||
20 | const now = new GregorianCalendar(zhCn); | ||
21 | now.setTime(Date.now()); | ||
22 | |||
23 | function onChange(value) { | ||
24 | console.log(value && formatter.format(value)); | ||
25 | } | ||
26 | |||
27 | ReactDom.render( | ||
28 | <TimePicker formatter={formatter} locale={TimePickerLocale} | ||
29 | showSecond={showSecond} | ||
30 | defaultValue={now} | ||
31 | className="xxx" | ||
32 | onChange={onChange} | ||
33 | disabledHours={[0, 1, 2, 3, 4, 5, 6, 7, 8, 22, 23]} | ||
34 | disabledMinutes={[0, 2, 4, 6, 8]} | ||
35 | hideDisabledOptions={true} />, | ||
36 | document.getElementById('__react-content') | ||
37 | ); | ||
diff --git a/examples/pick-time.js b/examples/pick-time.js index 074e72c..f66e416 100644 --- a/examples/pick-time.js +++ b/examples/pick-time.js | |||
@@ -24,27 +24,11 @@ function onChange(value) { | |||
24 | console.log(value && formatter.format(value)); | 24 | console.log(value && formatter.format(value)); |
25 | } | 25 | } |
26 | 26 | ||
27 | const options = { | ||
28 | disabledHours() { | ||
29 | return [0, 2, 21]; | ||
30 | }, | ||
31 | disabledMinutes(h) { | ||
32 | return h === 22 ? [0, 3, 31] : []; | ||
33 | }, | ||
34 | disabledSeconds(h, m) { | ||
35 | return []; | ||
36 | }, | ||
37 | }; | ||
38 | |||
39 | ReactDom.render( | 27 | ReactDom.render( |
40 | <TimePicker formatter={formatter} locale={TimePickerLocale} | 28 | <TimePicker formatter={formatter} locale={TimePickerLocale} |
41 | showSecond={showSecond} | 29 | showSecond={showSecond} |
42 | defaultValue={now} | 30 | defaultValue={now} |
43 | className="xxx" | 31 | className="xxx" |
44 | onChange={onChange} | 32 | onChange={onChange} />, |
45 | disabledHours={[0, 2, 21]} | ||
46 | disabledMinutes={[0, 2, 21]} | ||
47 | disabledSeconds={[]} | ||
48 | hideDisabledOptions={true} />, | ||
49 | document.getElementById('__react-content') | 33 | document.getElementById('__react-content') |
50 | ); | 34 | ); |