Skip to content

Commit 90bd404

Browse files
committed
Change Dump-erino
For lessons 1-10. First Github Commit Evar
1 parent fe83039 commit 90bd404

File tree

25 files changed

+701
-40
lines changed

25 files changed

+701
-40
lines changed

01 - JavaScript Drum Kit/index-FINISHED.html

100644100755
File mode changed.

01 - JavaScript Drum Kit/index-START.html

100644100755
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,24 @@
5858
<audio data-key="76" src="sounds/tink.wav"></audio>
5959

6060
<script>
61+
function playSound(e) {
62+
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
63+
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
64+
if (!audio) return; // stop function for non-mapped keys
65+
audio.currentTime = 0; // rewind to start
66+
audio.play();
67+
key.classList.add('playing');
68+
}
6169

70+
function removeTransition(e) {
71+
if (e.propertyName !== 'transform') return; // skip if not a transform
72+
this.classList.remove('playing');
73+
}
74+
75+
const keys = document.querySelectorAll('.key');
76+
keys.forEach( key => key.addEventListener('transitionend', removeTransition));
77+
78+
window.addEventListener('keydown', playSound);
6279
</script>
6380

6481

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>JS Drum Kit</title>
6+
<link rel="stylesheet" href="style.css">
7+
</head>
8+
<body>
9+
10+
11+
<div class="keys">
12+
<div data-key="65" class="key">
13+
<kbd>A</kbd>
14+
<span class="sound">clap</span>
15+
</div>
16+
<div data-key="83" class="key">
17+
<kbd>S</kbd>
18+
<span class="sound">hihat</span>
19+
</div>
20+
<div data-key="68" class="key">
21+
<kbd>D</kbd>
22+
<span class="sound">kick</span>
23+
</div>
24+
<div data-key="70" class="key">
25+
<kbd>F</kbd>
26+
<span class="sound">openhat</span>
27+
</div>
28+
<div data-key="71" class="key">
29+
<kbd>G</kbd>
30+
<span class="sound">boom</span>
31+
</div>
32+
<div data-key="72" class="key">
33+
<kbd>H</kbd>
34+
<span class="sound">ride</span>
35+
</div>
36+
<div data-key="74" class="key">
37+
<kbd>J</kbd>
38+
<span class="sound">snare</span>
39+
</div>
40+
<div data-key="75" class="key">
41+
<kbd>K</kbd>
42+
<span class="sound">tom</span>
43+
</div>
44+
<div data-key="76" class="key">
45+
<kbd>L</kbd>
46+
<span class="sound">tink</span>
47+
</div>
48+
</div>
49+
50+
<audio data-key="65" src="sounds/clap.wav"></audio>
51+
<audio data-key="83" src="sounds/hihat.wav"></audio>
52+
<audio data-key="68" src="sounds/kick.wav"></audio>
53+
<audio data-key="70" src="sounds/openhat.wav"></audio>
54+
<audio data-key="71" src="sounds/boom.wav"></audio>
55+
<audio data-key="72" src="sounds/ride.wav"></audio>
56+
<audio data-key="74" src="sounds/snare.wav"></audio>
57+
<audio data-key="75" src="sounds/tom.wav"></audio>
58+
<audio data-key="76" src="sounds/tink.wav"></audio>
59+
60+
<script>
61+
62+
63+
function playSound(e) {
64+
const audio = document.querySelector(`audio[data-key="${e.keyCode}"]`);
65+
const key = document.querySelector(`.key[data-key="${e.keyCode}"]`);
66+
if (!audio) return; // stop the fucntion from running all together
67+
audio.currentTime = 0; // rewind to the start
68+
audio.play();
69+
key.classList.add('playing');
70+
}
71+
function removeTransition(e) {
72+
if (e.propertyName !== 'transform') return; // skip it if it's not a transform
73+
this.classList.remove('playing');
74+
}
75+
76+
const keys = document.querySelectorAll('.key');
77+
keys.forEach(key => key.addEventListener('transitionend', removeTransition));
78+
window.addEventListener('keydown', playSound);
79+
80+
</script>
81+
82+
</body>
83+
</html>

01 - JavaScript Drum Kit/style.css

100644100755
File mode changed.

02 - JS + CSS Clock/index-FINISHED.html

100644100755
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>JS + CSS Clock</title>
5+
<title>Document</title>
66
</head>
77
<body>
88

@@ -42,7 +42,7 @@
4242
position: relative;
4343
padding:2rem;
4444
box-shadow:
45-
0 0 0 4px rgba(0,0,0,0.1),
45+
0 0 0px 4px rgba(0,0,0,0.1),
4646
inset 0 0 0 3px #EFEFEF,
4747
inset 0 0 10px black,
4848
0 0 10px rgba(0,0,0,0.2);
@@ -84,15 +84,13 @@
8484
const minsDegrees = ((mins / 60) * 360) + 90;
8585
minsHand.style.transform = `rotate(${minsDegrees}deg)`;
8686

87-
const hour = now.getHours();
88-
const hourDegrees = ((hour / 12) * 360) + 90;
87+
const hour = now.getMinutes();
88+
const hourDegrees = ((mins / 12) * 360) + 90;
8989
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
9090
}
9191

9292
setInterval(setDate, 1000);
9393

94-
setDate();
95-
9694
</script>
9795
</body>
9896
</html>

02 - JS + CSS Clock/index-START.html

100644100755
Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en">
33
<head>
44
<meta charset="UTF-8">
5-
<title>JS + CSS Clock</title>
5+
<title>Document</title>
66
</head>
77
<body>
88

@@ -42,7 +42,7 @@
4242
position: relative;
4343
padding:2rem;
4444
box-shadow:
45-
0 0 0 4px rgba(0,0,0,0.1),
45+
0 0 0px 4px rgba(0,0,0,0.1),
4646
inset 0 0 0 3px #EFEFEF,
4747
inset 0 0 10px black,
4848
0 0 10px rgba(0,0,0,0.2);
@@ -61,12 +61,35 @@
6161
background:black;
6262
position: absolute;
6363
top:50%;
64+
transform-origin: 100%;
65+
transform: rotate(90deg);
66+
transition: all 0.05s;
67+
transition-timing-function: cubic-bezier(0, 2.7, .58, 1);
6468
}
6569

6670
</style>
6771

6872
<script>
73+
const secondHand = document.querySelector('.second-hand');
74+
const minuteHand = document.querySelector('.min-hand');
75+
const hourHand = document.querySelector('.hour-hand');
76+
function setDate() {
77+
const now = new Date();
78+
const seconds = now.getSeconds();
79+
const secondsDegrees = ((seconds / 60) * 360) + 90;
80+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
6981

82+
const minutes = now.getMinutes();
83+
const minutesDegrees = ((minutes / 60) * 360) + 90;
84+
minuteHand.style.transform = `rotate(${minutesDegrees}deg)`;
85+
86+
const hour = now.getHours();
87+
if (hour > 12) return hour -= 12;
88+
const hourDegrees = ((hour / 12) * 360) + 90;
89+
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
90+
}
91+
92+
setInterval(setDate, 1000);
7093

7194
</script>
7295
</body>

02 - JS + CSS Clock/index.html

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Document</title>
6+
</head>
7+
<body>
8+
9+
10+
<div class="clock">
11+
<div class="clock-face">
12+
<div class="hand hour-hand"></div>
13+
<div class="hand min-hand"></div>
14+
<div class="hand second-hand"></div>
15+
</div>
16+
</div>
17+
18+
19+
<style>
20+
html {
21+
background:#018DED url(http://unsplash.it/1500/1000?image=881&blur=50);
22+
background-size:cover;
23+
font-family:'helvetica neue';
24+
text-align: center;
25+
font-size: 10px;
26+
}
27+
28+
body {
29+
font-size: 2rem;
30+
display:flex;
31+
flex:1;
32+
min-height: 100vh;
33+
align-items: center;
34+
}
35+
36+
.clock {
37+
width: 30rem;
38+
height: 30rem;
39+
border:20px solid white;
40+
border-radius:50%;
41+
margin:50px auto;
42+
position: relative;
43+
padding:2rem;
44+
box-shadow:
45+
0 0 0px 4px rgba(0,0,0,0.1),
46+
inset 0 0 0 3px #EFEFEF,
47+
inset 0 0 10px black,
48+
0 0 10px rgba(0,0,0,0.2);
49+
}
50+
51+
.clock-face {
52+
position: relative;
53+
width: 100%;
54+
height: 100%;
55+
transform: translateY(-3px); /* account for the height of the clock hands */
56+
}
57+
58+
.hand {
59+
width:50%;
60+
height:6px;
61+
background:black;
62+
position: absolute;
63+
top:50%;
64+
transform-origin: 100%;
65+
transform: rotate(90deg);
66+
transition: all 0.05s;
67+
transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1);
68+
}
69+
</style>
70+
71+
<script>
72+
const secondHand = document.querySelector('.second-hand');
73+
const minsHand = document.querySelector('.min-hand');
74+
const hourHand = document.querySelector('.hour-hand');
75+
76+
function setDate() {
77+
const now = new Date();
78+
79+
const seconds = now.getSeconds();
80+
const secondsDegrees = ((seconds / 60) * 360) + 90;
81+
secondHand.style.transform = `rotate(${secondsDegrees}deg)`;
82+
83+
const mins = now.getMinutes();
84+
const minsDegrees = ((mins / 60) * 360) + 90;
85+
minsHand.style.transform = `rotate(${minsDegrees}deg)`;
86+
87+
const hour = now.getMinutes();
88+
const hourDegrees = ((mins / 12) * 360) + 90;
89+
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
90+
}
91+
92+
setInterval(setDate, 1000);
93+
94+
</script>
95+
</body>
96+
</html>

03 - CSS Variables/index-FINISHED.html

100644100755
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
5757
margin-bottom: 50px;
5858
}
5959

60+
a {
61+
color: var(--base);
62+
text-decoration: none;
63+
}
64+
6065
input {
6166
width:100px;
6267
}

03 - CSS Variables/index-START.html

100644100755
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
2121
<img src="https://source.unsplash.com/7bwQXzbF6KE/800x500">
2222

2323
<style>
24+
:root {
25+
--base: #ffc600;
26+
--spacing: 10px;
27+
--blur: 10px;
28+
}
29+
30+
img {
31+
padding: var(--spacing);
32+
background: var(--base);
33+
filter: blur(var(--blur));
34+
}
35+
36+
.hl {
37+
color: var(--base);
38+
}
2439

2540
/*
2641
misc styles, nothing to do with CSS variables
@@ -42,12 +57,29 @@ <h2>Update CSS Variables with <span class='hl'>JS</span></h2>
4257
margin-bottom: 50px;
4358
}
4459

60+
a {
61+
color: var(--base);
62+
text-decoration: none;
63+
}
64+
4565
input {
4666
width:100px;
4767
}
4868
</style>
4969

5070
<script>
71+
72+
const inputs = document.querySelectorAll('.controls input');
73+
74+
function handleUpdate() {
75+
const suffix = this.dataset.sizing || '';
76+
document.documentElement.style.setProperty(`--${this.name}`, this.value + suffix);
77+
}
78+
79+
inputs.forEach(input => input.addEventListener('change', handleUpdate));
80+
inputs.forEach(input => input.addEventListener('mousemove', handleUpdate));
81+
82+
5183
</script>
5284

5385
</body>

0 commit comments

Comments
 (0)