|
1 | 1 | import React from 'react';
|
2 | 2 | import ReactDOM from 'react-dom';
|
| 3 | +import jsxToString from 'jsx-to-string'; |
3 | 4 |
|
4 | 5 | import MonthPickerInput from 'react-month-picker-input';
|
| 6 | +import { MonthFormat } from 'react-month-picker-input'; |
5 | 7 |
|
6 | 8 | ReactDOM.render(
|
7 | 9 | (
|
8 | 10 | <div>
|
9 |
| - <label htmlFor="ex-0"> |
10 |
| - Without default value |
| 11 | + <div className="example"> |
| 12 | + <h2>Without props</h2> |
| 13 | + |
| 14 | + <pre>{ jsxToString(<MonthPickerInput />) }</pre> |
| 15 | + |
11 | 16 | <MonthPickerInput inputProps={{id: "ex-0", name: "ex-0"}} />
|
12 |
| - </label> |
| 17 | + </div> |
| 18 | + |
| 19 | + <div className="example"> |
| 20 | + <h2>With only default year</h2> |
| 21 | + |
| 22 | + <pre> |
| 23 | + { |
| 24 | + jsxToString( |
| 25 | + <MonthPickerInput |
| 26 | + year={new Date().getFullYear()} /> |
| 27 | + ) |
| 28 | + } |
| 29 | + </pre> |
13 | 30 |
|
14 |
| - <label htmlFor="ex-1"> |
15 |
| - With only default year |
16 | 31 | <MonthPickerInput
|
17 | 32 | year={new Date().getFullYear()}
|
18 | 33 | inputProps={{id: "ex-1", name: "ex-1"}} />
|
19 |
| - </label> |
| 34 | + </div> |
| 35 | + |
| 36 | + <div className="example"> |
| 37 | + <h2>With default year and month</h2> |
| 38 | + |
| 39 | + <pre> |
| 40 | + { |
| 41 | + jsxToString( |
| 42 | + <MonthPickerInput |
| 43 | + year={new Date().getFullYear()} |
| 44 | + month={new Date().getMonth()} /> |
| 45 | + ) |
| 46 | + } |
| 47 | + </pre> |
20 | 48 |
|
21 |
| - <label htmlFor="ex-2"> |
22 |
| - With default year and month |
23 | 49 | <MonthPickerInput
|
24 | 50 | year={new Date().getFullYear()}
|
25 | 51 | month={new Date().getMonth()}
|
26 | 52 | inputProps={{id: "ex-2", name: "ex-2"}} />
|
27 |
| - </label> |
| 53 | + </div> |
28 | 54 |
|
29 |
| - <label htmlFor="ex-3"> |
30 |
| - Japanese format |
31 |
| - <MonthPickerInput |
32 |
| - year={new Date().getFullYear()} |
33 |
| - month={new Date().getMonth()} |
34 |
| - lang="ja" |
35 |
| - inputProps={{id: "ex-3", name: "ex-3"}} /> |
36 |
| - </label> |
37 | 55 |
|
38 |
| - <label htmlFor="ex-4"> |
39 |
| - Close on month select |
| 56 | + <div className="example"> |
| 57 | + <h2>Close on month select</h2> |
| 58 | + |
| 59 | + <pre> |
| 60 | + { jsxToString(<MonthPickerInput closeOnSelect={true} />) } |
| 61 | + </pre> |
| 62 | + |
40 | 63 | <MonthPickerInput
|
41 | 64 | closeOnSelect={true}
|
42 | 65 | inputProps={{id: "ex-3", name: "ex-3"}} />
|
43 |
| - </label> |
| 66 | + </div> |
| 67 | + |
| 68 | + <div className="example"> |
| 69 | + <h2>Custom translations</h2> |
| 70 | + |
| 71 | + <pre> |
| 72 | + { |
| 73 | + jsxToString( |
| 74 | + <MonthPickerInput |
| 75 | + lang='hu' |
| 76 | + i18n={{ |
| 77 | + monthFormat: MonthFormat.LONG, |
| 78 | + dateFormat: { |
| 79 | + hu: 'MM/YY' |
| 80 | + }, |
| 81 | + monthNames: { |
| 82 | + hu: [ |
| 83 | + 'Január', |
| 84 | + 'Február', |
| 85 | + 'Március', |
| 86 | + 'Aprilis', |
| 87 | + 'Május', |
| 88 | + 'Junius', |
| 89 | + 'Julius', |
| 90 | + 'Augusztus', |
| 91 | + 'Szeptember', |
| 92 | + 'Október', |
| 93 | + 'November', |
| 94 | + 'December' |
| 95 | + ] |
| 96 | + } |
| 97 | + }} /> |
| 98 | + ) |
| 99 | + }</pre> |
| 100 | + |
| 101 | + <MonthPickerInput |
| 102 | + lang="hu" |
| 103 | + i18n={{ |
| 104 | + monthFormat: MonthFormat.LONG, |
| 105 | + dateFormat: { |
| 106 | + hu: 'MM/YY' |
| 107 | + }, |
| 108 | + monthNames: { |
| 109 | + hu: [ |
| 110 | + 'Január', |
| 111 | + 'Február', |
| 112 | + 'Március', |
| 113 | + 'Aprilis', |
| 114 | + 'Május', |
| 115 | + 'Junius', |
| 116 | + 'Julius', |
| 117 | + 'Augusztus', |
| 118 | + 'Szeptember', |
| 119 | + 'Október', |
| 120 | + 'November', |
| 121 | + 'December' |
| 122 | + ] |
| 123 | + } |
| 124 | + }} |
| 125 | + inputProps={{id: "ex-4", name: "ex-4"}} /> |
| 126 | + </div> |
44 | 127 | </div>
|
45 | 128 | ),
|
46 | 129 | document.getElementById('examples')
|
|
0 commit comments