forked from nodejs/nodejs.dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnavigation-section.tsx
More file actions
45 lines (41 loc) · 1.03 KB
/
navigation-section.tsx
File metadata and controls
45 lines (41 loc) · 1.03 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
44
45
import React from 'react';
import { NavigationSectionItem } from '../types';
import NavigationItem from './navigation-item';
type 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) => {
return (
<ul className="side-nav__list">
<h2 className="side-nav__title">{title}</h2>
{section.map((item: NavigationSectionItem) => {
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;