Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: favorite feature and project (#2582)
## About the changes Add an ability to star a toggle from it's overiew. Co-authored-by: sjaanus <sellinjaanus@gmail.com>
- Loading branch information
Showing
16 changed files
with
370 additions
and
247 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
frontend/src/component/common/FavoriteIconButton/FavoriteIconButton.tsx
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { VFC } from 'react'; | ||
import { Dialogue } from 'component/common/Dialogue/Dialogue'; | ||
import useFeatureApi from 'hooks/api/actions/useFeatureApi/useFeatureApi'; | ||
import useToast from 'hooks/useToast'; | ||
import { formatUnknownError } from 'utils/formatUnknownError'; | ||
import { IconButton } from '@mui/material'; | ||
import { ConditionallyRender } from '../ConditionallyRender/ConditionallyRender'; | ||
import { | ||
Star as StarIcon, | ||
StarBorder as StarBorderIcon, | ||
} from '@mui/icons-material'; | ||
|
||
interface IFavoriteIconButtonProps { | ||
onClick: (event?: any) => void; | ||
isFavorite: boolean; | ||
size?: 'medium' | 'large'; | ||
} | ||
|
||
export const FavoriteIconButton: VFC<IFavoriteIconButtonProps> = ({ | ||
onClick, | ||
isFavorite, | ||
size = 'large', | ||
}) => { | ||
return ( | ||
<IconButton size={size} data-loading sx={{ mr: 1 }} onClick={onClick}> | ||
<ConditionallyRender | ||
condition={isFavorite} | ||
show={ | ||
<StarIcon | ||
color="primary" | ||
sx={{ | ||
fontSize: theme => | ||
size === 'medium' | ||
? theme.spacing(2) | ||
: theme.spacing(3), | ||
}} | ||
/> | ||
} | ||
elseShow={ | ||
<StarBorderIcon | ||
sx={{ | ||
fontSize: theme => | ||
size === 'medium' | ||
? theme.spacing(2) | ||
: theme.spacing(3), | ||
}} | ||
/> | ||
} | ||
/> | ||
</IconButton> | ||
); | ||
}; |
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
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.