Skip to content

Instantly share code, notes, and snippets.

@samselikoff
Created October 21, 2021 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samselikoff/fe398363ba51184679cb36176a5ebaf5 to your computer and use it in GitHub Desktop.
Save samselikoff/fe398363ba51184679cb36176a5ebaf5 to your computer and use it in GitHub Desktop.
<div className="grid grid-cols-2 mt-8 gap-y-4 gap-x-4">
{categories.map((category) => (
<motion.button
whileTap={{ scale: 1.05 }}
onMouseDown={() => setCategoryPressed(category.id)}
onMouseUp={() => setCategoryPressed(null)}
className="relative w-full py-3 overflow-hidden bg-white border rounded-lg"
key={category.id}
>
<motion.span
initial={{ clipPath: "inset(0% 100% 0% 0%)" }}
animate={{
clipPath:
categoryPressed === category.id
? "inset(0% 0% 0% 0%)"
: "inset(0% 100% 0% 0%)",
}}
transition={{ duration: 1.5 }}
// onAnimationComplete={() => {
// if (categoryPressed) {
// alert("hi");
// }
// }}
className="absolute inset-0 flex items-center justify-center w-full text-white bg-blue-500 pointer-events-none"
>
{category.label}
</motion.span>
<span className="">{category.label}</span>
</motion.button>
))}
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment