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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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 {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.header,
.marketing,
.footer {
  padding-right: 1rem;
  padding-left: 1rem;
}

.header {
  padding-bottom: 1rem;
  border-bottom: .05rem solid #e5e5e5;
  .h3 {
  margin-top: 0;
  margin-bottom: 0;
  line-height: 3rem;
}
}

.note-selector {
  display: flex;
  justify-content: center;
  li {
    margin: .6em;
    font-weight: bold;
    cursor: pointer;
    list-style-type: none;
  }
}

.jumbotron {
  text-align: center;
  border-bottom: .05rem solid #e5e5e5;
  .btn {
  padding: .75rem 1.5rem;
  font-size: 1.5rem;
  }
}

.form-signin {
  max-width: 330px;
  padding: 15px;
  margin: 0 auto;
  .form-signin-heading {
    margin-bottom: 10px;
  }
  .form-control {
    position: relative;
    height: auto;
    box-sizing: border-box;
    padding: 10px;
    font-size: 16px;
  }
  .form-control:focus {
  z-index: 2;
}
  input[type="text"] {
  margin-bottom: -1px;
  border-bottom-right-radius: 0;
  border-bottom-left-radius: 0;
}
}



/* Responsive Testing: Tablets and up */
@media screen and (min-width: 48em) {
  .header,
  .marketing,
  .footer {
    padding-right: 0;
    padding-left: 0;
  }
  
   .header {
    margin-bottom: 2rem;
  }
   .jumbotron {
    border-bottom: 0;
  }
}
  
              
            
!

JS

              
                const {
  HashRouter,
  Switch,
  Route,
  NavLink,
  Link
} = ReactRouterDOM;

class App extends React.Component {
  render() {
    return (
      <div className='container'>
        <Nav />
        <Switch>
          <Route exact path="/" component={Home} />
          <Route path="/signin" component={SignIn} />
          <Route path="/notepad" component={NotePadContainer} />
          <Route render={function () {
              return <p> Page Not Found! Please Click another Link </p>
            }} /> 
        </Switch>
      </div>
    )
  }
}

function Nav () { //Nav Bar 
  return (
    <div> 
      <nav className='navbar navbar-toggleable-md navbar-light header'>
        <button className='navbar-toggler navbar-toggler-right' type='button' data-toggle='collapse' data-target='#navbarSupportedContent'>
        <span className='navbar-toggler-icon'></span>
        </button>     
        
        <h3 className="navbar-brand text-muted">React NotePad</h3>
        
        <div classname='collapse navbar-collapse' id='#navbarSupportedContent'>
         <ul className="nav nav-pills justify-content-end">
          <li className="nav-item">
            <NavLink exact activeClassName="active" className="nav-link" to="/">
            Home
            </NavLink>
          </li>
          <li className="nav-item">
            <NavLink activeClassName="active" className="nav-link" to="/signin">
              Sign In     
            </NavLink>
          </li>
         <li className="nav-item">
            <NavLink activeClassName="active" className="nav-link" to="/notepad">
              NotePad     
            </NavLink>
          </li> 
        </ul>
          <WelcomeCard />
       </div>
      </nav>
        
    </div>
 
  )
}

class Home extends React.Component {//Landing Page 
  render() {
    return (
      <div>
        <div className="jumbotron">
          <h1 className="display-2">React NotePad</h1>
          <p className="lead">This is a example React single-page application that uses React, Bootstrap and React Router to build a incorporated: landing page, login page, and NotePad app.</p>
          <br />
          <p><Link className="btn btn-lg btn-success" role="button" to="/signin">
            Click Here to Sign in
            </Link></p>
        </div>
       </div>
    )
  }
}
 
class SignIn extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      username: ''
    };
    this.handleChange = this.handleChange.bind(this);
   }
    handleChange(event) {
      this.setState({
        username: event.target.value
      });
    }
  
  render() {
    return (
      <div className="container">
        
        <form className="form-signin">
          <h2 className="form-signin-heading">Hello, {this.state.username}
            <br /> Please Sign In</h2>
          <label for="username" className="sr-only">UserName</label>
          <input 
            type="text"
            id="username" 
            className="form-control" 
            value={this.state.username}
            onChange={this.handleChange}
            placeholder="Username" 
            required autofocus />
          <br />
           <button
             className="btn btn-lg btn-primary btn-block" 
             type="submit">Sign In</button>
       </form>
        </div>
    )
  }
}


var WelcomeCard = React.createClass({//Turn into sign in component that displays who is logged in
  render: function() {
    return (
      <div className="card">
        <div className="card-block">
          <h5>Welcome, {this.props.username}</h5>
        </div>
       </div> 
    );
  }
});

function SelectNote (props) {//Handles Note Selecting UI
  var notes = ['All Notes', 'New Note', 'Note 3', 'New Note 4'];
  return (
    <ul className='note-selector'>     
        {notes.map(function (note) {
          return (
            <li     
              style={note === props.selectedNote ? { color: '#428bca'} : null}
              onClick={props.onSelect.bind(null, note)}
              key={note}>
              {note}
            </li>  
          )
        })}
     </ul>
  )
}

SelectNote.propTypes = {
  selectedNote: PropTypes.string.isRequired,
  onSelect: PropTypes.func.isRequired,
}

class NotePadContainer extends React.Component {
  constructor (props) {
    super(props);
    this.state = {
      selectedNote: 'All'
    };
    
    this.updateNote = this.updateNote.bind(this);
  }
  updateNote(note) {
    this.setState(function () {
      return {
       selectedNote: note 
      }
    });
  }
  render() {
    return (
      <div>
        <SelectNote
          selectedNote={this.state.selectedNote}
          onSelect={this.updateNote}
          />
        </div>
    )
  }  
}


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

Console