about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/components/hashtag.js
blob: d75edd9947d264cb2edef49b4a5168bb4d963fda (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react';
import { Sparklines, SparklinesCurve } from 'react-sparklines';
import { FormattedMessage } from 'react-intl';
import ImmutablePropTypes from 'react-immutable-proptypes';
import Permalink from './permalink';
import { shortNumberFormat } from 'flavours/glitch/util/numbers';

const Hashtag = ({ hashtag }) => (
  <div className='trends__item'>
    <div className='trends__item__name'>
      <Permalink href={hashtag.get('url')} to={`/timelines/tag/${hashtag.get('name')}`}>
        #<span>{hashtag.get('name')}</span>
      </Permalink>

      <FormattedMessage id='trends.count_by_accounts' defaultMessage='{count} {rawCount, plural, one {person} other {people}} talking' values={{ rawCount: hashtag.getIn(['history', 0, 'accounts']), count: <strong>{shortNumberFormat(hashtag.getIn(['history', 0, 'accounts']))}</strong> }} />
    </div>

    <div className='trends__item__current'>
      {shortNumberFormat(hashtag.getIn(['history', 0, 'uses']))}
    </div>

    <div className='trends__item__sparkline'>
      <Sparklines width={50} height={28} data={hashtag.get('history').reverse().map(day => day.get('uses')).toArray()}>
        <SparklinesCurve style={{ fill: 'none' }} />
      </Sparklines>
    </div>
  </div>
);

Hashtag.propTypes = {
  hashtag: ImmutablePropTypes.map.isRequired,
};

export default Hashtag;