-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(motion-icons): re-design
LandingNav
hamburger button motion (#769)
- Loading branch information
1 parent
8ba7af4
commit d908726
Showing
14 changed files
with
197 additions
and
138 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,20 +1,58 @@ | ||
import type { MotionProps } from '@components/utils'; | ||
import { motion } from '@components/utils'; | ||
import type { MouseEvent } from 'react'; | ||
import { useCallback, useState } from 'react'; | ||
import IconFactory from './IconFactory'; | ||
|
||
const Svg = () => ( | ||
<motion.svg | ||
viewBox="0 0 1024 1024" | ||
p-id="7522" | ||
width="2em" | ||
height="2em" | ||
fill="currentColor" | ||
> | ||
<motion.path | ||
d="M904 160H120c-4.4 0-8 3.6-8 8v64c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-64c0-4.4-3.6-8-8-8zM904 784H120c-4.4 0-8 3.6-8 8v64c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-64c0-4.4-3.6-8-8-8zM904 472H120c-4.4 0-8 3.6-8 8v64c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-64c0-4.4-3.6-8-8-8z" | ||
p-id="7523" | ||
/> | ||
</motion.svg> | ||
); | ||
const firstVariants: MotionProps['variants'] = { | ||
checked: { y: '30%', rotate: 45 }, | ||
unchecked: { y: 0, rotate: 0 }, | ||
}; | ||
|
||
const secondVariants: MotionProps['variants'] = { | ||
checked: { scaleX: 0 }, | ||
unchecked: { scaleX: 1 }, | ||
}; | ||
|
||
const thirdVariants: MotionProps['variants'] = { | ||
checked: { y: '-30%', rotate: -45 }, | ||
unchecked: { y: 0, rotate: 0 }, | ||
}; | ||
|
||
const Svg = (): JSX.Element => { | ||
const [isChecked, setIsChecked] = useState(false); | ||
const handleClick = useCallback( | ||
(event: MouseEvent) => setIsChecked(isChecked => !isChecked), | ||
[] | ||
); | ||
|
||
return ( | ||
<motion.svg | ||
viewBox="0 0 1024 1024" | ||
p-id="7522" | ||
width="2em" | ||
height="2em" | ||
fill="currentColor" | ||
initial={false} | ||
animate={isChecked ? 'checked' : 'unchecked'} | ||
onClick={handleClick} | ||
data-testid="hamburger-icon" | ||
> | ||
<motion.path | ||
d="M904 160H120c-4.4 0-8 3.6-8 8v64c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-64c0-4.4-3.6-8-8-8z" | ||
variants={firstVariants} | ||
/> | ||
<motion.path | ||
d="M904 472H120c-4.4 0-8 3.6-8 8v64c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-64c0-4.4-3.6-8-8-8z" | ||
variants={secondVariants} | ||
/> | ||
<motion.path | ||
d="M904 784H120c-4.4 0-8 3.6-8 8v64c0 4.4 3.6 8 8 8h784c4.4 0 8-3.6 8-8v-64c0-4.4-3.6-8-8-8z" | ||
variants={thirdVariants} | ||
/> | ||
</motion.svg> | ||
); | ||
}; | ||
|
||
const Hamburger = IconFactory(Svg, 'Hamburger'); | ||
export default Hamburger; |
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
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
Oops, something went wrong.
d908726
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
blog – ./
blog-sabertaz.vercel.app
blog.tazimi.dev
blog-git-main-sabertaz.vercel.app