|
1 | 1 | import React from 'react'; |
| 2 | +import PropTypes from 'prop-types'; |
2 | 3 | import { Col, Navbar, Button } from 'reactstrap'; |
3 | 4 | import FontDropdown from './font-dropdown'; |
4 | 5 | import SizeDropdown from './size-dropdown'; |
5 | 6 | import ThemeDropdown from './theme-dropdown'; |
6 | 7 |
|
7 | | -const Toolbar = (props) => { |
| 8 | +const Toolbar = ({ fonts, activeFont, sizes, activeSize, themes, activeTheme, activeNumbers, onChange, onPrint }) => { |
8 | 9 | return ( |
9 | 10 | <Navbar color='#FFFFFF' light expand='sm' style={{ marginBottom: 5 }}> |
10 | 11 | <div className='form-row' style={{ width: '100%' }}> |
11 | 12 | <Col xs='9' md='4' className='my-2 my-md-0'> |
12 | | - <FontDropdown fonts={props.fonts} active={props.activeFont} onSelect={props.onChange.bind(null, 'font')} /> |
| 13 | + <FontDropdown fonts={fonts} active={activeFont} onSelect={onChange.bind(null, 'font')} /> |
13 | 14 | </Col> |
14 | 15 | <Col xs='3' md='2' className='my-2 my-md-0'> |
15 | | - <SizeDropdown sizes={props.sizes} active={props.activeSize} onSelect={props.onChange.bind(null, 'size')}/> |
| 16 | + <SizeDropdown sizes={sizes} active={activeSize} onSelect={onChange.bind(null, 'size')}/> |
16 | 17 | </Col> |
17 | 18 | <Col xs='9' md='3' className='my-2 my-md-0'> |
18 | | - <ThemeDropdown themes={props.themes} active={props.activeTheme} onSelect={props.onChange.bind(null, 'theme')}/> |
| 19 | + <ThemeDropdown themes={themes} active={activeTheme} onSelect={onChange.bind(null, 'theme')}/> |
19 | 20 | </Col> |
20 | 21 | <Col xs='3' md='auto' className='my-2 my-md-0'> |
21 | | - <Button active={props.activeNumbers} outline color='secondary' style={{ width: '100%' }} onClick={props.onChange.bind(null, 'numbers', !props.activeNumbers)}>#</Button> |
| 22 | + <Button active={activeNumbers} outline color='secondary' style={{ width: '100%' }} onClick={onChange.bind(null, 'numbers', !activeNumbers)}>#</Button> |
22 | 23 | </Col> |
23 | 24 | <Col xs='12' md='auto' className='my-2 my-md-0'> |
24 | | - <Button outline color='success' onClick={props.onPrint} style={{ width: '100%' }}>Print</Button> |
| 25 | + <Button outline color='success' onClick={onPrint} style={{ width: '100%' }}>Print</Button> |
25 | 26 | </Col> |
26 | 27 | </div> |
27 | 28 | </Navbar> |
28 | 29 | ); |
29 | 30 | }; |
30 | 31 |
|
| 32 | +Toolbar.propTypes = { |
| 33 | + fonts: PropTypes.arrayOf(PropTypes.string).isRequired, |
| 34 | + activeFont: PropTypes.string.isRequired, |
| 35 | + sizes: PropTypes.arrayOf(PropTypes.number).isRequired, |
| 36 | + activeSize: PropTypes.number.isRequired, |
| 37 | + themes: PropTypes.arrayOf(PropTypes.string).isRequired, |
| 38 | + activeTheme: PropTypes.string.isRequired, |
| 39 | + activeNumbers: PropTypes.bool.isRequired, |
| 40 | + onChange: PropTypes.func, |
| 41 | + onPrint: PropTypes.func |
| 42 | +}; |
| 43 | + |
31 | 44 | export default Toolbar; |
0 commit comments