1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-23 18:41:38 +01:00
metamask-extension/ui/app/first-time/disclaimer.js

113 lines
2.7 KiB
JavaScript
Raw Normal View History

2016-06-17 01:55:22 +02:00
const inherits = require('util').inherits
const Component = require('react').Component
const h = require('react-hyperscript')
const connect = require('react-redux').connect
const actions = require('../actions')
2016-07-01 06:46:19 +02:00
const ReactMarkdown = require('react-markdown')
2016-06-17 01:55:22 +02:00
const fs = require('fs')
const path = require('path')
const linker = require('extension-link-enabler')
const findDOMNode = require('react-dom').findDOMNode
2016-07-01 05:54:51 +02:00
const disclaimer = fs.readFileSync(path.join(__dirname, '..', '..', '..', 'USER_AGREEMENT.md')).toString()
2016-06-17 01:55:22 +02:00
module.exports = connect(mapStateToProps)(DisclaimerScreen)
2016-06-21 22:18:32 +02:00
function mapStateToProps (state) {
2016-06-17 01:55:22 +02:00
return {}
}
inherits(DisclaimerScreen, Component)
2016-06-21 22:18:32 +02:00
function DisclaimerScreen () {
2016-06-17 01:55:22 +02:00
Component.call(this)
}
2016-06-21 22:18:32 +02:00
DisclaimerScreen.prototype.render = function () {
const state = this.state || {disclaimerDisabled: true}
const disabled = state.disclaimerDisabled
2016-06-17 01:55:22 +02:00
return (
h('.flex-column.flex-center.flex-grow', [
2016-07-01 08:50:20 +02:00
h('h3.flex-center.text-transform-uppercase.terms-header', {
2016-06-17 01:55:22 +02:00
style: {
background: '#EBEBEB',
color: '#AEAEAE',
marginBottom: 24,
width: '100%',
fontSize: '20px',
2016-07-01 08:50:20 +02:00
textAlign: 'center',
2016-06-17 01:55:22 +02:00
padding: 6,
},
}, [
'MetaMask Terms & Conditions',
]),
2016-07-01 08:15:45 +02:00
h('style', `
.markdown {
font-family: Times New Roman;
overflow-x: hidden;
2016-07-01 08:15:45 +02:00
}
2016-07-01 08:50:20 +02:00
.markdown h1, .markdown h2, .markdown h3 {
2016-07-01 08:15:45 +02:00
margin: 10px 0;
font-weight: bold;
}
2016-10-05 03:39:54 +02:00
.markdown strong {
font-weight: bold;
}
.markdown em {
font-style: italic;
}
2016-10-05 03:45:01 +02:00
.markdown p {
margin: 10px 0;
}
.markdown a {
color: blue;
}
2016-07-01 08:15:45 +02:00
`),
h('div.markdown', {
onScroll: (e) => {
var object = e.currentTarget
if (object.offsetHeight + object.scrollTop + 100 >= object.scrollHeight) {
this.setState({disclaimerDisabled: false})
}
},
2016-06-17 01:55:22 +02:00
style: {
background: 'rgb(235, 235, 235)',
height: '310px',
2016-06-17 02:11:13 +02:00
padding: '6px',
2016-06-17 01:55:22 +02:00
width: '80%',
overflowY: 'scroll',
2016-06-21 22:18:32 +02:00
},
2016-07-01 06:46:19 +02:00
}, [
h(ReactMarkdown, {
source: disclaimer,
skipHtml: true,
}),
]),
2016-06-17 01:55:22 +02:00
h('button', {
2016-06-17 01:55:22 +02:00
style: { marginTop: '18px' },
2016-10-12 00:50:02 +02:00
disabled,
2016-06-21 22:18:32 +02:00
onClick: () => this.props.dispatch(actions.agreeToDisclaimer()),
}, disabled ? 'Scroll Down to Enable' : 'I Agree'),
2016-06-17 01:55:22 +02:00
])
)
}
DisclaimerScreen.prototype.componentDidMount = function () {
var node = findDOMNode(this)
linker.setupListener(node)
}
DisclaimerScreen.prototype.componentWillUnmount = function () {
var node = findDOMNode(this)
linker.teardownListener(node)
}