-
Notifications
You must be signed in to change notification settings - Fork 11
/
test.html
executable file
·92 lines (89 loc) · 3.05 KB
/
test.html
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
90
91
92
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Untitled</title>
<link rel="author" href="humans.txt">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/4.2.0/normalize.min.css">
<style>
body {
padding: 5em;
}
.form-control {
display: inline-block;
width: 300px;
}
.form-control > label {
display: block;
margin-bottom: 0.5em;
}
.color-input {
display: flex;
border-radius: 0.25em;
border: 1px solid rgb(167, 167, 167);
overflow: hidden;
}
.color-input-swatch {
border: none;
display: block;
border-right: 1px solid rgb(167, 167, 167);
width: 2.25em;
outline: none;
}
.color-input-value {
display: block;
padding: 0.5em;
}
</style>
</head>
<body>
<div id="app">
<div class="form-control">
<label>
Foreground color
</label>
<div class="color-input">
<button class="jscolor {value: '{{ fgColor }}', valueElement: null, onFineChange:'updateFg(this)'} color-input-swatch"></button>
<span class="color-input-value">{{ fgColor }}</span>
</div>
</div>
<div class="form-control">
<label>
Background color
</label>
<div class="color-input">
<button class="jscolor {value: '{{ bgColor }}', valueElement: null, onFineChange:'updateBg(this)'} color-input-swatch"></button>
<span class="color-input-value">{{ bgColor }}</span>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.26/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jscolor/2.0.4/jscolor.js"></script>
<script>
function updateFg(color) {
console.log(color);
vm.updateFg(color)
}
function updateBg(color) {
vm.updateBg(color)
}
const vm = new Vue({
data: {
fgColor: '#988CC8',
bgColor: '#C78BC3',
},
methods: {
updateFg(color) {
this.fgColor = ('#' + color).toUpperCase()
},
updateBg(color) {
this.bgColor = ('#' + color).toUpperCase()
}
}
});
vm.$mount('#app');
</script>
</body>
</html>