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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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>
  <body>
  <main class="row">
    <section class="large-centered head-container">
      <div class="container-headers large-11 medium-11 small-12 large-centered medium-centered small-centered">
        <h1>twitch streamers</h1>
      </div>
      
      <!---App header and btns -->
      <div class="large-6 medium-12 small-12 columns large-centered medium-centered small-centered">
          <button id="btnAllstreamers" class="large-3 medium-12 small-12 columns btns">all</button>
          <button id="btnOnlinestreamers" class="large-5 medium-12 small-12 columns btns">online</button>
          <button id="btnOfflinestreamers" class="large-4 medium-12 small-12 columns btns">offline</button>
      </div>
    <!---App header and btns -->
      
       <!-- search-->
       <div class="results-container__searchbar large-10 medium-8 small-10  large-centered medium-centered small-centered">
            <input type="text" id="searchStreamer" class="large-9 medium-8 small-8" placeholder="Search...">
            <i class="fa fa-search fa-3x icon large-1 medium-1 small-1" aria-hidden="true"></i>
        </div>
      <!-- search-->
      
    </section>
    <section class="large-centered results-container">
      <!--display results-->
        <ul id="result" class="large-10 medium-11 small-12 columns large-centered medium-centered small-centered">
        </ul>
      <!--display results-->
      
    </section>
  </main>
</body>
</html>
              
            
!

CSS

              
                $background-main-color:#27ae60;
$primary-color:#f1c40f;
$secondary-color: #ecf0f1;
$light-gray:#E6E8EB;
$animated-search-form-transition-duration: 0.4s;
html {
    font-size: 12px;

    @media (min-width: 800px) {
        font-size: 16px;
    }
    @media (min-width: 1200px) {
        font-size: 18px;
    }
}

body {
    background-color: $background-main-color
}

main {
    margin-top: 4rem;
}

.head-container {
    border-radius: 10px;

    p {
        text-align: center;
    }

    .container-headers {

        h1 {
            color: $primary-color;
            font-weight: 900;
            text-transform: capitalize;
            text-align: center;
            font-size: 5rem;
            font-style: oblique;
        }
    }
    button {
        font-size: 2.4rem;
        font-weight: 700;
        margin-bottom: 1rem;
        height: 5rem;
        color: $secondary-color;
        cursor: pointer;
        transition: .7s cubic-bezier(0.42, 0, 0.29, 1.32);

        &:hover {
            color: $primary-color;
        }
        &:focus {
            color: $primary-color;
        }
    }
}

.results-container__searchbar {
    margin-bottom: 3rem;
    display: flex;
    i {
        color: white;
        margin-left: 0.7em;
    }

    input {
        display: flex;
        width: 100%;
        border: 0.125rem solid $light-gray;
        box-shadow: 0 0 3.125rem rgba(0, 0, 0, 0.18);
        outline: none;
        border-radius: 10px;
        background-position: 0.625rem 1.4rem;
        background-repeat: no-repeat;
        padding: 0.75rem 1.25rem 0.75rem 2rem;
        height: 4rem;
        transition: width $animated-search-form-transition-duration ease-in-out;

        &:focus {
            border-left: 0px $primary-color;
            border-right: 0px $primary-color;
            border-top: 0px $primary-color;
        }
    }
} //next section - results
.results-container {

    .results-container__searchbar {

        .animated-search-form[type=search] {
            width: 100%;
            border: 0.125rem solid $light-gray;
            box-shadow: 0 0 3.125rem rgba(0, 0, 0, 0.18);
            border-radius: 10px;
            background-image: url('//image.ibb.co/i7NbrQ/search_icon_15.png');
            background-position: 0.625rem 1.4rem;
            background-repeat: no-repeat;
            padding: 0.75rem 1.25rem 0.75rem 2rem;
            height: 4rem;
            transition: width $animated-search-form-transition-duration ease-in-out;
        }
    }

    ul {
        list-style: none;
        margin-bottom: 4rem;

        .active {
            display: flex;
        }

        .online {
            font-size: 2rem;
        }
        .offline {
            font-size: 2rem;
        }


        .list-style {
            border: 2px solid $primary-color;
            border-radius: 10px;
        }

        li {
            padding: 1rem;
            display: none;
            align-items: center;
            margin-bottom: 1rem;

            figure {
                img {
                    border-radius: 50%;
                }
            }


            .channel {
                width: 5rem;
                height: 5rem;
                display: block;
            }

            .empty {
                content: '';
            }

            span {
                font-size: 1.2rem;
                color: $secondary-color;

                .results-container__statusOnline {
                    color: #f1c40f;
                    font-weight: 500;
                    font-size: 1.8rem;
                    letter-spacing: 0.3rem;
                }

                .results-container__statusOffline {
                    color: white;
                    @extend .results-container__statusOnline;
                }
            }
        }
    }
}
              
            
!

JS

              
                (function() {
//arrays
    const   arrOfStreams = [],
            arrOfOffline = [],
            streamer = ["ESL_SC2", "followgrubby", "kinggeorgetv", "redbull", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"],
            arr = [],
            arrOfLinks = [],
            offlineStreams = [],

            //endpoints and id
            endpointStreams = 'https://api.twitch.tv/kraken/streams/',
            endpointChannels = 'https://api.twitch.tv/kraken/channels/',
            twitchId = '?client_id=953x2pkg7mdtrsnqd9tpnf9w6gm0xf',
            //buttons
            Allstreamers = document.getElementById('btnAllstreamers'),
            Onlinestreamers = document.getElementById('btnOnlinestreamers'),
            Offlinestreamers = document.getElementById('btnOfflinestreamers'),
            button = document.querySelectorAll('.btns'),
            visibleAll = document.querySelectorAll('.online, .offline'),
            visibleOffline = document.querySelectorAll('.offline'),
            visibleOnline = document.querySelectorAll('.online');


    Allstreamers.addEventListener('click', filterAll);
    Onlinestreamers.addEventListener('click', filterOnline);
    Offlinestreamers.addEventListener('click', filterOffline);

    //--------------------filter categories

    function filterAll(e) {
        e.preventDefault();

        [].map.call(document.querySelectorAll('.online, .offline'), function(el) {
            el.classList.add('active');
        });
    }

    function filterOffline(e) {
        e.preventDefault();
        [].map.call(document.querySelectorAll('.offline, .online'), function(el) {
            el.classList.remove('active');
        });
        [].map.call(document.querySelectorAll('.offline'), function(el) {
            el.classList.add('active');
        });
    }


    function filterOnline(e) {
        e.preventDefault();
        [].map.call(document.querySelectorAll('.offline, .online'), function(el) {
            el.classList.remove('active');
        });
        [].map.call(document.querySelectorAll('.online'), function(el) {
            el.classList.add('active');
        });
    }
    //--------------------filter categories


    //--------------------Setting url

    function setUrl(endpoint, element, fn) {
        element.map((stream) => {
            let url = endpoint + stream + twitchId;
           arrOfLinks.push(url);
        });
    }
    setUrl(endpointStreams, streamer);
    //--------------------Setting url


    //--------------------Pull data 

Promise.all(arrOfLinks.map(url => 
    fetch(url)
    .then(resp => resp.json())
    .then(data => arr.push(data))))
    .then(() => {

      let onlineStreams = arr.filter((x) => x.stream !== null);
        console.log(onlineStreams)
            onlineStreams.map(x => {
                return appendOnline(
                    x.stream.channel.logo, 
                    x.stream.channel.name, 
                    x.stream.channel.game, 
                    x.stream.stream_type, 
                    x.stream.channel.url);
            });
    })
    .then(() => {
        let offlineStreams = arr.filter((x) => x.stream == null)
        .map(y => y._links.self.slice(37))
        .map(channelName => endpointChannels + channelName + twitchId);
        
        Promise.all(offlineStreams.map(url => 
            fetch(url)
            .then(resp => resp.json())
            .then(data => arrOfOffline.push(data))))
        .then(() => {
            let offlineStreamer = arrOfOffline.map(x => {
                return appendOffline(
                    x.logo, 
                    x.name, 
                    x._links.self);
            });


        })
    })

    //--------------------append results to elements

    function appendOnline(thumbnail, name, play, status, url) {
        document.getElementById("result").innerHTML +=
            `
        <li class="large-12 medium-12 small-12 columns list-style online active">
            <figure class="large-2 medium-3 small-3 columns"> 
              <img class="channel" src="${thumbnail}" alt=""> 
            </figure>
            <div class="large-3 medium-3 small-3columns">
              <span class="column">${name}</span>
            </div>
            <div class="large-5 medium-4 small-4 columns">
              <span class="column">${play}</span>
            </div>
            <div class="large-2 medium-2 small-2 columns">
             <span> <a class="results-container__statusOnline" href="${url}" target="_blank">${status}</a></span>
            </div>
        </li>
`;
    }

    function appendOffline(thumbnail, name, url) {
        document.getElementById("result").innerHTML +=
            `
         <li class="large-12 medium-12 small-12 columns list-style offline active">
            <figure class="large-2 medium-3 small-3 columns"> 
              <img class="channel" src="${thumbnail}" alt=""> 
            </figure>
            <div class="large-3 medium-4 small-4 columns">
              <span class="column">${name}</span>
            </div>
            <div class="large-7 medium-5 small-5 text-center columns">
             <span> 
                <a class="results-container__statusOffline" href="#" >Offline</a>
             </span>
            </div>
        </li>
`
    }
// console.log(arr);
    //--------------------append results to elements
})();
              
            
!
999px

Console