File size: 932 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { Button } from '@automattic/components';
import moment from 'moment';
import { createRef, PureComponent } from 'react';
import CalendarPopover from 'calypso/blocks/calendar-popover';

const tomorrow = ( date ) => date.date( date.date() + 1 );

class CalendarPopoverExample extends PureComponent {
	buttonRef = createRef();

	state = { show: false, currentDate: tomorrow( moment() ) };

	toggle = () => this.setState( { show: ! this.state.show } );

	close = () => this.setState( { show: false } );

	render() {
		return (
			<div>
				<Button primary ref={ this.buttonRef } onClick={ this.toggle }>
					Show Popover
				</Button>

				<CalendarPopover
					context={ this.buttonRef.current }
					isVisible={ this.state.show }
					selectedDay={ this.state.currentDate }
					onClose={ this.close }
				/>
			</div>
		);
	}
}

CalendarPopoverExample.displayName = 'CalendarPopover';

export default CalendarPopoverExample;