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

              
                <html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!--Custom stylesheet-->
    <link rel="stylesheet" href="stylesheets/app.css">
    <title>Twitch.tv API Usage</title>
</head>

<body>
    <div class="container">
        <!--Wrapper div for heading, contains main heading and buttons-->
        <div class="row mt-4 pt-4 wrapper">
            <!--Heading div-->
            <div class="heading col-sm-8 col-md-9">
                <h1 class="">Twitch Streamers</h1>
            </div>
            <!--Seperate div for buttons-->
            <div class="buttons pb-4 col-sm-1">
                <button class="btn mt-2 list offset-sm-8 offset-md-9" id="all">All</button>
                <button class="btn mt-2 list offset-sm-8 offset-md-9" id="online">Online</button>
                <button class="btn mt-2 list offset-sm-8 offset-md-9" id="offline">Offline</button>
            </div>
        </div>
        <!--Channels data from API comes here-->
        <div id="data">
            <!--First channel div-->
            <div id="fcc" class="row mt-3 pt-3 pl-2 channels">
                <img src="https://avatars2.githubusercontent.com/u/9892522?v=4&s=200" alt="FCC logo">
                <a href="https://www.twitch.tv/freecodecamp" target="_blank"><p class="ml-2 font">FreeCodeCamp</p></a>
            </div>
            <!--Second channel div-->
            <div id="esl" class="row mt-3 pt-3 pl-2 channels">
                <img src="https://static-cdn.jtvnw.net/jtv_user_pictures/esl_sc2-profile_image-d6db9488cec97125-300x300.jpeg" alt="ESL_SC2 Logo">
                <a href="https://www.twitch.tv/esl_sc2" target="_blank"><p class="ml-2 font">ESL_SC2</p></a>
            </div>
            <!--Third channel div-->
            <div id="ninja" class="row mt-3 pt-3 pl-2 channels">
                <img src="https://static-cdn.jtvnw.net/jtv_user_pictures/noobs2ninjas-profile_image-34707f847a73d934-300x300.png" alt="Noob to Ninjas Logo">
                <a href="https://www.twitch.tv/noobs2ninjas" target="_blank"><p class="ml-2 font">Noob to Ninjas</p></a>
            </div>

        </div>
    </div>
  </body>

</html>
              
            
!

CSS

              
                $white: #ffff;
@import url('https://fonts.googleapis.com/css?family=Oswald:400,700');
$body-background-color: #070D79;
$main-color: #B67B0B;
$fcc-color:  #006400;
body {
    font-family: 'Oswald', sans-serif;
    background-color: $body-background-color;
    .wrapper {
        border: 4px solid $main-color;
        .heading {
            h1 {
                color: $main-color;
                font-size: 400%;
                @media only screen and (max-width:768px){
                    font-size: 250%;
                }
            }
        }
        .buttons {
            
                .list {
                    text-align: center;
                    width: 80px;
                    background-color: $fcc-color;
                    color: $white;
                    border: 3px solid $main-color;
                    &:hover,
                    &:focus,
                    &:active {
                        background-color: $main-color;
                        color: $body-background-color;
                        width: 90px;
                    }
                }
            }
        }
        #data{
            .channels{
                border: 4px solid $main-color;
                overflow: hidden;
                img{
                    @media only screen and (min-width:769px){
                    height: 100px;
                    width: 100px;
                    border-radius: 50%;
                    border: 4px $main-color solid;
                    }
                    @media only screen and (max-width:768px){
                        height: 60px;
                        width: 60px;
                        border-radius: 50%;
                        border: 2px $main-color solid;
                        }
                }
                .font{
                    @media only screen and (min-width:769px){
                    text-align: center;
                    height: 100px;
                    line-height: 100px;
                    color: $main-color;
                    font-size: 20px;
                    font-weight: bold;
                    }
                    @media only screen and (max-width:768px){
                        text-align: center;
                        height: 60px;
                        line-height: 60px;
                        color: $main-color;
                        font-size: 15px;
                        font-weight: bold;
                     }
                }
                .status{
                    text-align: center;
                    height: 100px;
                    line-height: 100px;
                    color: $main-color;
                    font-size: 15px;
                }
            }
        }
    }

              
            
!

JS

              
                $(document).ready(function(){
        //Get data from api
        $.ajaxSetup({
            cache: false
        });
        // Saved addresses of all chanels in a array, to iterate over them.
        var address = ["https://wind-bow.glitch.me/twitch-api/streams/freecodecamp",
        "https://wind-bow.glitch.me/twitch-api/streams/ESL_SC2","https://wind-bow.glitch.me/twitch-api/streams/noobs2ninjas"]
        // Saved id's of data divs, to select and parse data into
        var ids = ["#fcc","#esl","#ninja"]
        /*Starting a loop to get started retrieving data in JSON form, and sending 
        it to appropriate div */
        for (let i=0;i<3;i++){
            $.getJSON(address[i],function (data){
            //if channel is offline do this
            if (data.stream == null){
                $(ids[i]).append("<p class='ml-5 font'>Offline<p>");
                // Add class off, to show this channel is offline
                $(ids[i]).addClass("off");
            }
            //if channel is online append it's status (if it is a video) or it's game to the specific div.
            else {
                $(ids[i]).append("<p class='ml-5 status'>"+ data.stream.channel.status || data.stream.channel.game + "<p>");
                // Add class on, to show this channel is online
                $(ids[i]).addClass("on");
            }
        });
        }
        //Configuring all three buttons.
        $("#all").click(function(){
            $('#fcc,#esl,#ninja').show();
        });
        $("#online").click(function(){
            $(".off").hide();
            $(".on").show();
        });
        $("#offline").click(function(){
            $(".off").show();
            $(".on").hide();
        });
        
        });
              
            
!
999px

Console