cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

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.

            
              <div id="menuContainer"></div>
<div>
 
</div>
            
          
!
            
              .shape-enter {
  transform: scale(0);
}

.shape-enter.shape-enter-active {
  transform: scale(1);
  transition: all .5s ease-in;
}

.shape-leave {
  transform: scale(1);
}

.shape-leave.shape-leave-active {
  transform: scale(0);
  transition: all .5s ease-in;
}

.shape-menu {
  display: block;
  width: 100%;
  margin:  30px 0;
}
.fa {
  width: 50px;
  margin: 0 20px;
  font-size: 2em;
}
            
          
!
            
              let ReactCSSTransitionGroup = React.addons.CSSTransitionGroup

class ShapeContainer extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      lazyKey: 0,
      elements: []
    };
    this.addTriangle = this.addTriangle.bind(this);
    this.addCircle = this.addCircle.bind(this);
    this.deleteShape = this.deleteShape.bind(this);
  }

  addTriangle() {
    const key = this.state.lazyKey;
    this.setState({lazyKey: this.state.lazyKey + 1});
    this.setState({ elements: [...this.state.elements, <Triangle key={key} id={key} handleDelete={this.deleteShape}/>]});
  }
  
  addCircle() {
    const key = this.state.lazyKey;
    this.setState({lazyKey: this.state.lazyKey + 1});
    this.setState({ elements: [...this.state.elements, <Circle key={key} id={key} handleDelete={this.deleteShape}/>]});
  }
  
  deleteShape(item) {
    const elements = this.state.elements.filter((element) => {
      return element.key != item;
    });
    this.setState({elements: elements})
  }
  
  render() {
    const elements = this.state.elements
    return ( 
      <div id = "shapes">
        <div className="shape-menu">
          <h1> Click icon to add shape. Click shape to remove.</h1>
          <i className = "fa fa-exclamation-triangle" onClick = { this.addTriangle }/> 
          <i className = "fa fa-circle" onClick = { this.addCircle }/> 
        </div>
        <ReactCSSTransitionGroup
          transitionName = "shape"
          transitionEnterTimeout={500}
          transitionLeaveTimeout={500}
         >
          {elements}
        </ReactCSSTransitionGroup>
      </div>
    )
  }
}

const Circle = ({id, handleDelete})  => (
<svg onClick={()=>handleDelete(id)} width="100px" height="100px" viewBox="124 128 100 100">
    <circle id="Oval" stroke="none" fill="#D8D8D8" fill-rule="evenodd" cx="174" cy="178" r="50"></circle>
</svg>
)

const Triangle = ({id, handleDelete}) => (
<svg onClick={()=>handleDelete(id)} width="100px" height="100px" viewBox="115 248 100 100">
    <polygon id="Triangle" stroke="none" fill="#f8e81c" fill-rule="evenodd" points="165 248 215 348 115 348"></polygon>
</svg>
)

ReactDOM.render(
  <ShapeContainer />,
    document.getElementById('menuContainer')
);
            
          
!
999px
Loading ..................

Console