Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                 <link rel="stylesheet" href="https://unpkg.com/flickity@2/dist/flickity.css">
<script src="https://unpkg.com/flickity@2/dist/flickity.pkgd.min.js"></script>

<div class="wrap" id="vue-instagram-clone">
 <div class="phone relative bg-white" >

     <div @click="triggerFilePicker" v-if="!photoHasBeenUploaded" class="empty-state absolute tc top-1 left-1 right-1 bottom-1 flex items-center justify-center pa3 ba">
        <input @change="handlePhotoUpload" class="hide" ref="upload" type="file">
        <h2 class="fw5 f5 black-30">Click to upload an image</h2>
     </div>
  <transition name="fade">
  <main class="flex flex-column h-100" v-if="photoHasBeenUploaded">
   <header class="flex items-center relative overflow-hidden">
     <transition mode="out-in" name="fade-in"
    enter-active-class="animated fadeInUp"
    leave-active-class="animated fadeOutDown">
       <div class="flex items-center ph2" v-if="editingFilterStrength">
        <h5 class="ma0 flex fw5 items-center">
         {{ this.filters[this.activeFilterIndex].displayName }} 
        <h5>
         </div>
     </transition>
     <transition mode="out-in" name="fade-out"
    enter-active-class="animated fadeInUp"
    leave-active-class="animated fadeOutDown">
     <div v-if="!editingFilterStrength" class="flex items-center w-100 absolute top-0 left-0 right-0 bottom-0">
       <div class="w-third flex items-center">
      <button @click="reset" class="button-reset mr1 black-60 bg-transparent bn pv0 flex items-center">
       <i class="material-icons">keyboard_arrow_left</i>
      </button>
    </div>
    <div class="w-third justify-center flex items-center">
      <img style="height: 25px;" class="img" src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Instagram_logo.svg/500px-Instagram_logo.svg.png" alt="" />
    </div>
    <div class="w-third tr flex items-center justify-end pr2">
      <h5 class="ma0 flex fw5 items-center"><a class="link blue" href="http://lmgtfy.com/?q=instagram" target="_blank">Next</a></h4>
    </div>
      </div>
        </transition>
   </header>
   <section class="preview relative">
    <figure class="ma0 absolute h-100 w-100 top-0 left-0 right-0 bottom-0 center-no-repeat z-4" v-bind:style="{ backgroundImage: 'url(' + uploadedPhoto + ')' }">
    </figure>
    <figure class="ma0 absolute h-100 w-100 top-0 left-0 right-0 bottom-0 center-no-repeat z-5" v-bind:class="[activeFilterClassname]" v-bind:style="{ backgroundImage: 'url(' + uploadedPhoto + ')', opacity: filters[activeFilterIndex].opacity }">
    </figure>
   
   </section>
   <nav class="pt3 flex-auto relative">
      <transition name="fade" mode="out-in">
      <filter-list v-if="!editingFilterStrength" style="height: 100%;" :active="activeFilterIndex" :source="uploadedPhoto" :filters="filters"></filter-list>
      </transition>
      <transition name="fade" mode="out-in">
        <div class="pa4" v-if="editingFilterStrength">
         <strength-slider value="filterStrength"></strength-slider>
         <div class="mt4 tc">
          <button @click="toggleFilterStrength" class="button-reset fw5 f6 ttu black bn bg-white">Done</button>
         </div>
       </div>
      </transition>
   </nav>
  </main>
  </transition>
 </div>
</div>

<script type="x-template" id="filter-list">
<div class="">
  <div is="filter-preview"
   :filter="filter" :index="index" :source="source" v-for="(filter, index) in filters">
  </div>
</div>
</script>

<script type="x-template" id="filter-preview">
	<a @click="changeFilter(filter, index)" class="filter fw5 tc mr2">
 	{{ filter.displayName }}
<figure v-bind:class="filter.className" class="mh0 mb0 mt2 db bg-transparent aspect-ratio aspect-ratio--1x1">
		<div class="aspect-ratio--object cover" v-bind:style="{ backgroundImage: 'url(' + source + ')' }"></div>
	 </figure>
 </a>
</script>

<script type="x/template" id="strength-slider">
	<div id="slider"></div>
</script>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Roboto:400,500|Material+Icons');

$shadow: 0 15px 5px -10px rgba(0,0,0,0.05);
$header-height: 40px;
$thumbnail-height: 60%;
$sans-serif: 'Roboto', 'Helvetica Neue', 'Helvetica', sans-serif;

.animated {
 animation-duration: .3s;
}

body {
 -webkit-font-smoothing: antialiased;
 background: #eee;
 font-family: $sans-serif;
 overflow: hidden;
 position: relative;
 
 &:before {
  background-image: url("data:image/svg+xml;base64,PHN2ZyBmaWxsPSIjMDAwMDAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGRhdGEtbmFtZT0iWW91ciBJY29uIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCIgeD0iMHB4IiB5PSIwcHgiPjxkZWZzPjxzdHlsZT4uY2xzLTEsLmNscy0ye2ZpbGw6bm9uZTtzdHJva2U6IzAwMDAwMDtzdHJva2UtbGluZWNhcDpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9LmNscy0xe3N0cm9rZS13aWR0aDo3cHg7fS5jbHMtMntzdHJva2Utd2lkdGg6NnB4O308L3N0eWxlPjwvZGVmcz48dGl0bGU+0LjQvdGB0YLQsNCz0YDQsNC80Lw8L3RpdGxlPjxjaXJjbGUgY2xhc3M9ImNscy0xIiBjeD0iNTAiIGN5PSI1MCIgcj0iMTguOTQiLz48Y2lyY2xlIGNsYXNzPSJjbHMtMiIgY3g9Ijc0LjUiIGN5PSIyNy4xMyIgcj0iMi45MSIvPjxyZWN0IGNsYXNzPSJjbHMtMSIgeD0iOSIgeT0iOSIgd2lkdGg9IjgyIiBoZWlnaHQ9IjgyIiByeD0iMTkiIHJ5PSIxOSIvPjwvc3ZnPg==");
  background-size: 60px;
  content: '';
  height: 200%;
  left: -50%;
  opacity: .020;
  pointer-events: none;
  position: absolute;
  right: 0;
  top: -50%;
  transform: rotate(-30deg);
  width: 200%;
 }
}

button {
 font-family: $sans-serif;
}

.hide {
 position: absolute !important;
 height: 1px;
 width: 1px;
 overflow: hidden;
 clip: rect(1px, 1px, 1px, 1px);
}

.wrap {
 overflow: hidden;
 height: 100vh;
 max-height: 100vh;
 
 @media(min-width: 30em) {
  align-items: center;
  display: flex;
  justify-content: center;
 }
}

.phone {
 height: 100%;
 width: 100%;
 
 @media(min-width: 30em) {
  border: 1px solid #e6e6e6;
  height: (960px * .6);
  width: (540px * .6);
 }
}

.empty-state {
 border-color: rgba(0, 0, 0, .15);
 border-style: dashed;
 border-width: 2px;
 cursor: pointer;
 transition: border .2s ease-out;
 
 &:hover {
  border-color: #3897f0;
 }
}

header {
 background: #FAFAFA;
 box-shadow: 0 2px 3px rgba(0, 0, 0, .10);
 height: $header-height;
 z-index: 999;
}

.preview {
 height: 60%;
 width: 100%;
 
 @media(min-width: 30em) {
  height: 330px;
 }
}

.center-no-repeat {
 background-position: center center;
 background-repeat: no-repeat;
 background-size: cover;
}

nav {
 overflow-y: hidden;
 height: 150px;
}

.filter {
 box-shadow: 0 20px 20px -10px rgba(0, 0, 0, 0.10);
 color: rgba(0, 0, 0, .5);
 font-size: 12px;
 height: 125px;
 transform-style: preserve-3d;
 transition: transform .2s cubic-bezier(.17,.67,.83,.67);
 width: 105px;
 
 &:active {
  transform: scale3d(.95, .95, .95);
 }
 
 &.is-selected {
  color: #222;
 }
}

.fade-enter-active, .fade-leave-active {
  transition: opacity .3s
}
.fade-enter, .fade-leave-to {
  opacity: 0
}

.noUi-target {
 background: darken(#f8f8f8, 2%);
 border: 0;
 box-shadow: none;
}

.noUi-horizontal {
 height: 3px;
}

.noUi-connect {
 background: #000;
 box-shadow: none;
}

.noUi-handle {
 background: black;
 border: 0;
 border-radius: 50%;
 box-shadow: none;
 left: -5px !important;
 height: 15px !important;
 transition: box-shadow .2s ease-out;
 width: 15px !important;
 
 &:active {
  box-shadow: 0 0 0px 7px rgba(0, 0, 0, .1);
 }
 
 &:before, &:after {
  content: none;
 }
}

.noUi-tooltip  {
 background: transparent;
 border: 0;
 color: rgba(0, 0, 0, .5);
 font-size: 12px;
}
              
            
!

JS

              
                let eventHub = new Vue();
let flkty = null;

function generateFilters() {
 return [
   { displayName: '1977', className: '_1977', opacity: 1 },
   { displayName: 'Aden', className: 'aden', opacity: 1 },
   { displayName: 'Brannan', className: 'brannan', opacity: 1 },
   { displayName: 'Brooklyn', className: 'brooklyn', opacity: 1 },
   { displayName: 'Clarendon', className: 'clarendon', opacity: 1 },
   { displayName: 'Earlybird', className: 'earlybird', opacity: 1 },
   { displayName: 'Gingham', className: 'gingham', opacity: 1 },
   { displayName: 'Hudson', className: 'hudson', opacity: 1 },
   { displayName: 'Inkwell', className: 'inkwell', opacity: 1 },
   { displayName: 'Kelvin', className: 'kelvin', opacity: 1 },
   { displayName: 'Lark', className: 'lark', opacity: 1 },
   { displayName: 'Lo-Fi', className: 'lofi', opacity: 1 },
   { displayName: 'Maven', className: 'maven', opacity: 1 },
   { displayName: 'Mayfair', className: 'mayfair', opacity: 1 },
   { displayName: 'Moon', className: 'moon', opacity: 1 },
   { displayName: 'Nashville', className: 'nashville', opacity: 1 },
   { displayName: 'Perpetua', className: 'perpetua', opacity: 1 },
   { displayName: 'Reyes', className: 'reyes', opacity: 1 },
   { displayName: 'Rise', className: 'rise', opacity: 1 },
   { displayName: 'Slumber', className: 'slumber', opacity: 1 },
   { displayName: 'Stinson', className: 'stinson', opacity: 1 },
   { displayName: 'Toaster', className: 'toaster', opacity: 1 },
   { displayName: 'Valencia', className: 'valencia', opacity: 1 },
   { displayName: 'Walden', className: 'walden', opacity: 1 },
   { displayName: 'Willow', className: 'willow', opacity: 1 },
   { displayName: 'X-pro II', className: 'xpro2, opacity: 1' }
 ];
}

Vue.component('filter-list', {
 template: '#filter-list',
 props: ['filters', 'source', 'active'],
 created: function() {
  var self = this;
  setTimeout(function() {
   var el = self.$el;
   flkty = new Flickity(el, {
     cellAlign: 'center',
     contain: true,
     initialIndex: self.active,
     pageDots: false,
     setGallerySize: false,
     prevNextButtons: false
   });
  }, 0)
 }
});

Vue.component('strength-slider', {
 template: '#strength-slider',
 created: function() {
  let self = this;
  let initialFilterStrength = instagramClone.$data.filters[instagramClone.$data.activeFilterIndex].opacity * 100;
  let sliderOpts = {
   connect: [true, false],
   tooltips: true,
   format: wNumb({
    decimals: 0,
   }),
   start: [ initialFilterStrength ],
    step: 1,
    range: {
     'min': [ 0 ],
     'max': [ 100 ]
    }
  };
  
  setTimeout(function() {
    let slider = noUiSlider.create(self.$el, sliderOpts);
    slider.on('update', function(e){
     let newVal = e[0] / 100;
     eventHub.$emit('adjust-filter-opacity', {
      opacity: newVal
     });
    });
   
  }, 0);
 }
})

Vue.component('filter-preview', {
 template: '#filter-preview',
 props: ['filter', 'source', 'index'],
 methods: {
  changeFilter: function(filter, index) {
   let cachedIndex = instagramClone.$data.activeFilterIndex;
   if(cachedIndex == index) {
    this.toggleFilterStrength(filter);
    return;
   }
  
   flkty.select(index);
   eventHub.$emit('change-filter', {
    filter: filter,
    index: index
   });
  },
  toggleFilterStrength: function(filter) {
   eventHub.$emit('toggle-filter-strength', {
    filter: filter
   });
  }
 }
});

var instagramClone = new Vue({
 el: '#vue-instagram-clone',
 computed: {
  photoHasBeenUploaded: function() {
   return this.uploadedPhoto !== null;
  },
  shouldShowFilterList: function() {
   return !this.editingFilterStrength; 
  }
 },
 created: function() {
  eventHub.$on('change-filter', this.changeFilter);
  eventHub.$on('toggle-filter-strength', this.toggleFilterStrength);
  eventHub.$on('adjust-filter-opacity', this.adjustFilterOpacity);
 },
 data: {
  activeFilterClassname: null,
  activeFilterIndex: 0,
  filters: generateFilters(),
  filterStrength: 100,
  editingFilterStrength: false,
  uploadedPhoto: null
 },
 methods: {
  changeFilter: function(obj) {
   this.activeFilterClassname = obj.filter.className;
   this.activeFilterIndex = obj.index;
  },
  toggleFilterStrength: function() {
   this.editingFilterStrength = !this.editingFilterStrength;
  },
  adjustFilterOpacity: function(obj) {
   this.filters[this.activeFilterIndex].opacity = obj.opacity;
  },
  handlePhotoUpload: function(e) {
   let self = this;
   let reader = new FileReader();
   reader.onload = function(e) {
    self.uploadedPhoto = e.target.result;
   }
   reader.readAsDataURL(e.target.files[0]);
  },
  triggerFilePicker: function(photo) {
   this.$refs.upload.click();
  },
  reset: function() {
   this.activeFilterIndex = 0;
   this.activeFilterClassname = null;
   this.uploadedPhoto = null;
   this.filters = generateFilters();
  }
 }
});
              
            
!
999px

Console