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="login-signup">
</div>

              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Quicksand:300,400,700);

@import url(https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css);

body {
  background: rgba(47,100,90,1);
  background: -moz-linear-gradient(
    left, 
    rgba(47,100,90,1) 0%, 
    rgba(111,161,123,1) 100%
  );
  background: -webkit-gradient(
    left top, 
    right top, 
    color-stop(0%, rgba(47,100,90,1)), 
    color-stop(100%, rgba(111,161,123,1))
  );
  background: -webkit-linear-gradient(
    left, 
    rgba(47,100,90,1) 0%, 
    rgba(111,161,123,1) 100%
  );
  margin: 0;
  pdading: 0;
  height: 100%;
  background-repeat: no-repeat;
  background-attachment: fixed;
  font-family: 'quicksand';
}

hr {
  border: 0;
  height: 1px;
  opacity: .3;
  background-image: linear-gradient(
    to right, 
    rgba(255,255,255,.2), 
    rgba(255,255,255,1), 
    rgba(255,255,255,.2)
  );
}

.login {
  opacity: 1;
  visiblity: visible;
  position: absolute;
  z-index: 1000;
  top: 50%;
  left: 50%;
  margin-top: -230px;
  margin-left: -210px;
  padding-top: 20px;
  padding-bottom: 20px;
  background-color: rgba(255,255,255,.3);
  height: 440px;
  width: 400px;
  color: white;
  text-align: center;
  border-radius: 2px;
  -webkit-box-shadow: 10px 10px 15px -6px rgba(0,0,0,0.25);
  transition: 
    opacity .3s ease-in .3s,
    visibility .3s ease-in .3s;
  transform: scale(.9);
}

.sign-up {
  opacity: 1;
  visiblity: visible;
  position: absolute;
  z-index: 2000;
  top: 50%;
  left: 50%;
  margin-top: -330px;
  margin-left: -210px;
  padding-top: 20px;
  padding-bottom: 20px;
  background-color: rgba(255,255,255,.3);
  height: 640px;
  width: 400px;
  color: white;
  text-align: center;
  border-radius: 2px;
  -webkit-box-shadow: 10px 10px 15px -6px rgba(0,0,0,0.25);
  transition: 
    opacity .3s ease-in .3s,
    visibility .3s ease-in .3s;
  transform: scale(.9);
}

.login-closed {
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  margin-left: -400px;
  transition: 
    opacity .3s ease-out,
    visibility .3s ease-out,
    margin .3s cubic-bezier(0.600, -0.280, 0.735, 0.045);
}

.sign-up-closed {
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  margin-left: -400px;
  transition: 
    opacity .3s ease-out,
    visibility 3s ease-out,
    margin .3s cubic-bezier(0.600, -0.280, 0.735, 0.045);
}

.field {
  margin: 20px;
  margin-left: 50px;
  text-align: left;
}

.input {
  margin: 5px;
  width: 300px;
  margin-left: -5px;
  height: 40px;
  border-radius: 2px;
  border: none;
  font-size: 18px;
  padding: 5px;
  color: #25291b;
  background-color: rgba(255,255,255, .5);
  -webkit-box-shadow: 10px 10px 10px -10px rgba(0,0,0,0.3);
  transition: background-color .4s ease-out;
}

.input:focus {
  outline: none;
  background-color: rgba(255,255,255, .8)
}

.label {
  font-weight: lighter;
  margin-left: -5px;
}

.submit-button {
  cursor: pointer;
  margin-top: 20px;
  width: 310px;
  height: 50px;
  font-size: 20px;
  border: none;
  background-color: rgba(0,0,0,.6);
  border-radius: 2px;
  color: white;
  font-weight: bold;
  letter-spacing: 3px;

  transition: background-color .4s ease-out;
}

.submit-button:hover {
  background-color: rgba(0,0,0,.7);
}

.submit-button:focus {
  outline: none;
  background-color: rgba(0,0,0,.7);
}

.in-out {
  font-size: 12px;
  margin-top: 30px;
  padding-right: 5px;
  padding-left: 5px;
}

.in-out a {
  color: rgba(0,0,0, .7);
  text-decoration: none;
  margin-left: 17px;
  border: 1px solid rgba(0,0,0, .7);
  border-radius: 2px;
  padding: 2px;
  transition: all .4s ease-out;
}

.in-out a:hover {
  color: rgba(255,255,255, 1);
  border: 1px solid rgba(255,255,255, 1);
}

.field-in {
  animation: pulse .7s 1;
}

.animate-check {
  margin-left: 5px;
  animation: pulse2 .4s 1;
}

@keyframes pulse {
  0% { transform: scale(.8); }
  40% { transform: scale(1.2); }
  70% { transform: scale(1); }
  90% { transform: scale(1.01); }
  100%{ transform: scale(1); }
}

@keyframes pulse2 {
  0% { transform: scale(.1); opacity: 0;}
  50% { transform: scale(1.4); opacity: 1;}
  100% { transform: scale(1); }
}
              
            
!

JS

              
                const loginInputs = [
  {
    label: "User Name",
    type: "text",
    show: true,
    validated: "",
    id: "a"
  }, {
    label: "Password",
    type: "password",
    show: true,
    validated: "",
    id: "b"
  }
];

const signupInputs = [
  {
    label: "User Name",
    type: "text",
    show: false,
    validated: "",
    id: "c"
  }, {
    label: "Email",
    type: "email",
    show: false,
    validated: "",
    id: "d"
  }, {
    label: "Password",
    type: "password",
    show: false,
    validated: "",
    id: "e"
  }, {
    label: "Re-Enter Password",
    type: "password",
    show: false,
    validated: "",
    id: "f"
  }
];

const LoginWrapper = React.createClass({
  
  getInitialState () {
    return {
      signUp: false, 
      signupInputs: signupInputs, 
      loginInputs: loginInputs
    };
  },
  
  inUpClick () {
    this.setState({signUp: !this.state.signUp});
    this.animateFields("signupInputs");
    setTimeout(()=>{this.animateFields("loginInputs");}, 100); 
  },
  
  animateFields (formName) {
    let start, length, newForm;
    
    if (formName === "loginInputs") {
      newForm = this.state.loginInputs.slice();
    } else if (formName === "signupInputs") {
      newForm = this.state.signupInputs.slice();
    }
    
    start = 0;
    length = newForm.length;
    
    console.log(newForm);
    
    let stagger = (i) => {
      if (i < length) {
      	setTimeout(() => {
        	newForm[i].show = !newForm[i].show
          this.setState({[formName]: newForm});
          stagger(i + 1);
        },70);
      }
    };
    stagger(start);  
  },
  
  submitForm (e) {
    e.preventDefault();
  },
  
  validateField(event, id) {
    let newState, fieldInState;
    const value = event.target.value;
    
    const getField = (field) => (
      field.id === id
    );
    
    const validate = (v) => (
      v.length > 0
    );
    
    if (this.state.signUp === true) {
      newState = this.state.signupInputs.slice();
      fieldInState = newState.find(getField);
        
      fieldInState.validated = validate(value) ? true : false;
      this.setState({signupInputs: newState});
    }
    else {
      newState = this.state.loginInputs.slice();
      fieldInState = newState.find(getField);

      fieldInState.validated = validate(value) ? true : false;
      this.setState({loginInputs: newState});
    }
  },
  
  render () {
    
    return (
      <div>
        <Login 
          signUp={this.state.signUp}
          inputs={this.state.loginInputs}
          inUpClick={this.inUpClick}
          submitForm={this.submitForm}
          validateField={this.validateField}

        />
        <SignUp
          signUp={this.state.signUp}
          inputs={this.state.signupInputs}
          inUpClick={this.inUpClick}
          submitForm={this.submitForm}
          validateField={this.validateField}
        />
      </div>
    );
  }
});

const Login = ({
  inputs, 
  signUp, 
  inUpClick, 
  submitForm, 
  validateField
}) => (
  <div className={signUp ? "login login-closed" : "login"} >
    <h1>Log In</h1>
    <hr />
    <Form 
      inputs={inputs} 
      submitForm={submitForm}
      validateField={validateField}
    />
    <SignupLink inUpClick={inUpClick} />
  </div>
);

const SignUp = ({
  inputs, 
  signUp, 
  inUpClick, 
  submitForm, 
  validateField
}) => (  
  <div 
    className={signUp 
      ? "sign-up" 
      : "sign-up sign-up-closed"}
  >
    <h1>Sign Up</h1>
    <hr />
    <Form 
      inputs={inputs} 
      submitForm={submitForm}
      validateField={validateField}
    />
    <LoginLink inUpClick={inUpClick} />
  </div>
);

const Form = ({
  inputs, 
  submitForm, 
  validateField
}) => {
  const inputsMapped = inputs.map((i) => (
    <Input 
      label={i.label} 
      type={i.type}
      show={i.show}
      validated={i.validated}
      id={i.id}
      validateField={validateField}
    />
  ));
  
  return (
    <form onSubmit={submitForm}>
      {inputsMapped}
      <Submit />
    </form>
  );
};

const Submit = () => (
  <div>
    <hr />
    <button
      className="submit-button"
      type="submit"
    > Submit
    </button>
  </div>
);

const Input = ({
  label, 
  type, 
  show, 
  validated, 
  id, 
  validateField
}) => (
  <div className={show ? "field field-in" : "field"}>
    <label className="label">{label}
      <i 
        className={validated 
          ? "fa fa-check animate-check" 
          : ""}
        aria-hidden="true"
      ></i>
    </label>
    <br />
    <input 
      className="input" 
      type={type}
      onBlur={()=>{validateField(event, id);}}
    />
  </div>
);

const SignupLink = ({inUpClick}) => (
  <div className="signup-link">
    <p className="in-out"> 
      Don't have an account? {" "}
      <a href="#" onClick={inUpClick}>Sign Up Here</a>
    </p>
  </div>
);

const LoginLink = ({inUpClick}) => (
  <div className="signup-link">
    <p className="in-out"> 
      Already have an account? {" "}
      <a href="#" onClick={inUpClick}>Log In Here</a>
    </p>
  </div>
);

ReactDOM.render(
  <LoginWrapper />, 
  document.getElementById('login-signup')
);
              
            
!
999px

Console