AllenYuan

Untitled

Jun 1st, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. import React from 'react';
  2. import { Helmet } from 'react-helmet';
  3. import styled from 'styled-components';
  4. import PropTypes from 'prop-types';
  5. import { connect } from 'react-redux';
  6. import constants from '../constants';
  7.  
  8. // styling
  9. const Styled = styled.div`
  10. .container {
  11. display: flex;
  12. justify-content: center;
  13. flex-direction: column;
  14. align-items: center;
  15. padding-top: 50px;
  16. }
  17.  
  18. .message {
  19. font-weight: var(--fontWeightLight);
  20. text-align: center;
  21. font-size: 32px;
  22. width: 420px;
  23. margin-top: 20px;
  24. }
  25.  
  26. .FourOhFour {
  27. background-color: var(--textColorPriamry);
  28. color: var(--textColorSecondary);
  29. text-transform: uppercase;
  30. padding: 6px 10px;
  31. font-family: 'Courier New', Courier, monospace;
  32. font-weight: bold;
  33. margin: 30px auto 0;
  34. opacity: 0.6;
  35. }
  36.  
  37. .msg {
  38. color: ${constants.colorRed};
  39. }
  40. `;
  41.  
  42. // select a random image
  43. const imageList = ['sad', 'bawl', 'charm-cry'];
  44. const randomImage = imageList[Math.floor(Math.random() * imageList.length)];
  45.  
  46. // render 404 page
  47. const FourOhFour = ({ strings, msg }) => (
  48. <Styled>
  49. <div className = "container">
  50. <Helmet title={`${strings.error} 404`} />
  51. <img
  52. src={`/assets/images/${randomImage}.gif`}
  53. alt=""
  54. />
  55. <div className="message">
  56. {strings.error_four_oh_four_message}
  57. </div>
  58. <div className="msg">
  59. {msg}
  60. </div>
  61. <div className = "FourOhFour">
  62. {strings.error} 404
  63. </div>
  64. </div>
  65. </Styled>
  66. );
  67.  
  68. const mapStateToProps = state => ({
  69. strings: state.app.strings,
  70. });
  71.  
  72. FourOhFour.propTypes = {
  73. strings: PropTypes.shape({}),
  74. msg: PropTypes.string,
  75. };
  76.  
  77. export default connect(mapStateToProps, null)(FourOhFour);
Add Comment
Please, Sign In to add comment