feat(ui): add hover show/hide to appVersion

This commit is contained in:
psychedelicious 2023-07-08 19:55:19 +10:00
parent 3333805821
commit 078a829b3a

View File

@ -1,12 +1,17 @@
import { Flex, Image, Text } from '@chakra-ui/react'; import { Flex, Image, Text } from '@chakra-ui/react';
import InvokeAILogoImage from 'assets/images/logo.png'; import InvokeAILogoImage from 'assets/images/logo.png';
import { AnimatePresence, motion } from 'framer-motion';
import { useRef } from 'react';
import { useHoverDirty } from 'react-use';
import { useGetAppVersionQuery } from 'services/api/endpoints/appInfo'; import { useGetAppVersionQuery } from 'services/api/endpoints/appInfo';
const InvokeAILogoComponent = () => { const InvokeAILogoComponent = () => {
const { data: appVersion } = useGetAppVersionQuery(); const { data: appVersion } = useGetAppVersionQuery();
const ref = useRef(null);
const isHovered = useHoverDirty(ref);
return ( return (
<Flex alignItems="center" gap={3} ps={1}> <Flex alignItems="center" gap={3} ps={1} ref={ref}>
<Image <Image
src={InvokeAILogoImage} src={InvokeAILogoImage}
alt="invoke-ai-logo" alt="invoke-ai-logo"
@ -22,7 +27,22 @@ const InvokeAILogoComponent = () => {
<Text sx={{ fontSize: 'xl', userSelect: 'none' }}> <Text sx={{ fontSize: 'xl', userSelect: 'none' }}>
invoke <strong>ai</strong> invoke <strong>ai</strong>
</Text> </Text>
{appVersion && ( <AnimatePresence>
{isHovered && appVersion && (
<motion.div
key="statusText"
initial={{
opacity: 0,
}}
animate={{
opacity: 1,
transition: { duration: 0.15 },
}}
exit={{
opacity: 0,
transition: { delay: 0.8 },
}}
>
<Text <Text
sx={{ sx={{
fontWeight: 600, fontWeight: 600,
@ -34,7 +54,9 @@ const InvokeAILogoComponent = () => {
> >
{appVersion.version} {appVersion.version}
</Text> </Text>
</motion.div>
)} )}
</AnimatePresence>
</Flex> </Flex>
</Flex> </Flex>
); );