MenuToggle improved
This commit is contained in:
1 parent
c2146e82bb
commit
733260f663
1 file changed
+10
-12
@@ -1,24 +1,22 @@
|
|||||||
import { Button } from "@/ui/Button"
|
import { Button, ButtonProps } from "@/ui/Button"
|
||||||
import { HamburgerMenuIcon, Cross1Icon } from "@radix-ui/react-icons"
|
import { HamburgerMenuIcon, Cross1Icon } from "@radix-ui/react-icons"
|
||||||
|
|
||||||
export interface IMenuToggleProps {
|
export type MenuToggleProps = Omit<ButtonProps, "theme"> & {
|
||||||
style?: React.CSSProperties
|
|
||||||
open: boolean
|
open: boolean
|
||||||
onClick: () => void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MenuToggle: React.FC<IMenuToggleProps> = props => {
|
export const MenuToggle: React.FC<MenuToggleProps> = ({ open, ...props }) => {
|
||||||
|
const icon = open ? (
|
||||||
|
<Cross1Icon width={24} height={24} />
|
||||||
|
) : (
|
||||||
|
<HamburgerMenuIcon width={24} height={24} />
|
||||||
|
)
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
onClick={props.onClick}
|
{...props}
|
||||||
style={props.style}
|
|
||||||
theme={"icon"}
|
theme={"icon"}
|
||||||
>
|
>
|
||||||
{props.open ? (
|
{icon}
|
||||||
<Cross1Icon width={24} height={24} />
|
|
||||||
) : (
|
|
||||||
<HamburgerMenuIcon width={24} height={24} />
|
|
||||||
)}
|
|
||||||
</Button>
|
</Button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user