1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-14 07:10:05 +02:00
copilot/ui/docs/containers/app/navigation.js

49 lines
872 B
JavaScript
Raw Normal View History

2016-10-25 16:01:42 +03:00
const paramCase = require('param-case');
const React = require('react');
const ReactRouter = require('react-router');
const Docs = require('../../../src/docs');
const {
Link
} = ReactRouter;
const getList = (items, parent) => {
let isNested = false;
const lis = Object.keys(items).map((name) => {
const item = items[name];
const param = paramCase(name);
const href = parent ? `${parent}/${param}` : `/${param}`;
isNested = (typeof item !== 'string');
return (
2016-10-26 16:05:07 +03:00
<li key={href}>
2016-10-25 16:01:42 +03:00
<Link to={href}>{name}</Link>
{isNested ? getList(item, href) : null}
</li>
);
});
return (
2016-10-26 16:05:07 +03:00
<ul>
2016-10-25 16:01:42 +03:00
{lis}
</ul>
);
};
2016-10-25 22:15:33 +03:00
const Navigation = () => {
2016-10-25 16:01:42 +03:00
return (
<div>
2016-10-26 16:05:07 +03:00
<div>
2016-10-25 16:01:42 +03:00
<nav role='navigation'>
{getList(Docs)}
</nav>
</div>
</div>
);
};
2016-10-25 22:15:33 +03:00
module.exports = Navigation;