123

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">
  <div id="wizard" class="wizard">
    <div class="wizard__content">
      <header class="wizard__header">
        <div class="wizard__header-overlay"></div>
        
        <div class="wizard__header-content">
          <h1 class="wizard__title" >Get start with Javascript!</h1>
          <p class="wizard__subheading">Start with <span>3</span> simple steps.</p>
        </div>
        
        <div class="wizard__steps">
          <nav class="steps">
          <div class="step">
            <div class="step__content">
              <p class="step__number"><i class="fa fa-github-alt"></i></p>
              <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
                <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
                <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
              </svg>

              <div class="lines">
                <div class="line -start">
                </div>

                <div class="line -background">
                </div>

                <div class="line -progress">
                </div>
              </div>  
            </div>
          </div>

          <div class="step">
            <div class="step__content">
              <p class="step__number"><i class="fa fa-book"></i></p>
              <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
                <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
                <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
              </svg>

              <div class="lines">
                <div class="line -background">
                </div>

                <div class="line -progress">
                </div>
              </div> 
            </div>
          </div>

          <div class="step">
            <div class="step__content">
              <p class="step__number"><i class="fa fa-group"></i></p>
              <svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52">
                <circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none"/>
                <path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8"/>
              </svg>

              <div class="lines">
                <div class="line -background">
                </div>

                <div class="line -progress">
                </div>
              </div> 
            </div>
          </div>
        </nav>
        </div>
      </header>
      
      
      <div class="panels">
        <div class="panel">
            <header class="panel__header">
              <h2 class="panel__title">Create a Github account</h2>
              <p class="panel__subheading">With github you can show your projects and find new things everyday!</p>
            </header>
           
           <p class="panel__content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna culpa qui officia deserunt mollit anim id est laborum.</p>
          
          <p class="panel__content">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
        </div>

        <div class="panel">
           <header class="panel__header">
              <h2 class="panel__title">Learn more about pure Javascript.</h2>
              <p class="panel__subheading">We have cool frameworks, but none is better then VanillaJS</p>
           </header>
          
           <p class="panel__content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna culpa qui officia deserunt mollit anim id est laborum.</p>
           <p class="panel__content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>

        <div class="panel">
          <header class="panel__header">
            <h2 class="panel__title">Stay in touch with the community.</h2>
            <p class="panel__subheading">Community is everything, and here we do some crazy stuff.</p>
           </header>
          
          <p class="panel__content">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna culpa qui officia deserunt mollit anim id est laborum.</p>
        </div>
      </div>

      <div class="wizard__footer">
      <button class="button previous">Previous</button>
      <button class="button next">Next</button>
    </div>
    </div>
    
    <h1 class="wizard__congrats-message">
      Congratulations, you are now in a world of pain and suffering!
    </h1>
  </div>
</div>


            
          
!
            
              // Variables
$background-color: #F7F8FA;

$main-color: #4D637B;
$main-black: #676767;
$main-gray: #c3c3c3;

$secondary-color: #75b2f5;
$secondary-color-variant: #5094de;

$default-padding: 15px;
$big-padding: 30px;
$huge-padding: 50px;

$wrapper-size: 1080px;
$wizard-size: 620px;

$circle-size: 40px;
$line-height: 6px;
$default-border-radius: 5px;

$animation-time: .5s;
$curve: cubic-bezier(0.650, 0.000, 0.450, 1.000);
$background-url: 'http://cdn-image.travelandleisure.com/sites/default/files/styles/1600x1000/public/1444253482/DG2015-paris.jpg?itok=XH81cBH9';

// Page 
body, html{
  padding: 0;
  margin: 0;  
  background: $background-color;
  font-family: 'Lato', sans-serif;
  color: $main-black;
}

// General classes
.wrapper{
  position: relative;
  max-width: $wrapper-size;
  margin: 50px auto;
}

// Wizard
.wizard{
  max-width: $wizard-size;
  margin: 0 auto;
  
  &__header{
    position: relative;
    color: #FFF;
    padding: $huge-padding;
    border-radius: $default-border-radius;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    text-align: center;
    height: 100px;
    
    background: url($background-url);
    background-color: $main-color;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
  }
  
  &__header-content{
    position: absolute;
    width: 100%;
    padding: 0 $huge-padding;
    text-align: center;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -60%);
  }
  
  &__header-overlay{
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: rgba($main-color, 0.6);
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
  }
  
  &__title{
    font-size: 1.5rem;
    line-height: 2rem;
    margin: 0;
  }
  
  &__subheading{
    text-transform: uppercase;
    margin: 0;
    font-size: .8rem;
    font-weight: 100;
    letter-spacing: 2px;
    
    span{
      font-weight: 600;
    }
  }
  
  &__steps{
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    transform: translateY(50%);
    z-index: 10;
  }
  
  &__footer{
    padding: 0 $huge-padding $huge-padding;
    border-radius: $default-border-radius;
  }
  
  &__content{
    background: #FFF;
    box-shadow: 0px 0px 10px #c5c5c5;
    border-radius: $default-border-radius;
  }
  
  &__congrats-message{
    color: $main-black;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    
  }
  
  &.completed{
    .wizard__content{
      animation: gettingOut 2s cubic-bezier(1,-0.71, 1, 1.16) forwards;
    }
    
    .wizard__congrats-message{
      animation: fadeIn 2s cubic-bezier(1,-0.71, 1, 1.16) forwards;
    }
  }
}

// Lines
.line{
  position: absolute;
  top: $circle-size / 2;
  left: 50%;
  z-index: -1;
  height: $line-height;
  transition: all $animation-time ease;
  
  &.-start{
    left: 0%;
    background: $secondary-color-variant;
    width: 50%;
  }
  
  &.-end{
    left: 50%;
    background: $secondary-color-variant;
    width: 50%;
  }
  
  &.-background{
    background: $main-gray;
    width: 100%;
  }
  
  &.-progress{
    background: $secondary-color-variant;
    width: 100%;
    transform: scaleX(0);
    transform-origin: left center;
  }
  
  &.-in-progress{
    transform: scaleX(1);
  }
}

// Panels
.panels{
  position: relative;
  overflow: hidden;
}

.panel{
  position: absolute;
  top: 0;
  left: 0;
  transition: .5s all;
  padding: $huge-padding;
  
  &__header{
    margin-bottom: $big-padding;
  }
  
  &__title{
    font-size: 1.5rem;
    line-height: 2rem;
    margin: 0;
  }
  
  &__subheading{
    font-size: .9rem;
    line-height: 1.2rem;
    margin: 0;
  }
 
  &.movingOutBackward{
    transform: translateX($wizard-size * -1);
  }
  
  &.movingOutFoward{
    transform: translateX($wizard-size);
  }
  
  &.movingIn{
    transform: translateX(0);
  }
}

// Steps
.steps{
  position: relative;
  display: flex;
  flex: 0 1 auto;
  color: #fff;
}

.step{
  flex-basis: 0;
  flex-grow: 1;
  max-width: 100%;
  box-sizing: border-box;
  text-align: center;
  border-radius: 5px;
  
  &__content{
    position: relative;
    z-index: 2;
  }
  
  &__number{
    font-size: 1.3rem;
    color: $main-black;
    background: #FFF;
    font-weight: 800;
    width: $circle-size;
    height: $circle-size;
    line-height: $circle-size;
    margin: 0 auto;
    border-radius: 50%;
    border: 5px solid $main-gray;
    
    transition: opacity .5s;
    opacity: 1;
    z-index: 5;
  }
  
  &.-completed{
    .step__number{
      opacity: 0;
    }
    
    .checkmark{
      z-index: 0;
      animation:  fill .4s ease-in-out forwards, 
                  scale .3s ease-in-out .6s both;
    }
    
    .checkmark__check {
      animation: stroke .5s linear .4s forwards;
    }
    
    .line{
      transform: scaleX(1);
    } 
  }
  
  &:last-child{
    .line{
      width: 50%;
    }
  }
}

// Checkmark
.checkmark {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: $circle-size + 10px;
  height: $circle-size + 10px;
  border-radius: 50%;
  stroke-width: 2;
  stroke: #fff;
  stroke-miterlimit: 10;
  box-shadow: inset 0px 0px 0px $secondary-color;
  z-index: -1;
  
  &__circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 8;
    stroke-miterlimit: 10;
    stroke: $secondary-color-variant;
    fill: none;
    animation: stroke .6s $curve forwards;
  }
  
  &__check {
    transform-origin: 50% 50%;
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    stroke: #FFF;
    stroke-width: 5;
  }
}

// Buttons
.button{
  cursor: pointer;
  font-size: 1rem;
  line-height: 1rem;
  background: $secondary-color-variant;
  color: #FFF;
  padding: 10px 15px;
  border: none;
  outline: none;
  display: inline-block;
  transition: all .3s;
  
  &:hover{
    background: lighten($secondary-color-variant, 10%);
  }
  
  &.previous{
    margin-right: 5px;
  }
  
  &.disabled{
    background: $main-gray;
    cursor: default;
  }
}

// Animations
@keyframes stroke {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes scale {
  50% {
    transform: translateX(-50%) scale3d(1.5, 1.5, 1.5);
  }
  
  100% {
    transform: scale3d(0);
  }
}

@keyframes fill {
  100% {
    box-shadow: inset 0px 0px 0px 30px $secondary-color;
  }
}

@keyframes gettingOut {  
  0%{
    transform: translateY(0%);
  }
  
  30%{
    transform: translateY(100px);  
  }
  
  100%{
    transform: translateY(-200%);
  }
}

@keyframes fadeIn {
  100%{
    opacity: 1;
  }
}
            
          
!
            
              class Steps{
  constructor(wizard){
    this.wizard = wizard;
    this.steps = this.getSteps();
    this.stepsQuantity = this.getStepsQuantity();
    this.currentStep = 0;
  }
  
  setCurrentStep(currentStep){
    this.currentStep = currentStep;
  }
  
  getSteps(){
    return this.wizard.getElementsByClassName('step');
  }
  
  getStepsQuantity(){
    return this.getSteps().length;
  }
  
  handleConcludeStep(){
    this.steps[this.currentStep].classList.add('-completed');
  }
  
  handleStepsClasses(movement){
    if(movement > 0)
      this.steps[this.currentStep - 1].classList.add('-completed');
    else if(movement < 0)
      this.steps[this.currentStep].classList.remove('-completed');  
  }
}

class Panels{
  constructor(wizard){
    this.wizard = wizard;
    this.panelWidth = this.wizard.offsetWidth;
    this.panelsContainer = this.getPanelsContainer();
    this.panels = this.getPanels();
    this.currentStep = 0;
    
    this.updatePanelsPosition(this.currentStep);
    this.updatePanelsContainerHeight();
  }
  
  getCurrentPanelHeight(){
    return `${this.getPanels()[this.currentStep].offsetHeight}px`;
  }
  
  getPanelsContainer(){
    return this.wizard.querySelector('.panels');
  }
  
  getPanels(){
    return this.wizard.getElementsByClassName('panel');
  }
  
  updatePanelsContainerHeight(){
    this.panelsContainer.style.height = this.getCurrentPanelHeight();
  }
  
  updatePanelsPosition(currentStep){
    const panels = this.panels;
    const panelWidth = this.panelWidth;
    
    for (let i = 0; i < panels.length; i++) {
      panels[i].classList.remove(
         'movingIn',
         'movingOutBackward',
         'movingOutFoward'
      );
        
      if(i !== currentStep){
        if(i < currentStep) panels[i].classList.add('movingOutBackward');
        else if( i > currentStep ) panels[i].classList.add('movingOutFoward');
      }else{
        panels[i].classList.add('movingIn');
      }
    }
    
    this.updatePanelsContainerHeight();
  }
  
  setCurrentStep(currentStep){
    this.currentStep = currentStep;
    this.updatePanelsPosition(currentStep);
  }
}

class Wizard{
  constructor(obj){
    this.wizard = obj;
    this.panels = new Panels(this.wizard);
    this.steps = new Steps(this.wizard);
    this.stepsQuantity = this.steps.getStepsQuantity();
    this.currentStep = this.steps.currentStep;
    
    this.concludeControlMoveStepMethod = this.steps.handleConcludeStep.bind(this.steps);
    this.wizardConclusionMethod = this.handleWizardConclusion.bind(this);
  }
  
  updateButtonsStatus(){
    if(this.currentStep === 0)
      this.previousControl.classList.add('disabled');
    else
      this.previousControl.classList.remove('disabled');
  }
  
  updtadeCurrentStep(movement){   
    this.currentStep += movement;
    this.steps.setCurrentStep(this.currentStep);
    this.panels.setCurrentStep(this.currentStep);
    
    this.handleNextStepButton();
    this.updateButtonsStatus();
  }
  
  handleNextStepButton(){   
    if(this.currentStep === this.stepsQuantity - 1){      
      this.nextControl.innerHTML = 'Conclude!';
      
      this.nextControl.removeEventListener('click', this.nextControlMoveStepMethod);
      this.nextControl.addEventListener('click', this.concludeControlMoveStepMethod);
      this.nextControl.addEventListener('click', this.wizardConclusionMethod);
    }else{
      this.nextControl.innerHTML = 'Next';
      
      this.nextControl.addEventListener('click', this.nextControlMoveStepMethod);
      this.nextControl.removeEventListener('click', this.concludeControlMoveStepMethod);
      this.nextControl.removeEventListener('click', this.wizardConclusionMethod);
    }
  }
  
  handleWizardConclusion(){
    this.wizard.classList.add('completed');
  };
  
  addControls(previousControl, nextControl){
    this.previousControl = previousControl;
    this.nextControl = nextControl;
    this.previousControlMoveStepMethod = this.moveStep.bind(this, -1);
    this.nextControlMoveStepMethod = this.moveStep.bind(this, 1);
    
    previousControl.addEventListener('click', this.previousControlMoveStepMethod);
    nextControl.addEventListener('click', this.nextControlMoveStepMethod);
    
    this.updateButtonsStatus();
  }
  
  moveStep(movement){
    if(this.validateMovement(movement)){
      this.updtadeCurrentStep(movement);
      this.steps.handleStepsClasses(movement);
    }else{
       throw('This was an invalid movement');
    }
  }
  
  validateMovement(movement){
    const fowardMov = movement > 0 && this.currentStep < this.stepsQuantity - 1;
    const backMov = movement < 0 && this.currentStep > 0;
    
    return fowardMov || backMov;
  }
}

let wizardElement = document.getElementById('wizard');
let wizard = new Wizard(wizardElement);
let buttonNext = document.querySelector('.next');
let buttonPrevious = document.querySelector('.previous');

wizard.addControls(buttonPrevious, buttonNext);

            
          
!
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.

Console