-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0b7d50
commit 5a28043
Showing
11 changed files
with
191 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,65 @@ | ||
import { useTrendingTags } from '@/hooks' | ||
import { | ||
List, | ||
ListItem, | ||
ListItemText, | ||
Typography, | ||
Box, | ||
Paper | ||
Paper, | ||
CircularProgress | ||
} from '@mui/material' | ||
import { Link, useNavigate } from 'react-router' | ||
import { Link } from 'react-router' | ||
|
||
const TrendingTags = ({ tags }) => { | ||
const navigate = useNavigate() | ||
const TrendingTags = () => { | ||
const { data: tags, isLoading } = useTrendingTags() | ||
return ( | ||
<Paper sx={{ p: 2 }} role="presentation" elevation={0}> | ||
<Typography variant="h6" gutterBottom> | ||
Trending Topics | ||
</Typography> | ||
<List sx={{ p: 0 }}> | ||
{tags.map((tag) => ( | ||
<ListItem | ||
key={tag.hashtag} | ||
to={`/hashtag/${tag.hashtag}`} | ||
sx={{ | ||
cursor: 'pointer', | ||
':hover': { | ||
bgcolor: 'primary.main', | ||
transition: 'background-color 0.2s' | ||
}, | ||
p: 0.5, | ||
px: 1, | ||
textDecoration: 'none', | ||
color: 'inherit', | ||
borderRadius: 1 | ||
}} | ||
component={Link} | ||
> | ||
<ListItemText | ||
primary={`#${tag.hashtag}`} | ||
secondary={`${tag.count} posts`} | ||
primaryTypographyProps={{ | ||
fontWeight: 'medium' | ||
}} | ||
secondaryTypographyProps={{ | ||
fontSize: '0.8rem', | ||
color: 'text.muted' | ||
}} | ||
/> | ||
</ListItem> | ||
))} | ||
</List> | ||
{isLoading ? ( | ||
<CircularProgress size={20} /> | ||
) : ( | ||
<TagsList tags={tags} /> | ||
)} | ||
</Paper> | ||
) | ||
} | ||
|
||
const TagsList = ({ tags }) => { | ||
return ( | ||
<List sx={{ p: 0 }}> | ||
{tags.map((tag) => ( | ||
<ListItem | ||
key={tag.hashtag} | ||
to={`/hashtag/${tag.hashtag}`} | ||
sx={{ | ||
cursor: 'pointer', | ||
':hover': { | ||
bgcolor: 'primary.main', | ||
transition: 'background-color 0.2s' | ||
}, | ||
p: 0.5, | ||
px: 1, | ||
textDecoration: 'none', | ||
color: 'inherit', | ||
borderRadius: 1 | ||
}} | ||
component={Link} | ||
> | ||
<ListItemText | ||
primary={`#${tag.hashtag}`} | ||
secondary={`${tag.count} posts`} | ||
primaryTypographyProps={{ | ||
fontWeight: 'medium' | ||
}} | ||
secondaryTypographyProps={{ | ||
fontSize: '0.8rem', | ||
color: 'text.muted' | ||
}} | ||
/> | ||
</ListItem> | ||
))} | ||
</List> | ||
) | ||
} | ||
export default TrendingTags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.