-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathindex.js
89 lines (78 loc) · 1.57 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
79
80
81
82
83
84
85
86
87
88
89
import Vue from 'vue'
import styled, { theme } from '../src'
const color = theme('mode', {
light: 'black',
dark: 'white'
})
const backgroundColor = theme('mode', {
light: 'white',
dark: 'black'
})
const Button = styled('button')`
color: ${color};
background-color: ${backgroundColor};
border: 1px solid ${color};
padding: 10px 20px;
font-size: ${props => props.fontSize};
`
const Controls = styled('div')`
background-color: #f0f0f0;
padding: 10px;
margin-bottom: 10px;
`
const App = {
name: 'app',
data() {
return {
theme: {
mode: 'light'
},
fontSize: 16
}
},
provide() {
return {
theme: this.theme
}
},
methods: {
updateMode(e) {
this.theme.mode = e.target.value
},
updateFontSize(e) {
this.fontSize = e.target.value
}
},
render() {
return (
<div>
<Controls>
Theme:{' '}
<select onChange={this.updateMode}>
<option
value="light"
selected={this.theme.mode === 'light'}>
Light
</option>
<option
value="dark"
selected={this.theme.mode === 'dark'}>
Dark
</option>
</select>
{' '}Font Size:{' '}
<input
type="number"
value={this.fontSize}
onInput={this.updateFontSize}
/>
</Controls>
<Button class="foo" fontSize={this.fontSize}>Button</Button>
</div>
)
}
}
new Vue({
el: '#app',
render: h => h(App)
})