feat(ui-toolkit): add bottom nav to jump to previous or next session
This commit is contained in:
parent
867e9b35a0
commit
8bb4c31aba
50
packages/ui-toolkit/src/styleguide/bottomNav.js
Normal file
50
packages/ui-toolkit/src/styleguide/bottomNav.js
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import remcalc from 'remcalc';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
import { Arrow } from 'joyent-icons';
|
||||||
|
|
||||||
|
const BottomNav = styled.div`
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin: 36px 0;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Link = styled.a`
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
color: #3b46cc;
|
||||||
|
font-size: 15px;
|
||||||
|
line-height: 24px;
|
||||||
|
text-decoration: none;
|
||||||
|
`;
|
||||||
|
|
||||||
|
export default props => {
|
||||||
|
const items = props.items.map(item => item.name);
|
||||||
|
const selectedIndex =
|
||||||
|
items.indexOf(props.link) > -1 ? items.indexOf(props.link) : 0;
|
||||||
|
|
||||||
|
if (!items.length) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BottomNav>
|
||||||
|
<div>
|
||||||
|
{selectedIndex > 0 ? (
|
||||||
|
<Link href={`/#!/${items[selectedIndex - 1]}`}>
|
||||||
|
<Arrow direction="right" fill="#3B46CC" /> {' '}
|
||||||
|
{items[selectedIndex - 1]}
|
||||||
|
</Link>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
{selectedIndex < items.length ? (
|
||||||
|
<Link href={`/#!/${items[selectedIndex + 1]}`}>
|
||||||
|
{items[selectedIndex + 1]} {' '}
|
||||||
|
<Arrow direction="left" fill="#3B46CC" />
|
||||||
|
</Link>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</BottomNav>
|
||||||
|
);
|
||||||
|
};
|
@ -7,6 +7,7 @@ import { ParallaxProvider } from 'react-scroll-parallax';
|
|||||||
import theme from '../theme';
|
import theme from '../theme';
|
||||||
import Header from './header';
|
import Header from './header';
|
||||||
import Parallax from './parallax';
|
import Parallax from './parallax';
|
||||||
|
import BottomNav from './bottomNav';
|
||||||
|
|
||||||
const Main = styled(Row)`
|
const Main = styled(Row)`
|
||||||
padding-top: ${remcalc(24)};
|
padding-top: ${remcalc(24)};
|
||||||
@ -71,6 +72,7 @@ const StyleGuideRenderer = ({
|
|||||||
)}
|
)}
|
||||||
<Col xs={hasSidebar ? 9 : 12} lg={hasSidebar ? 8 : 12}>
|
<Col xs={hasSidebar ? 9 : 12} lg={hasSidebar ? 8 : 12}>
|
||||||
{children}
|
{children}
|
||||||
|
<BottomNav items={toc.props.sections} link={link} />
|
||||||
</Col>
|
</Col>
|
||||||
</Main>
|
</Main>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
Loading…
Reference in New Issue
Block a user