MenuToggle improved

This commit is contained in:
tmshv committed 2022-09-06 20:53:55 +03:00
1 parent c2146e82bb
commit 733260f663
1 file changed
+11 -13
+11 -13
View File
@@ -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 }) => {
return ( const icon = open ? (
<Button
onClick={props.onClick}
style={props.style}
theme={"icon"}
>
{props.open ? (
<Cross1Icon width={24} height={24} /> <Cross1Icon width={24} height={24} />
) : ( ) : (
<HamburgerMenuIcon width={24} height={24} /> <HamburgerMenuIcon width={24} height={24} />
)} )
return (
<Button
{...props}
theme={"icon"}
>
{icon}
</Button> </Button>
) )
} }