File size: 1,488 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// @flow
import React, { Component } from 'react';
import {
  ClusterOne,
  ClusterTwo,
  ClusterThree,
  ClusterFour,
} from 'src/components/illustrations';
import Icon from 'src/components/icon';
import { FullscreenViewContainer, Illustrations, CloseLink } from './style';
import { ESC } from 'src/helpers/keycodes';

type Props = {
  closePath: string,
  children: any,
};

class FullscreenView extends Component<Props> {
  componentDidMount() {
    document.addEventListener('keydown', this.handleKeyPress, false);
  }

  componentWillUnmount() {
    document.removeEventListener('keydown', this.handleKeyPress, false);
  }

  handleKeyPress = (e: any) => {
    const { closePath } = this.props;
    // if person taps esc, close the dialog
    if (closePath && e.keyCode === ESC) {
      return (window.location = closePath);
    }
  };

  render() {
    const { closePath, children } = this.props;

    return (
      <FullscreenViewContainer>
        <CloseLink href={closePath}>
          <Icon glyph={'view-close'} size={32} />
        </CloseLink>

        <Illustrations>
          <ClusterOne src="/img/cluster-2.svg" role="presentation" />
          <ClusterTwo src="/img/cluster-1.svg" role="presentation" />
          <ClusterThree src="/img/cluster-5.svg" role="presentation" />
          <ClusterFour src="/img/cluster-4.svg" role="presentation" />
        </Illustrations>

        {children}
      </FullscreenViewContainer>
    );
  }
}

export default FullscreenView;