fix: favorite button status error

This commit is contained in:
QiShaoXuan
2022-12-26 15:13:48 +08:00
parent f20b9d5728
commit e04547be9c
3 changed files with 12 additions and 1 deletions
@@ -23,6 +23,7 @@ import { useRouter } from 'next/router';
import { useAppState } from '@/providers/app-state-provider/context';
import { toast } from '@/ui/toast';
import { usePageHelper } from '@/hooks/use-page-helper';
import { useTheme } from '@/providers/themeProvider';
const FavoriteTag = ({
pageMeta: { favorite, id },
@@ -30,6 +31,7 @@ const FavoriteTag = ({
pageMeta: PageMeta;
}) => {
const { toggleFavoritePage } = usePageHelper();
const { theme } = useTheme();
return (
<Tooltip
content={favorite ? 'Favourited' : 'Favourite'}
@@ -43,6 +45,10 @@ const FavoriteTag = ({
toggleFavoritePage(id);
toast(!favorite ? 'Removed to Favourites' : 'Added to Favourites');
}}
style={{
color: favorite ? theme.colors.primaryColor : theme.colors.iconColor,
}}
className="favorite-button"
>
{favorite ? (
<FavouritedIcon data-testid="favourited-icon" />
@@ -39,6 +39,9 @@ export const StyledTitleLink = styled.div(({ theme }) => {
export const StyledTableRow = styled(TableRow)(() => {
return {
cursor: 'pointer',
'.favorite-button': {
display: 'none',
},
'&:hover': {
'.favorite-button': {
display: 'flex',
+3 -1
View File
@@ -117,7 +117,9 @@ export const Popper = ({
},
onPointerEnter: onPointerEnterHandler,
onPointerLeave: onPointerLeaveHandler,
className: anchorClassName,
className: `${anchorClassName ? anchorClassName + ' ' : ''}${
children.props.className
}`,
})}
{content && (
<BasicStyledPopper