1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-11-15 17:45:28 +01:00
portfolio/src/pages/404.jsx

73 lines
1.7 KiB
React
Raw Normal View History

2018-05-06 23:22:42 +02:00
import React, { Component } from 'react'
2018-06-23 00:54:45 +02:00
import PropTypes from 'prop-types'
2018-06-22 18:54:29 +02:00
import { Link } from 'gatsby'
2018-05-06 23:22:42 +02:00
import giphyAPI from 'giphy-js-sdk-core'
import Layout from '../components/Layout'
2018-05-06 23:22:42 +02:00
import Content from '../components/atoms/Content'
2018-07-14 19:22:38 +02:00
import Button from '../components/atoms/Button'
2018-05-06 23:22:42 +02:00
import './404.scss'
2018-04-25 23:37:23 +02:00
2018-05-06 23:22:42 +02:00
// Famous last words:
// "It's just the 404 page so why not expose the dev API key"
const giphyClient = giphyAPI('LfXRwufRyt6PK414G2kKJBv3L8NdnxyR')
const tag = 'fail-cat'
class NotFound extends Component {
constructor(props) {
super(props)
this.state = { gif: '' }
this.handleClick = this.handleClick.bind(this)
}
componentDidMount() {
this.getRandomGif()
}
getRandomGif() {
giphyClient
.random('gifs', { tag })
.then(response => {
const gif = response.data.images.original.mp4
this.setState({ gif })
})
.catch(err => {
return err
})
}
handleClick(e) {
e.preventDefault()
this.getRandomGif()
}
render() {
return (
2018-06-23 00:54:45 +02:00
<Layout location={this.props.location}>
<Content className="content content--404">
<h1>Shenanigans, page not found.</h1>
<p>
You might want to check the url, or{' '}
<Link to={'/'}>go back to the homepage</Link>. Or just check out
2018-07-14 19:22:38 +02:00
some cat fail gifs, entirely your choice.
</p>
<video className="gif" src={this.state.gif} autoPlay loop />
<div>
2018-07-14 19:22:38 +02:00
<Button onClick={this.handleClick}>
Show me another cat fail gif
2018-07-14 19:22:38 +02:00
</Button>
</div>
</Content>
</Layout>
2018-05-06 23:22:42 +02:00
)
}
}
2018-04-25 23:37:23 +02:00
2018-06-23 00:54:45 +02:00
NotFound.propTypes = {
location: PropTypes.object
}
2018-04-25 23:37:23 +02:00
export default NotFound