|
| 1 | +import { |
| 2 | + GithubIcon, |
| 3 | + InstagramIcon, |
| 4 | + LinkedInIcon, |
| 5 | + MediumIcon, |
| 6 | + SunIcon, |
| 7 | +} from '@assets'; |
| 8 | +import { IconButton, transition, VStack } from '@chakra-ui/react'; |
| 9 | +import { useCursor } from '@components'; |
| 10 | +import { useRef } from 'react'; |
| 11 | + |
| 12 | +const IconProps = { |
| 13 | + variant: 'ghost', |
| 14 | + color: 'white', |
| 15 | + transition: 'transform 0.3s', |
| 16 | + transform: 'scale(1.5)', |
| 17 | + _hover: { |
| 18 | + transform: 'scale(2.2)', |
| 19 | + }, |
| 20 | +}; |
| 21 | + |
| 22 | +const SocialNavigation = () => { |
| 23 | + const ref = useRef<HTMLDivElement>(null); |
| 24 | + const { setCursorInsets } = useCursor(); |
| 25 | + const onMouseEnter = () => { |
| 26 | + const { width, height, top, left } = |
| 27 | + ref.current?.getBoundingClientRect() || { |
| 28 | + width: 56, |
| 29 | + height: 56, |
| 30 | + top: 0, |
| 31 | + left: 0, |
| 32 | + }; |
| 33 | + setCursorInsets(undefined); |
| 34 | + setTimeout(() => { |
| 35 | + setCursorInsets({ height, width, top, left, borderRadius: '30px' }); |
| 36 | + }, 0); |
| 37 | + }; |
| 38 | + const onMouseLeave = () => { |
| 39 | + setCursorInsets(undefined); |
| 40 | + }; |
| 41 | + return ( |
| 42 | + <VStack |
| 43 | + ref={ref} |
| 44 | + position={'fixed'} |
| 45 | + bottom={20} |
| 46 | + left={10} |
| 47 | + px={2} |
| 48 | + py={5} |
| 49 | + border={'1px solid white'} |
| 50 | + borderRadius={'30px'} |
| 51 | + outline={'1px solid violet'} |
| 52 | + onMouseEnter={onMouseEnter} |
| 53 | + onMouseLeave={onMouseLeave} |
| 54 | + > |
| 55 | + <IconButton aria-label="" icon={<GithubIcon />} {...IconProps} /> |
| 56 | + <IconButton icon={<LinkedInIcon />} aria-label="" {...IconProps} /> |
| 57 | + <IconButton icon={<MediumIcon />} aria-label="" {...IconProps} /> |
| 58 | + <IconButton icon={<InstagramIcon />} aria-label="" {...IconProps} /> |
| 59 | + </VStack> |
| 60 | + ); |
| 61 | +}; |
| 62 | + |
| 63 | +export default SocialNavigation; |
0 commit comments