From da2ad0ac2e9305e77e6bd9b9b7b80680040b8853 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Tue, 15 Nov 2022 15:53:27 -0800 Subject: [PATCH] Animate activity song change --- .../users/components/user-activity-item.tsx | 135 +++++++++++------- 1 file changed, 84 insertions(+), 51 deletions(-) diff --git a/src/renderer/features/users/components/user-activity-item.tsx b/src/renderer/features/users/components/user-activity-item.tsx index 4283ce6a8..97b58d187 100644 --- a/src/renderer/features/users/components/user-activity-item.tsx +++ b/src/renderer/features/users/components/user-activity-item.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { Avatar, Group, Indicator, Stack } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; -import { motion } from 'framer-motion'; +import { AnimatePresence, motion, Variants } from 'framer-motion'; import { IoIosPause } from 'react-icons/io'; import { RiPlayFill, RiServerLine, RiUserLine } from 'react-icons/ri'; import { generatePath } from 'react-router'; @@ -57,6 +57,8 @@ const ItemInfoContainer = styled.div` grid-area: info; `; +const MotionStack = motion(Stack); + export const UserActivityItem = ({ user }: UserActivityItemProps) => { const { data: serverMap } = useServerMap(); const [opened, { close, open }] = useDisclosure(false); @@ -72,9 +74,27 @@ export const UserActivityItem = ({ user }: UserActivityItemProps) => { const status = user?.activity?.status; const albumArtists = user?.activity?.song?.albumArtists; - console.log('serverMap', serverMap); - - console.log('serverId', serverId); + const infoVariants: Variants = { + animate: { + opacity: 1, + transition: { + duration: 0.2, + }, + x: 0, + }, + exit: { + opacity: 0, + transition: { + duration: 0.2, + ease: 'easeInOut', + }, + x: 10, + }, + initial: { + opacity: 0, + x: -10, + }, + }; return ( @@ -113,56 +133,69 @@ export const UserActivityItem = ({ user }: UserActivityItemProps) => { - - - {songId ? songName : 'Idle...'} - - - {albumArtists?.length ? ( - albumArtists.map((artist, index) => ( - - {index > 0 ? ', ' : null} - - {artist.name} - - - )) - ) : ( - - )} - - {albumId ? ( - - {albumName} + + + + {songId ? songName : 'Not Playing'} - ) : ( - — + {albumArtists?.length ? ( + albumArtists.map((artist, index) => ( + + {index > 0 ? ', ' : null} + + {artist.name} + + + )) + ) : ( + + )} - )} - + {albumId ? ( + + + {albumName} + + + ) : ( + + — + + )} + + {status === 'playing' ? (