2017-11-14 08:04:23 -08:00
|
|
|
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
|
2018-07-30 06:01:21 -07:00
|
|
|
const { title, body } = notice
|
2018-08-03 07:19:13 -07:00
|
|
|
const state = this.state || { disclaimerDisabled: false }
|
2017-11-14 08:04:23 -08:00
|
|
|
const disabled = state.disclaimerDisabled
|
|
|
|
|
|
|
|
return (
|
|
|
|
h('.flex-column.flex-center.flex-grow', {
|
|
|
|
style: {
|
|
|
|
width: '100%',
|
2018-08-03 07:19:13 -07:00
|
|
|
fontFamily: 'Nunito SemiBold',
|
2017-11-14 08:04:23 -08:00
|
|
|
},
|
|
|
|
}, [
|
|
|
|
h('style', `
|
|
|
|
|
|
|
|
.markdown {
|
|
|
|
overflow-x: hidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
.markdown h1, .markdown h2, .markdown h3 {
|
2018-08-03 07:19:13 -07:00
|
|
|
margin: 20px 0;
|
|
|
|
line-height: 18px;
|
|
|
|
font-weight: normal;
|
2017-11-14 08:04:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
.markdown strong {
|
2018-08-03 07:19:13 -07:00
|
|
|
font-weight: normal;
|
2017-11-14 08:04:23 -08:00
|
|
|
}
|
|
|
|
.markdown em {
|
|
|
|
font-style: italic;
|
|
|
|
}
|
|
|
|
|
|
|
|
.markdown p {
|
2018-08-03 07:19:13 -07:00
|
|
|
margin: 20px 0;
|
|
|
|
line-height: 18px;
|
|
|
|
font-weight: normal;
|
2017-11-14 08:04:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
.markdown a {
|
2018-08-20 09:45:52 -07:00
|
|
|
color: #60db97;
|
2017-11-14 08:04:23 -08:00
|
|
|
}
|
|
|
|
|
2018-08-03 07:19:13 -07:00
|
|
|
.markdown::-webkit-scrollbar {
|
|
|
|
width: 16px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.markdown::-webkit-scrollbar-track {
|
|
|
|
background-color: transparent;
|
|
|
|
}
|
|
|
|
|
|
|
|
.markdown::-webkit-scrollbar-thumb {
|
|
|
|
background-color: #411a6a;
|
|
|
|
border-radius: 2px;
|
|
|
|
border: 6px solid transparent;
|
|
|
|
background-clip: content-box;
|
|
|
|
}
|
2017-11-14 08:04:23 -08:00
|
|
|
|
2018-08-03 07:19:13 -07:00
|
|
|
`), [
|
|
|
|
h('h3.flex-center.terms-header', {
|
|
|
|
key: 'notice-key',
|
|
|
|
style: {
|
|
|
|
color: '#ffffff',
|
|
|
|
width: '100%',
|
|
|
|
fontSize: '16px',
|
|
|
|
textAlign: 'center',
|
|
|
|
margin: '20px 0px',
|
|
|
|
},
|
|
|
|
}, [
|
|
|
|
title,
|
|
|
|
]),
|
|
|
|
h('div.markdown', {
|
2018-08-03 07:36:22 -07:00
|
|
|
key: 'notice-div-key',
|
2018-08-03 07:19:13 -07:00
|
|
|
onScroll: (e) => {
|
|
|
|
var object = e.currentTarget
|
|
|
|
if (object.offsetHeight + object.scrollTop + 100 >= object.scrollHeight) {
|
|
|
|
this.setState({disclaimerDisabled: false})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
background: '#542289',
|
|
|
|
color: '#ffffff',
|
2018-08-06 11:11:06 -07:00
|
|
|
height: '430px',
|
2018-08-03 07:19:13 -07:00
|
|
|
width: '90%',
|
|
|
|
overflowY: 'scroll',
|
|
|
|
scroll: 'auto',
|
|
|
|
borderRadius: '3px',
|
|
|
|
fontSize: '14px',
|
|
|
|
},
|
|
|
|
}, [
|
|
|
|
h(ReactMarkdown, {
|
|
|
|
className: 'notice-box',
|
|
|
|
source: body,
|
|
|
|
skipHtml: true,
|
|
|
|
}),
|
|
|
|
]),
|
2017-11-14 08:04:23 -08:00
|
|
|
|
2018-08-03 07:19:13 -07:00
|
|
|
h('button', {
|
2018-08-03 07:36:22 -07:00
|
|
|
key: 'notice-button-key',
|
2018-08-03 07:19:13 -07:00
|
|
|
disabled,
|
|
|
|
onClick: () => {
|
|
|
|
this.setState({disclaimerDisabled: true})
|
|
|
|
onConfirm()
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
marginTop: '18px',
|
|
|
|
},
|
|
|
|
}, 'Accept'),
|
|
|
|
],
|
2017-11-14 08:04:23 -08:00
|
|
|
])
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
Notice.prototype.componentDidMount = function () {
|
|
|
|
// eslint-disable-next-line react/no-find-dom-node
|
|
|
|
var node = findDOMNode(this)
|
|
|
|
linker.setupListener(node)
|
2018-08-02 02:29:18 -07:00
|
|
|
if (document.getElementsByClassName('notice-box')[0].clientHeight < 300) {
|
2017-11-14 08:04:23 -08:00
|
|
|
this.setState({disclaimerDisabled: false})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Notice.prototype.componentWillUnmount = function () {
|
|
|
|
// eslint-disable-next-line react/no-find-dom-node
|
|
|
|
var node = findDOMNode(this)
|
|
|
|
linker.teardownListener(node)
|
|
|
|
}
|