<commit_before>import * as React from "react";
import Menu from "./Menu";
import {MenuItemProps} from "./Menu";
import ReactUtils from "../utils/ReactUtils";

export interface MenuButtonProps extends React.Props<MenuButton>
{
	menu:MenuItemProps[];
}

export interface MenuButtonState
{
	
}

export default class MenuButton extends React.Component<MenuButtonProps, MenuButtonState>
{
	element:HTMLElement;
	menu:Menu;
	constructor(props:MenuButtonProps)
	{
		super(props)
	}
	
	closeMenu=()=>
	{
		if(this.menu)
		{
			ReactUtils.closePopup(this.menu);
			this.menu = null;
		}
	}

	openMenu=()=>
	{
		var clientRect = this.element.getBoundingClientRect();
		// close the popup if it was already open
		if(this.menu)
		{
			this.closeMenu();
		}
		else
		{
			this.menu = ReactUtils.openPopup(
				<Menu menu={this.props.menu} 
					xPos={clientRect.left} 
					yPos={clientRect.top+this.element.clientHeight}
					onClick={this.closeMenu}
				/>,
				true
			) as Menu;
		}
	}
	
	render():JSX.Element
	{
		return (
			<button ref={(elt:Element) => this.element = elt as HTMLElement} onMouseDown={this.openMenu}>
				<i className="fa fa-bars"/>
			</button>
		);
	}
}<commit_msg>modified MenuButton to accomodate optional children<commit_after>import * as React from "react";
import * as ReactDOM from 'react-dom';
import Menu from "./Menu";
import {MenuItemProps} from "./Menu";
import ReactUtils from "../utils/ReactUtils";
import Button from "../semantic-ui/Button";

export interface MenuButtonProps extends React.Props<MenuButton>
{
	menu:MenuItemProps[];
	showHamburgerIcon?:boolean;
}

export interface MenuButtonState
{
	
}

export default class MenuButton extends React.Component<MenuButtonProps, MenuButtonState>
{
	element:HTMLElement;
	menu:Menu;
	constructor(props:MenuButtonProps)
	{
		super(props)
	}

	static defaultProps:MenuButtonProps = { showHamburgerIcon : true, menu:[] };

	componentDidMount (){
		this.element = ReactDOM.findDOMNode(this) as HTMLElement;
	}

	closeMenu=()=>
	{
		if(this.menu)
		{
			ReactUtils.closePopup(this.menu);
			this.menu = null;
		}
	}

	openMenu=()=>
	{
		var clientRect = this.element.getBoundingClientRect();
		// close the popup if it was already open
		if(this.menu)
		{
			this.closeMenu();
		}
		else
		{
			this.menu = ReactUtils.openPopup(
				<Menu menu={this.props.menu} 
					xPos={clientRect.left} 
					yPos={clientRect.top+this.element.clientHeight}
					onClick={this.closeMenu}
				/>,
				true
			) as Menu;
		}
	}
	
	render():JSX.Element
	{
		return (
			<Button onMouseDown={this.openMenu}>
				{ this.props.showHamburgerIcon ? <i className="fa fa-bars"/> : '' }
				{ this.props.children }
			</Button>
		);
	}
}
{'fraction_non_alphanumeric': 0.13710879284649777, 'fraction_numerical': 0.0, 'mean_word_length': 3.7606382978723403, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '944993', 'n_tokens_mistral': 1034, 'n_tokens_neox': 920, 'n_words': 182}