Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css"/>
  <link rel='icon' href='https://sandbox.roberrini.com/wp-content/uploads/2020/03/okayweathericon.svg' type='image/x-icon' >
    <title>Okay Weather | by Jeremie ROBERRINI NEVEU</title>
</head>
<body>
    <main>
        <section class="currently big-column">
            <h1 id="location">City</h1>
            <article class="now">
                <section class="now-principal">
                    <section class="now-image">
                        <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/error.svg" alt="current weather icon" id="now-icon">
                    </section>
                    <section class="now-temp">
                        <p id="now-temp">0</p>
                        <p>°</p>
                    </section>
                </section>
                <section class="now-detail">
                    <section class="now-detail-card" >
                        <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/wind-dark.svg" alt="wind">
                        <p id="now-wind">0</p>
                        <p> km/h</p>
                    </section>
                    <section class="now-detail-card" >
                        <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/rain-dark.svg" alt="rain">
                        <p id="now-rain">0</p>
                        <p> %</p>
                    </section>
                </section>
            </article>
            <article class="today">
                <H2>Today</H2>
                <section class="today-wrapper">
                    <section class="today-card" id="today-morning">
                        <section class="today-card-wrapper">
                            <section class="today-card-main">
                                <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/error.svg" alt="morning icon" id="morning-icon">
                                <p id="morning-temp">0</p>
                                <p>°</p>
                            </section>
                            <section class="today-card-secondary-wrapper">
                                <section class="today-card-secondary">
                                    <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/wind-light.svg" alt="wind">
                                    <p id="morning-wind">0</p>
                                </section>
                                <section class="today-card-secondary">
                                    <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/rain-light.svg" alt="rain">
                                    <p id="morning-rain">0</p>
                                </section>                                
                            </section>
                        </section>
                        <h3>Morning</h3>
                    </section>
                    <section class="today-card" id="today-afternoon">
                        <section class="today-card-wrapper">
                            <section class="today-card-main">
                                <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/error.svg" alt="afternoon icon" id="afternoon-icon">
                                <p id="afternoon-temp">0</p>
                                <p>°</p>
                            </section>
                            <section class="today-card-secondary-wrapper">
                                <section class="today-card-secondary">
                                    <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/wind-light.svg" alt="wind">
                                    <p id="afternoon-wind">0</p>
                                </section>
                                <section class="today-card-secondary">
                                    <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/rain-light.svg" alt="rain">
                                    <p id="afternoon-rain">0</p>
                                </section>                                
                            </section>
                        </section>
                        <h3>Afternoon</h3>
                    </section>
                    <section class="today-card" id="today-night">
                        <section class="today-card-wrapper">
                            <section class="today-card-main">
                                <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/error.svg" alt="night icon" id="night-icon">
                                <p id="night-temp">0</p>
                                <p>°</p>
                            </section>
                            <section class="today-card-secondary-wrapper">
                                <section class="today-card-secondary">
                                    <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/wind-light.svg" alt="wind">
                                    <p id="night-wind">0</p>
                                </section>
                                <section class="today-card-secondary">
                                    <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/rain-light.svg" alt="rain">
                                    <p id="night-rain">0</p>
                                </section>                                
                            </section>
                        </section>
                        <h3>Night</h3>
                    </section>
                </section>
            </article>
            <article class="rain">
                <h2>Rain</h2>
                <section class="rain-graphic">
                    <section class="rain-wrapper">
                        <section class="rain-chart">
                            <hr id="6">
                            <hr id="7">
                            <hr id="8">
                            <hr id="9">
                            <hr id="10">
                            <hr id="11">
                            <hr id="12">
                            <hr id="13">
                            <hr id="14">
                            <hr id="15">
                            <hr id="16">
                            <hr id="17">
                            <hr id="18">
                            <hr id="19">
                            <hr id="20">
                            <hr id="21">
                            <hr id="22">
                        </section>
                        <hr>
                        <Section class="rain-time">
                            <p>6am</p>
                            <p></p>
                            <p>12pm</p>
                            <p>5pm</p>
                            <p>10pm</p>                        
                        </Section>
                    </section>
                </section>
            </article>
        </section>
        <section class="future big-column">
            <article class="week">
                <h1>This week</h1>
                <section class="week-wrapper">
                    <section class="week-card" id="day1">
                        <section class="week-card-day">
                            <span id="day1-text">dd</span>
                            <span>,</span>
                            <span id="day1-number">00</span>
                        </section>
                        <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/error.svg" alt="weather icon" id="day1-icon">
                        <p id="day1-temp">o</p>
                        
                        <section class="week-card-info">
                            <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/rain-dark.svg" alt="rain">
                            <p id="day1-rain">0</p>
                            <span>%</span>
                        </section>
                        <section class="week-card-info">
                            <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/wind-dark.svg" alt="wind">
                            <p id="day1-wind">0</p>
                            <span>k/h</span>
                        </section>
                    </section>

                    <section class="week-card" id="day2">
                        <section class="week-card-day">
                            <span id="day2-text">dd</span>
                            <span>,</span>
                            <span id="day2-number">00</span>
                        </section>
                        <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/error.svg" alt="weather icon" id="day2-icon">
                        <p id="day2-temp">o</p>
                        
                        <section class="week-card-info">
                            <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/rain-dark.svg" alt="rain">
                            <p id="day2-rain">0</p>
                            <span>%</span>
                        </section>
                        <section class="week-card-info">
                            <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/wind-dark.svg" alt="wind">
                            <p id="day2-wind">0</p>
                            <span>k/h</span>
                        </section>
                    </section>

                        <section class="week-card" id="day3">
                            <section class="week-card-day">
                                <span id="day3-text">dd</span>
                                <span>,</span>
                                <span id="day3-number">00</span>
                            </section>
                            <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/error.svg" alt="weather icon" id="day3-icon">
                            <p id="day3-temp">o</p>
                            
                            <section class="week-card-info">
                                <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/rain-dark.svg" alt="rain">
                                <p id="day3-rain">0</p>
                                <span>%</span>
                            </section>
                            <section class="week-card-info">
                                <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/wind-dark.svg" alt="wind">
                                <p id="day3-wind">0</p>
                                <span>k/h</span>
                            </section>
                        </section>

                        <section class="week-card" id="day4">
                            <section class="week-card-day">
                                <span id="day4-text">dd</span>
                                <span>,</span>
                                <span id="day4-number">00</span>
                            </section>
                            <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/error.svg" alt="weather icon" id="day4-icon">
                            <p id="day4-temp">o</p>
                            
                            <section class="week-card-info">
                                <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/rain-dark.svg" alt="rain">
                                <p id="day4-rain">0</p>
                                <span>%</span>
                            </section>
                            <section class="week-card-info">
                                <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/wind-dark.svg" alt="wind">
                                <p id="day4-wind">0</p>
                                <span>k/h</span>
                            </section>
                        </section>

                        <section class="week-card" id="day5">
                            <section class="week-card-day">
                                <span id="day5-text">dd</span>
                                <span>,</span>
                                <span id="day5-number">00</span>
                            </section>
                            <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/error.svg" alt="weather icon" id="day5-icon">
                            <p id="day5-temp">o</p>
                            
                            <section class="week-card-info">
                                <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/rain-dark.svg" alt="rain">
                                <p id="day5-rain">0</p>
                                <span>%</span>
                            </section>
                            <section class="week-card-info">
                                <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/wind-dark.svg" alt="wind">
                                <p id="day5-wind">0</p>
                                <span>k/h</span>
                            </section>
                        
                    </section>
                    
                </section>
            </article>
            <h2>Details</h2>
            <article class="detail">
                
                <section class="detail-left">
                    <section class="detail-card">
                        <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/sunrise.svg" alt="sunrise">
                        <p id="sunrise">Sunrise</p>
                    </section>
                    <section class="detail-card">
                        <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/moon.svg" alt="moon">
                        <p id="moon">moon</p>
                    </section>
                    <section class="detail-card">
                        <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/cloud.svg" alt="clouds">
                        <p id="clouds">clouds</p>
                    </section>
                    
                </section>
                <section class="detail-right">
                    <section class="detail-card">
                        <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/sunset.svg" alt="sunset">
                        <p id="sunset">Sunset</p>
                    </section>
                    <section class="detail-card">
                        <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/uv.svg" alt="uv">
                        <p id="uv">uv</p>
                    </section>
                    <section class="detail-card">
                        <img src="https://sandbox.roberrini.com/wp-content/uploads/2020/03/humidity.svg" alt="humidity">
                        <p id="humidity">humidity</p>
                    </section>
                    
                </section>
            </article>
        </section>
    </main>

    <script src="app.js"></script>
</body>
</html>
              
            
!

CSS

              
                :root{
    --myblack: #2d2d2d;
    --mygrey: #f0f0f0;
}

*{
    Margin:0;
    Padding:0;
    box-sizing:0;
}
html {
    scroll-behavior: smooth;
}
main{
    background-color: #fafafa;
    font-family: 'Montserrat', Helvetica, sans-serif;
    color: var(--myblack);
    padding: 2%;
    
    height: 100%;
    display: flex;
    flex-direction: row;
    align-items: top;
}
h1{
    font-size: 30px;
    letter-spacing: 5px;
    font-weight: 800 bold;
    margin-bottom: 5%;
}
h2{
    font-size: 30px;
    letter-spacing: 5px;
    font-weight: 800;
    padding-top: 10%;
    padding-bottom: 5%;
}
.big-column{
    width: 45%;
    padding-right: 5%;
    padding-left: 5%;
    display: flex;
    flex-direction: column;
    justify-content: stretch;
}
.now{
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    height: 4%;
    margin-top: 10%;
    margin-bottom: 10%;
}
.now-principal{
    width: 60%;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: flex-end;
}

.now-image{
width: 50%;
}
.now-image img{
    width: 100%;
}
.now-temp{
    display: flex;
    flex-direction: row;
    justify-content: start;
    align-items: center;
}
.now-temp p{
    font-size: 74px;
    font-weight: 300;
}
.now-detail{
    width: 40%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.now-detail-card{
    display: flex;
    flex-direction: row;
    justify-content: start;
    align-items: space-around;
}
.now-detail-card img{
    width: 20%;
}
.now-detail-card p{
    font-size: 30px;
    font-weight: 300;
}
.today-wrapper{
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-content: center;
}
.today-card{
    width: 30%;
    height: 10%;
    display: flex;
    flex-direction: column;
    padding-left: 2%;
    padding-bottom: 2%;
    padding-top: 2%;
    border-radius: 8px;
}
.today-card-wrapper{
    display: flex;
    justify-content: space-between;
    flex-direction: row;
}
.today-card-main{
    width: 60%;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
}
.today-card-main img{
    width: 50%;
}
.today-card-main p{
    font-size: 30px;
    font-weight: 600;
    color: white;
}
.today-card-secondary-wrapper{
    width: 40%;
    display: flex;
    flex-direction: column;
    justify-content: start;
    align-items: space-between;
}
.today-card-secondary{
    display: flex;
    flex-direction: row;
    align-items: center;
}
.today-card-secondary img{
    width: 30%;
}
.today-card-secondary p{
    font-size: 18px;
    font-weight: 600;
    color: white;
}
.today-card h3{
    font-size: 20px;
    font-weight: 500;
    color: white;
}
#today-morning{
    background-image: url(https://sandbox.roberrini.com/wp-content/uploads/2020/03/morning.svg);
    background-size: cover;
    background-repeat: no-repeat;
    background-color: peru;
}
#today-afternoon{
    background-image: url(https://sandbox.roberrini.com/wp-content/uploads/2020/03/afternoon.svg);
    background-size: cover;
    background-repeat: no-repeat;
    background-color: blue;
}
#today-night{
    background-image: url(https://sandbox.roberrini.com/wp-content/uploads/2020/03/night.svg);
    background-size: cover;
    background-repeat: no-repeat;
    background-color: purple;
}
.rain-graphic{
    margin-top: -5%;
}
.rain-wrapper{
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: start;
    align-content: stretch;
}
.rain-chart{
    height: 13vh;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
}

.rain-wrapper hr{
    height: 4px;
    background-color: var(--myblack);
    width: 100%;
    border-radius: 20px;
}
.rain-chart hr{
    height: 100%;
    width: 4%;
    background-color: var(--mygrey);
    opacity: 50%;
    border-radius: 0;
    border: 0;
}
.rain-time{
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
}
.rain-time p{
    font-size: 18px;
}
.week-wrapper{
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}
.week-card{
    background-color: var(--mygrey);
    border-radius: 8px;
    padding: 2%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 15%;
}
.week-card-day span{
    font-size: 14px;
    font-weight: bold;
}
.week-card img{
    width: 100%;
    padding-top: 2%;
    margin-bottom: 0%;

}
.week-card p{
    font-size: 50px;
    font-weight: 300,lighter;

}
.week-card-info{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding-top: 1%;
}
.week-card-info img{
    width: 25%;
}
.week-card-info p{
    font-size: 20px;
    font-weight: 300, lighter;
}
.week-card-info span{
    font-size: 20px;
    font-weight: 300, lighter;
}
.detail{
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}
.detail-card{
    width: 60%;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    height: 25%;
}
.detail-card img{
    width: 50%;
}
.detail-card p{
    font-size: 20px;
    font-weight: 500;
}
@media screen and (max-width: 800px){
    main{
        flex-direction: column;
    }
    .big-column{
        width: 98%;
      padding:1%;
    }
    .now-temp p{
        font-size: 60px;
    }
    .now-detail-card p{
        font-size: 25px;
    }
    .today-card-main p{
        font-size: 25px;
    }
    .today-card-secondary p{
        font-size: 14px;
    }
    .today-card h3{
        font-size: 16px;
    }
    .rain-time p{
        font-size: 16px;
    }
    .week-card-day span{
        font-size: 12px;
    }
    .week-card p{
        font-size: 35px;    
    }
    .week-card-info p{
        font-size: 16px;
    }
    .week-card-info span{
        font-size: 16px;        
    }
     .rain-chart{
        height: 18vh;
    }
}
              
            
!

JS

              
                window.addEventListener('load', ()=>{
    let long;
    let lat;
    let location = document.getElementById('location');
    //delacre rightnow
    let nowIcon = document.getElementById('now-icon');
    let nowTemp = document.getElementById('now-temp');
    let nowWind = document.getElementById('now-wind');
    let nowRain = document.getElementById('now-rain');

    if(navigator.geolocation){
        navigator.geolocation.getCurrentPosition(position => {
            long = position.coords.longitude;
            lat = position.coords.latitude;

            const proxy = 'https://cors-anywhere.herokuapp.com/';
            fetch(proxy)
                            
            const api = proxy  +'https://api.darksky.net/forecast/d3e1bb2bc9c8c4a78a66c1106c8f5f18/' + lat +','+ long + '?units=ca';
            
            
            fetch(api)
                .then(response => {
                    return response.json();
                })
                .then(data => {
                    console.log(data);
                    //place
                    location.textContent = data.timezone
                    //now
                    nowTemp.textContent = Math.round(data.currently.temperature);
                    nowRain.textContent = Math.round(data.currently.precipProbability*100);
                    nowWind.textContent = Math.round(data.currently.windSpeed);
                    nowIcon.src = 'https://sandbox.roberrini.com/wp-content/uploads/2020/03/'+ data.currently.icon +'.svg';
                    
                    //week data
                    day = 1;
                    for (let day = 1;day < 6; day++) {
                        //date
                        date = new Date(data.daily.data[day].time * 1000);
                        var dayText = ['Su','Mo','Tu','We','Th','Fr','Sa','Su']
                        document.getElementById('day'+day+'-number').textContent = date.getDate();
                        document.getElementById('day'+day+'-text').textContent = dayText[date.getDay()];                         
                        //weather 
                        document.getElementById('day'+day+'-icon').src = 'https://sandbox.roberrini.com/wp-content/uploads/2020/03/' + data.daily.data[day].icon + '.svg';
                        document.getElementById('day'+day+'-temp').textContent = Math.round((data.daily.data[day].temperatureMin + data.daily.data[day].temperatureMax)/2)+'°';
                        document.getElementById('day'+day+'-wind').textContent = Math.round(data.daily.data[day].windSpeed);
                        document.getElementById('day'+day+'-rain').textContent = Math.round(data.daily.data[day].precipProbability*100);
                    }
                    
                    //details
                    rise = new Date(data.daily.data[0].sunriseTime * 1000);
                    document.getElementById('sunrise').textContent = rise.getHours() + ':' + rise.getMinutes();
                    set = new Date(data.daily.data[0].sunsetTime * 1000);
                    document.getElementById('sunset').textContent = set.getHours() + ':' + set.getMinutes();

                    document.getElementById('moon').textContent = Math.round(data.daily.data[0].moonPhase*100) + '%';
                    document.getElementById('uv').textContent = 'uv: ' + Math.round(data.daily.data[0].uvIndex);
                    document.getElementById('clouds').textContent =  Math.round(data.daily.data[0].cloudCover*100) + '%';
                    document.getElementById('humidity').textContent =  Math.round(data.daily.data[0].humidity*100) + '% humidity';
                    
                   test = new Date(data.hourly.data[0].time);
                   console.log(test.getHours());

                });

                //We need to get today date with midnight in UX time format
                time= new Date();
                today = new Date(time.getFullYear(),time.getMonth(),time.getDate(),0,0,0,0);                
                now = Math.round(today.getTime()/1000);
                
                const dayApi = proxy  +'https://api.darksky.net/forecast/d3e1bb2bc9c8c4a78a66c1106c8f5f18/' + lat +','+ long + ','+ now +'?units=ca';
            
            //getting the info to the day right
            fetch(dayApi)
                .then(response => {
                    return response.json();
                })
                .then(info =>{
                    console.log(info);
                    test2= new Date(info.hourly.data[0].time)
                    console.log(test2.getHours());
                    //morning
                    document.getElementById('morning-temp').textContent = Math.round(info.hourly.data[9].temperature);
                    document.getElementById('morning-wind').textContent = Math.round(info.hourly.data[9].windSpeed);
                    document.getElementById('morning-rain').textContent = Math.round(info.hourly.data[9].precipProbability*100);
                    document.getElementById('morning-icon').src = 'https://sandbox.roberrini.com/wp-content/uploads/2020/03/'+ info.hourly.data[9].icon +'.svg';

                    //afternoon
                    document.getElementById('afternoon-temp').textContent = Math.round(info.hourly.data[17].temperature);
                    document.getElementById('afternoon-wind').textContent = Math.round(info.hourly.data[17].windSpeed);
                    document.getElementById('afternoon-rain').textContent = Math.round(info.hourly.data[17].precipProbability*100);
                    document.getElementById('afternoon-icon').src = 'https://sandbox.roberrini.com/wp-content/uploads/2020/03/'+ info.hourly.data[17].icon +'.svg';

                    //night
                    document.getElementById('night-temp').textContent = Math.round(info.hourly.data[22].temperature);
                    document.getElementById('night-wind').textContent = Math.round(info.hourly.data[22].windSpeed);
                    document.getElementById('night-rain').textContent = Math.round(info.hourly.data[22].precipProbability*100);
                    document.getElementById('night-icon').src = 'https://sandbox.roberrini.com/wp-content/uploads/2020/03/'+ info.hourly.data[22].icon +'.svg';


                    //rain chart loop
                    time = 6;
                    for (let time = 6; time < 23; time++) {
                        document.getElementById(time).style.opacity = info.hourly.data[time].precipProbability;
                        if (info.hourly.data[time].precipIntensity < 2) {
                            document.getElementById(time).style.backgroundColor = '#5ECFF4';
                            document.getElementById(time).style.height = (info.hourly.data[time].precipIntensity/2)*100+'%';

                        } else {
                            document.getElementById(time).style.backgroundColor = 'purple';
                            document.getElementById(time).style.height = '100%';
                        }
                    }
                }

                )
                
        })

    }else { location.textContent = "we couldn't find you"};



});
              
            
!
999px

Console