-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (37 loc) · 906 Bytes
/
index.js
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
import './style'
import {Component} from 'preact'
export default class App extends Component {
constructor() {
super()
this.state = {
color: this.generateColor(),
}
}
generateColor() {
return `#${this.generateHex()}${this.generateHex()}${this.generateHex()}`
}
generateHex() {
const candidate = Math.floor(Math.random() * 256).toString(16)
return candidate.length === 1 ? `0${candidate}` : candidate
}
render() {
const style = {
backgroundColor: this.state.color,
}
return (
<div style={style}>
<h1>
<span>{this.state.color}</span>
</h1>
<div>
<span>
<span>© 2018 Takaya Kobayashi </span>
<a href="https://kbys.tk/y" target="_blank">
https://kbys.tk/y
</a>
</span>
</div>
</div>
)
}
}