summaryrefslogtreecommitdiffstats
path: root/frontend/components/Page.js
blob: ab14b1085c976e99a541d39c01ebb85172727d88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from 'react';
import styled, { ThemeProvider, injectGlobal } from 'styled-components';
import PropTypes from 'prop-types';
import Header from './Header';
import Meta from './Meta';
import { client } from '../lib/withData';
import { CURRENT_USER_QUERY } from '../queries';

const theme = {
  red: '#FF0000',
  black: '#393939',
  grey: '#3A3A3A',
  lightgrey: '#E1E1E1',
  offWhite: '#EDEDED',
  maxWidth: '1300px',
  bs: '0 12px 24px 0 rgba(0, 0, 0, 0.09)',
};

injectGlobal`
  html {
   box-sizing: border-box;
   font-size: 10px;
  }
  body {
   font-family: 'radnika next', sans-serif;
   padding: 0;
   background-color: #ffffff;
   margin: 0;
   font-size: 1.5rem;
   line-height: 2;
   background: red;
  }
  *, *:before, *:after {
    box-sizing: inherit;
  }
  a {
    color: ${theme.black};
    text-decoration: none;
  }
`;

const Inner = styled.div`
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem;
`;

const StyledPage = styled.div`
  color: ${props => props.theme.black};
  background: white;
`;

class Page extends React.Component {
  static propTypes = {
    children: PropTypes.node.isRequired,
  };
  componentDidMount() {
    // The first time we load in the client, we need to refetch the current user data
    if (typeof window !== 'undefined' && !window.__CLIENTLOADED__) {
      client.query({ query: CURRENT_USER_QUERY, fetchPolicy: 'network-only' });
      window.__CLIENTLOADED__ = true;
    }
  }
  render() {
    return (
      <ThemeProvider theme={theme}>
        <StyledPage className="main">
          <Meta />
          <Header />
          <Inner>{this.props.children}</Inner>
        </StyledPage>
      </ThemeProvider>
    );
  }
}

export default Page;