-
Notifications
You must be signed in to change notification settings - Fork 331
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add favorite activities UI to activity library (#9680)
- Loading branch information
1 parent
63e1ebd
commit d6a775d
Showing
7 changed files
with
118 additions
and
11 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
packages/client/components/ActivityLibrary/ActivityCardFavorite.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,46 @@ | ||
import {Favorite} from '@mui/icons-material' | ||
import clsx from 'clsx' | ||
import React, {useState} from 'react' | ||
import {Tooltip} from '../../ui/Tooltip/Tooltip' | ||
import {TooltipContent} from '../../ui/Tooltip/TooltipContent' | ||
import {TooltipTrigger} from '../../ui/Tooltip/TooltipTrigger' | ||
|
||
type Props = { | ||
className?: string | ||
} | ||
|
||
const ActivityCardFavorite = (props: Props) => { | ||
const {className} = props | ||
const [isSelected, setIsSelected] = useState(false) | ||
const tooltipCopy = isSelected ? 'Remove from favorites' : 'Add to favorites' | ||
|
||
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => { | ||
e.preventDefault() | ||
setIsSelected((prev) => !prev) | ||
} | ||
|
||
return ( | ||
<Tooltip> | ||
<div | ||
className={clsx( | ||
className, | ||
`z-10 flex h-10 w-10 items-center justify-center rounded-full bg-white` | ||
)} | ||
> | ||
<TooltipTrigger asChild> | ||
<button | ||
onClick={handleClick} | ||
className='flex h-full w-full cursor-pointer items-center justify-center bg-transparent' | ||
> | ||
<Favorite className={isSelected ? 'text-rose-600' : 'text-slate-600'} /> | ||
</button> | ||
</TooltipTrigger> | ||
</div> | ||
<TooltipContent side='bottom' align='center' sideOffset={20}> | ||
{tooltipCopy} | ||
</TooltipContent> | ||
</Tooltip> | ||
) | ||
} | ||
|
||
export default ActivityCardFavorite |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.