-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working forecast block with base styling
- Loading branch information
1 parent
0c4265f
commit bd9d4d6
Showing
8 changed files
with
438 additions
and
75 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,42 @@ | ||
/** | ||
* Empty for now. | ||
* On DOM Ready | ||
* @param {Object} options | ||
*/ | ||
|
||
document.addEventListener( 'DOMContentLoaded', () => { | ||
const forecastDays = document.querySelectorAll( '.forecast-day' ); | ||
|
||
forecastDays.forEach( ( day ) => { | ||
// Add the toggle class to the forecast-day element | ||
day.addEventListener( 'click', () => day.classList.toggle( 'open' ) ); | ||
|
||
// Sort the hours by data-rating | ||
const hours = day.querySelectorAll( '.forecast-hour' ); | ||
const hoursArray = Array.from( hours ); | ||
const sortedHours = hoursArray.sort( ( a, b ) => a.dataset.rating - b.dataset.rating ); | ||
sortedHours[0].classList.add( 'best-hour' ); | ||
sortedHours[1].classList.add( 'best-hour' ); | ||
|
||
// Tag the best and worst wind and wave forecasts | ||
const wind = day.querySelectorAll( '.wind' ); | ||
const windArray = Array.from( wind ); | ||
windArray.map( ( wind ) => { | ||
if ( 3.9 >= wind.dataset.speed ) { | ||
wind.classList.add( 'good' ); | ||
} else if ( 10 <= wind.dataset.speed ) { | ||
wind.classList.add( 'bad' ); | ||
} | ||
} ); | ||
|
||
const wave = day.querySelectorAll( '.wave' ); | ||
const waveArray = Array.from( wave ); | ||
waveArray.map( ( wave ) => { | ||
if ( .3 >= wave.dataset.height ) { | ||
wave.classList.add( 'good' ); | ||
} else if ( 1 <= wave.dataset.height ) { | ||
wave.classList.add( 'bad' ); | ||
} | ||
} ); | ||
} ); | ||
|
||
}); |
Oops, something went wrong.