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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <h2>ReactJS Animation Card</h2>
<h3>removing/reloading components</h3>
<div id="app"></div>
<p class="love">Made with ♥ by <a href="http://www.makecodenotwar.co/" target="_blank">Deven</a></p>
              
            
!

CSS

              
                body {
  background:linear-gradient(180deg,#3ba4ff,#66a5ff);
  line-height: 2;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

h2 {
  margin-top: 70px;
  margin-bottom: 20px;
}
h3 {
  margin-bottom: 30px;
  
}
h2, h3 {
  text-align: center;
  text-shadow: 1px 1px 6px rgba(0, 0, 0, .1);
}
.list-group {
  position: relative;
  margin: 0 auto 20px;
  max-width: 320px;
  overflow: hidden;
  background: #fff;
  border-radius: 5px;
  box-shadow: 1px 1px 9px rgba(0, 0, 0, .25);
}

.list-group-item {
  padding-right: 50px;
}
.list-group-item:hover {
  background-color: #f5f5f5;
}
.list-group-item-warning:hover {
  background-color: #faf2cc;
}
.btn {
  position: absolute;
  top: 7px;
  right: 7px;
}

.btn-warning:hover {
  background-color: #d9534f;  
}

.glyphicon {
  line-height: inherit;
}
/* animation */

.slide-enter {
  opacity: 0.01;
  left: -100%;
  height: 0;
}

.slide-enter.slide-enter-active {
  opacity: 1;
  height: 50px;
  left: 0;
  transition: all 150ms ease-out;
}

.slide-leave {
  opacity: 1;
  height: 50px;
  left: 0;
}

.slide-leave.slide-leave-active {
  opacity: 0;
  left: 100%;
  height: 0;
  transition: all 150ms ease-in;
}

.love {
  text-align: center;
  font-size: 14px;
  color: white;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.2em;
  
  a {
    text-decoration: none;
    color: black;
  }
  a:hover {
    color: white;
  }
}
              
            
!

JS

              
                const { Component } = React
const { render } = ReactDOM
const { CSSTransitionGroup } = React.addons;

class MyComponent extends Component {
  constructor() {
    super();
    this.state = {
      arr: data.slice()
    };
  }
  removeItem(i) {
    const items = this.state.arr;
    items.splice(i, 1);
    this.setState({
      arr: items
    });
  }
  loadSamples(e) {
    this.setState({
      arr: data.slice()
    });
  }
  render() {
    const { arr } = this.state;
    const list = arr.map((item, i) => {
      return <Row removeItem={ ()=> this.removeItem( i ) } 
                      key={ item } 
                      value={ item } 
                      index={ i } />
    });
    return (
      <ul className="list-group">
        <CSSTransitionGroup           
          transitionName="slide" 
          transitionEnterTimeout={150} 
          transitionLeaveTimeout={150}>
            { list }          
            <Reload loadSamples={ (e)=> this.loadSamples(e) } arr={ arr }/>
         </CSSTransitionGroup>         
      </ul>
    )
  }
}

class Reload extends React.Component {
  render() {
    const { arr, loadSamples } = this.props
    return ( 
      <li className="list-group-item  list-group-item-warning text-center">
        Reload samples (available: { 10 - arr.length} item{ arr.length === 9 ? "" : "s"})
        <button type="button" 
                onClick={ loadSamples } 
                className="btn btn-info"
                disabled={ arr.length === 10 ? "disabled": "" }>
          <span className="glyphicon glyphicon-refresh" aria-hidden="true"></span>
        </button>          
      </li>
    )
  }
} 

class Row extends React.Component {
  render() {
    const { index : i, value, removeItem } = this.props
    return (
      <li className="list-group-item">
        { value }
        <button type="button" className="btn btn-warning"  onClick={ removeItem }>
          <span className="glyphicon glyphicon-remove" aria-hidden="true"></span>
        </button>
      </li>
    )
  }
}

const data = ["01 work", "02 touched tree", "03 pizza", "04 running", "05 television", "06 work", "07 touched tree", "08 pizza ", "09 running", "10 television"]

const mountNode = document.getElementById('app')
render(<MyComponent />, mountNode);
              
            
!
999px

Console