Commit f51ec9ce authored by Robert Knight's avatar Robert Knight

Support custom styles for menu content

This can be used to set a custom minimum width for a particular menu for
example.
parent a25b7679
...@@ -45,6 +45,7 @@ let ignoreNextClick = false; ...@@ -45,6 +45,7 @@ let ignoreNextClick = false;
function Menu({ function Menu({
align = 'left', align = 'left',
children, children,
contentClass,
defaultOpen = false, defaultOpen = false,
label, label,
menuIndicator = true, menuIndicator = true,
...@@ -128,7 +129,8 @@ function Menu({ ...@@ -128,7 +129,8 @@ function Menu({
<div <div
className={classnames( className={classnames(
'menu__content', 'menu__content',
`menu__content--align-${align}` `menu__content--align-${align}`,
contentClass
)} )}
role="menu" role="menu"
> >
...@@ -166,6 +168,11 @@ Menu.propTypes = { ...@@ -166,6 +168,11 @@ Menu.propTypes = {
propTypes.arrayOf(propTypes.object), propTypes.arrayOf(propTypes.object),
]), ]),
/**
* Additional CSS classes to apply to the menu.
*/
contentClass: propTypes.string,
/** /**
* Whether the menu is open or closed when initially rendered. * Whether the menu is open or closed when initially rendered.
*/ */
......
...@@ -126,4 +126,13 @@ describe('Menu', () => { ...@@ -126,4 +126,13 @@ describe('Menu', () => {
wrapper.setProps({ align: 'right' }); wrapper.setProps({ align: 'right' });
assert.isTrue(wrapper.exists('.menu__content--align-right')); assert.isTrue(wrapper.exists('.menu__content--align-right'));
}); });
it('applies custom content class', () => {
const wrapper = createMenu({
defaultOpen: true,
contentClass: 'special-menu',
});
const content = wrapper.find('.menu__content');
assert.isTrue(content.hasClass('special-menu'));
});
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment