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.

            
              transparentBg {
  background: 'transparent';
}
            
          
!
            
              const {
  Router,
  Route,
  Link,
  IndexRoute,
  hashHistory
} = ReactRouter;

class PromptContainer extends React.Component {
  constructor(props) {
    super(props)
    this.state = { username: '' }
    this.onUpdateUser = this.onUpdateUser.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }

  onUpdateUser(event) {
    this.setState({
      username: event.target.value
    });
  }

  handleSubmit(event) {
    event.preventDefault()

    if (this.props.params.playerOne) {
      // go to battle
      alert("sorry game isn't quite finished yet");
    } else {
      this.context.router.push('/playerTwo/' + this.state.username)
    }
    this.setState({ username: '' })
  }

  render () {
    return (
       <div className="jumbotron col-sm-6 col-sm-offset-3 text-center transparentBg">
        <h1>{this.props.route.header}</h1>
        <div className="col-sm-12">
          <form onSubmit={this.handleSubmit}>
            <div className="form-group">
              <input 
                className="form-control" 
                placeholder="Github Username"
                type="text"
                onChange={this.onUpdateUser} 
                value={this.state.username} />
            </div>
            <div className="form-group col-sm-4 col-sm-offset-4">
              <button
                className="btn btn-block btn-success"
                type="submit">
                  Continue
              </button>
            </div>
          </form>
        </div>
       </div>
    );
  }
}

PromptContainer.contextTypes = {
  router: React.PropTypes.object
};

class App extends React.Component {
  render() {
    return (
      <div>
        <h1 className='text-center'>Github Battle</h1>
        {this.props.children}
      </div>
    ) 
  }
}

class Home extends React.Component {
  render() {
    return (
      <div className="jumbotron col-sm-12 text-center transparentBg" >
        <Link to='/playerOne'>
          <button type='button' className='btn btn-lg btn-success'>
            Get Started
          </button>
        </Link>
      </div>
    )
  }
}

class Routes extends React.Component {
  render() {
    return (
       <Router history={hashHistory}>
          <Route path='/' component={App}>
            <IndexRoute component={Home}></IndexRoute>
            <Route path='playerOne' header='Player One' component={PromptContainer} />
            <Route path='playerTwo/:playerOne' header='Player Two' component={PromptContainer} />
          </Route>
      </Router>
     )
  }
}

ReactDOM.render(<Routes />, document.getElementById('app'))
            
          
!
999px
Loading ..................

Console