menu animation
This commit is contained in:
parent
e21067a99f
commit
2aa5ab58d4
|
|
@ -3,48 +3,43 @@ import { cn } from "@/shared/lib";
|
|||
import Button from "@mui/material/Button";
|
||||
import { Link } from "@tanstack/react-router";
|
||||
|
||||
interface LinkItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
||||
interface LinkItemProps {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
to: string;
|
||||
isSelected?: boolean;
|
||||
}
|
||||
|
||||
export default function LinkItem({
|
||||
children,
|
||||
className,
|
||||
to,
|
||||
isSelected = false,
|
||||
...props
|
||||
}: LinkItemProps) {
|
||||
return (
|
||||
<li className={cn("", className)} {...props}>
|
||||
<Link to={to}>
|
||||
<Button
|
||||
variant={isSelected ? "contained" : "text"}
|
||||
sx={{
|
||||
width: "100%",
|
||||
justifyContent: "start",
|
||||
textTransform: "none",
|
||||
fontWeight: "semibold",
|
||||
color: isSelected ? "white" : "#9B99B0",
|
||||
borderRadius: "6px",
|
||||
<Link to={to}>
|
||||
<Button
|
||||
variant={isSelected ? "contained" : "text"}
|
||||
sx={{
|
||||
width: "100%",
|
||||
justifyContent: "start",
|
||||
textTransform: "none",
|
||||
fontWeight: "semibold",
|
||||
color: isSelected ? "white" : "#9B99B0",
|
||||
borderRadius: "6px",
|
||||
boxShadow: "none",
|
||||
paddingInline: "16px",
|
||||
":hover": {
|
||||
boxShadow: "none",
|
||||
paddingInline: "16px",
|
||||
":hover": {
|
||||
boxShadow: "none",
|
||||
},
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"bg-neutral mr-2 h-2 w-2 rounded-full",
|
||||
isSelected && "bg-white",
|
||||
)}
|
||||
/>
|
||||
<span>{children}</span>
|
||||
</Button>
|
||||
</Link>
|
||||
</li>
|
||||
},
|
||||
}}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
"mr-2 h-2 w-2 rounded-full bg-neutral",
|
||||
isSelected && "bg-white",
|
||||
)}
|
||||
/>
|
||||
<span>{children}</span>
|
||||
</Button>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,28 @@
|
|||
import { Children } from "react";
|
||||
import { cn } from "@/shared/lib";
|
||||
import { motion, AnimatePresence } from "framer-motion";
|
||||
|
||||
interface RootProps extends React.HTMLAttributes<HTMLUListElement> {
|
||||
interface RootProps {
|
||||
children?: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export default function Root({ className, ...props }: RootProps) {
|
||||
return <ul className={cn("", className)} {...props} />;
|
||||
export default function Root({ children, className }: RootProps) {
|
||||
return (
|
||||
<motion.ul className={cn("", className)}>
|
||||
<AnimatePresence initial={false}>
|
||||
{Children.map(children, (child, index) => (
|
||||
<motion.li
|
||||
layout
|
||||
key={index}
|
||||
initial={{ opacity: 0, height: 0 }}
|
||||
animate={{ opacity: 1, height: "auto" }}
|
||||
exit={{ opacity: 0, height: 0 }}
|
||||
>
|
||||
{child}
|
||||
</motion.li>
|
||||
))}
|
||||
</AnimatePresence>
|
||||
</motion.ul>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user