mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 08:54:13 +00:00
style: add smooth transition
This commit is contained in:
parent
b7c7d40bf9
commit
e7fc951310
2 changed files with 21 additions and 10 deletions
|
|
@ -13,6 +13,7 @@
|
|||
background-color: var(--color-neutral-100);
|
||||
color: var(--color-foreground-subtle);
|
||||
cursor: pointer;
|
||||
line-height: 0;
|
||||
outline: none;
|
||||
|
||||
&.isFavorite {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { BiHeart, BiSolidHeart } from 'react-icons/bi/index';
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
|
||||
import { useFavoriteStore } from '@/store/favorite';
|
||||
import { cn } from '@/helpers/styles';
|
||||
|
|
@ -14,15 +15,24 @@ export function Like({ id }: LikeProps) {
|
|||
const toggleFavorite = useFavoriteStore(state => state.toggleFavorite);
|
||||
|
||||
return (
|
||||
<button
|
||||
aria-label="Add Sound to Favorites"
|
||||
className={cn(styles.favoriteButton, isFavorite && styles.isFavorite)}
|
||||
onClick={e => {
|
||||
e.stopPropagation();
|
||||
toggleFavorite(id);
|
||||
}}
|
||||
>
|
||||
{isFavorite ? <BiSolidHeart /> : <BiHeart />}
|
||||
</button>
|
||||
<AnimatePresence initial={false} mode="wait">
|
||||
<button
|
||||
aria-label="Add Sound to Favorites"
|
||||
className={cn(styles.favoriteButton, isFavorite && styles.isFavorite)}
|
||||
onClick={e => {
|
||||
e.stopPropagation();
|
||||
toggleFavorite(id);
|
||||
}}
|
||||
>
|
||||
<motion.span
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
initial={{ opacity: 0 }}
|
||||
key={isFavorite ? `${id}-is-favorite` : `${id}-not-favorite`}
|
||||
>
|
||||
{isFavorite ? <BiSolidHeart /> : <BiHeart />}
|
||||
</motion.span>
|
||||
</button>
|
||||
</AnimatePresence>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue