import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
import { Tooltip } from 'antd'
import styles from './index.less'

export default class LineWrap extends PureComponent {
  static propTypes = {
    title: PropTypes.string,
    lineClampNum: PropTypes.number,
    // colWidth: PropTypes.string
  }

  render() {
    const { title, lineClampNum, colWidth } = this.props
    const lineWidth = colWidth !== '' && colWidth !== undefined ? colWidth : '80px'

    return (
      <Tooltip placement="topLeft" title={title}>
        <span className={styles.col} style={{ WebkitLineClamp: lineClampNum, width: lineWidth }}>
            {title}
        </span>
      </Tooltip>
    )
  }
}
