forked from nodejs/nodejs.dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnavigation-section.tsx
More file actions
43 lines (39 loc) · 1.17 KB
/
navigation-section.tsx
File metadata and controls
43 lines (39 loc) · 1.17 KB
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
import React from 'react';
import { NavigationSectionItem } from '../types';
import NavigationItem from './navigation-item';
interface Props {
key: string;
title: string;
section: NavigationSectionItem[];
currentSlug: string;
onItemClick: () => void;
readSections: Set<NavigationSectionItem['slug']>;
autoScroll: (height: number) => void;
}
const NavigationSection = ({ title, section, currentSlug, onItemClick, readSections, autoScroll }: Props): JSX.Element => {
return (
<ul className="side-nav__list">
<h2 className="t-body2 side-nav__title">
<i className="material-icons">offline_bolt</i>
{title}
</h2>
{section.map(
(item: NavigationSectionItem): JSX.Element => {
const isRead: boolean = readSections.has(item.slug);
return (
<NavigationItem
key={item.slug}
title={item.title}
slug={item.slug}
isRead={isRead}
isActive={item.slug === currentSlug}
onClick={onItemClick}
autoScroll={autoScroll}
/>
);
}
)}
</ul>
);
};
export default NavigationSection;