aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/notice.js
blob: 23ded9d5d23bf9ee63c941d5eb30b6611d33b9eb (plain) (blame)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
const ReactMarkdown = require('react-markdown')
const linker = require('extension-link-enabler')
const findDOMNode = require('react-dom').findDOMNode

module.exports = Notice

inherits(Notice, Component)
function Notice () {
  Component.call(this)
}

Notice.prototype.render = function () {
  const { notice, onConfirm } = this.props
  const { title, date, body } = notice
  const state = this.state || { disclaimerDisabled: true }
  const disabled = state.disclaimerDisabled

  return (
    h('.flex-column.flex-center.flex-grow', [
      h('h3.flex-center.text-transform-uppercase.terms-header', {
        style: {
          background: '#EBEBEB',
          color: '#AEAEAE',
          width: '100%',
          fontSize: '20px',
          textAlign: 'center',
          padding: 6,
        },
      }, [
        title,
      ]),

      h('h5.flex-center.text-transform-uppercase.terms-header', {
        style: {
          background: '#EBEBEB',
          color: '#AEAEAE',
          marginBottom: 24,
          width: '100%',
          fontSize: '20px',
          textAlign: 'center',
          padding: 6,
        },
      }, [
        date,
      ]),

      h('style', `

        .markdown {
          overflow-x: hidden;
        }

        .markdown h1, .markdown h2, .markdown h3 {
          margin: 10px 0;
          font-weight: bold;
        }

        .markdown strong {
          font-weight: bold;
        }
        .markdown em {
          font-style: italic;
        }

        .markdown p {
          margin: 10px 0;
        }

        .markdown a {
          color: #df6b0e;
        }

      `),

      h('div.markdown', {
        onScroll: (e) => {
          var object = e.currentTarget
          if (object.offsetHeight + object.scrollTop + 100 >= object.scrollHeight) {
            this.setState({disclaimerDisabled: false})
          }
        },
        style: {
          background: 'rgb(235, 235, 235)',
          height: '310px',
          padding: '6px',
          width: '90%',
          overflowY: 'scroll',
          scroll: 'auto',
        },
      }, [
        h(ReactMarkdown, {
          source: body,
          skipHtml: true,
        }),
      ]),

      h('button', {
        disabled,
        onClick: onConfirm,
        style: {
          marginTop: '18px',
        },
      }, 'Continue'),
    ])
  )
}

Notice.prototype.componentDidMount = function () {
  var node = findDOMNode(this)
  linker.setupListener(node)
}

Notice.prototype.componentWillUnmount = function () {
  var node = findDOMNode(this)
  linker.teardownListener(node)
}