Make a social widget

In this example below you will see how to do a Make a social widget with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by natertot12, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright natertot12 ©
  • HTML
  • CSS
  • JavaScript
    <div id="header" class="text-center well">
  <h2>Social Widget Creater</h2>
  <p>By Nathan O'Neel</p>
  <div class="nextPrevButtons">
    <button id="prev" class="btn btn-secondary"><i class="fa fa-angle-left"></i> Previous</button>
    <button id="next" class="btn btn-secondary">Next <i class="fa fa-angle-right"></i></button>
  </div>
</div>
<div class="scenes col-sm-12">
  <div id="scene-1" class="col-sm-12">
    <h3 class="text-center">Please Select</h3>
    <br>
    <div class="row container center-block text-center">
      <label class="switch-3">
      <input id="scene-1-codepen" class="toggle-3" name="scene-1-social" type="checkbox">
      <div class="codepen slider-3"><i class="fa fa-large fa-codepen"></i></div>
    </label>
      <label class="switch-3">
      <input id="scene-1-facebook" class="toggle-3" name="scene-1-social" type="checkbox">
      <div class="facebook slider-3"><i class="fa fa-large fa-facebook"></i></div>
    </label>
      <label class="switch-3">
      <input id="scene-1-google-plus" class="toggle-3" name="scene-1-social" type="checkbox">
      <div class="google-plus slider-3"><i class="fa fa-large fa-google-plus"></i></div>
    </label>
      <label class="switch-3">
      <input id="scene-1-github" class="toggle-3" name="scene-1-social" type="checkbox">
      <div class="github slider-3"><i class="fa fa-large fa-github"></i></div>
    </label>
    </div>
    <div class="row container center-block text-center">
      <label class="switch-3">
      <input id="scene-1-pinterest" class="toggle-3" name="scene-1-social" type="checkbox">
      <div class="pinterest slider-3"><i class="fa fa-large fa-pinterest"></i></div>
    </label>
      <label class="switch-3">
      <input id="scene-1-twitter" class="toggle-3" name="scene-1-social" type="checkbox">
      <div class="twitter slider-3"><i class="fa fa-large fa-twitter"></i></div>
    </label>
    </div>
  </div>
  <div id="scene-2" class="col-sm-12">
    <h3 class="text-center">Please Select Type</h3>
    <br>
    <form class="text-center">
      <input id="scene-2-type-1" type="radio" checked>Button
    </form>
    <div class="row container center-block text-center">
      <div class="col-sm-3">
        <h3>Buttons</h3>
        <div class="social-button-type-1 codepen"><i class="fa fa-small fa-codepen"></i></div>
        <div class="social-button-type-1 facebook"><i class="fa fa-small fa-facebook"></i></div>
        <div class="social-button-type-1 google-plus"><i class="fa fa-small fa-google-plus"></i></div>
        <div class="social-button-type-1 github"><i class="fa fa-small fa-github"></i></div>
        <div class="social-button-type-1 pinterest"><i class="fa fa-small fa-pinterest"></i></div>
        <div class="social-button-type-1 twitter"><i class="fa fa-small fa-twitter"></i></div>
      </div>
    </div>
  </div>
  <div id="scene-3" class="col-sm-12 text-center">
    <h3>Widget Customizer</h3>
    <br>
    <div class="container">
      <div class="scene-3-custom-social-icons codepen"><i class="fa fa-scene-3-custom fa-codepen"></i></div>
      <div class="scene-3-custom-social-icons facebook"><i class="fa fa-scene-3-custom fa-facebook"></i></div>
      <div class="scene-3-custom-social-icons google-plus"><i class="fa fa-scene-3-custom fa-google-plus"></i></div>
      <div class="scene-3-custom-social-icons github"><i class="fa fa-scene-3-custom fa-github"></i></div>
      <div class="scene-3-custom-social-icons pinterest"><i class="fa fa-scene-3-custom fa-pinterest"></i></div>
      <div class="scene-3-custom-social-icons twitter"><i class="fa fa-scene-3-custom fa-twitter"></i></div>
    </div>
    <div class="row">
      <form>
        <p>Width</p>
        <input id="scene-3-width" size="10" type="text" name="width" placeholder="100px">
        <p>Height</p>
        <input id="scene-3-height" size="10" type="text" name="width" placeholder="100px">
        <p>Border radius</p>
        <input id="scene-3-border" size="10" type="text" name="width" placeholder="0% OR 0px">
      </form>
      <br>
      <form>
        <p>Icon Size</p>
        <input id="scene-3-icon-size" size="10" type="text" name="width" placeholder="50px">
        <p>Icon Color</p>
        <input id="scene-3-icon-color" size="10" type="text" name="width" placeholder="#FFFFFF">
        <p>Icon Text Shadow</p>
        <input id="scene-3-icon-shadow" size="20" type="text" name="width" placeholder="2px 2px 3px #000000">
      </form>
      <br>
      <form id="scene-3-ori">
        <p>Orientation</p>
        <input id="scene-3-horizontal" type="radio" name="orientation-1" value="inline-block" checked> Horizontal<br>
        <input id="scene-3-vertical" type="radio" name="orientation-1" value="block"> Vertical<br>
      </form>
      <form>
        <p>Social Links</p>
        <br>
        <p class="codepen">Codepen</p>
        <input id="scene-3-link-codepen" class="normal-background codepen" type="text" placeholder="https://codepen.io/natertot12/pen/YqbvoL">
        <br class="codepen normal-background">
        <p class="facebook">Facebook</p>
        <input id="scene-3-link-facebook" class="normal-background facebook" type="text" placeholder="https://www.facebook.com/nathan.oneel.3">
        <br class="facebook normal-background">
        <p class="google-plus">Google+</p>
        <input id="scene-3-link-google-plus" class="normal-background google-plus" type="text" placeholder="https://plus.google.com/110356183553113913154/">
        <br class="google-plus normal-background">
        <p class="github">Github</p>
        <input id="scene-3-link-gihub" class="normal-background github" type="text" placeholder="https://github.com/natertot12/">
        <br class="github normal-background">
        <p class="pinterest">Pinterest</p>
        <input id="scene-3-link-pinterest" class="normal-background pinterest" type="text" placeholder="https://www.pinterest.com/anapinskywalker/">
        <br class="pinterest normal-background">
        <p class="twitter">Twitter</p>
        <input id="scene-3-link-twitter" class="normal-background twitter" type="text" placeholder="https://twitter.com/natertot12">
      </form>
      <br>
      <button id="update-1" class="btn btn-warning">Update</button>
    </div>
    <p>Remember to include <a href="https://www.bootstrapcdn.com/fontawesome/">Font Awesome</a></p>
    <br>
    <code id="scene-3-result-html">Result</code>
    <br>
    <br>
    <code id="scene-3-result-css"></code>
  </div>
</div>

/*Downloaded from https://www.codeseek.co/natertot12/make-a-social-widget-YqbvoL */
    /** Global **/
#scene-2, #scene-3 {
  display: none;
}
.codepen {
  background-color: #191919;
}
.facebook {
  background-color: #3b5998;
}
.google-plus {
  background-color: #dc4e41;
}
.github {
  background-color: #666666;
}
.pinterest {
  background-color: #bd081c;
}
.twitter {
  background-color: #55acee;
}
.normal-background {
  background-color: #FFFFFF !important;
}
.fa-large {
  font-size: 50px;
  display:inline-block;
  line-height: 100px;
  color: white;
  width: 50px;
  height: 50px;
  text-shadow: 2px 2px 3px #000;
  text-align: center;
  vertical-align: bottom;
  -moz-transition: all 300ms linear;
  -webkit-transition: all 300ms linear;
  -o-transition: all 300ms linear;
  transition: all 300ms linear;
}
.fa-small {
  font-size: 24px;
  display:inline-block;
  line-height: 50px;
  color: white;
  width: 50px;
  height: 50px;
  text-shadow: 2px 2px 3px #000;
  text-align: center;
  vertical-align: bottom;
  -moz-transition: all 300ms linear;
  -webkit-transition: all 300ms linear;
  -o-transition: all 300ms linear;
  transition: all 300ms linear;
}

/** Header **/
#header {
  line-height: 10px;
  height: 100px;
}

/** Scenes **/
.scenes {
  height: 100%;
}


/** Scene-1 **/
.switch-3 {
  position: relative;
  display: inline-block;
  width: 100px;
  height: 100px;
}
.switch-3 .toggle-3 {display:none;}
.slider-3 {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  -webkit-transition: .4s;
  transition: .4s;
}
.toggle-3:checked + .slider-3 i {
  color: #00cc00;
}

/** Scene 2 **/
.social-button-type-1 {
  display: inline-block;
  height: 50px;
  width: 50px;
}


/** Scene 3 **/
.scene-3-custom-social-icons {
  height: 100px;
  width: 100px;
  display: inline-block;
  -moz-transition: all 300ms linear;
  -webkit-transition: all 300ms linear;
  -o-transition: all 300ms linear;
  transition: all 300ms linear;
}
.fa-scene-3-custom {
  font-size: 50px;
  line-height: 100px;
  color: white;
  width: 50px;
  height: 50px;
  text-shadow: 2px 2px 3px #000;
  display: inline-block;
  text-align: center;
  vertical-align: bottom;
  -moz-transition: all 300ms linear;
  -webkit-transition: all 300ms linear;
  -o-transition: all 300ms linear;
  transition: all 300ms linear;
}

/** Footer **/
#footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  margin-bottom: 0px !important;
}
#next {
  float: right;
}
#prev {
  float: left;
  display: none;
}














.codepen{background-color: #191919;}
.facebook{background-color:#3b5998;}
.google-plus{background-color: #dc4e41;}
.github{background-color:#666666;}
.pinterest{background-color:#bd081c;}
.twitter{background-color:#55acee;}


/*Downloaded from https://www.codeseek.co/natertot12/make-a-social-widget-YqbvoL */
    $(document).ready(function() {
  var currentScene = 1;
  
  function updateScene() {
    if(currentScene == 1) $('#prev').hide();
    else $('#prev').show();
    $('#scene-' + (currentScene - 2).toString()).hide();
    $('#scene-' + (currentScene - 1).toString()).hide();
    $('#scene-' + (currentScene + 1).toString()).hide();
    $('#scene-' + (currentScene + 2).toString()).hide();
    $('#scene-' + (currentScene).toString()).show();
  }
  $('#next').click(function() {
    if(currentScene == 1) {
      if(!$('#scene-1-codepen').is(':checked')) $('.codepen').hide();
      if(!$('#scene-1-facebook').is(':checked')) $('.facebook').hide();
      if(!$('#scene-1-google-plus').is(':checked')) $('.google-plus').hide();
      if(!$('#scene-1-github').is(':checked')) $('.github').hide();
      if(!$('#scene-1-pinterest').is(':checked')) $('.pinterest').hide();
      if(!$('#scene-1-twitter').is(':checked')) $('.twitter').hide();
    }
    currentScene++;
    if(currentScene == 3) $(this).hide();
    updateScene();
  });
  $('#prev').click(function() {
    currentScene--;
    if(currentScene == 1) {
      $('.codepen').show();
      $('.facebook').show();
      $('.google-plus').show();
      $('.github').show();
      $('.pinterest').show();
      $('.twitter').show();
    }
    if(currentScene == 1) $(this).hide();
    updateScene();
  });
  
  
  
  /*Scene 3*/
  function buildSocialType1Html() {
    var final = "<div class='social-widget'>";
    if($('#scene-1-codepen').is(':checked')) final += '<a href="'+($('#scene-3-link-codepen').val()?$('#scene-3-link-codepen').val():'#')+'"><div class="social-icons codepen"><i class="fa fa-codepen"></i></div></a>';
    if($('#scene-1-facebook').is(':checked')) final += '<a href="'+($('#scene-3-link-facebook').val()?$('#scene-3-link-facebook').val():'#')+'"><div class="social-icons facebook"><i class="fa fa-facebook"></i></div></a>';
    if($('#scene-1-google-plus').is(':checked')) final += '<a href="'+($('#scene-3-link-google-plus').val()?$('#scene-3-link-google-plus').val():'#')+'"><div class="social-icons google-plus"><i class="fa fa-google-plus"></i></div></a>';
    if($('#scene-1-github').is(':checked')) final += '<a href="'+($('#scene-3-link-github').val()?$('#scene-3-link-github').val():'#')+'"><div class="social-icons github"><i class="fa fa-github"></i></div></a>';
    if($('#scene-1-pinterest').is(':checked')) final += '<a href="'+($('#scene-3-link-pinterest').val()?$('#scene-3-link-pinterest').val():'#')+'"><div class="social-icons pinterest"><i class="fa fa-pinterest"></i></div></a>';
    if($('#scene-1-twitter').is(':checked')) final += '<a href="'+($('#scene-3-link-twitter').val()?$('#scene-3-link-twitter').val():'#')+'"><div class="social-icons twitter"><i class="fa fa-twitter"></i></div></a>';
    final += "</div>"
    console.log(final);
    return final
  }
  function buildSocialType1Css() {
    var final = '.social-icons {height:' + ($('#scene-3-height').val() ? $('#scene-3-height').val() : '100px') + ';width:' + ($('#scene-3-width').val() ? $('#scene-3-width').val() : '100px') + ';display:'+$("#scene-3-ori input[type='radio']:checked").val()+';}.social-icons i.fa{font-size:'+($('#scene-3-icon-size').val() ? $('#scene-3-icon-size').val() : '50px')+';line-height:'+($('#scene-3-height').val() ? $('#scene-3-height').val() : '100px')+';color:'+($('#scene-3-icon-color').val() ? $('#scene-3-icon-color').val() : '#FFFFFF')+';width:100%;height:100%;text-shadow:'+($('#scene-3-icon-shadow').val() ? $('#scene-3-icon-shadow').val() : '2px 2px 3px #000000')+';display:inline-block;text-align:center;vertical-align:bottom;}';
    if($('#scene-1-codepen').is(':checked')) final += '.codepen{background-color:#191919;}';
    if($('#scene-1-facebook').is(':checked')) final += '.facebook{background-color:#3b5998;}';
    if($('#scene-1-google-plus').is(':checked')) final += '.google-plus{background-color:#dc4e41;}';
    if($('#scene-1-github').is(':checked')) final += '.github{background-color:#666666;}';
    if($('#scene-1-pinterest').is(':checked')) final += '.pinterest{background-color:#bd081c;}';
    if($('#scene-1-twitter').is(':checked')) final += '.twitter{background-color:#55acee;}';
    return final;
  }
  $('#update-1').click(function() {
    $('.scene-3-custom-social-icons').css({
      "width": $('#scene-3-width').val(),
      "height": $('#scene-3-height').val(),
      "border-radius": $('#scene-3-border').val(),
      "display": $("#scene-3-ori input[type='radio']:checked").val()
    });
    if(!$('#scene-1-codepen').is(':checked')) $('.codepen').hide();
    if(!$('#scene-1-facebook').is(':checked')) $('.facebook').hide();
    if(!$('#scene-1-google-plus').is(':checked')) $('.google-plus').hide();
    if(!$('#scene-1-github').is(':checked')) $('.github').hide();
    if(!$('#scene-1-pinterest').is(':checked')) $('.pinterest').hide();
    if(!$('#scene-1-twitter').is(':checked')) $('.twitter').hide();
    $('.fa-scene-3-custom').css({
      'font-size': $('#scene-3-icon-size').val(),
      'line-height': $('#scene-3-height').val(),
      'color': $('#scene-3-icon-color').val(),
      'width': '100%',
      'height': '100%',
      'text-shadow': $('#scene-3-icon-shadow').val(),
      'text-align': 'center'
    });
    $('#scene-3-result-html').text(buildSocialType1Html());
    $('#scene-3-result-css').text(buildSocialType1Css())
  });
});

Comments