|
1 | | -import React, { Component } from 'react'; |
| 1 | +// Import External Dependencies |
| 2 | +import React from 'react'; |
| 3 | + |
| 4 | +// Import Local Components |
2 | 5 | import Shield from '../Shield/Shield'; |
3 | 6 | import SidebarItem from '../SidebarItem/SidebarItem'; |
| 7 | + |
| 8 | +// Load Styling |
4 | 9 | import '../Sidebar/Sidebar.scss'; |
5 | 10 |
|
6 | | -export default class Sidebar extends Component { |
7 | | - render() { |
8 | | - let { className = '', pages, currentPage } = this.props; |
9 | | - let group; |
| 11 | +// Create and export the component |
| 12 | +export default ({ |
| 13 | + className = '', |
| 14 | + pages, |
| 15 | + currentPage, |
| 16 | + ...props |
| 17 | +}) => { |
| 18 | + let group; |
10 | 19 |
|
11 | | - return ( |
12 | | - <nav className={`sidebar ${className}`}> |
13 | | - <div className="sidebar__inner"> |
14 | | - <a href="https://github.com/webpack/webpack/releases"> |
15 | | - <Shield content="npm/v/webpack" label="webpack" /> |
16 | | - </a> |
| 20 | + return ( |
| 21 | + <nav className={`sidebar ${className}`}> |
| 22 | + <div className="sidebar__inner"> |
| 23 | + <a href="https://github.com/webpack/webpack/releases"> |
| 24 | + <Shield content="npm/v/webpack" label="webpack" /> |
| 25 | + </a> |
17 | 26 |
|
18 | | - {pages.map((page, index) => { |
19 | | - let displayGroup = group !== page.group && page.group !== '-'; |
20 | | - group = page.group; |
| 27 | + {pages.map((page, index) => { |
| 28 | + let displayGroup = group !== page.group && page.group !== '-'; |
| 29 | + group = page.group; |
21 | 30 |
|
22 | | - return ( |
23 | | - <div key={`sidebar-item-${index}`}> |
24 | | - {displayGroup ? <h4 className="sidebar__group">{group}</h4> : null} |
| 31 | + return ( |
| 32 | + <div key={`sidebar-item-${index}`}> |
| 33 | + {displayGroup ? <h4 className="sidebar__group">{group}</h4> : null} |
25 | 34 |
|
26 | | - <SidebarItem |
27 | | - index={index} |
28 | | - url={page.url} |
29 | | - title={page.title} |
30 | | - anchors={page.anchors} |
31 | | - currentPage={currentPage} |
32 | | - /> |
33 | | - </div> |
34 | | - ); |
35 | | - })} |
36 | | - </div> |
37 | | - </nav> |
38 | | - ); |
39 | | - } |
40 | | -} |
| 35 | + <SidebarItem |
| 36 | + index={index} |
| 37 | + url={page.url} |
| 38 | + title={page.title} |
| 39 | + anchors={page.anchors} |
| 40 | + currentPage={currentPage} |
| 41 | + /> |
| 42 | + </div> |
| 43 | + ); |
| 44 | + })} |
| 45 | + </div> |
| 46 | + </nav> |
| 47 | + ); |
| 48 | +}; |
0 commit comments