Skip to content

Commit

Permalink
Refactor templates
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Dec 11, 2018
1 parent eec06db commit db4098b
Show file tree
Hide file tree
Showing 14 changed files with 455 additions and 447 deletions.
8 changes: 8 additions & 0 deletions src/components/Container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import styled from 'styled-components'

const Container = styled.div`
max-width: 800px;
margin: 0 auto;
`

export default Container
8 changes: 6 additions & 2 deletions src/components/LoginControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import Button from './Button'
import { Button as MaterialButton } from '@material-ui/core'
import { signOut, getCachedUserDetails } from '../services/moocfi'
import { navigate } from 'gatsby'
import LoginStateContext from '../contexes/LoginStateContext'
import LoginStateContext, {
withLoginStateContext,
} from '../contexes/LoginStateContext'

export default class LoginControls extends React.Component {
class LoginControls extends React.Component {
static contextType = LoginStateContext

doSignOut = e => {
Expand Down Expand Up @@ -43,3 +45,5 @@ export default class LoginControls extends React.Component {
)
}
}

export default withLoginStateContext(LoginControls)
8 changes: 8 additions & 0 deletions src/contexes/LoginStateContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ export class LoginStateContextProvider extends React.Component {
}
}

export function withLoginStateContext(Component) {
return props => (
<LoginStateContextProvider>
<Component {...props} />
</LoginStateContextProvider>
)
}

export default LoginStateContext
12 changes: 8 additions & 4 deletions src/pages/404.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React from 'react'
import Layout from '../templates/layout'
import Layout from '../templates/Layout'
import Container from '../components/Container'
import { withLoginStateContext } from '../contexes/LoginStateContext'

const NotFoundPage = () => (
<Layout>
<h1>NOT FOUND</h1>
<p>You just hit a route that doesn&#39;t exist... the sadness.</p>
<Container>
<h1>Ei löytynyt</h1>
<p>Olet päätynyt osoitteeseen, jota ei ole olemassa.</p>
</Container>
</Layout>
)

export default NotFoundPage
export default withLoginStateContext(NotFoundPage)
Loading

0 comments on commit db4098b

Please sign in to comment.