IframeSection.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import React from 'react'
  2. import debounce from 'lodash/debounce'
  3. import { Row, Col, Input } from 'antd'
  4. const styles = require('../Workbench.less')
  5. export interface IframeConfig {
  6. src: string
  7. }
  8. interface IframeSectionProps {
  9. title: string
  10. config: IframeConfig
  11. onChange: (prop: string, value: any) => void
  12. }
  13. export class IframeSection extends React.PureComponent<IframeSectionProps, {}> {
  14. private debounceInputChange = null
  15. constructor (props: IframeSectionProps) {
  16. super(props)
  17. this.debounceInputChange = debounce(props.onChange, 1500)
  18. }
  19. private inputChange = (prop) => (e: React.ChangeEvent<HTMLInputElement>) => {
  20. this.debounceInputChange(prop, e.target.value)
  21. }
  22. public render () {
  23. const { title, config } = this.props
  24. const { src } = config
  25. return (
  26. <div className={styles.paneBlock}>
  27. <h4>{title}</h4>
  28. <div className={styles.blockBody}>
  29. <Row gutter={8} type="flex" align="middle" className={styles.blockRow}>
  30. <Col span={24}>
  31. <Input onChange={this.inputChange('src')} placeholder="网页地址" defaultValue={src}/>
  32. </Col>
  33. </Row>
  34. </div>
  35. </div>
  36. )
  37. }
  38. }
  39. export default IframeSection