diff --git a/01 - JavaScript Drum Kit/b9r5sEL.jpg b/01 - JavaScript Drum Kit/b9r5sEL.jpg new file mode 100644 index 0000000000..590036d636 Binary files /dev/null and b/01 - JavaScript Drum Kit/b9r5sEL.jpg differ diff --git a/01 - JavaScript Drum Kit/code.js b/01 - JavaScript Drum Kit/code.js new file mode 100644 index 0000000000..ae573127c1 --- /dev/null +++ b/01 - JavaScript Drum Kit/code.js @@ -0,0 +1,49 @@ +(function DrumKit () { + const variables = { + className: 'playing', + keyEvent: 'keydown', + transitionEvent: 'transitionend', + }; + + function _addClass(element, name) { + element.classList.add(name); + } + + function _removeClass(event) { + if (event.propertyName === 'transform') { + event.target.classList.remove(variables.className); + } + } + + function _attachTransitionListener () { + Array + .from(document.querySelectorAll('.key')) + .forEach((key) => key.addEventListener(variables.transitionEvent, _removeClass)); + } + + function _playAudioFor (keyCode) { + const audioElement = document.querySelector(`audio[data-key="${keyCode}"]`); + if (audioElement !== null) { + audioElement.currentTime = 0; + audioElement.play(); + } + } + + function _toggleClassFor(keyCode) { + const divElement = document.querySelector(`div[data-key="${keyCode}"]`); + if (divElement !== null) { + _addClass(divElement, variables.className); + _attachTransitionListener(); + } + } + + function _initAudio (event) { + _playAudioFor(event.keyCode); + _toggleClassFor(event.keyCode); + } + + function _attachListener () { + document.addEventListener(variables.keyEvent, _initAudio); + } + _attachListener(); +}()); \ No newline at end of file diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..baf1385a2b 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -57,10 +57,6 @@ - - - + diff --git a/01 - JavaScript Drum Kit/style.css b/01 - JavaScript Drum Kit/style.css index 3e0a320b37..918f5929e4 100644 --- a/01 - JavaScript Drum Kit/style.css +++ b/01 - JavaScript Drum Kit/style.css @@ -1,6 +1,6 @@ html { font-size: 10px; - background:url(http://i.imgur.com/b9r5sEL.jpg) bottom center; + background:url(b9r5sEL.jpg) bottom center; background-size: cover; } body,html { diff --git a/02 - JS + CSS Clock/index-START.html b/02 - JS + CSS Clock/index-START.html index 2712384201..a3bbbb22c7 100644 --- a/02 - JS + CSS Clock/index-START.html +++ b/02 - JS + CSS Clock/index-START.html @@ -9,16 +9,16 @@
-
-
-
+
+
+
diff --git a/03 - CSS Variables/index-MINE.html b/03 - CSS Variables/index-MINE.html new file mode 100644 index 0000000000..96f4ebb98e --- /dev/null +++ b/03 - CSS Variables/index-MINE.html @@ -0,0 +1,83 @@ + + + + + Scoped CSS Variables and JS + + +

Update CSS Variables with JS

+ +
+ + + + + + + + +
+ + + + + + + + + diff --git a/04 - Array Cardio Day 1/index-MINE.html b/04 - Array Cardio Day 1/index-MINE.html new file mode 100644 index 0000000000..e148c88b5b --- /dev/null +++ b/04 - Array Cardio Day 1/index-MINE.html @@ -0,0 +1,80 @@ + + + + + Array Cardio 💪 + + +

Psst: have a look at the JavaScript Console 💁

+ + + diff --git a/05 - Flex Panel Gallery/index-MINE.html b/05 - Flex Panel Gallery/index-MINE.html new file mode 100644 index 0000000000..04a857dcf7 --- /dev/null +++ b/05 - Flex Panel Gallery/index-MINE.html @@ -0,0 +1,143 @@ + + + + + Flex Panels 💪 + + + + + + +
+
+

Hey

+

Let's

+

Dance

+
+
+

Give

+

Take

+

Receive

+
+
+

Experience

+

It

+

Today

+
+
+

Give

+

All

+

You can

+
+
+

Life

+

In

+

Motion

+
+
+ + + + + + +