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

              
                <html>

<head>
  <meta charset="utf-8" />
  <!-- Bootstrap 4 Styling -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
  <!-- FontAwesome Icons -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
  <!-- React CDNS -->
</head>

  <body>
    <div class="content">
      <div id="root"></div>
    </div>
  </body>
</html>
              
            
!

CSS

              
                html,
body,
.content {
  background-color: #ccc;
  height: 100%;
}

img {
  margin-right: 30px;  
}

.profile-row {
  display: flex;
  flex-direction: row;
  margin-bottom: 20px;
}

p, .like-component {
  margin-left: 20px;
}

.profile-pic {
  height: 70px;
  width: 70px;
}

.post-time {
  color: #90949c;
}

.blue-icon {
  color: #0099ff;
}

.no-outline {
  border-color: white !important;
}

              
            
!

JS

              
                class Comment extends React.Component {
  constructor () {
    super()    
    this.handleChange = this.handleChange.bind(this)
    this.state = {
      characterCount: 0
    }
  }
  
  handleChange (event) {
    console.log(this)
    this.setState({
      characterCount: event.target.value.length
    })
  }
  
  render() {
    return (
      <div>
        <textarea className="form-control" placeholder="Write a comment..." onChange={this.handleChange}/>
        <small>{this.props.maxLetters - this.state.characterCount} Remaining</small>
      </div>
    )
  }
}

class LikeIcon extends React.Component {
  render () {
    return (
      <div>
        <span className="fa-stack fa-sm">
          <i className="fa fa-circle fa-stack-2x blue-icon" />
          <i className="fa fa-thumbs-up fa-stack-1x fa-inverse" />
        </span>
      </div>
    )
  }
}

class Like extends React.Component {
  constructor() {
    super()
    
    this.state = {
      liked: false
    }
    
    this.toggleLike = this.toggleLike.bind(this)
  }
  
  toggleLike () {
        this.setState(previousState => ({
      liked: !previousState.liked
    }))
  }
  
  render() {
    return (
      <div className="like-component">
        {/* Include the LikeIcon subcomponent within the Like component*/}
        {this.state.liked && <LikeIcon />}
        <hr />
          <button type="button" className="btn no-outline btn-secondary" onClick={this.toggleLike}>
          <i
            className="fa fa-thumbs-o-up fa-4 align-middle"
            aria-hidden="true"
          />
          &nbsp;
          <span className="align-middle">Like</span>
        </button>
      </div>
    )
  }
}

class Status extends React.Component {
  render() {
    return (
      <div className="col-8 offset-2">
        <div className="card">
          <div className="card-block">
            <div className="profile-row">
              <img src="https://zen-of-programming.com/react-intro/selfiesquare.jpg" className="profile-pic" />
              <div className="info">
                <div className="row">
                  <a href="#">The Zen of Programming</a>
                </div>
                <div className="row">
                  <small className="post-time">10 mins</small>
                </div>
              </div>
              </div>
            </div>
            <p>Hello, world!</p>
            <Like />
          </div>
          <div className="card-footer text-muted">
            <Comment maxLetters={140} />
          </div>
      </div>
    )
  }
}

ReactDOM.render(<Status />, document.getElementById("root"))

              
            
!
999px

Console