import classNames from 'classnames/bind' import { urlRegex } from '../features/compose/util/url_regex' import Button from './button' import DotTextSeperator from './dot_text_seperator' import Image from './image' import RelativeTimestamp from './relative_timestamp' import Text from './text' const cx = classNames.bind(_s) export default class TrendingItem extends PureComponent { static propTypes = { index: PropTypes.number, url: PropTypes.string.isRequired, title: PropTypes.string.isRequired, description: PropTypes.string, imageUrl: PropTypes.string, author: PropTypes.string, publishDate: PropTypes.string, isLast: PropTypes.bool, wide: PropTypes.bool, } static defaultProps = { title: '', description: '', author: '', } state = { hovering: false, } handleOnMouseEnter = () => { this.setState({ hovering: true }) } handleOnMouseLeave = () => { this.setState({ hovering: false }) } render() { const { index, url, title, description, imageUrl, author, publishDate, isLast, wide, } = this.props const { hovering } = this.state const containerClasses = cx({ default: 1, noUnderline: 1, px15: 1, pt10: 1, pb5: 1, borderColorSecondary: !isLast, borderBottom1PX: !isLast, backgroundSubtle_onHover: 1, }) const subtitleClasses = cx({ ml5: 1, underline: hovering, }) const correctedAuthor = author.replace('www.', '') const correctedDescription = description.length >= 120 ? `${description.substring(0, 120).trim()}...` : description const descriptionHasLink = correctedDescription.match(urlRegex) const image = ( {title} ) return ( ) } }