]>
cat aescling's git repositories - mastodon.git/blob - app/javascript/mastodon/components/hashtag.js
2 import React
from 'react';
3 import { Sparklines
, SparklinesCurve
} from 'react-sparklines';
4 import { FormattedMessage
} from 'react-intl';
5 import PropTypes
from 'prop-types';
6 import ImmutablePropTypes
from 'react-immutable-proptypes';
7 import Permalink
from './permalink';
8 import ShortNumber
from 'mastodon/components/short_number';
10 class SilentErrorBoundary
extends React
.Component
{
13 children: PropTypes
.node
,
20 componentDidCatch () {
21 this.setState({ error: true });
25 if (this.state
.error
) {
29 return this.props
.children
;
35 * Used to render counter of how much people are talking about hashtag
37 * @type {(displayNumber: JSX.Element, pluralReady: number) => JSX.Element}
39 const accountsCountRenderer
= (displayNumber
, pluralReady
) => (
41 id
='trends.counter_by_accounts'
42 defaultMessage
='{count, plural, one {{counter} person} other {{counter} people}} talking'
45 counter: <strong
>{displayNumber
}</strong
>,
50 const Hashtag
= ({ hashtag
}) => (
51 <div className
='trends__item'>
52 <div className
='trends__item__name'>
54 href
={hashtag
.get('url')}
55 to
={`/tags/${hashtag.get('name')}`}
57 #<span
>{hashtag
.get('name')}</span
>
62 hashtag
.getIn(['history', 0, 'accounts']) * 1 +
63 hashtag
.getIn(['history', 1, 'accounts']) * 1
65 renderer
={accountsCountRenderer
}
69 <div className
='trends__item__current'>
72 hashtag
.getIn(['history', 0, 'uses']) * 1 +
73 hashtag
.getIn(['history', 1, 'uses']) * 1
78 <div className
='trends__item__sparkline'>
86 .map((day
) => day
.get('uses'))
89 <SparklinesCurve style
={{ fill: 'none' }} />
91 </SilentErrorBoundary
>
97 hashtag: ImmutablePropTypes
.map
.isRequired
,
100 export default Hashtag
;
This page took 0.091775 seconds and 4 git commands to generate.