2017-12-15 16:09:09 +02:00
|
|
|
import React from 'react';
|
2018-01-30 18:04:03 +02:00
|
|
|
import { Grid, Row, Col } from 'joyent-react-styled-flexboxgrid';
|
2017-12-15 16:09:09 +02:00
|
|
|
import styled, { ThemeProvider } from 'styled-components';
|
|
|
|
import remcalc from 'remcalc';
|
|
|
|
import is from 'styled-is';
|
2018-01-26 15:48:02 +02:00
|
|
|
|
|
|
|
import theme from '../theme';
|
2017-12-15 16:09:09 +02:00
|
|
|
|
|
|
|
const Main = styled(Row)`
|
|
|
|
padding-top: ${remcalc(40)};
|
|
|
|
`;
|
|
|
|
|
|
|
|
const Sticky = styled.div`
|
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
|
|
|
z-index: 9;
|
|
|
|
|
|
|
|
${is('sidebar')`
|
|
|
|
top: ${remcalc(100)};
|
2018-01-29 20:09:18 +02:00
|
|
|
margin-left: ${remcalc(10)};
|
2017-12-15 16:53:59 +02:00
|
|
|
max-height: 85vh;
|
|
|
|
overflow: auto;
|
2017-12-15 16:09:09 +02:00
|
|
|
`};
|
|
|
|
`;
|
|
|
|
|
|
|
|
const fullTheme = {
|
|
|
|
...theme,
|
2018-01-29 20:09:18 +02:00
|
|
|
flexboxgrid: {
|
|
|
|
...theme.flexboxgrid,
|
|
|
|
breakpoints: {
|
|
|
|
xs: 0, // em
|
|
|
|
sm: 48, // em
|
|
|
|
md: 68, // em
|
|
|
|
lg: 85 // em
|
|
|
|
},
|
|
|
|
container: {
|
|
|
|
sm: 48, // rem
|
|
|
|
md: 68, // rem
|
|
|
|
lg: 85 // rem
|
|
|
|
}
|
2017-12-15 16:09:09 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const StyleGuideRenderer = ({
|
|
|
|
title,
|
|
|
|
homepageUrl,
|
|
|
|
children,
|
|
|
|
toc,
|
|
|
|
hasSidebar
|
|
|
|
}) => (
|
|
|
|
<ThemeProvider theme={fullTheme}>
|
2018-01-26 15:48:02 +02:00
|
|
|
<Grid>
|
|
|
|
<Main>
|
|
|
|
{hasSidebar && (
|
|
|
|
<Col xs={3}>
|
|
|
|
<Sticky sidebar>{toc}</Sticky>
|
2017-12-15 16:09:09 +02:00
|
|
|
</Col>
|
2018-01-26 15:48:02 +02:00
|
|
|
)}
|
|
|
|
<Col xs={hasSidebar ? 9 : 12} lg={hasSidebar ? 8 : 12}>
|
|
|
|
{children}
|
|
|
|
</Col>
|
|
|
|
</Main>
|
|
|
|
</Grid>
|
2017-12-15 16:09:09 +02:00
|
|
|
</ThemeProvider>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default StyleGuideRenderer;
|