-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
78 lines (69 loc) · 1.81 KB
/
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
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
var createReactClass = require('create-react-class')
require('./elements')
var Greeting = createReactClass({
getInitialState() {
return {
excitement: '',
x: 0,
y: 0
}
},
generateExcitement() {
console.log('click' + this.state.excitement)
var intensity = 6 + 6 * Math.random()
this.setState({
excitement: this.state.excitement + '!',
x: intensity * (-.5 + (Math.random() + 0.5 | 0)),
y: intensity * (-.5 + (Math.random() + 0.5 | 0))
})
setTimeout(() => {
this.setState({
x: 0,
y: 0
})
}, 75)
},
render() {
return div.container(
h1.style({transform: `translate3d(${this.state.x}px, ${this.state.y}px, 0)`})('Hello ' + this.props.toWhat + this.state.excitement),
div.row(
div.four.columns(
img.style({width: '100%'}).src('https://avatars1.githubusercontent.com/u/3056518?v=3&s=460')
),
div.eight.columns(
"Testing text that has ",
a.href('https://www.google.com')('some link'),
" it it. Weird."
)
),
hr(),
div.row(
div.twelve.columns(
button.onClick(this.generateExcitement)('Click Me', span.style({color: '#aaaaaa'})(' to generate excitement')),
div.unique_class_name(hr()),
React.createElement(Toggle, {key: 'climate-change-toggle'}, null)
)
)
)
}
})
var Toggle = createReactClass({
getInitialState() {
return {
isOn: false
}
},
toggle() {
this.setState({isOn: !this.state.isOn})
},
render() {
return div(
label(['off', 'on'][+this.state.isOn]),
button.onClick(this.toggle)(this.props.label || 'Toggle')
)
}
})
ReactDOM.render(
React.createElement(Greeting, {toWhat: 'World'}, null),
document.getElementById('root')
)