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

              
                
<div class="container">
  <h1>YOUR FAVOURITE TWITCH STREAMERS</h1>
  <ul>
    <li data-stat="streamers">All</li>
    <li data-stat="online"><i class="fa fa-circle green"></i>Online</li>
    <li data-stat="offline"><i class="fa fa-circle gray"></i>Offline</li>
  </ul>
  <div id="streamers" class="row">
    <div class="add"><input type="text" placeholder="Add user"><i class="fa fa-plus-circle"></i></div>
  </div>
  <div id="online" class="row">
  </div>
  <div id="offline" class="row">
  </div>
</div>

<footer>
  <div class="line"></div>
  Coded by Thayyeb Salim
  <i class="icon-heart-empty"></i>
</footer>
              
            
!

CSS

              
                body {
  background: linear-gradient(70deg,#159957,#155799);
  background-size: cover;
  background-repeat: no-repeat;
  font-family: 'Unica One',cursive;
  padding: 10px 10px 0 10px;
}
h1 {
  text-align: center;
  font-family: 'Text Me One';
  color: white;
}
.container {
  min-height:82.7vh;
  max-width: 800px;
  margin: 20px auto 30px auto;
}
ul {
  margin: 0;
  padding: 0;
  width: 100%;
}
li {
  font-weight: bold;
  font-family: 'Offside',cursive;
  text-align: center;
  display: inline-block;
  font-size: 1.8rem;
  background: rgba(255, 255, 255, 0.6);
  padding: 0 20px 15px 20px;
  border-radius: 5px;
  position: relative;
  bottom: -15px;
  cursor: pointer;
}
li:first-child {
  background: white;
  margin-left:15px;
}
.fa-circle {
  position: relative;
  bottom: 2.7px;
  font-size: 20px;
  right: 5px;
}
.green {
  color: green;
}
.gray {
  color: grey;
}
#streamers, #offline, #online {
  display: flex;
  justify-content: center;
  background: white;
  border-radius: 10px;
  padding: 20px 20px;
  position: relative;
}
.add {
  position: absolute;
  top: 20px;
  width: 100%;
  text-align: center;
}
input {
  padding-left: 10px;
  border-radius: 5px;
  width: 50%;
  margin-right: 10px;
  outline: none;
  border: 0.5px solid grey;
}
.fa-plus-circle {
  color: rgb(39, 174, 96);
  position: relative;
  bottom: -3.5px;
  font-size: 25px;
  cursor: pointer;
}
.fa-plus-circle:hover {
  color: green;
}
.user {
  height: 270px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 15px;
  border: 1px solid;
  background: white;
  text-align: center;
  max-width: 220px;
  padding: 0;
  box-shadow: 5px 5px 15px black;
  border-radius: 15px;
  transition: all 0.3s ease-in-out;
}
.user:hover {
  transform: scale(1.1, 1.1);
  color: black;
}
a:link, a:visited, a:active {
  text-decoration: none;
  color: black;
}
img {
  height: 210px;
  width: 100%;
  display: block;
}
.status {
  background: rgba(127, 140, 141, 0.5);
  padding: 3px;
  color: white;
  height: 29px;
  bottom: -1px;
  position: relative;
}
figure {
  position: relative;
  margin: 0;
}
figcaption {
  position: absolute;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 20px;
  height: 210px;
  width: 220px;
  transition: all 0.3s ease-in-out;
  transition-delay: 0.4s;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  margin: 0;
  padding: 0 5px;
  bottom: 0;
  left: -240px;
}
.greenbg {
  background: rgb(39, 174, 96);
}
.graybg {
  background: rgb(44, 62, 80);
}
#streamers {
  padding-top: 60px;
}
footer{
  margin: 35px -9px 0 -10px;
  height: 20x;
  background: rgba(0, 0, 0, 0.7);
  font-size: 13px;
  color: white;
  font-family: 'Quicksand';
  text-align: center;
  padding:7px 0 5px 0;
}
.line{
  height:2px;
  margin-bottom:5px;
  width:100%;
  background:white;
}
@media screen and (max-width: 500px) {
  input {
    width: 75%;
  }
  li {
    display: block;
    margin:0 0 10px 0;
    width: 100%;
    position: static;
    padding: 5px;
  }
}

              
            
!

JS

              
                $(document).ready(function() {
  var users = [
    "ESL_SC2",
    "unfitcheetah",
    "sirpumpkn",
    "freecodecamp",
    "stefl1504",
    "IMP_meles",
    "jessicamak",
    "malukah",
    "DizzyKitten",
    "legendarylea",
    "moushn",
    "bigotrazos"
  ];

  $(".fa-plus-circle").on("click", function() {
    var add = $("input").val();
    if (add === "") alert("Enter a username");
    users.push(add);
    $(".user").remove();
    $("#online,#offline").html("");
    twitch(users);
  }); //button click to add new steamers. Will reset on refresh

  $("input").keyup(function(enter) {
    if (enter.keyCode == 13) {
      $(".fa-plus-circle").click();
    }
  }); //to add with enter

  $("#online,#offline").hide(); //hide the tabs till toggle

  $("li:first-child").click();

  twitch(users); //main function trigger

  function twitch(users) {
    $("input").val("");
    users.forEach(function(user) {
      var detailUrl = "https://wind-bow.glitch.me/twitch-api/channels/" + user; //Stream detail API

      $.getJSON(detailUrl, function(detail) {
        var streamUrl = "https://wind-bow.glitch.me/twitch-api/streams/" + user; //Stream status API

        $.getJSON(streamUrl, function(current) {
          var streamStat,
            game,
            img = detail.logo,
            link = detail.url,
            name = detail.display_name;

          if (img === null) {
            img = "https://www.twitch.tv/p/assets/uploads/glitch_474x356.png";
          } //to set a place holder for non existing images

          if (current.stream === null) {
            game = "OFFLINE";
            streamStat = "";
          } else {
            game = current.stream.channel.game+":";
            streamStat = current.stream.channel.status;
          }

          if (detail.status != 422 && detail.status != 404)
            putDetail(user, link, img, name, streamStat, game);
          else {
            alert(
              "You seem to have a time machine, That user hasn't registered yet"
            );
            users.pop();
          }

          if (game == "OFFLINE") putOffline(user);
          else putOnline(user);

          $(".user").on("mouseover", function() {
            $(this).find("figcaption").css("left", "0%");
          });

          $(".user").on("mouseout", function() {
            $("figcaption").css("left", "-240px");
          });
        }); //stream url JSON ends
      }); //detailUrl JSON
    }); //forEach function
  }

  $("li").on("click", function() {
    var id = $(this).attr("data-stat"),
      somear = ["streamers", "online", "offline"];
    $("li").css("background-color", "rgba(255,255,255,0.6)");
    $(this).css("background-color", "white");
    for (var i = 0; i < somear.length; i++) {
      $("#" + somear[i]).show();
    }
    for (i = 0; i < somear.length; i++) {
      if (somear[i] != id) {
        $("#" + somear[i]).hide();
      }
    }
  }); //fn for tabbed navigation

  function putDetail(user, link, img, name, stat, game) {
    $("#streamers").append("<div class='user' id=" + user + "></div>");
    $("#" + user).append(
      "<a href=" +
        link +
        " target='_blank'><div><strong>" +
        name +
        "</strong><figure><img src=" +
        img +
        "><figcaption>" +
        game +
        "<br><br>" +
        stat +
        "</figcaption></figure></div></a>"
    );
  } //fn putDetail ends. This fn creates the cards and inserts the details

  function putOnline(user, game) {
    $("#" + user).append("<div class='status greenbg'>Online</div>");
    $("#" + user).clone().appendTo("#online");
  } //fn putOnline ends. This fn puts the online under the picture

  function putOffline(user) {
    $("#" + user).append("<div class='status graybg'>Offline</div>");
    $("#" + user).clone().appendTo("#offline"); //
  } //fn putOffline ends. This fn puts the offline under the picture
}); //document ready ends

              
            
!
999px

Console