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

CSS

              
                body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;
}

.App {
  text-align: center;
}

.App-logo {
  animation: App-logo-spin infinite 20s linear;
  height: 80px;
}

.App-header {
  background-color: #222;
  height: 150px;
  padding: 20px;
  color: white;
}

.issues-box{
  text-align: left;
  max-width: 1200px;
  margin:0 auto;
}

.issue-info{
    border-bottom: 1px solid #3498db;
    margin-bottom: 15px;
    padding-bottom: 15px;
    padding-left:15px;
    padding-right:15px;
 }

.App-intro {
  font-size: large;
}

@keyframes App-logo-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

input[type='text']{
  padding: 15px;
  width: 300px;
  margin: 15px 0;
}

button{
  background: #3498db;
  background-image: -webkit-linear-gradient(top, #3498db, #2980b9);
  background-image: -moz-linear-gradient(top, #3498db, #2980b9);
  background-image: -ms-linear-gradient(top, #3498db, #2980b9);
  background-image: -o-linear-gradient(top, #3498db, #2980b9);
  background-image: linear-gradient(to bottom, #3498db, #2980b9);
  -webkit-border-radius: 28;
  -moz-border-radius: 28;
  border-radius: 28px;
  font-family: Arial;
  color: #ffffff;
  font-size: 20px;
  padding: 10px 20px 10px 20px;
  text-decoration: none;
}

.error{
  color:red;
}

.hidden{
  display:none;
}
              
            
!

JS

              
                class App extends React.Component {

  constructor() {
    super();
    this.state = {
      data: [],
    };

    this.loadIssues = this.loadIssues.bind(this);
  };

  loadIssues(initialState) {
    this.setState({
      api_message: null,
      input: initialState,
      data: [],
      titleVisible: false
    });

    const endpoint = `https://api.github.com/repos/${initialState}/issues`;

    return fetch(endpoint)
      .then((response) => {
        this.setState({ titleVisible: false });
        //Handle 400s and 500s
        if (response.status !== 200) {
          this.setState({ api_message: 'Invalid org/repo yo.' });
          throw new Error('Network response was not ok.');
        }
        return response.json();
      })
      .then((responseJson) => {
        if (!responseJson.length) {
          this.setState({ api_message: `No issues for ${initialState}` });
          return;
        }
        this.setState({ titleVisible: true });
        let json = responseJson;
        this.setState({
          data: json,
          api_message: null
        });
      })
      .catch((error) => {
        console.error(error);
      });
  }

  render() {
    return (
      <div className="App">
        <div className="App-header">
          <img src="https://upload.wikimedia.org/wikipedia/en/a/a7/React-icon.svg" className="App-logo" alt="logo" />
          <h2>Welcome to the React Github Widget</h2>
        </div>
        <div className="App-intro">
          <h3 className="message error">{this.state.api_message}</h3>
        </div>
        <Issues loadIssues={this.loadIssues} repoName={this.state.input} titleVisible={this.state.titleVisible} />
        <div className="issues-box">
          {
            Object.keys(this.state.data).map(key =>
              <IssueInfo key={key} index={key} details={this.state.data[key]} />)
          }
        </div>
      </div>
    );
  }
}

class Issues extends React.Component {

  constructor(props) {
    super(props);

    this.onSubmit = this.onSubmit.bind(this);
    this.onInput = this.onInput.bind(this);

    // init state
    this.state = {
      input: ''
    };
  }

  // input change handler
  onInput(e) {
    this.setState({
      input: e.target.value
    });
    // console.log(this.state);
  }

  // submit handler
  onSubmit(evt) {
    this.props.loadIssues(this.state.input);
    evt.preventDefault();
  }

  render() {
    return (
      <div className="issues">
        <form onSubmit={this.onSubmit}>
        <input
          // use value and onChange so it will be a controlled component
          value={ this.state.value }
          onChange={ this.onInput }
          type="text"
          placeholder="Enter a Github repo Ex. WordPress/WordPress" />
        <button type="submit">Lookup</button>
      </form>
      <h3 className={this.props.titleVisible ? '': 'hidden'}>Github Issues for: {this.props.repoName}</h3>
      </div>
    );
  }
}

class IssueInfo extends React.Component {
    render() {
        const details = this.props.details;

        return (
            <div className="issue-info">
                <h3><a href={details.html_url} target="_blank">{details.title}</a></h3>
                <p><small>reported by - <a href={details.user.html_url} target="_blank">{details.user.login}</a></small></p>
                <div>
                    {details.body.split('\n').map((item, key) => {
                        return <span key={key}>{item}<br /></span>;
                    })}
                </div>
            </div>
        );
    }
}

ReactDOM.render(
  <App />,
  document.getElementById('root')
);

              
            
!
999px

Console