Skip to content

Commit 99041d2

Browse files
committed
Finished the 3rd project
1 parent bc7151a commit 99041d2

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

Diff for: Challenges/03 - Playing with CSS Variables and JS/assets/css/style.css

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
:root {
2+
--base-color: #f2c94c;
3+
--spacing: 10px;
4+
--blur: 10px;
5+
}
6+
17
@font-face {
28
font-family: 'Roboto';
39
font-style: normal;
@@ -64,8 +70,9 @@ input[type="range"]::-moz-range-track {
6470
}
6571

6672
img {
73+
background: var(--base-color);
6774
box-sizing: border-box;
75+
filter: blur(var(--blur));
76+
padding: var(--spacing);
6877
width: 100%;
69-
border: 10px solid #333;
70-
filter: blur(.1rem)
7178
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const inputs = document.querySelectorAll('input');
2+
3+
function handleUpdate(e) {
4+
const suffix = e.target.dataset.metric || '';
5+
document.documentElement.style.setProperty(`--${e.target.name}`, e.target.value + suffix);
6+
}
7+
8+
inputs.forEach(input => {
9+
input.addEventListener('change', handleUpdate);
10+
input.addEventListener('mousemove', handleUpdate);
11+
});

Diff for: Challenges/03 - Playing with CSS Variables and JS/index.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ <h1 class="title">
1818
<main>
1919
<section class="controls">
2020
<label for="spacing">Spacing</label>
21-
<input type="range" name="spacing" min="0" max="200" value=10>
21+
<input type="range" name="spacing" min="0" max="200" value=10 data-metric="px">
2222
<label for="blur">Blur</label>
23-
<input type="range" name="blur" min="0" max="25" value=10>
24-
<label for="color">Base Color</label>
25-
<input type="color" name="color" value=#ffc600>
23+
<input type="range" name="blur" min="0" max="25" value=10 data-metric="px">
24+
<label for="base-color">Base Color</label>
25+
<input type="color" name="base-color" value=#ffc600>
2626
</section>
2727
<section>
2828
<img src="assets/images/main-image.jpg" title="Photo by NASA">
2929
</section>
3030
</main>
31-
<!-- <script src="./assets/js/script.js"></script> -->
31+
<script src="./assets/js/script.js"></script>
3232
</body>
3333
</html>

0 commit comments

Comments
 (0)