css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="Wrapper-flex">
  <section class="Content">
    <h1 class="Title align-center">Twitch Streammers</h1>
    <form action="" class="Form">
      <ul class="Button-items is-flex">
        <li class="Button-item">
          <button class="Btn Btn-action" id="button-all">All</button>
        </li>
        <li class="Button-item">
          <button class="Btn Btn-action" id="button-online">Online</button>
        </li>
        <li class="Button-item">
          <button class="Btn Btn-action" id="button-offline">Offline</button>
        </li>
      </ul>
      <div class="Input-holder">
        <input type="search" class="Input-search" id="input-search"placeholder="Search in your channel">
      </div>
    </form>

    <ul class="User-items" id="user-items">
    </ul>
    <div class="Error-search align-center is-hidden">
      <p id="error-search">This channel doesn't exist.</p>
    </div>
  </section>
  <footer class="Footer">
    <p class="mb0">Coded and design by <a target="_blank" href="http://gemaderus.com/">Gema de Rus</a></p>
  </footer>
</div>

            
          
!
            
              @import url("https://fonts.googleapis.com/css?family=Comfortaa");

*,
*:before,
*:after {
  box-sizing: border-box;
}

html {
  // -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
  font-family: 'Comfortaa', cursive;
  font-size: 62.5%;
  line-height: 1.5;
  position: relative;
}

html,
body {
  color: #505F69;
  height: 100%;
}

body {
  background: #00C8C9;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
}

a {
  color: white;
  cursor: pointer;
  text-decoration: underline;

  &:hover {
    text-decoration: none;
  }
}

ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

p {
  margin: 0;
}

.Avatar {
  margin-right: 2rem;

  img {
    border-radius: 50%;
    border: 5px solid white;
    height: 50px;
    width: 50px;
  }
}

.Btn {
  -webkit-appearance: none;
  -moz-appearance:    none;
  appearance:         none;
  background-color: transparent;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
  display: inline-block;
  font-family: inherit;
  font-size: 16px;
  line-height: 1;
  margin: 0;
  outline: none;
  padding: 2rem;
  text-align: center;
  text-decoration: none;
  text-transform: uppercase;
  transition: 0.25s;
}

.Btn-action {
  background-color: #FF5959;
  color: white;

  &:hover {
    background-color: darken(#FF5959, 10);
  }
}

.Button-items {
  margin-bottom: 3rem;
  justify-content: center;

  @media screen and (min-width: 600px) {
    justify-content: space-between;
    margin-bottom: 0;
  }
}

.Button-item {
  margin-right: 2rem;

  &:last-child {
    margin-right: 0;
  }

  @media screen and (min-width: 600px) {
    margin-right: 3rem;

    &:last-child {
      margin-right: 3rem;
    }
  }
}

.Content {
  flex: 1;
  padding: 4rem 0;
  position: relative;
  width: 100%;

  @media screen and (min-width: 600px) {
    max-width: 1200px;
  }
}

.Error-search {
  color: white;
  font-size: 20px;
}

.Footer {
  font-size: 16px;
  padding: 20px;
  text-align: center;
}

.Form {
  padding: 0 2rem;
  margin-bottom: 4rem;
  
  @media screen and (min-width: 600px) {
    display: flex;
  }
}

.Input-holder {
  @media screen and (min-width: 600px) {
    flex: 1;
  }
}

.Input-search {
  border-radius: 6px;
  border: 0;
  color: #505F69;
  font-size: 1.6rem;
  line-height: 1;
  outline: none;
  padding: 1.8rem;
  width: 100%;

  &:focus {
    box-shadow: inset 0 0 0 1px #505F69;
  }
}

.is-flex {
  display: flex;
}

.Wrapper-flex {
  align-items: center;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.Title {
  font-size: 3rem;
  margin-bottom: 4rem;
}

.User-items {
  display: flex;
  flex-wrap: wrap;
  padding: 0 1rem;
}

.User-item-padded {
  flex-basis: 100%;
  padding: 1rem;

  @media screen and (min-width: 600px) {
    flex-basis: 50%;
  }

  @media screen and (min-width: 1200px) {
    flex-basis: 33.3333%;
  }
}

.User-item {
  border-radius: 6px;
  height: 200px;
  padding: 1.5rem;
  position: relative;
}

.User-info {
  bottom: 10px;
  color: white;
  font-size: 1.6rem;
  position: absolute;
}

.Closed-advice {
  display: none;
}

.Background-gradient {
  background: #505f69; /* Old browsers */
  background: -moz-linear-gradient(left, #505f69 0%, #dddddd 100%); /* FF3.6-15 */
  background: -webkit-linear-gradient(left, #505f69 0%,#dddddd 100%); /* Chrome10-25,Safari5.1-6 */
  background: linear-gradient(to right, #505f69 0%,#dddddd 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#505f69', endColorstr='#dddddd',GradientType=1 ); /* IE6-9 */
}

.align-center {
  text-align: center;
}

.align-right {
  text-align: right;
}

.align-right {
  text-align: left;
}

.is-visible {
  display: block;
}

.is-hidden {
  display: none;
}
            
          
!
            
              var channels = [{id: 1, channel: "ESL_SC2"}, {id: 2, channel: "OgamingSC2"}, {id: 3, channel: "cretetion"}, {id: 4, channel: "freecodecamp"}, {id: 5, channel: "storbeck"}, {id: 6, channel: "habathcx"}, {id: 7, channel: "brunofin"}, {id: 8, channel: "noobs2ninjas"}, {id: 9, channel: "medrybw"}, {id: 10, channel: "monstercat"}, {id: 11, channel: "RobotCaleb"}, {id: 12, channel: "comster404"}];

var template = '<li class="User-item-padded"><div class="User-item"><div class="Avatar"></div><div class="User-info"><p><a href="#" class="User-name"></a><span class="Status"></span></p><p class="Game"></p><p id="error"></p></div></div></div></li>';

var users = $("#user-items");

function makeURL(type, name) {
  return 'https://api.twitch.tv/kraken/' + type + '/' + name + '?client_id=c09cvez4remudiu2rau8edykwhpp3t0';
}

function urlStream(type, item, nodo) {
  $.getJSON(makeURL(type, item), function(response) {
    updateData(nodo, response);
  });
};

function urlChannels(type, item, nodo) {
  $.getJSON(makeURL(type, item), function(response) {
    infoUserName(nodo, response);
    infoLogo(nodo, response);
    bannerImage(nodo, response);
  }).fail(function(error) {
    updateError(nodo, error);
  });
};

function updateError(nodo, data) {
  var channelError = JSON.parse(data.responseText);
  nodo.find('.Avatar').append('<img src="https://www.dropbox.com/s/gtx0nldzgy38sxu/logo.svg?raw=1" alt="logo" class="logo-default">');
  nodo.find("#error").html(channelError.message);
  nodo.find(".User-item").toggleClass("Background-gradient");

}

$(function() {
  channels.forEach(function(channel) {
    var nodo = createNodo(channel);
    urlStream("streams", channel.channel, nodo);
    urlChannels("channels", channel.channel, nodo);
  });

  onlineGamers();
  offlineGamers();
  allGamers();
  filterInput();
});

function createNodo(channel) {
  var nodo = $(template);
  nodo.attr('id', 'channel' + channel.id);
  users.append(nodo);
  return nodo;
}

function filterInput(str) {
  //var nodo = $(".Error-search");

  $("#input-search").on("keyup", function(e) {
    var search = $("#input-search").val();

    if ($.trim(search) !== '') {
      $('.User-item-padded').each(function () {
        var nodo = $(this);
        var algo = nodo.find('.User-name').text();

        if (algo.indexOf(search) !== -1) {
          nodo.show();

        } else {
          nodo.hide();
          $(".Error-search").removeClass("is-hidden");
        }
      });
    } else {
       $('.User-item-padded').show();
    }
  });
}

function updateData(nodo, data) {
  var status;
  var jsClass;

  if(data.stream === null) {
    status = " - Offline";
    jsClass = 'js-offline';
  } else if (data.stream === undefined) {
    status = " - Account Closed"
    jsClass = 'js-closed';
  } else {
    status = " - Online";
    jsClass = 'js-online';
  };

  nodo.find(".Status").html(status);
  nodo.addClass(jsClass);
  onlineData(nodo, data);
}

function onlineData(nodo, item) {
  if (!item.stream) {
    return;
  }

  var game = item.stream.game;
  nodo.find(".Game").html(game);
}

function infoLogo(nodo, user) {
  var userLogo = user.logo;
  var avatar = nodo.find('.Avatar');

  if(userLogo === null) {
    avatar.append('<img src="images/logo.svg" alt="logo" class="logo-default">');
  } else {
    avatar.append('<img src="' + userLogo +'" alt="logo">');
  }
}

function infoUserName(nodo, user) {
  var userName = user.name;
  var urlChannel = user.url;
  nodo.find(".User-name").html(userName).attr("href", urlChannel);
}

function bannerImage(nodo, image) {
  var banner = image.profile_banner;
  if( banner !== null) {
    nodo.find(".User-item").css({'background-image': 'url('+ banner + ')',
                                 'background-size': 'cover'});
  } else {
    nodo.find(".User-item").toggleClass("Background-gradient");
  }
}

function onlineGamers() {
  $("#button-online").on("click", function(e) {
    e.preventDefault();

    $('.User-item-padded').hide();
    $('.User-item-padded.js-online').show();
  });
}

function offlineGamers() {
  $("#button-offline").on("click", function(e) {
    e.preventDefault();

    $('.User-item-padded').hide();
    $('.User-item-padded.js-offline').show();
  });
}

function allGamers() {
  $("#button-all").on("click", function(e) {
    e.preventDefault();

    $('.User-item-padded').show();
  });
}
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console