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 Button from "@mui/material/Button";
|
||||||
import { Link } from "@tanstack/react-router";
|
import { Link } from "@tanstack/react-router";
|
||||||
|
|
||||||
interface LinkItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
interface LinkItemProps {
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
className?: string;
|
|
||||||
to: string;
|
to: string;
|
||||||
isSelected?: boolean;
|
isSelected?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function LinkItem({
|
export default function LinkItem({
|
||||||
children,
|
children,
|
||||||
className,
|
|
||||||
to,
|
to,
|
||||||
isSelected = false,
|
isSelected = false,
|
||||||
...props
|
|
||||||
}: LinkItemProps) {
|
}: LinkItemProps) {
|
||||||
return (
|
return (
|
||||||
<li className={cn("", className)} {...props}>
|
<Link to={to}>
|
||||||
<Link to={to}>
|
<Button
|
||||||
<Button
|
variant={isSelected ? "contained" : "text"}
|
||||||
variant={isSelected ? "contained" : "text"}
|
sx={{
|
||||||
sx={{
|
width: "100%",
|
||||||
width: "100%",
|
justifyContent: "start",
|
||||||
justifyContent: "start",
|
textTransform: "none",
|
||||||
textTransform: "none",
|
fontWeight: "semibold",
|
||||||
fontWeight: "semibold",
|
color: isSelected ? "white" : "#9B99B0",
|
||||||
color: isSelected ? "white" : "#9B99B0",
|
borderRadius: "6px",
|
||||||
borderRadius: "6px",
|
boxShadow: "none",
|
||||||
|
paddingInline: "16px",
|
||||||
|
":hover": {
|
||||||
boxShadow: "none",
|
boxShadow: "none",
|
||||||
paddingInline: "16px",
|
},
|
||||||
":hover": {
|
}}
|
||||||
boxShadow: "none",
|
>
|
||||||
},
|
<span
|
||||||
}}
|
className={cn(
|
||||||
>
|
"mr-2 h-2 w-2 rounded-full bg-neutral",
|
||||||
<span
|
isSelected && "bg-white",
|
||||||
className={cn(
|
)}
|
||||||
"bg-neutral mr-2 h-2 w-2 rounded-full",
|
/>
|
||||||
isSelected && "bg-white",
|
<span>{children}</span>
|
||||||
)}
|
</Button>
|
||||||
/>
|
</Link>
|
||||||
<span>{children}</span>
|
|
||||||
</Button>
|
|
||||||
</Link>
|
|
||||||
</li>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,28 @@
|
||||||
|
import { Children } from "react";
|
||||||
import { cn } from "@/shared/lib";
|
import { cn } from "@/shared/lib";
|
||||||
|
import { motion, AnimatePresence } from "framer-motion";
|
||||||
|
|
||||||
interface RootProps extends React.HTMLAttributes<HTMLUListElement> {
|
interface RootProps {
|
||||||
|
children?: React.ReactNode;
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Root({ className, ...props }: RootProps) {
|
export default function Root({ children, className }: RootProps) {
|
||||||
return <ul className={cn("", className)} {...props} />;
|
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