|
| 1 | +import React from 'react'; |
| 2 | + |
| 3 | +import CheckboxTree from '../../../src/index'; |
| 4 | + |
| 5 | +const nodes = [ |
| 6 | + { |
| 7 | + value: 'Documents', |
| 8 | + label: 'Documents', |
| 9 | + children: [ |
| 10 | + { |
| 11 | + value: 'Employee Evaluations.zip', |
| 12 | + label: 'Employee Evaluations.zip', |
| 13 | + icon: <i className="fa fa-file-archive-o" />, |
| 14 | + }, |
| 15 | + { |
| 16 | + value: 'Expense Report.pdf', |
| 17 | + label: 'Expense Report.pdf', |
| 18 | + icon: <i className="fa fa-file-pdf-o" />, |
| 19 | + }, |
| 20 | + { |
| 21 | + value: 'notes.txt', |
| 22 | + label: 'notes.txt', |
| 23 | + icon: <i className="fa fa-file-text-o" />, |
| 24 | + }, |
| 25 | + ], |
| 26 | + }, |
| 27 | + { |
| 28 | + value: 'Photos', |
| 29 | + label: 'Photos', |
| 30 | + children: [ |
| 31 | + { |
| 32 | + value: 'nyan-cat.gif', |
| 33 | + label: 'nyan-cat.gif', |
| 34 | + icon: <i className="fa fa-file-image-o" />, |
| 35 | + }, |
| 36 | + { |
| 37 | + value: 'SpaceX Falcon9 liftoff.jpg', |
| 38 | + label: 'SpaceX Falcon9 liftoff.jpg', |
| 39 | + icon: <i className="fa fa-file-image-o" />, |
| 40 | + }, |
| 41 | + ], |
| 42 | + }, |
| 43 | +]; |
| 44 | + |
| 45 | +class CustomIconsExamples extends React.Component { |
| 46 | + constructor() { |
| 47 | + super(); |
| 48 | + |
| 49 | + this.state = { |
| 50 | + checked: [], |
| 51 | + expanded: [ |
| 52 | + 'Documents', |
| 53 | + ], |
| 54 | + }; |
| 55 | + |
| 56 | + this.onCheck = this.onCheck.bind(this); |
| 57 | + this.onExpand = this.onExpand.bind(this); |
| 58 | + } |
| 59 | + |
| 60 | + onCheck(checked) { |
| 61 | + this.setState({ checked }); |
| 62 | + } |
| 63 | + |
| 64 | + onExpand(expanded) { |
| 65 | + this.setState({ expanded }); |
| 66 | + } |
| 67 | + |
| 68 | + render() { |
| 69 | + const { checked, expanded } = this.state; |
| 70 | + |
| 71 | + return ( |
| 72 | + <CheckboxTree |
| 73 | + checked={checked} |
| 74 | + expanded={expanded} |
| 75 | + nodes={nodes} |
| 76 | + onCheck={this.onCheck} |
| 77 | + onExpand={this.onExpand} |
| 78 | + /> |
| 79 | + ); |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +export default CustomIconsExamples; |
0 commit comments