bigbuffet-rw/app/soapbox/features/ui/components/trends-panel.tsx

29 lines
704 B
TypeScript
Raw Normal View History

2022-03-21 11:09:01 -07:00
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import Hashtag from 'soapbox/components/hashtag';
import { Widget } from 'soapbox/components/ui';
2022-08-10 06:35:07 -07:00
import useTrends from 'soapbox/queries/trends';
2022-03-21 11:09:01 -07:00
interface ITrendsPanel {
limit: number
}
const TrendsPanel = ({ limit }: ITrendsPanel) => {
2022-08-10 06:35:07 -07:00
const { data: trends, isFetching } = useTrends();
2022-03-21 11:09:01 -07:00
2022-08-10 06:35:07 -07:00
if (trends?.length === 0 || isFetching) {
2022-03-21 11:09:01 -07:00
return null;
}
return (
<Widget title={<FormattedMessage id='trends.title' defaultMessage='Trends' />}>
2022-08-10 08:33:23 -07:00
{trends?.slice(0, limit).map((hashtag) => (
<Hashtag key={hashtag.name} hashtag={hashtag} />
))}
</Widget>
2022-03-21 11:09:01 -07:00
);
};
export default TrendsPanel;