-
Notifications
You must be signed in to change notification settings - Fork 5
/
cssJs.jade
65 lines (47 loc) · 1.58 KB
/
cssJs.jade
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
extends base
block vars
- var title = 'CSS Variables and JS'
block styles
link(rel="stylesheet" type="text/css" href="styles/cssJS.css")
//- CSS Variables
style.
:root {
--base: #FFC600;
--spacing: 10px;
--blur: 10px;
}
img {
padding: var(--spacing);
background: var(--base);
filter: blur(var(--blur));
}
.hl { color: var(--base); }
a {
color: var(--base);
text-decoration: none;
}
input { width: 100px; }
block body
h2 Update stuffs
span.hl ¯\_(ツ)_/¯
.controls
label(for="spacing") Spacing:
input(type="range" name="spacing" min="10" max="200" value="10", data-sizing="px")
label(for="blur") Blur:
input(type="range" name="blur" min="0" max="25" value="10", data-sizing="px")
label(for="base") Base Color:
input(type="color" name="base" value="#FFC600")
img(src="images/35e28e9ffc2424f8b93954c964dbc23b.jpg")
script(type="text/javascript").
const $inputs = document.querySelectorAll('.controls input')
function updateHandler() {
const suffix = this.dataset.sizing || ''
document.documentElement.style.setProperty(`--${this.name}`, `${this.value + suffix}`)
}
function addMultipleListeners(elem, e, handler) {
if (!(e instanceof Array))
throw 'addMultipleListeners: please supply an array of eventstrings (like ["click","mouseover"])'
for (let i = 0; i < e.length; i++)
elem.addEventListener(e[i], handler)
}
$inputs.forEach(input => addMultipleListeners(input, ['change', 'mousemove'], updateHandler))