From 3ff5e06cd0779e76b2db2ef0f4981d1f0e9227ac Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Wed, 6 Jun 2018 19:16:58 -0700 Subject: [PATCH 01/17] first commit, and just about done with this first exercise --- 01 - JavaScript Drum Kit/index-START.html | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 4070d32767..0d2012ef4b 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,7 +58,32 @@ From 38f92de39b14fcbd7820c2d4c43c02898408a96b Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Wed, 6 Jun 2018 19:37:10 -0700 Subject: [PATCH 02/17] ok finished this one --- 01 - JavaScript Drum Kit/index-START.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/01 - JavaScript Drum Kit/index-START.html b/01 - JavaScript Drum Kit/index-START.html index 0d2012ef4b..72bd58ad88 100644 --- a/01 - JavaScript Drum Kit/index-START.html +++ b/01 - JavaScript Drum Kit/index-START.html @@ -58,7 +58,7 @@ From 302ec4eb6f62a914c1f89da8228281c7cf3ca957 Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Thu, 7 Jun 2018 18:08:28 -0700 Subject: [PATCH 03/17] heres da clock --- 02 - JS and CSS Clock/index-START.html | 28 ++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index-START.html index ee7eaefb1f..a2f77be08f 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index-START.html @@ -62,13 +62,41 @@ background:black; position: absolute; top:50%; + transform-origin: 100%; + transform: rotate(90deg); + transition: all 0.05s; + transition-timing-function: cubic-bezier(0.1, 2.7, 0.58, 1); } From 5b855e9c985c052aacfa16b3977b3898f5d429de Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Thu, 7 Jun 2018 19:21:45 -0700 Subject: [PATCH 04/17] this is cleaner --- 02 - JS and CSS Clock/index-START.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/02 - JS and CSS Clock/index-START.html b/02 - JS and CSS Clock/index-START.html index a2f77be08f..1c7d85c915 100644 --- a/02 - JS and CSS Clock/index-START.html +++ b/02 - JS and CSS Clock/index-START.html @@ -77,23 +77,23 @@ const hourHand = document.querySelector('.hour-hand'); const now = new Date(); const seconds = now.getSeconds(); + const mins = now.getMinutes(); + const hours = now.getHours(); // example if its 60 seconds // (60 / 60) * 360 would be 360 degrees // const secondsDegrees = (seconds / 60) * 360; // then we have to add 90 degrees to counter the // css transform to move the hand where we need it const secondsDegrees = ((seconds / 60) * 360) + 90; - const mins = now.getMinutes(); const minsDegrees = ((mins / 60) * 360) + 90; - const hours = now.getHours(); const hoursDegrees = ((hours / 12) * 360) + 90; secondHand.style.transform = `rotate(${secondsDegrees}deg)`; minsHand.style.transform = `rotate(${minsDegrees}deg)`; hourHand.style.transform = `rotate(${hoursDegrees}deg)`; - console.log('secondsDegrees: ', secondsDegrees); - console.log('seconds: ', seconds); + // console.log('secondsDegrees: ', secondsDegrees); + // console.log('seconds: ', seconds); }; setInterval(setDate, 1000); From 88266557668f4a371ffb9b620145feb6b8b35cda Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Tue, 12 Jun 2018 19:12:23 -0700 Subject: [PATCH 05/17] that was a fun and informative css variables example, coolio --- 03 - CSS Variables/index-START.html | 78 ++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 23 deletions(-) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index 8a4f0d556e..f3f0969746 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -3,6 +3,45 @@ Scoped CSS Variables and JS +

Update CSS Variables with JS

@@ -18,33 +57,26 @@

Update CSS Variables with JS

- - - From 38d698313ed446d13df1dfdcb5c669540282d1fe Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Tue, 12 Jun 2018 19:25:42 -0700 Subject: [PATCH 06/17] interesting, i tried to apply the inline style to controls div instead of the html element and it doesnt work, you can see the values changing like it does on the html elmeent but it doesnt change the rendering at all --- 03 - CSS Variables/index-START.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/03 - CSS Variables/index-START.html b/03 - CSS Variables/index-START.html index f3f0969746..e168d26b7f 100644 --- a/03 - CSS Variables/index-START.html +++ b/03 - CSS Variables/index-START.html @@ -62,6 +62,7 @@

Update CSS Variables with JS

From b650930b9001247b0e533bfab51ee4bd3b3fb573 Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Sat, 16 Jun 2018 11:32:55 -0700 Subject: [PATCH 10/17] flex gallerying, animation and transforming here is cool --- 05 - Flex Panel Gallery/index-START.html | 54 ++++++++++++++++++++---- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/05 - Flex Panel Gallery/index-START.html b/05 - Flex Panel Gallery/index-START.html index c6509bed02..7e271d800a 100644 --- a/05 - Flex Panel Gallery/index-START.html +++ b/05 - Flex Panel Gallery/index-START.html @@ -22,16 +22,17 @@ } .panels { + display: flex; min-height:100vh; overflow: hidden; } .panel { - background:#6B0F9C; - box-shadow:inset 0 0 0 5px rgba(255,255,255,0.1); - color:white; - text-align: center; - align-items:center; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + flex: 1; /* Safari transitionend event.propertyName === flex */ /* Chrome + FF transitionend event.propertyName === flex-grow */ transition: @@ -39,8 +40,12 @@ flex 0.7s cubic-bezier(0.61,-0.19, 0.7,-0.11), background 0.2s; font-size: 20px; - background-size:cover; - background-position:center; + text-align: center; + background-size: cover; + background-position: center; + background: #6B0F9C; + box-shadow: inset 0 0 0 5px rgba(255,255,255,0.1); + color: white; } @@ -51,25 +56,47 @@ .panel5 { background-image:url(https://source.unsplash.com/3MNzGlQM7qs/1500x1500); } .panel > * { + display: flex; + flex: 1 0 auto; + justify-content: center; + align-items: center; margin:0; width: 100%; transition:transform 0.5s; } + .panel > *:first-child { + transform: translateY(-100%); + } + + .panel > *:last-child { + transform: translateY(100%); + } + .panel p { text-transform: uppercase; font-family: 'Amatic SC', cursive; 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 { + flex: 5; font-size:40px; } + .panel.open-active > *:first-child { + transform: translateY(0); + } + + .panel.open-active > *:last-child { + transform: translateY(0); + } + @@ -102,7 +129,18 @@ From 756d8ce01531fd9c7ec528f8d0f9c9b2ec1a612b Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Sun, 17 Jun 2018 12:21:35 -0700 Subject: [PATCH 11/17] man some really really useful stuff in this one, from fetching data to working with it on the user end to redisplay it, so much to learn here take this one slow, mad real world here! --- 06 - Type Ahead/index-START.html | 130 +++++++++++++++++++++++++++++-- 1 file changed, 125 insertions(+), 5 deletions(-) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 1436886918..149e3bbccf 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -6,7 +6,6 @@ -
    @@ -14,9 +13,130 @@
  • or a state
- - + const displayMatches = () => { + // console.log('this value in displayMatches: ', searchInput.value); + // console.log('this value in displayMatches: ', this.value); + // note if you are not using an arrow function use this which refers + // to the searchInput + // so in here we are going to use findMatches: + const matchArray = findMatches(searchInput.value, cities); + // console.log('matchArray: ', matchArray); + // when we map over each place the map method will return an + // array, when we really want one string, so we can call a quick + // .join on the end and that will turn it from an array with + // multiple items, into one big string + const html = matchArray.map(place => { + // const regex = new RegExp(this.value, 'gi'); + // const cityName = place.city.replace( + // regex, + // `${this.value}` + // ); + const regex = new RegExp(searchInput.value, 'gi'); + const cityName = place.city.replace( + regex, + `${searchInput.value}` + ); + const stateName = place.state.replace( + regex, + `${searchInput.value}` + ); + return ` +
  • + ${cityName}, ${stateName} + ${numberWithCommas(place.population)} +
  • + `; + }) + .join(''); + suggestions.innerHTML = html; + }; + + searchInput.addEventListener('change', displayMatches); + // at this point we only listen for change which happens when + // a user focuses off the input, not when they type something different + // so lets add another listener and run displayMatches on keyup + searchInput.addEventListener('keyup', displayMatches); + /* + couple last things we need to do here is to format the population + value as well as highlighting the input value if it matches + lets go back to our displayMatches map function and before that return lets + create a regex that will match the city name and then we'll use + that regex to replace the word that it matches with a span with + a class of `hl` and the word that it matches + */ + + From af80a2e5073d165f2cf620aeacc7ad7243aec79e Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Mon, 18 Jun 2018 20:13:43 -0700 Subject: [PATCH 12/17] updating some comments and moved some code around to make it read better --- 06 - Type Ahead/index-START.html | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index 149e3bbccf..c61a5c7e16 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -21,7 +21,7 @@ fetch(endpoint) .then( data => { - /* if you check the log at this point you + /* if you check console.log(data) at this point you will see that its a Response and a 200 status looks good but beyond that its weird looking and where actually is our data? (this is why wes calls this var 'blob') @@ -66,8 +66,8 @@ `g` is for global - meaning its going to look thru the entire string for that specific one, `i` is insensitve meaning its case insensitive and will match on either uppercase or lowercase. - then we call .match and pass in our regex and return if either - a city or state from `wordToMatch` matches + then we call .match and pass in the value of our regex wordToMatch + and return if either a city or state from `wordToMatch` matches */ const regex = new RegExp(wordToMatch, 'gi'); return place.city.match(regex) || place.state.match(regex); @@ -76,15 +76,10 @@ /* now we need to create a displayMatches function that is going to be called every time someone - changes the value + changes the value in our search input */ const searchInput = document.querySelector('.search'); const suggestions = document.querySelector('.suggestions'); - // wes didnt explain this function just that it formats a string into - // commented one and just grabbed it from the internet - const numberWithCommas = (x) => { - return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); - }; const displayMatches = () => { // console.log('this value in displayMatches: ', searchInput.value); @@ -123,7 +118,14 @@ .join(''); suggestions.innerHTML = html; }; + + // wes didnt explain this function just that it formats a string into + // commented one and just grabbed it from the internet + const numberWithCommas = (x) => { + return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); + }; + console.log('cites: ', cities); searchInput.addEventListener('change', displayMatches); // at this point we only listen for change which happens when // a user focuses off the input, not when they type something different From d2a4573dbdc7e102847de275ef342aa378afdad6 Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Wed, 20 Jun 2018 20:33:58 -0700 Subject: [PATCH 13/17] housekeeping --- 06 - Type Ahead/index-START.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/06 - Type Ahead/index-START.html b/06 - Type Ahead/index-START.html index c61a5c7e16..d661443076 100644 --- a/06 - Type Ahead/index-START.html +++ b/06 - Type Ahead/index-START.html @@ -45,7 +45,7 @@ item in the cities array. so the way that we can change this array into individual arguments is we _spread into it_ via the es6 spread operator! */ - .then(data => cities.push(...data)); + .then(data => cities.push(...data)); }); /* next when someone types into the text input we want to write a function (findMatches()) that takes this massive cites array and From 22de835015a41e2a80c74b25626cd6b69d667ac3 Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Mon, 9 Jul 2018 18:31:46 -0700 Subject: [PATCH 14/17] array cardio day 2 donez0 --- 07 - Array Cardio Day 2/index-START.html | 69 +++++++++++++++++++++++- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/07 - Array Cardio Day 2/index-START.html b/07 - Array Cardio Day 2/index-START.html index 969566ff78..866199d266 100644 --- a/07 - Array Cardio Day 2/index-START.html +++ b/07 - Array Cardio Day 2/index-START.html @@ -26,15 +26,80 @@ // Some and Every Checks // Array.prototype.some() // is at least one person 19 or older? + // const isAdult = people.some((person) => { + // const currentYear = (new Date()).getFullYear(); + // if (currentYear - person.year >= 19) { + // return true; + // } + // }); + // we can rewrite the above with a simpler return: + // const isAdult = people.some((person) => { + // const currentYear = (new Date()).getFullYear(); + // console.log({currentYear}); + // return currentYear - person.year >= 19; + // }); + // heres the HOT SHOT version: + const isAdult = people.some( + person => ( (new Date()). + getFullYear() ) - person.year >= 19 + ); + console.log({isAdult}); // Array.prototype.every() // is everyone 19 or older? - + const allAdults = people.every( + person => ( (new Date()). + getFullYear() ) - person.year >= 19 + ); + console.log({allAdults}); // Array.prototype.find() // Find is like filter, but instead returns just the one you are looking for // find the comment with the ID of 823423 - + // const comment = comments.find( + // (comment) => { + // if (comment.id === 823423) { + // return true; + // } + // } + // ); + // console.log({comment}); + // heres the hotshot version - + // we dont need the if statement + // because our return is going to be + // either true or false: + const comment = comments.find( + comment => comment.id === 823423 + ); + console.log({comment}); // Array.prototype.findIndex() // Find the comment with this ID // delete the comment with the ID of 823423 + const index = comments.findIndex(comment => comment.id === 823423); + console.log({index}); + // to delete it we can do that a couple of ways: + // comments.splice(index, 1); + console.table(comments); + /* + wes didnt do this but i think if i was going to + use splice id assign it to a var so i wasnt changing + the actual array... + */ + const splicedComments = comments.splice(index, 1); + console.log({splicedComments}); + // you can see now that the super good comment is gone + // you can also do it by creating a new array of updated comments: + // const newComments = [ + // comments.slice(0, index), + // comments.slice(index + 1) + // ]; + // console.log({newComments}); + // oops notice in the log that we have arrays in the + // array? thats because we didnt spread into the array: + const newComments = [ + ...comments.slice(0, index), + ...comments.slice(index + 1) + ]; + console.log({newComments}); + + From 40828a0e607297c93a0883c19480d8d80492a82e Mon Sep 17 00:00:00 2001 From: Clint Fisher Date: Mon, 9 Jul 2018 19:30:00 -0700 Subject: [PATCH 15/17] committing about halfway thru, this is a really cool canvas example for drawing and using events --- 08 - Fun with HTML5 Canvas/index-START.html | 58 +++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/08 - Fun with HTML5 Canvas/index-START.html b/08 - Fun with HTML5 Canvas/index-START.html index 37c148df07..aac38b96c1 100644 --- a/08 - Fun with HTML5 Canvas/index-START.html +++ b/08 - Fun with HTML5 Canvas/index-START.html @@ -7,6 +7,64 @@