forked from folio-org/stripes-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavListSection.js
59 lines (54 loc) · 1.29 KB
/
NavListSection.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
49
50
51
52
53
54
55
56
57
58
59
import React, { forwardRef } from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import Headline from '../Headline';
import css from './NavListSection.css';
import NavListSectionContext from './NavListSectionContext';
const NavListSection = forwardRef(({
activeLink,
children,
className,
label,
striped,
...rest
}, ref) => (
<NavListSectionContext.Provider
value={{
activeLink,
striped
}}
>
<div
className={classnames(css.root, { [css.striped]: striped }, className)}
ref={ref}
data-test-nav-list-section
{...rest}
>
{label && (
<div className={css.header} data-test-nav-list-section-header>
<Headline className={css.label}>
{label}
</Headline>
</div>
)}
<div className={css.content}>
{children}
</div>
</div>
</NavListSectionContext.Provider>
));
NavListSection.propTypes = {
activeLink: PropTypes.string,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]),
className: PropTypes.string,
label: PropTypes.node,
striped: PropTypes.bool,
};
NavListSection.defaultProps = {
activeLink: null,
};
NavListSection.displayName = 'NavListSection';
export default NavListSection;