diff --git a/01 - JavaScript Drum Kit/app.js b/01 - JavaScript Drum Kit/app.js new file mode 100644 index 0000000000..6a079b268f --- /dev/null +++ b/01 - JavaScript Drum Kit/app.js @@ -0,0 +1,22 @@ +const removeTransition = (e) => { + if (e.propertyName == "transform") { + e.target.classList.remove("playing"); + } +}; + +const playSound = (e) => { + const audioSoundBtn = document.querySelector( + `audio[data-key="${e.key.toUpperCase()}"]` + ); + const key = document.querySelector(`div[data-key="${e.key.toUpperCase()}"]`); + if (audioSoundBtn) { + key.classList.add("playing"); + audioSoundBtn.currentTime = 0; + audioSoundBtn.play(); + } +}; +const keys = document.querySelectorAll(".key"); +keys.forEach((key) => { + key.addEventListener("transitionend", removeTransition); +}); +window.addEventListener("keydown", playSound); diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..1e96a1e846 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -7,60 +7,56 @@ -
-
+
A clap
-
+
S hihat
-
+
D kick
-
+
F openhat
-
+
G boom
-
+
H ride
-
+
J snare
-
+
K tom
-
+
L tink
- - - - - - - - - - - + + + + + + + + + + diff --git a/01 - JavaScript Drum Kit/style.css b/01 - JavaScript Drum Kit/style.css index bfdba84312..7a172c8cba 100644 --- a/01 - JavaScript Drum Kit/style.css +++ b/01 - JavaScript Drum Kit/style.css @@ -30,6 +30,7 @@ body,html { color: white; background: rgba(0,0,0,0.4); text-shadow: 0 0 .5rem black; + z-index:10; } .playing { diff --git a/02 - JS and CSS Clock/app.js b/02 - JS and CSS Clock/app.js new file mode 100644 index 0000000000..cb6f8a28a9 --- /dev/null +++ b/02 - JS and CSS Clock/app.js @@ -0,0 +1,30 @@ +const secondHand = document.querySelector(".second-hand"); +const minuteHand = document.querySelector(".min-hand"); +const hourHand = document.querySelector(".hour-hand"); + +console.log(secondHand); +const moveClocks = () => { + const now = new Date(); + const seconds = now.getSeconds(); + const secondsDegrees = (seconds / 60) * 360 + 90; + secondHand.style.transform = `rotate(${secondsDegrees}deg)`; + if (seconds === 0) { + secondHand.style.transition = "all 0s"; + } + + const minute = now.getMinutes(); + const minutesDegrees = (minute / 60) * 360 + 90; + minuteHand.style.transform = `rotate(${minutesDegrees}deg)`; + if (minutes === 0) { + minuteHand.style.transition = "all 0s"; + } + + const hour = now.getHours(); + const hoursDegrees = (hour / 60) * 360 + 90; + hourHand.style.transform = `rotate(${hoursDegrees}deg)`; + if (hours === 0) { + hourHand.style.transition = "all 0s"; + } +}; + +setInterval(moveClocks, 1000); diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index.html similarity index 80% rename from 02 - JS and CSS Clock/index-START.html rename to 02 - JS and CSS Clock/index.html index 7a6d27d5bd..8a93cf4101 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index.html @@ -5,8 +5,6 @@ JS + CSS Clock - -
@@ -43,9 +41,9 @@ position: relative; padding: 2rem; box-shadow: - 0 0 0 4px rgba(0,0,0,0.1), - inset 0 0 0 3px #EFEFEF, - inset 0 0 10px black, + 0 0 0 4px rgba(0,0,0,0.1), + inset 0 0 0 3px #EFEFEF, + inset 0 0 10px black, 0 0 10px rgba(0,0,0,0.2); } @@ -61,14 +59,16 @@ height: 6px; background: black; position: absolute; + transition: all 0.1s; + transition-timing-function:cubic-bezier(0.5, 2.7, 0.58, 1); + transform: rotate(90deg); + transform-origin: 100%; top: 50%; } - - - + diff --git a/03 - CSS Variables/app.js b/03 - CSS Variables/app.js new file mode 100644 index 0000000000..cf6fd096ae --- /dev/null +++ b/03 - CSS Variables/app.js @@ -0,0 +1,14 @@ +const inputs = document.querySelectorAll(".controls input"); + +console.log(inputs); +const updateValues = (e) => { + console.log(e.target); + const suffix = e.target.dataset.sizing || ""; + document.documentElement.style.setProperty( + `--${e.target.name}`, + e.target.value + suffix + ); +}; + +inputs.forEach((input) => input.addEventListener("change", updateValues)); +inputs.forEach((input) => input.addEventListener("mousemove", updateValues)); diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 6b9b539c09..b827bc8747 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -21,7 +21,17 @@

Update CSS Variables with JS

- + diff --git a/04 - Array Cardio Day 1/index-START.html b/04 - Array Cardio Day 1/index-START.html index 21bec96e8c..8ae1cd93f3 100644 --- a/04 - Array Cardio Day 1/index-START.html +++ b/04 - Array Cardio Day 1/index-START.html @@ -34,32 +34,64 @@ 'Berne, Eric', 'Berra, Yogi', 'Berry, Wendell', 'Bevan, Aneurin', 'Ben-Gurion, David', 'Bevel, Ken', 'Biden, Joseph', 'Bennington, Chester', 'Bierce, Ambrose', 'Billings, Josh', 'Birrell, Augustine', 'Blair, Tony', 'Beecher, Henry', 'Biondo, Frank' ]; - + // Array.prototype.filter() // 1. Filter the list of inventors for those who were born in the 1500's + const oldInventors = inventors.filter(inventor => inventor.year >= 1500 && inventor.year <= 1600) + + console.table(oldInventors) + // Array.prototype.map() // 2. Give us an array of the inventors first and last names + const firstLast = inventors.map(inventor => { + return `${inventor.first} ${inventor.last}` + }) + console.log(firstLast) // Array.prototype.sort() // 3. Sort the inventors by birthdate, oldest to youngest + const inventorSorted = inventors.sort((a,b) => a.year < b.year ? -1 : 1) + console.table(inventorSorted) // Array.prototype.reduce() // 4. How many years did all the inventors live all together? - + const inventorsLifes = inventors.reduce((total,inventor)=>{ + return total + (inventor.passed - inventor.year) + },0) + console.log(inventorsLifes) // 5. Sort the inventors by years lived - + const inventorsSortedByYears = inventors.sort((a,b)=>{ + const aYears = a.passed - a.year; + const bYears = b.passed - b.year; + return aYears > bYears ? -1 : 1; + }) + console.table(inventorsSortedByYears) // 6. create a list of Boulevards in Paris that contain 'de' anywhere in the name // https://en.wikipedia.org/wiki/Category:Boulevards_in_Paris // 7. sort Exercise // Sort the people alphabetically by last name + const peopleName = people.sort((a,b) => { + const Aname = a.slice(", "); + const Bname = b.slice(", "); + return Aname > Bname ? 1 : -1; + }) + console.log(peopleName) // 8. Reduce Exercise // Sum up the instances of each of these - const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck' ]; + const data = ['car', 'car', 'truck', 'truck', 'bike', 'walk', 'car', 'van', 'bike', 'walk', 'car', 'van', 'car', 'truck', 'walk', 'skateboard' ]; + const dataSummedUp = data.reduce((obj,item)=>{ + if(!obj[item]){ + obj[item] = 0; + } + obj[item]++; + return obj + },{}) + console.log(dataSummedUp) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index 71d1c26f00..622ef3c7ad 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -14,11 +14,11 @@ font-size: 20px; font-weight: 200; } - + body { margin: 0; } - + *, *:before, *:after { box-sizing: inherit; } @@ -26,6 +26,7 @@ .panels { min-height: 100vh; overflow: hidden; + display:flex; } .panel { @@ -43,6 +44,9 @@ font-size: 20px; background-size: cover; background-position: center; + flex:1; + display:flex; + flex-direction: column; } .panel1 { background-image:url(https://source.unsplash.com/gYl-UtwNg_I/1500x1500); } @@ -56,7 +60,16 @@ margin: 0; width: 100%; transition: transform 0.5s; + display:flex; + justify-content: center; + align-items: center; + flex: 1 0 auto; + } + .panel > *:first-child {transform: translateY(-100%);} + .panel > *:last-child {transform: translateY(100%);} + .panel.open-active > *:first-child {transform: translateY(0);} + .panel.open-active > *:last-child {transform: translateY(0);} .panel p { text-transform: uppercase; @@ -64,13 +77,14 @@ text-shadow: 0 0 4px rgba(0, 0, 0, 0.72), 0 0 14px rgba(0, 0, 0, 0.45); font-size: 2em; } - + .panel p:nth-child(2) { font-size: 4em; } .panel.open { font-size: 40px; + flex:5; } @@ -105,6 +119,22 @@