-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathindex.js
More file actions
49 lines (42 loc) · 1.39 KB
/
index.js
File metadata and controls
49 lines (42 loc) · 1.39 KB
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
// https://www.reddit.com/r/javascript/comments/332v73/is_anyone_using_es6_in_a_large_project_hows_it/cqh2u7i
import hex from 'hex-rgb';
const rgb = str => hex(str).map(x => x / 255);
import React from 'react';
import ReactDOM from 'react-dom';
import BaseComponent from './components/BaseComponent';
// Class Property Declarations is stage 1 proposal currently https://github.com/eslint/eslint/issues/4683#issuecomment-164217757
// http://egorsmirnov.me/2015/08/16/react-and-es6-part3.html
// http://www.newmediacampaigns.com/blog/refactoring-react-components-to-es6-classes
// http://stackoverflow.com/questions/34244888/how-do-i-configure-eslint-to-allow-fat-arrow-class-methods/34254000#34254000
class NoLink extends BaseComponent {
state = {
message: '#abde13',
someStyle: {
color: 'white',
backgroundColor: '#C594C5',
},
};
handleChange = event => {
this.setState(
{
message: event.target.value,
someStyle: { color: 'white', backgroundColor: event.target.value },
}
);
}
render() {
const message = this.state.message;
return (
<div>
<input style={this.state.someStyle} type="text" value={message}
onChange={this.handleChange}
/>
<input type="text" value={rgb(message)} readOnly />
</div>
);
}
}
ReactDOM.render(
<NoLink txt="some text" />,
document.getElementById('app')
);