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

              
                <div id="app"></div>
              
            
!

CSS

              
                body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  background-color: #fff;
}

.App {
    margin-top: 55px;
    text-align: center;
}

.App .source-link {
    font-size: 12px;
    display: inline-block;
    margin: 40px;
    color: #666;
    text-decoration: none;
    font-weight: 100;
}

.App .source-link:hover {
    text-decoration: underline;
}

h1 {
    text-transform: uppercase;
    font-weight: 100;
    color: #666;
    opacity: 0;
 }

h1.animate {
     opacity: 1;
     transition: all 3s;
 }

.tubes-wrapper {
    margin-top: 80px;
    text-align: center;
    width: 100%;
}

.tubes-wrapper .tube-wrapper {
    display: inline-block;
    margin-bottom: 70px;
}

.tubes-wrapper .tube-wrapper .level-name {
    display: block;
    text-align: center;
    text-transform: uppercase;
    margin-top: 30px;
    color: #666;
    font-weight: 100;
}

.tubes-wrapper .tube {
    display: inline-block;
    height: 290px;
    width: 70px;
    margin: 0 50px;
    border: 2px solid #333;
    border-bottom-left-radius: 15px;
    border-bottom-right-radius: 15px;
    border-top: 0;
    position: relative;
}

.tubes-wrapper .tube .liquid {
    position: absolute;
    bottom: 0;
    top: 0;
    left: 0;
    right: 0;
    transition: all 1s;
    background-color: #eee;
    border-bottom-left-radius: 13px;
    border-bottom-right-radius: 13px;
    z-index: -1;
}

.tubes-wrapper .tube .metrics {
    position: absolute;
    bottom: 0;
    top: 0;
    left: 0;
    right: 0;
    height: 280px;
    width: 25px;
}

.tubes-wrapper .tube .side-line {
    position: absolute;
    bottom: 40px;
    right: 7px;
    height: 85px;
    border-left: 2px solid #333;
}

.tubes-wrapper .tube .neck {
    position: absolute;
    top: -20px;
    right: -2px;
    left: -2px;
    height: 20px;
    border-left: 2px solid #333;
    border-right: 2px solid #333;
}

.tubes-wrapper .tube .head {
    position: absolute;
    top: -27px;
    right: -6px;
    left: -6px;
    height: 5px;
    border-radius: 6px;
    border: 2px solid #333;

}

.tubes-wrapper .tube .metrics .line {
    width: 50%;
    border-top: 2px solid #333;
    display: block;
    margin-bottom: 2px;
    margin-top: 2px;
}

.tubes-wrapper .tube .metrics .line:first-child {
    margin-top: 0;
}

.tubes-wrapper .tube .metrics .line:nth-child(5n) {
    width: 100%;
}

.tubes-wrapper .tube .liquid .circle,
.tubes-wrapper .tube .liquid .circle2,
.tubes-wrapper .tube .liquid .circle3,
.tubes-wrapper .tube .liquid .circle4,
.tubes-wrapper .tube .liquid .circle5,
.tubes-wrapper .tube .liquid .circle6
 {
     z-index: -1;
     opacity: 0;
     height: 20px;
     width: 20px;
     border-radius: 50%;
     background-color: #5DF810;
     display: block;
     left: 0px;
     top: 0;
     position: absolute;
 }

.tubes-wrapper .tube .liquid .circle7,
.tubes-wrapper .tube .liquid .circle8,
.tubes-wrapper .tube .liquid .circle9
{
    z-index: -2;
    opacity: 0;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background-color: #fff !important;
    display: block;
    left: 0px;
    bottom: 0;
    position: absolute;
}

.tubes-wrapper .tube .liquid.animate .circle {
    animation: lol 2s;
    animation-delay: 1s;
}

.tubes-wrapper .tube .liquid.animate .circle2 {
    animation: lol2 2s;
    animation-delay: 1s;
}

.tubes-wrapper .tube .liquid.animate .circle3 {
    animation: lol3 2s;
    animation-delay: 1s;
}

.tubes-wrapper .tube .liquid.animate .circle4 {
    animation: lol4 2s;
    animation-delay: 1s;
}

.tubes-wrapper .tube .liquid.animate .circle5 {
    animation: lol5 2s;
    animation-delay: 1s;
}

.tubes-wrapper .tube .liquid.animate .circle6 {
    animation: lol6 2s;
    animation-delay: 1s;
}

.tubes-wrapper .tube .liquid.animate .circle7 {
    animation: lol7 1.5s;
    animation-delay: .4s;
}

.tubes-wrapper .tube .liquid.animate .circle8 {
    animation: lol8 1.5s;
    animation-delay: .4s;
}

.tubes-wrapper .tube .liquid.animate .circle9 {
    animation: lol9 1.5s;
    animation-delay: .4s;
}

.tubes-wrapper .tube .liquid.dopamine {
    background-color: #2BA5EF;

}

.tubes-wrapper .tube .liquid.serotonin {
    background-color: #5DF810;
}

.tubes-wrapper .tube .liquid.oxytocin {
    background-color: #D303BB;
}

.tubes-wrapper .tube .liquid .bubble {
    background-color: #eee;

}

.tubes-wrapper .tube .liquid.dopamine .bubble {
    background-color: #2BA5EF;

}

.tubes-wrapper .tube .liquid.serotonin .bubble {
    background-color: #5DF810;
}

.tubes-wrapper .tube .liquid.oxytocin .bubble {
    background-color: #D303BB;
}

@keyframes lol {
    0% {
        opacity: 1;
        left: 50%;
        height: 0px;
        width: 0px;
    }

    50% {

        opacity: 1;
        left: 20%;
        height: 15px;
        width: 15px;
    }

    100% {
        opacity: 1;
        top: -80px;
        left: 55%;
        height: 0px;
        width: 0px;
    }
}

@keyframes lol2 {
    0% {
        opacity: 1;
        left: 50%;
        height: 0px;
        width: 0px;
    }

    50% {

        opacity: 1;
        left: 60%;
        height: 10px;
        width: 10px;
    }

    100% {
        opacity: 1;
        top: -100px;
        left: 35%;
        height: 0px;
        width: 0px;
    }
}

@keyframes lol3 {
    0% {
        opacity: 1;
        left: 50%;
        height: 0px;
        width: 0px;
    }

    50% {

        opacity: 1;
        left: 60%;
        height: 10px;
        width: 10px;
    }

    100% {
        opacity: 1;
        top: -40px;
        left: 35%;
        height: 0px;
        width: 0px;
    }
}

@keyframes lol4 {
    0% {
        opacity: 1;
        left: 65%;
        height: 0px;
        width: 0px;
    }

    50% {

        opacity: 1;
        left: 55%;
        height: 10px;
        width: 10px;
    }

    100% {
        opacity: 1;
        top: -60px;
        left: 70%;
        height: 0px;
        width: 0px;
    }
}

@keyframes lol5 {
    0% {
        opacity: 1;
        left: 25%;
        height: 0px;
        width: 0px;
    }

    50% {

        opacity: 1;
        left: 35%;
        height: 5px;
        width: 5px;
    }

    100% {
        opacity: 1;
        top: -20px;
        left: 40%;
        height: 0px;
        width: 0px;
    }
}

@keyframes lol6 {
     0% {
         opacity: 1;
         left: 50%;
         height: 0px;
         width: 0px;
     }

     50% {

         opacity: 1;
         left: 50%;
         height: 5px;
         width: 5px;
     }

     100% {
         opacity: 1;
         top: -35px;
         left: 55%;
         height: 0px;
         width: 0px;
     }
 }

@keyframes lol7 {
    0% {
        opacity: 1;
        left: 50%;
        height: 0px;
        width: 0px;
    }

    50% {

        opacity: 1;
        left: 50%;
        height: 5px;
        width: 5px;
    }

    100% {
        opacity: 1;
        bottom: 80px;
        left: 55%;
        height: 0px;
        width: 0px;
    }
}

@keyframes lol8 {
    0% {
        opacity: 1;
        left: 50%;
        height: 0px;
        width: 0px;
    }

    50% {

        opacity: 1;
        left: 60%;
        height: 10px;
        width: 10px;
    }

    100% {
        opacity: 1;
        bottom: 30px;
        left: 35%;
        height: 0px;
        width: 0px;
    }
}

@keyframes lol9 {
    0% {
        opacity: 1;
        left: 50%;
        height: 0px;
        width: 0px;
    }

    50% {

        opacity: 1;
        left: 20%;
        height: 10px;
        width: 10px;
    }

    100% {
        opacity: 1;
        bottom: 50px;
        left: 55%;
        height: 0px;
        width: 0px;
    }
}

              
            
!

JS

              
                const {Component} = React;
const {render} = ReactDOM;

class Level extends Component {
  render() {
    const {
      levelName,
      animate,
      percentage
    } = this.props;
    return (
      <div className="tube-wrapper">
                    <div className="tube">
                        <div className={"liquid " + levelName + ' ' + animate} style={{top: (100 - percentage) + '%'}}>
                            <div className="bubble circle"></div>
                            <div className="bubble circle2"></div>
                            <div className="bubble circle3"></div>
                            <div className="bubble circle4"></div>
                            <div className="bubble circle5"></div>
                            <div className="bubble circle6"></div>
                          <div className="bubble circle7"></div>
                        <div className="bubble circle8"></div>
                        <div className="bubble circle9"></div>
                        </div>
                        <div className="metrics">
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                            <div className="line"></div>
                        </div>
                        <div className="side-line"></div>
                        <div className="neck"></div>
                        <div className="head"></div>
                    </div>
                <span className="level-name">{this.props.levelName}</span>
            </div>
    )
  }
};

class App extends Component {
  state = {
    feelingIndex: 0,
    animate: '',
    current: 0
  };

  getFeelings = () => [{
    feeling: 'love',
    levels: {
      dopamine: 93,
      serotonin: 93,
      oxytocin: 93
    }
  }, {
    feeling: 'depression',
    levels: {
      dopamine: 28,
      serotonin: 14,
      oxytocin: 3
    }
  }, {
    feeling: 'happiness',
    levels: {
      dopamine: 3,
      serotonin: 100,
      oxytocin: 7
    }
  }, {
    feeling: 'anxiety',
    levels: {
      dopamine: 20,
      serotonin: 3,
      oxytocin: 3
    }
  }];

  changeFeeling = () => {
    let start = Date.now();
    this.setState({
      feelingIndex: this.state.current,
      animate: 'animate'
    });
    this.setState({
      current: this.state.current + 1
    });
    if (this.state.current === this.getFeelings().length) {
      this.setState({
        current: 0
      });
    }
    setTimeout(() => {
      let end = Date.now() - start;
      if (end > 3950) {
        this.setState({
          animate: ''
        });
      }
    }, 4000)
  };

  setInterval = () => {
    this.changeFeeling();
    setInterval(this.changeFeeling, 4500);
  };

  componentDidMount() {
    this.setInterval();
  };

  render() {
    const {
      feelingIndex,
      animate
    } = this.state;
    const feeling = this.getFeelings()[feelingIndex];
    const feelingName = feeling.feeling;
    const levels = feeling.levels;
    return (
      <div className="App">
                <h1 className={animate}>{feelingName}</h1>
                <div className="tubes-wrapper">
                    { Object.keys(levels).map((level, index) => <Level key={index} animate={animate} levelName={level} percentage={levels[level]}></Level>) }
                </div>
                            <a className="source-link" target="_blank" href="https://github.com/edindelan/animated-feelings">Source code - GitHub</a>
            </div>
    );
  }
}

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

Console