diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-05-30 18:41:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-30 18:41:47 +0200 |
commit | 1a7a74ff76a129031a3fd6d73688ab9409899002 (patch) | |
tree | 11206fd0870e920b4fcd4c27ce37e39010f2e40b /app/javascript/mastodon/components/hashtag.js | |
parent | 9130b3cda9cd460aa137e399a8b50880aba3bb63 (diff) |
Improve getting started column (#7676)
* Adjust footer of getting started column - Improved style - Moved hotkeys, about this instance and logout to footer - Removed FAQ, User Guide, Apps links - Use hamburger icon for the column * Add edit profile action button to profile and more to dropdown * Add "Trending now" to getting started column * Add preferences/security links on mobile layout
Diffstat (limited to 'app/javascript/mastodon/components/hashtag.js')
-rw-r--r-- | app/javascript/mastodon/components/hashtag.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/app/javascript/mastodon/components/hashtag.js b/app/javascript/mastodon/components/hashtag.js new file mode 100644 index 000000000..cc37a91e2 --- /dev/null +++ b/app/javascript/mastodon/components/hashtag.js @@ -0,0 +1,41 @@ +import React from 'react'; +import { Sparklines, SparklinesCurve } from 'react-sparklines'; +import { Link } from 'react-router-dom'; +import { FormattedMessage, FormattedNumber } from 'react-intl'; +import ImmutablePropTypes from 'react-immutable-proptypes'; + +const shortNumberFormat = number => { + if (number < 1000) { + return <FormattedNumber value={number} />; + } else { + return <React.Fragment><FormattedNumber value={number / 1000} maximumFractionDigits={1} />K</React.Fragment>; + } +}; + +const Hashtag = ({ hashtag }) => ( + <div className='trends__item'> + <div className='trends__item__name'> + <Link to={`/timelines/tag/${hashtag.get('name')}`}> + #<span>{hashtag.get('name')}</span> + </Link> + + <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; |