diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2019-07-28 14:37:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-28 14:37:52 +0200 |
commit | cfb2ed78231758a79af038a964ab7f7b7b35274e (patch) | |
tree | 7f94dada733b514a2034839c3ca6fb6776487250 /app/javascript/mastodon/components/autosuggest_hashtag.js | |
parent | 15de24a425cb07efd58db5299b043e4110fa138f (diff) |
Add autosuggestions for hashtags (#11422)
Diffstat (limited to 'app/javascript/mastodon/components/autosuggest_hashtag.js')
-rw-r--r-- | app/javascript/mastodon/components/autosuggest_hashtag.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/javascript/mastodon/components/autosuggest_hashtag.js b/app/javascript/mastodon/components/autosuggest_hashtag.js new file mode 100644 index 000000000..eabb8b178 --- /dev/null +++ b/app/javascript/mastodon/components/autosuggest_hashtag.js @@ -0,0 +1,28 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import { shortNumberFormat } from 'mastodon/utils/numbers'; +import { FormattedMessage } from 'react-intl'; + +export default class AutosuggestHashtag extends React.PureComponent { + + static propTypes = { + tag: PropTypes.shape({ + name: PropTypes.string.isRequired, + url: PropTypes.string, + history: PropTypes.array.isRequired, + }).isRequired, + }; + + render () { + const { tag } = this.props; + const weeklyUses = shortNumberFormat(tag.history.reduce((total, day) => total + (day.uses * 1), 0)); + + return ( + <div className='autosuggest-hashtag'> + <div className='autosuggest-hashtag__name'>#<strong>{tag.name}</strong></div> + <div className='autosuggest-hashtag__uses'><FormattedMessage id='autosuggest_hashtag.per_week' defaultMessage='{count} per week' values={{ count: weeklyUses }} /></div> + </div> + ); + } + +} |