|
|
@ -5,6 +5,7 @@ import PropTypes from 'prop-types'; |
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes'; |
|
|
|
import { FormattedMessage, defineMessages } from 'react-intl'; |
|
|
|
import Hashtag from '../../../components/hashtag'; |
|
|
|
import { Link } from 'react-router-dom'; |
|
|
|
|
|
|
|
const messages = defineMessages({ |
|
|
|
refresh_trends: { id: 'trends.refresh', defaultMessage: 'Refresh' }, |
|
|
@ -19,6 +20,9 @@ export default class Trends extends ImmutablePureComponent { |
|
|
|
static propTypes = { |
|
|
|
trends: ImmutablePropTypes.list, |
|
|
|
loading: PropTypes.bool.isRequired, |
|
|
|
showTrends: PropTypes.bool.isRequired, |
|
|
|
fetchTrends: PropTypes.func.isRequired, |
|
|
|
toggleTrends: PropTypes.func.isRequired, |
|
|
|
}; |
|
|
|
|
|
|
|
componentDidMount () { |
|
|
@ -29,8 +33,12 @@ export default class Trends extends ImmutablePureComponent { |
|
|
|
this.props.fetchTrends(); |
|
|
|
} |
|
|
|
|
|
|
|
handleToggle = () => { |
|
|
|
this.props.toggleTrends(!this.props.showTrends); |
|
|
|
} |
|
|
|
|
|
|
|
render () { |
|
|
|
const { intl, trends, loading } = this.props; |
|
|
|
const { intl, trends, loading, showTrends } = this.props; |
|
|
|
|
|
|
|
if (!trends || trends.size < 1) { |
|
|
|
return null; |
|
|
@ -44,13 +52,18 @@ export default class Trends extends ImmutablePureComponent { |
|
|
|
<i className='fa fa-fire fa-fw' /> |
|
|
|
<FormattedMessage id='trends.header' defaultMessage='Trending now' /> |
|
|
|
</button> |
|
|
|
|
|
|
|
<div className='column-header__buttons'> |
|
|
|
<button onClick={this.handleRefreshTrends} className='column-header__button' title={intl.formatMessage(messages.refresh_trends)} aria-label={intl.formatMessage(messages.refresh_trends)} disabled={loading}><i className={classNames('fa', 'fa-refresh', { 'fa-spin': loading })} /></button> |
|
|
|
{showTrends && <button onClick={this.handleRefreshTrends} className='column-header__button' title={intl.formatMessage(messages.refresh_trends)} aria-label={intl.formatMessage(messages.refresh_trends)} disabled={loading}><i className={classNames('fa', 'fa-refresh', { 'fa-spin': loading })} /></button>} |
|
|
|
<button onClick={this.handleToggle} className='column-header__button'><i className={classNames('fa', showTrends ? 'fa-chevron-down' : 'fa-chevron-up')} /></button> |
|
|
|
</div> |
|
|
|
</h1> |
|
|
|
</div> |
|
|
|
|
|
|
|
<div className='getting-started__scrollable'>{trends.take(3).map(hashtag => <Hashtag key={hashtag.get('name')} hashtag={hashtag} />)}</div> |
|
|
|
{showTrends && <div className='getting-started__scrollable'> |
|
|
|
{trends.take(3).map(hashtag => <Hashtag key={hashtag.get('name')} hashtag={hashtag} />)} |
|
|
|
<Link to='/trends' className='load-more'><FormattedMessage id='status.load_more' defaultMessage='Load more' /></Link> |
|
|
|
</div>} |
|
|
|
</div> |
|
|
|
); |
|
|
|
} |
|
|
|