0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-15 14:52:39 +00:00

Working dropdown component on the Share Page

This commit is contained in:
Trevor Buckner
2021-10-13 11:53:01 -04:00
parent 2b2869dc47
commit a695540f60
4 changed files with 74 additions and 80 deletions

View File

@@ -68,6 +68,46 @@ const Nav = {
}
}),
dropdown : createClass({
getInitialState : function() {
return {
showDropdown : false
};
},
handleDropdown : function(show){
this.setState({
showDropdown : show
});
},
renderDropdown : function(dropdownChildren){
if(!this.state.showDropdown) return null;
return (
<div className='navDropdown'>
{dropdownChildren}
</div>
);
},
render : function () {
const dropdownChildren = React.Children.map(this.props.children, (child, i) => {
// Ignore the first child
if (i < 1) return;
return child;
});
return (
<div className='navDropdownContainer'
onMouseEnter={()=>this.handleDropdown(true)}
onMouseLeave={()=>this.handleDropdown(false)}>
{this.props.children[0]}
{this.renderDropdown(dropdownChildren)}
</div>
)
}
})
};