Pen Settings

HTML

CSS

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

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

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.

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();
  }

  _generateExpandEffect(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: 250 /* + 20 * index */, 
        // delay: 20 * index,
        fill: 'forwards',
      };
      return new KeyframeEffect(el, keyframes, timing);
  }
  
  componentDidMount() {
    let effects = this.menuButtonRefs.map(this._generateExpandEffect);
    const groupEffect = new GroupEffect(effects);
    this.player = new Animation(groupEffect, 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();
    // doesn't work in IE/Edge
    // this.player.finish();
    // works in IE/Edge
    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