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

              
                #app
              
            
!

CSS

              
                $buttonSize: 3.5rem
$color: rebeccapurple
$background: lighten(rebeccapurple, 30%)

html, body
  width: 100%
  height: 100%
  background: $background

body
  display: flex
  align-items: center
  justify-content: center
  
.Menu360-container
  height: $buttonSize
  width: $buttonSize
  position: relative
  & > button
    position: absolute
    font-size: 2rem
    width: $buttonSize
    height: $buttonSize
    border-radius: 50%
    outline: none
    border: none
    color: white
    text-shadow: 1px 1px 1px black
    background-color: $color
    &:focus
      border: 3px solid white
      box-shadow: 0 0 10px 3px $color
    &.Menu360-button
      will-change: transform
              
            
!

JS

              
                // a menu button which, when clicked, reveals other buttons surrounding it
class Menu360 extends React.Component {
  constructor() {
    super();
    /*
     I think this should come from props, but for this demo I'm just hard coding it These strings are fa icon names, try adding or removing from this list. 
    */
    this.buttonIcons = [
      'facebook', 
      'twitter', 
      'linkedin', 
      'github', 
      'codepen', 
      'reddit', 
      'youtube', 
      // 'pinterest', 
      // 'google-plus'
    ];
    
    this.menuButtonRefs = [];   
    this._toggleMenu = this._toggleMenu.bind(this);
  }
  
  _toggleMenu() {
    if (!this.player) return;
    this.player.reverse();
  }
  
  _generateButtonEffect(el, index, array) {
      const endX = Math.round( 80 * Math.cos(index * 2 * Math.PI/array.length));
      const endY = Math.round( 80 * Math.sin(index * 2 * Math.PI/array.length));
      let keyframes = [
        {transform: 'translate(0,0)'}, 
        {transform: `translate(${endX}px, ${endY}px)`}
      ];

      let timing = {
        duration: 150,
        fill: 'forwards', 
        easing: 'ease-in-out',
      };
      return new KeyframeEffect(el, keyframes, timing);
  }
  
  componentDidMount() {
    let effects = this.menuButtonRefs.map(this._generateButtonEffect);
    /*
     SequenceEffect crashes chrome when reversed
    */
    const sequenceEffect = new SequenceEffect(effects);
    this.player = new Animation(sequenceEffect, document.timeline);
    /*
     Initializing the animation to be reversed but finished. This allows the animation to toggle with only additional calls to player.reverse(). There should probably be more robust state handling, but...LOL
    */
    this.player.reverse();
    this.player.currentTime = 0;
  }

  render() {
    return (
      <div className="Menu360-container">
        {this.buttonIcons.map( (iconName, index) => {
          let classes = `fa fa-${iconName}`;
          return (
            <button key={iconName}
              ref={(r) => this.menuButtonRefs[index] = r }
              className="Menu360-button"
              >
              <i className={classes}/>
            </button>
          );
        })}
        <button className="Menu360-toggle" onClick={this._toggleMenu}>
          <i className="fa fa-bars"/>
        </button>
      </div>
    )
  }
}

ReactDOM.render(<Menu360 />, document.getElementById('app'));
              
            
!
999px

Console