diff options
author | Renaud Chaput <renchap@gmail.com> | 2023-02-25 14:34:32 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2023-02-25 14:35:31 +0100 |
commit | 81ef21a0c802f1d905f37a2a818544a8b400793c (patch) | |
tree | 33043286868ca9efb627ed38accab03c756adbcb /app/javascript/flavours/glitch/components/hashtag.js | |
parent | 859eb01aacc27fa01a8d4063f26a5a1f81e5d3a9 (diff) |
[Glitch] Rename JSX files with proper `.jsx` extension
Port 44a7d87cb1f5df953b6c14c16c59e2e4ead1bcb9 to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Diffstat (limited to 'app/javascript/flavours/glitch/components/hashtag.js')
-rw-r--r-- | app/javascript/flavours/glitch/components/hashtag.js | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/app/javascript/flavours/glitch/components/hashtag.js b/app/javascript/flavours/glitch/components/hashtag.js deleted file mode 100644 index 422b9a8fa..000000000 --- a/app/javascript/flavours/glitch/components/hashtag.js +++ /dev/null @@ -1,115 +0,0 @@ -// @ts-check -import React from 'react'; -import { Sparklines, SparklinesCurve } from 'react-sparklines'; -import { FormattedMessage } from 'react-intl'; -import PropTypes from 'prop-types'; -import ImmutablePropTypes from 'react-immutable-proptypes'; -import Permalink from './permalink'; -import ShortNumber from 'flavours/glitch/components/short_number'; -import Skeleton from 'flavours/glitch/components/skeleton'; -import classNames from 'classnames'; - -class SilentErrorBoundary extends React.Component { - - static propTypes = { - children: PropTypes.node, - }; - - state = { - error: false, - }; - - componentDidCatch () { - this.setState({ error: true }); - } - - render () { - if (this.state.error) { - return null; - } - - return this.props.children; - } - -} - -/** - * Used to render counter of how much people are talking about hashtag - * - * @type {(displayNumber: JSX.Element, pluralReady: number) => JSX.Element} - */ -export const accountsCountRenderer = (displayNumber, pluralReady) => ( - <FormattedMessage - id='trends.counter_by_accounts' - defaultMessage='{count, plural, one {{counter} person} other {{counter} people}} in the past {days, plural, one {day} other {{days} days}}' - values={{ - count: pluralReady, - counter: <strong>{displayNumber}</strong>, - days: 2, - }} - /> -); - -export const ImmutableHashtag = ({ hashtag }) => ( - <Hashtag - name={hashtag.get('name')} - href={hashtag.get('url')} - to={`/tags/${hashtag.get('name')}`} - people={hashtag.getIn(['history', 0, 'accounts']) * 1 + hashtag.getIn(['history', 1, 'accounts']) * 1} - history={hashtag.get('history').reverse().map((day) => day.get('uses')).toArray()} - /> -); - -ImmutableHashtag.propTypes = { - hashtag: ImmutablePropTypes.map.isRequired, -}; - -const Hashtag = ({ name, href, to, people, uses, history, className, description, withGraph }) => ( - <div className={classNames('trends__item', className)}> - <div className='trends__item__name'> - <Permalink href={href} to={to}> - {name ? <React.Fragment>#<span>{name}</span></React.Fragment> : <Skeleton width={50} />} - </Permalink> - - {description ? ( - <span>{description}</span> - ) : ( - typeof people !== 'undefined' ? <ShortNumber value={people} renderer={accountsCountRenderer} /> : <Skeleton width={100} /> - )} - </div> - - {typeof uses !== 'undefined' && ( - <div className='trends__item__current'> - <ShortNumber value={uses} /> - </div> - )} - - {withGraph && ( - <div className='trends__item__sparkline'> - <SilentErrorBoundary> - <Sparklines width={50} height={28} data={history ? history : Array.from(Array(7)).map(() => 0)}> - <SparklinesCurve style={{ fill: 'none' }} /> - </Sparklines> - </SilentErrorBoundary> - </div> - )} - </div> -); - -Hashtag.propTypes = { - name: PropTypes.string, - href: PropTypes.string, - to: PropTypes.string, - people: PropTypes.number, - description: PropTypes.node, - uses: PropTypes.number, - history: PropTypes.arrayOf(PropTypes.number), - className: PropTypes.string, - withGraph: PropTypes.bool, -}; - -Hashtag.defaultProps = { - withGraph: true, -}; - -export default Hashtag; |