Skip to content

Commit 7b44e90

Browse files
committed
Completed exercise 03
1 parent 2afb628 commit 7b44e90

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

03 - CSS Variables/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
1313

1414
<label for="blur">Blur:</label>
1515
<input type="range" name="blur" min="0" max="25" value="10" data-sizing="px">
16+
<!-- data-sizing is a custom attribute to specify the suffix of the css property -->
1617

1718
<label for="base">Base Color</label>
1819
<input type="color" name="base" value="#2e8efc">
@@ -75,10 +76,12 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
7576
const inputs = document.querySelectorAll(".controls input");
7677

7778
function handleUpdate() {
78-
console.log(this.value);
79+
const suffix = this.dataset.sizing || '';
80+
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix)
7981
}
8082

81-
inputs.forEach (input => input.addEventListener('change', handleUpdate));
83+
inputs.forEach (input => input.addEventListener('change', handleUpdate)); /*updates when you let go*/
84+
inputs.forEach (input => input.addEventListener('mousemove', handleUpdate)); /*changes when moved*/
8285

8386
</script>
8487

0 commit comments

Comments
 (0)