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" class="container">
</div>
              
            
!

CSS

              
                body {
  background: #3D5473;
}

.main-text {
  font-family: 'Permanent Marker', cursive;
}

.card {
  background: #BF4539;
}

.input-field input[type=text]:focus {
  border-bottom: 1px solid #D9A25F;
  box-shadow: 0 1px 0 0 #D9A25F;
}

.btn-floating {
  margin-bottom: 2px;
}

#random-btn {
  margin-top: -10px
}

.searchmatch {
  color: #F2C3A7;
}
              
            
!

JS

              
                // **********************************
class Card extends React.Component {
  constructor(props) {
    super(props);
  }
  
  render() {
    return (
      <div className='row'>
        <div className='col s12 m8 offset-m2'>
          <div className='card hoverable'>
            <div className='card-content white-text'>
              <span className='card-title'>{this.props.title}</span>
              <p dangerouslySetInnerHTML={{__html: this.props.snippet}}></p>
            </div>
            <div className='card-action'>
              <a href={'https://en.wikipedia.org/?title='+this.props.title} target='_blank'>view full page</a>
            </div>
          </div>
        </div>
      </div>
    )
  }
}

// ************************************
class Search extends React.Component {
  constructor(props) {
    super(props);
  }
  
  render() {
    return (
      <div className='row'>
        <div className='input-field col s10 m7 offset-m2 white-text'>
          <input placeholder='Word(s) to Be Searched' type='text' onChange={this.props.getValues}/>
        </div>
        <div className='col s2 m1'>
          <a href='https://en.wikipedia.org/wiki/Special:Random' target='_blank'>
            <button className='btn-floating btn-small black' id='random-btn' title='Random Post'>
              R
            </button>
          </a>
          <button className='btn-floating btn-small black' onClick={this.props.search}>
            <i className='fa fa-search'/>
          </button>
        </div>
      </div>
    )
  }
}

// *********************************
class App extends React.Component {
  constructor() {
    super();
    this.state = {
      searchVals: '',
      results: []
    }
  }
  
  search() {
    const self = this;
    $.ajax({
      url: 'https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=' + this.state.searchVals + '&format=json&callback=?',
      jsonp: "callback",
      dataType: "jsonp",
      success: function(response) {
        self.setState({results: response.query.search}); 
      }
    });
  }
  
  getValues(event) {
    this.setState({searchVals: event.target.value});
  }
  
  render(){
    return (
      <div className='main'>
        <h2 className='main-text center-align'>Fake Wikipedia</h2>
        <Search search={this.search.bind(this)} getValues={this.getValues.bind(this)} />
        { this.state.results.map(result => <Card title={result.title} snippet={result.snippet}/>) }
      </div>
    )
  }
}

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

Console