-
Notifications
You must be signed in to change notification settings - Fork 80
/
Copy pathFormatsExample.js
61 lines (49 loc) · 1.79 KB
/
FormatsExample.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import React, { useState } from 'react'
import { enUS } from 'date-fns/locale'
import { DatePicker } from '../../src'
import Example from './Example'
const code = `
import React, { useState } from 'react'
import { enUS } from 'date-fns/locale'
import { DatePicker } from 'react-nice-dates'
import 'react-nice-dates/build/style.css'
export default function LocalesExample() {
const [date, setDate] = useState()
return (
<div>
<p>Month format:</p>
<DatePicker date={date} onDateChange={setDate} locale={enUS} monthFormat='GGGG yyyy, MMMM'>
{({ inputProps, focused }) => (
<input className={'input' + (focused ? ' -focused' : '')} {...inputProps} placeholder='GGGG yyyy, MMMM' />
)}
</DatePicker>
<p>Weekday format:</p>
<DatePicker date={date} onDateChange={setDate} locale={enUS} weekdayFormat="eeee">
{({ inputProps, focused }) => (
<input className={'input' + (focused ? ' -focused' : '')} {...inputProps} placeholder='eeee' />
)}
</DatePicker>
</div>
)
}
`;
export default function FormatsExample() {
const [date, setDate] = useState()
return (
<Example code={code}>
<p>Month format:</p>
<DatePicker date={date} onDateChange={setDate} locale={enUS} monthFormat='GGGG yyyy, MMMM'>
{({ inputProps, focused }) => (
<input className={'input' + (focused ? ' -focused' : '')} {...inputProps} placeholder='GGGG yyyy, MMMM' />
)}
</DatePicker>
<br />
<p>Weekday format:</p>
<DatePicker date={date} onDateChange={setDate} locale={enUS} weekdayFormat="eeee">
{({ inputProps, focused }) => (
<input className={'input' + (focused ? ' -focused' : '')} {...inputProps} placeholder='eeee' />
)}
</DatePicker>
</Example>
)
}