saleor-dashboard/src/components/MenuToggle.tsx

43 lines
742 B
TypeScript
Raw Normal View History

2019-08-09 10:26:22 +00:00
import React from "react";
2019-06-19 14:40:52 +00:00
interface MenuToggleProps {
ariaOwns?: string;
2019-10-30 14:34:24 +00:00
children: (props: {
actions: {
open: () => void;
close: () => void;
};
open: boolean;
}) => React.ReactElement<any>;
2019-06-19 14:40:52 +00:00
}
interface MenuToggleState {
open: boolean;
}
class MenuToggle extends React.Component<MenuToggleProps, MenuToggleState> {
state = {
open: false
};
handleClick = () => {
this.setState({ open: true });
};
handleClose = () => {
this.setState({ open: false });
};
render() {
const { children } = this.props;
const { open } = this.state;
return children({
2019-12-02 10:49:14 +00:00
actions: { close: this.handleClose, open: this.handleClick },
2019-06-19 14:40:52 +00:00
open
});
}
}
export default MenuToggle;