ToolboxSection.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import React from 'react'
  2. import { Row, Col, Checkbox } from 'antd'
  3. const styles = require('../Workbench.less')
  4. export interface IToolboxConfig {
  5. showToolbox: boolean
  6. }
  7. interface IToolboxSectionProps {
  8. title: string
  9. config: IToolboxConfig
  10. onChange: (prop: string, value: any) => void
  11. }
  12. export class ToolboxSection extends React.PureComponent<IToolboxSectionProps, {}> {
  13. private checkboxChange = (prop) => (e) => {
  14. this.props.onChange(prop, e.target.checked)
  15. }
  16. public render () {
  17. const { title, config } = this.props
  18. const { showToolbox } = config
  19. return (
  20. <div className={styles.paneBlock}>
  21. <h4>{title}</h4>
  22. <div className={styles.blockBody}>
  23. <Row gutter={8} type="flex" align="middle" className={styles.blockRow}>
  24. <Col span={24}>
  25. <Checkbox
  26. checked={showToolbox}
  27. onChange={this.checkboxChange('showToolbox')}
  28. >
  29. Toolbox
  30. </Checkbox>
  31. </Col>
  32. </Row>
  33. </div>
  34. </div>
  35. )
  36. }
  37. }
  38. export default ToolboxSection