-
Notifications
You must be signed in to change notification settings - Fork 37
/
MenuSection.js
48 lines (44 loc) · 1.13 KB
/
MenuSection.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
* MenuSection
*/
import React from 'react';
import classNames from 'classnames';
import PropTypes from 'prop-types';
import uniqueId from 'lodash/uniqueId';
import css from './MenuSection.css';
import Headline from '../Headline';
const MenuSection = ({ className, children, id, label, labelTag = 'h3', ...rest }) => {
const sectionId = id || uniqueId('menu-section-');
return (
<section
id={sectionId}
className={classNames(css.menuSection, className)}
aria-labelledby={`${sectionId}-label`}
{...rest}
data-test-menu-section
>
{ label && (
<Headline
id={`${sectionId}-label`}
size="small"
margin="none"
tag={labelTag}
className={css.menuSection__label}
faded
data-test-menu-section-label
>
{label}
</Headline>
)}
{children}
</section>
);
};
MenuSection.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
id: PropTypes.string,
label: PropTypes.node,
labelTag: PropTypes.oneOf(['div', 'h2', 'h3', 'h4', 'h5', 'h6'])
};
export default MenuSection;