cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              body
  background orange
  background radial-gradient(ellipse at center, orange 0%, darken(orange, 20%) 100%)
  width 100%
  height 100vh
  font-family 'San Francisco', 'Helvetica Neue', Roboto, Helvetica, Arial, sans-serif
  font-weight 100
  
button.main
  margin 10%
  outline none
  font-size 40px
  border none
  background none
  color mix(white, orange, 80%)
  transition color .3s ease-in-out
  &:hover
    color mix(white, orange, 90%)

 lightBlue = mix(blue, white, 20%)
 
.Menu
  position fixed
  top 0
  right 0
  width 250px
  height 100vh
  background mix(blue, black, 20%)
  color lightBlue
  border-left 1px solid alpha(lightBlue, 50%)
  box-shadow 0 2px 20px black
  transform translateX(300px)
  opacity 0
  button
    outline none
    font-size 30px
    border none
    background none
    color mix(red, orange, 50%)
    text-align left
    width 100%
    transition color .3s ease-in-out
    transform translateY(-40px)
    opacity 0
    &:hover
      color mix(red, orange, 70%)
  .MenuItem
    border-bottom 1px solid alpha(lightBlue, 50%)
    padding 5px 10px
    font-size 120%
    opacity 0
    i
      color orange
      margin-right 20px
            
          
!
            
              const MenuItem = ({iconName, text}) => (
  <div className='MenuItem'>
    <i className={classNames('fa', 'fa-' + iconName)}/>
    <span>{text}</span>
  </div>
)

const Menu = ({onClick}) => {
 const items = [
   { iconName: 'home', text: 'Welcome' },
   { iconName: 'cog', text: 'Settings' },
   { iconName: 'unlock', text: 'Log out' }
 ];
 return (
  <div className='Menu'>
     <button onClick={onClick}>
       <i className='fa fa-times' />
     </button>
    {
       items.map(i => <MenuItem key={i.iconName} iconName={i.iconName} text={i.text} />)
     }
  </div>
 ) 
};

class MainApp extends React.Component {
  constructor(props) {
    super(props);
    this.state = { open: false };
    this.onClick = this.onClick.bind(this);
  }
  onClick() {
    this.setState({open: !this.state.open});
    const $Menu = $('.Menu');
    const $button = $Menu.find('button');
    const $MenuItems = $Menu.find('.MenuItem');
    const options = {display: false, duration: 150, easing: 'ease-in-out', stagger: 60 };
    const seqIn = [
      {e: $Menu, p: 'transition.slideRightIn', o: options },
      {e: $MenuItems, p: 'transition.slideRightIn', o: options },
      {e: $button, p: 'transition.slideDownIn', o: options}
    ];
    const seqOut = [
      {e: $MenuItems, p: 'transition.slideRightOut', o: options },
      {e: $button, p: 'transition.slideUpOut', o: options},
      {e: $Menu, p: 'transition.slideRightOut', o: options }
    ];
    $.Velocity.RunSequence(this.state.open ? seqOut : seqIn);
  }
  render() {
    return (
      <div>
        <button className='main' onClick={this.onClick} >
          <i className={classNames('fa', {
            'fa-toggle-on': this.state.open,
            'fa-toggle-off': !this.state.open,
          })} />
        </button>
        <Menu onClick={this.onClick} />
      </div>
    );
  }
}

React.render(
  <MainApp />, 
  document.getElementById('react-root'));
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console