Skip to content

Commit 8865d09

Browse files
committed
adds from 3 and 6
1 parent 5b87f05 commit 8865d09

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
1515
<input type="range" name="blur" min="0" max="25" value="10" data-sizing="px">
1616

1717
<label for="base">Base Color</label>
18-
<input type="color" name="base" value="#ffc600">
18+
<input type="color" name="base" value="#ffcf00">
1919
</div>
2020

2121
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">
@@ -26,6 +26,25 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
2626
misc styles, nothing to do with CSS variables
2727
*/
2828

29+
:root {
30+
--base: #ffc600;
31+
--spacing: 10px;
32+
33+
}
34+
35+
h1 {
36+
color: var(--base);
37+
--blur: 0px;
38+
39+
}
40+
41+
img {
42+
padding: var(--spacing);
43+
background: var(--base);
44+
filter: blur(var(--blur));
45+
46+
}
47+
2948
body {
3049
text-align: center;
3150
}
@@ -53,6 +72,15 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
5372
</style>
5473

5574
<script>
75+
const inputs = document.querySelectorAll('.controls input');
76+
function handleUpdate() {
77+
const suffux = this.dataset.sizing || '';
78+
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffux);
79+
}
80+
81+
inputs.forEach(input => input.addEventListener('change', handleUpdate));
82+
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
83+
5684
</script>
5785

5886
</body>

06 - Type Ahead/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
const matchArray = findMatches(this.value, cities);
3434
const html = matchArray.map(place => {
3535
const regex = new RegExp(this.value, 'gi');
36-
const cityName = place.city.replace(regex, `<span class="hl">${this.value}</span>`);
36+
const cityName = place.city.replace(regex, `<span class="hl"> ${this.value}</span>`);
3737
const stateName = place.state.replace(regex, `<span class="hl">${this.value}</span>`);
3838
return `
3939
<li>

0 commit comments

Comments
 (0)