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="wrap vh-100 overflow-hidden" id="instagram">
  <div class="phone relative bg-white w-100 h-100">
    <transition 
      name="mainStageTransition"
      enter-active-class="animated fadeIn"
      leave-active-class="animated fadeOut">
      <empty-state v-if="noPhotoUploaded"                 
       v-on:photo-uploaded="setPhoto"></empty-state>
      <main class="flex flex-column h-100" v-if="photoUploaded">
        <app-header
          :showing-filter="showingFilterStrength"
          :active-filter="activeFilterName"
         v-on:go-back="resetApp"
            ></app-header>
        <photo-preview
           :active-strength="activeFilterStrength"
           :active-class="activeFilterClass"
           :photo="photo"
           ></photo-preview>
        <div class="filter-area">
          <transition
            name="filterAreaTransition"
            mode="out-in"
            enter-active-class="animated fadeIn"
            leave-active-class="animated fadeOut">
            <filter-list
               v-if="!showingFilterStrength"
               v-on:filter-double-tapped="showFilterStrength"
               v-on:filter-selected="setFilter"
               :active-index="activeFilterIndex"
               :filters="filters"
               :photo="photo">
            </filter-list>
            <strength-slider 
             v-if="showingFilterStrength"
             :active-strength="activeFilterStrength"
             v-on:hide-filter-strength="hideFilterStrength"
             v-on:adjusted-filter-strength="adjustFilterStrength">
            </strength-slider>
          </transition>
        </div>
      </main>
    </transition>
  </div>
</div>
            
          
!
            
              body {
 -webkit-font-smoothing: antialiased;
 background: #eee;
 font-family: 'Roboto', 'Helvetica Neue', 'Helvetica', sans-serif;
}

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

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

.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;
 }
}

.app-header {
  height: 70px;
}

.filter-preview {
  box-shadow: 0 20px 20px -10px rgba(0, 0, 0, 0.10);
  height: 150px;
  width: 150px;
}

.filter {
  color: lighten(#222, 45%);
  transform-style: preserve-3d;
  transition: transform .2s cubic-bezier(.17,.67,.83,.67);
  
  &:active {
    transform: scale3d(.95, .95, .95);
  }

  &.is-selected {
    color: #222;
  }
}

.filter-area {
  min-height: 208px;
}

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

Vue.component('strength-slider', {
  props: ['activeStrength'],
  template:
  `<div class="pa5">
    <div id="slider"></div>
    <div class="mt4 tc">
      <button @click="hideFilterStrength" class="fw6 f6 ttu black bn bg-white">Done</button>
    </div>
  </div>`,
  methods: {
    hideFilterStrength: function () {
      this.$emit('hide-filter-strength')
    }
  },
  mounted: function () {
    let self = this
    let sliderEl = this.$el.querySelector('#slider')
    let options = {
     connect: [true, false],
     tooltips: true,
     format: wNumb({
      decimals: 0,
     }),
     start: [this.activeStrength],
      step: 1,
      range: {
       'min': [0],
       'max': [100]
      }
    }
    
    let slider = noUiSlider.create(sliderEl, options)
    
    slider.on('update', function (e) {
     let newVal = e[0]
     self.$emit('adjusted-filter-strength', newVal)
    })
  }
})

Vue.component('app-header', {
  props: ['showingFilter', 'activeFilter'],
  template: `
  <div class="flex items-center relative overflow-hidden app-header bb b--black-10">
    <transition
      mode="out-in"
      name="headerTransition"
      enter-active-class="animated fadeInUp"
      leave-active-class="animated fadeOutDown">
      <div v-if="!showingFilter" class="absolute top-0 left-0 right-0 bottom-0 w-100 flex items-center">
       <div class="w-third">
         <button @click="goBack" class="mr1 black-60 bg-transparent bn pv0 flex items-center">
          <i class="material-icons">keyboard_arrow_left</i>
         </button>
       </div>
       <div class="w-third flex justify-center">
         <img class="h2" src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Instagram_logo.svg/500px-Instagram_logo.svg.png" alt="" />
       </div>
       <div class="w-third flex justify-end pr3">
         <h5 class="mv0 flex fw5 items-center f5"><a class="link blue" href="http://lmgtfy.com/?q=instagram" target="_blank">Next</a></h5>
       </div>
     </div>
    </transition>
    <transition 
      mode="out-in"
      name="filterTrans"
      enter-active-class="animated fadeInUp"
      leave-active-class="animated fadeOutDown">
     <div v-if="showingFilter" class="pl3">
        {{ activeFilter }}
     </div>
      </transition>
  </div>
  `,
  methods: {
    goBack: function () {
      this.$emit('go-back')
    }
  }
})

Vue.component('photo-preview', {
  props: ['photo', 'activeClass', 'activeStrength'],
  computed: {
    photoAsBackgroundImageUrl: function () {
      return `url(${this.photo})`
    },
    filterOpacity: function () {
      return this.activeStrength / 100
    }
  },
  template: `
    <div class="relative flex-auto h-100">
      <div v-bind:style="{backgroundImage: photoAsBackgroundImageUrl}" class="w-100 h-100 bg-center cover absolute top-0 left-0 bottom-0 right-0 z-4"></div>
      <div v-bind:class="[activeClass]" v-bind:style="{opacity: filterOpacity, backgroundImage: photoAsBackgroundImageUrl}" class="w-100 h-100 bg-center cover absolute top-0 left-0 bottom-0 right-0 z-5"></div>
    </div>
  `
})
 
Vue.component('filter-list', {
  props: ['photo', 'filters', 'activeIndex'],
  template: `
    <div class="filter-list pa3">
      <div class="tc dib mr3 filter" v-for="(filter, index) in filters" @click="selectFilter(index)">
        <h4 class="f5 fw5 mt0 mb2">{{ filter.displayName }}</h4>
      <div v-bind:class="[filter.className]" class="filter-preview aspect-ratio aspect-ratio--1x1">
    <div class="aspect-ratio--object cover bg-center" v-bind:style="{backgroundImage: photoAsBackgroundImageUrl}"></div>
      </div>
    </div>
  </div>`,
  data: function () {
    return {
      flickityInstance: {}  
    }
  },
  mounted: function () {
    this.flickityInstance = new Flickity(this.$el, {
      cellAlign: 'center',
      contain: true,
      initialIndex: this.activeIndex,
      pageDots: false,
      setGallerySize: true,
      prevNextButtons: false
    })
  },
  methods: {
    selectFilter: function (index) {
      if (this.activeIndex === index) {
        this.$emit('filter-double-tapped', index)
      }
      
      this.flickityInstance.select(index)
      this.$emit('filter-selected', index)
    },
  },
  computed: {
    photoAsBackgroundImageUrl: function () {
      return `url(${this.photo})`
    }
  }
})

Vue.component('empty-state', {
  template: `
  <div 
    @click="triggerFilePicker"
    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 mv0 black-30">Click to upload a photo</h2>
  </div>
`,
  methods: {
    handlePhotoUpload: function(e) {
      let self = this;
      let reader = new FileReader();

      reader.onload = function(e) {
        self.$emit("photo-uploaded", e.target.result);
      };

      reader.readAsDataURL(e.target.files[0]);
    },
    triggerFilePicker: function() {
      this.$refs.upload.click();
    }
  }
});

new Vue({
  el: '#instagram',
  data: {
    activeFilterIndex: 0,
    photo: '',
    filters: generateFilters(),
    showingFilterStrength: false
  },
  computed: {
    activeFilterClass: function() {
      return this.filters[this.activeFilterIndex].className
    },
    activeFilterName: function () {
      return this.filters[this.activeFilterIndex].displayName
    },
    activeFilterStrength: function() {
      return this.filters[this.activeFilterIndex].strength
    },
    noPhotoUploaded: function() {
      return this.photo.length === 0
    },
    photoUploaded: function() {
      return this.photo.length > 0
    }
  },
  methods: {
    setPhoto: function (photoString) {
      this.photo = photoString
    },
    setFilter: function (filterIndex) {
      this.activeFilterIndex = filterIndex
    },
    resetApp: function () {
      this.photo = ''
      this.activeFilterIndex = 0
      this.filters = generateFilters()
    },
    showFilterStrength: function () {
      this.showingFilterStrength = true
    },
    hideFilterStrength: function () {
      this.showingFilterStrength = false
    },
    adjustFilterStrength: function (strength) {
      this.filters[this.activeFilterIndex].strength = strength
    }
  }
});

            
          
!
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