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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              <!-- React component gets rendered in this element -->
<div id="app"></div>
            
          
!
            
              $pink: #EE71A6; 
$dark: #17120B;
$orange: #EEB771;

@keyframes tint{
  
  50%{
    border: 1px solid $orange;
  }

  
}

@keyframes fill{
  
  50%{
    transform: scale(.8);
  }
}

*, :before, :after{
  box-sizing: border-box;
}

body, html{
  font-size: 18px;
  height: 100%;
  padding: 0;
}
body{
  background: $dark;
  font-family: 'PT Sans', sans-serif;
}

img{
  max-width: 100%;
  width: 100%;
  object-fit: fill;
}

#app{
  background: $dark;
  background-size: cover;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.search{
  position: absolute;
  bottom: 20px;
  left: 20px;
  border-width: 0 0 2px;
  border-style: solid;
  border-color: #EEB771;
  background: transparentize(black, .8);
  color: $orange;
  font-size: 4rem;
  padding: 0 20px;
  transition: all 300ms ease-in;
  
  &:focus{
    outline: none;
    background: transparentize(black, .3);
  }
}
.component{
  background-size: cover;
  background-position: center;
  text-align: center;
  width: 100%;
  height: 100%;
}

.loader{
  color: #EEB771;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-content: center;
  align-items: center;
  text-align: center;
  padding: 2rem 0;
   
  
  &__dots__dot{
    width: 20px;
    height: 20px;
    background: transparent;
    
    display: inline-block;
    border: 1px solid white;
    position: relative;
    margin-right: 10px;
    
    &:before, {
      content: "";
      width: 18px;
      height: 18px;
      display: block;
      background: white;
      position: absolute;
      transform: scale(.5);
      top: 0;
      left: 0;
      transform-origin: center;
    }
    
    &:nth-child(1){
      animation: tint 1200ms infinite;
    
      &:before{
        animation: fill 1200ms infinite;
      }
    }
    &:nth-child(2){
      animation: tint 1200ms infinite 200ms;

      &:before{
        animation: fill 1200ms infinite 200ms;
      }
    }
    &:nth-child(3){
      animation: tint 1200ms infinite 400ms;

      &:before{
        animation: fill 1200ms infinite 400ms;
      }
    }
    
   
  }
  
  
}

.stage{
  position: relative;
  width: 100%;
  height: 100%;
}

.component{
  position: absolute;
  width: 100%;
  height: 100%;
}

.crossfade-appear {
  opacity: 0.01;
}

.crossfade-appear.crossfade-appear-active {
  opacity: 1;
  transition: all .5s ease-in;
}

.crossfade-enter {
  opacity: 0.01;
}

.crossfade-enter.crossfade-enter-active {
  opacity: 1;
  transition: all 500ms linear;
}

.crossfade-leave {
  opacity: 1;
}

.crossfade-leave.crossfade-leave-active {
  opacity: 0.01;
  transition: all 300ms ease-in;
}
            
          
!
            
              /*
 * Base for building React Components. 
 */

/* 
 * Using ES6 Syntax
 * https://facebook.github.io/react/docs/reusable-components.html#es6-classes
 */

const ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;

const Loader = ({
      loading,
      children
    }) => {
const loader = (
            <div className="loader component" key="loader">
            <div className="loader__dots">
              <span className="loader__dots__dot"/>
              <span className="loader__dots__dot"/>
              <span className="loader__dots__dot"/>
            </div>
          </div>
)           
        return (
          <ReactCSSTransitionGroup 
            className="stage"
            transitionName="crossfade"
            transitionAppear={true} 
            transitionAppearTimeout={500}
            transitionEnterTimeout={500} 
            transitionLeaveTimeout={300}
            component="div"
            aria-busy={loading} // easy aria-role attribute while we’re here
            >
            {loading ? loader : children}
          </ReactCSSTransitionGroup>
        );
      
    }

class Component extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: true,
      image: ''
    }
    this.loaded = this.loaded.bind(this);
    this.getImage = this.getImage.bind(this);
    this.search = this.search.bind(this);
  }

  componentDidMount() {
    this.getImage();
  }
  
  search(e){
    e.preventDefault();
    this.getImage(this.refs.search.value);
  }
  
  getImage(search='flower'){
    this.setState({
      loading: true
    });
    let img = new Image;
    let src='https://source.unsplash.com/featured/?' + search;
    img.src = src;
    img.onload = (e)=>{
      this.setState({
        image: src,
        loading: false
      })
    } 
  }
  


  loaded() {
    this.setState({
      loading: false
    });
  }

  render() {

    let style = {
      'backgroundImage': 'url(' + this.state.image + ')'
    }
    return (
      <Loader loading={this.state.loading}>
        <div 
          className="component" 
          key="component"
          style={style}
          >
          <form onSubmit={this.search}>
            <input className="search" type="text" placeholder="search" ref="search"/>
          </form>
        </div>
      </Loader>
        
    );
  }
}

// Render the component in div#app
ReactDOM.render(<Component/>, document.getElementById('app'));
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console