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

              
                <!-- Page Contents -->
<div class="info">
  <h1 class="title">
    <pre>&lt;zap-slideout&gt;</pre>
  </h1>
  <p class="description">Give it a jolt. Click <strong>Open</strong> at the top.</p>
</div>

<zap-slideout></zap-slideout>

<!-- Zap Slideout Template -->
<script id="zap-slideout" type="text/x-template">
  <div class="zap-slideout"
       :class="{ isOpen: isOpen }">
    <div class="zap-slideout-opener"
         @click="toggle">{{openerText}}</div>
    <ul class="zap-slideout-menu">
      <li class="zap-slideout-menu-item">
        <img class="zap-emoji" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/19332/zap-emoji.svg" alt="Zap Emoji" />
      </li>
      <li class="zap-slideout-menu-item"
      	v-for="item in menu">{{item}}</li>
      <li class="zap-slideout-menu-item--small"
      	v-for="item in smallMenu">{{item}}</li>
    </ul>
  </div>
</script>


              
            
!

CSS

              
                /* 
Some fancy Pen styling
 */

body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  color: #fff;
  background-color: #2c3e50;
  -webkit-font-smoothing: antialiased;
}

* {
  box-sizing: border-box;
}

strong {
  font-weight: 600;
}

.info {
  position: absolute;
  top: 50%; left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.title {
  font-size: 24px;
  font-weight: 600;
}

.description {
  margin-top: 20px;
}

/* 
Our Zap Slideout styles...
 */
.zap-slideout {
  position: relative;
  width: 240px;
  height: 100vh;
  padding: 30px;
  background-color: #34495e;
  transform: translateX(-100%);
  transition: transform 0.6s ease(out-cubic);
  
  &.isOpen {
    transform: translateX(0);
  }
}

.zap-slideout-opener {
  position: absolute;
  top: 20px;
  left: 100%;
  margin-left: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #fff;
  cursor: pointer;
  
  &:hover {
    text-decoration: underline;
  }
}

.zap-slideout-menu {
  font-weight: 600;
  color: #fff;
}

.zap-slideout-menu-item,
.zap-slideout-menu-item--small {
  cursor: pointer;
  
  &:hover {
    text-decoration: underline;
  }
  
  & + & {
    margin-top: 20px;
  }
}

.zap-slideout-menu-item {
  font-size: 36px;
  
  & + .zap-slideout-menu-item--small {
    margin-top: 30px;
  }
}

.zap-slideout-menu-item--small {
  font-size: 18px;
  font-weight: normal;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #ecf0f1;
}

/* The famed Zap agency logo (TM) */
.zap-emoji {
  height: 120px;
}
              
            
!

JS

              
                /*
Zap Slideout - Vue Component

This is our component definition. It tells Vue to look for our template, which is the little snippet of HTML that will be used for our component. Every time we use our component in HTML as <zap-slideout>, this template gets plopped into our page, which makes it reusable without pasting it everywhere! */

Vue.component('zap-slideout', {
  template: '#zap-slideout',
  data: () => ({
    openerText: 'Open',
    isOpen: false,
    menu: [ 'Home', 'Work', 'Contact' ],
    smallMenu: [ 'Tips', 'Resources', 'Shenanigans' ]
  }),
  methods: {
    open() {
      this.openerText = 'Close';
      this.isOpen = true;
    },
    close() {
      this.openerText = 'Open';
      this.isOpen = false;
    },
    toggle() {
      if (this.isOpen) {
        this.close();
      } else {
        this.open();
      }
    }
  }
});

/*
Start the engines...

Vue.js has to be started in order for your components to work in your page. Passing 'body' to the `el` property tells Vue it should keep track of everything inside our <body> tag. In this case, everything inside CodePen's HTML panel could be considered our page body.
*/

let app = new Vue({
  el: 'body'
});
              
            
!
999px

Console