-
Notifications
You must be signed in to change notification settings - Fork 126
/
HubLinks.jsx
67 lines (63 loc) · 1.61 KB
/
HubLinks.jsx
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
60
61
62
63
64
65
66
67
import React from 'react';
import PropTypes from 'prop-types';
import recordEvent from '~/platform/monitoring/record-event';
const HubSection = ({ title, links }) => {
const listItems = links.map(({ href, text }, index) => (
<li key={`${href}--${index}`}>
<va-link
class="mhv-c-link"
disable-analytics
href={href}
text={text}
onClick={() => {
recordEvent({
event: 'nav-linkslist',
'links-list-header': text,
'links-list-section-header': title,
});
}}
/>
</li>
));
return (
<>
<h2>{title}</h2>
<nav>
<ul className="mhv-c-link-list">{listItems}</ul>
</nav>
</>
);
};
const HubLinks = ({ hubs }) => {
const hubLayout = hubs.map((h, index) => (
<div
key={h.title}
className="vads-l-col--12 medium-screen:vads-l-col mhv-u-grid-gap"
data-testid={`mhv-link-group-hub-${index}`}
>
<HubSection title={h.title} links={h.links} />
</div>
));
return (
<div className="vads-l-grid-container large-screen:vads-u-padding-x--0">
<div className="vads-l-row vads-u-margin-bottom--3">{hubLayout}</div>
</div>
);
};
HubSection.propTypes = {
links: PropTypes.arrayOf(
PropTypes.shape({ text: PropTypes.string, href: PropTypes.string }),
),
title: PropTypes.string,
};
HubLinks.propTypes = {
hubs: PropTypes.arrayOf(
PropTypes.shape({
title: PropTypes.string,
links: PropTypes.arrayOf(
PropTypes.shape({ text: PropTypes.string, href: PropTypes.string }),
),
}),
),
};
export default HubLinks;