File size: 1,849 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { Button } from '@automattic/components';
import { PureComponent } from 'react';
import accept from 'calypso/lib/accept';
import { Checklist, Task } from '../';

export default class ChecklistExample extends PureComponent {
	static displayName = 'ChecklistExample';

	state = {
		showPlaceholder: false,
	};

	togglePlaceholder = () =>
		void this.setState( ( { showPlaceholder } ) => ( { showPlaceholder: ! showPlaceholder } ) );

	getClickHandler = ( taskId ) => () =>
		accept(
			'Will you complete this thing?',
			( accepted ) => ( accepted ? void this.setState( { [ taskId ]: true } ) : undefined ),
			'Yes',
			'No'
		);
	getToggleHandler = ( taskId ) => () =>
		void this.setState( ( state ) => ( { [ taskId ]: ! state[ taskId ] } ) );

	render() {
		return (
			<>
				<Button onClick={ this.togglePlaceholder }>
					{ this.state.showPlaceholder ? 'Hide Placeholder' : 'Show Placeholder' }
				</Button>
				<Checklist isPlaceholder={ this.state.showPlaceholder }>
					<Task
						onClick={ this.getClickHandler( 'reticulateSplines' ) }
						onDismiss={ this.getToggleHandler( 'reticulateSplines' ) }
						title="Reticulate splines"
						buttonText="Reticulate!"
						completedTitle="Splines are reticulated 👍"
						description="Make sure that all the splines are reticulated."
						duration="1 minute"
						completed={ this.state.reticulateSplines }
					/>
					<Task
						onClick={ this.getClickHandler( 'shaveYak' ) }
						onDismiss={ this.getToggleHandler( 'shaveYak' ) }
						title="Shave yaks!"
						buttonText="Buzzzz"
						completedTitle="Yaks shaved."
						description="Make sure you shave the yaks so you can get on with your life."
						duration="10,000 minutes"
						completed={ this.state.shaveYak }
					/>
					<Task title="Overwaxing banisters!" inProgress />
				</Checklist>
			</>
		);
	}
}