Skip to content

Commit

Permalink
Adjust page layout
Browse files Browse the repository at this point in the history
  • Loading branch information
jxnblk committed Jul 16, 2017
1 parent 8df94ee commit d1a88ee
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 36 deletions.
47 changes: 30 additions & 17 deletions docs/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
Box,
Border,
} from 'rebass'
import NavBar from './NavBar'
import Home from './Home'
import GettingStarted from './GettingStarted'
import PropsView from './PropsView'
Expand All @@ -22,10 +23,11 @@ import Component from './Component'
import SideNav from './SideNav'

const StickySide = styled(Box)`
display: none;
// display: none;
@media screen and (min-width: 32em) {
flex: none;
order: 0;
display: block;
position: -webkit-sticky;
position: sticky;
Expand All @@ -36,20 +38,24 @@ const StickySide = styled(Box)`
}
`

const App = props => (
<Provider theme={theme}>
<Home pattern='/' />
{props.location.pathname !== '/' && (
<Flex>
<StickySide w={[ 1, 192 ]}>
<Border right>
<SideNav {...props} />
</Border>
</StickySide>
<Box flex='0 1 auto' w={[ 1, 'calc(100% - 192px)' ]}>
const App = props => {
const { pathname } = props.location

return (
<Provider theme={theme}>
<NavBar
bg={pathname === '/' ? 'transparent' : 'black'}
/>
<Home pattern='/' />
<Flex wrap>
<Box
flex='0 1 auto'
order={[ null, 2 ]}
w={[ 1, 'calc(100% - 192px)' ]}>
<Container
mt={5}
pb={6}
mt={6}
px={4}
pb={3}
width={1024}>
<GettingStarted pattern='/getting-started' />
<PropsView pattern='/props' />
Expand All @@ -61,10 +67,17 @@ const App = props => (
<Component pattern='/components/:name' />
</Container>
</Box>
{pathname !== '/' && (
<StickySide w={[ 1, 192 ]}>
<Border right>
<SideNav {...props} />
</Border>
</StickySide>
)}
</Flex>
)}
</Provider>
)
</Provider>
)
}

const theme = {
maxWidth: 1280
Expand Down
2 changes: 0 additions & 2 deletions docs/src/Home.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import { createView } from 'rrx'
import { Container } from 'rebass'
import NavBar from './NavBar'
import Header from './Header'
import About from './About'
import Features from './Features'
Expand All @@ -20,7 +19,6 @@ import Footer from './Footer'

const Home = props => (
<div>
<NavBar />
<Header />
<About />
<Features />
Expand Down
19 changes: 11 additions & 8 deletions docs/src/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ import Hide from 'hidden-styled'
import Tweet from './Tweet'

const NavBar = props => (
<Absolute top left right>
<Toolbar bg='transparent'>
<Hide xs>
<NavLink
href='http://jxnblk.com/rebass'
children='Rebass'
/>
</Hide>
<Absolute
z={2}
top
left
right>
<Toolbar bg='transparent' {...props}>
<NavLink
is={Link}
href='/'
children='Rebass'
/>
<Hide xs>
<NavLink
href='https://github.com/jxnblk/rebass'
Expand Down
2 changes: 1 addition & 1 deletion docs/src/Pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from 'rebass'

const Pagination = props => (
<Flex my={5}>
<Flex my={[ 3, 5 ]}>
{props.previous && (
<NavLink
is={Link}
Expand Down
27 changes: 19 additions & 8 deletions docs/src/SideNav.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
import React from 'react'
import { Link as RLink } from 'rrx'
import styled from 'styled-components'
import {
Flex,
Box,
Subhead,
Divider,
NavLink
} from 'rebass'
import { components } from './examples'

const Link = props => (
const Link = styled(props => (
<NavLink
is={RLink}
href={'#' + props.name}
children={props.name}
{...props}
w={1}
f={[ 0, 1 ]}
w={[ 1/2, 1 ]}
px={3}
py={1}
/>
)
))([], props => ({
color: props.active ? 'white' : 'inherit',
backgroundColor: props.active ? props.theme.colors.blue : 'transparent',
'&:hover': {
backgroundColor: props.active ? props.theme.colors.blue : null,
}
}))

const SideNav = props => {
const { pathname } = props.location

return (
<nav>
<Box py={3}>
<Link href='/' children='Rebass' />
<Flex wrap py={4}>
<Divider w={1} my={3} color='gray3' />
<Link
href='/getting-started'
children='Getting Started'
Expand Down Expand Up @@ -57,7 +66,7 @@ const SideNav = props => {
children='Server Side Rendering'
active={pathname === '/server-side-rendering'}
/>
<Divider my={3} color='gray3' />
<Divider w={1} my={3} color='gray3' />
<Link
href='/components'
children={components.length + ' Components'}
Expand All @@ -71,22 +80,24 @@ const SideNav = props => {
active={pathname === '/components/' + name}
/>
))}
<Divider my={3} color='gray3' />
<Divider w={1} my={3} color='gray3' />
<Link
href='/storybook'
children='Storybook'
/>
<Link
is='a'
f={0}
href='https://github.com/jxnblk/rebass'
children='GitHub'
/>
<Link
f={0}
is='a'
href='http://jxnblk.com'
children='Made by Jxnblk'
/>
</Box>
</Flex>
</nav>
)
}
Expand Down

0 comments on commit d1a88ee

Please sign in to comment.