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

              
                *{box-sizing:border-box;}
body {
  font-family: Verdana, sans-serif;
}

h1,
h2,
h3 {
  font-size: 1em;
}

ul.menu {
  list-style: none;
  padding: 0;
}
ul.menu li {
  display: inline-block;
  margin: 2px;
}
ul.menu li a {
  text-decoration: none;
  color: black;
  padding: 1em;
  background: #efefef;
  display: inline-block;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
ul.menu li a.active {
  background: TEAL;
  color: white;
}
ul.menu li a.active:hover {
  background: #00b3b3;
}
ul.menu li a:hover {
  background: #dedede;
}

.bio-list {
  list-style: none;
  padding: 0;
}
.bio-list li {
  overflow: auto;
  padding: 1em 0;
}
.bio-list li figure {
  float: left;
  margin: 0;
  margin-right: 1em;
}
.bio-list li figure img {
  max-width: 100px;
}

.speakers-false,
.agenda-false,
.ticket-false {
  display: none;
}

a.active {
  font-weight: bold;
}

.buy-now {
  background: TEAL;
  padding: 1em;
  display: block;
  text-align: center;
  color: white;
  text-decoration: none;
  border-bottom: 3px solid #004d4d;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.buy-now:hover {
  background: #00b3b3;
  border-bottom-color: TEAL;
  border-bottom-width: 6px;
  margin-top: -3px;
}
.buy-now:active {
  border-bottom-width: 3px;
  margin-top: 0;
}

label {
  display: block;
}

/* App Things */
html,
body {
  height: 100vh;  /* 100vh */
  width: 100%; /* 100 vw */
  // position: fixed;
  background: #222;
  // background: linear-gradient(to bottom, #222, white);
  -webkit-overflow-scrolling: touch;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  // -webkit-overflow-scrolling: touch;
}
#app section {
  flex: 1;
  overflow: scroll;
  -webkit-overflow-scrolling: touch;
  padding: 0 1.2em;
  background: white;
}
#app section > div {
  min-height: 76vh;
}
#app header {
  flex: 0 1 auto;
  background: #222;
  color: white;
  // border-top: 3px solid TEAL;
  padding: 1em 1.2em;
  text-align: center;
  position: -webkit-sticky;
  top: 0;
  z-index: 9;
}
#app footer {
  flex: 0 1 auto;
  background: #efefef;
  border-bottom: 3px solid TEAL;
  padding: 0.5em 1.2em;
  position: -webkit-sticky;
  bottom: 0;
}
              
            
!

JS

              
                class Ticket extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      name: "",
      info: ""
    };
    this.handleNameChange = this.handleNameChange.bind(this);
    this.handleInfoChange = this.handleInfoChange.bind(this);
  }
  handleNameChange(e) {
    let newName = e.target.value;
    this.setState({name: newName.substring(0,10)});      
    if (newName.length <= 10) {
    }
  }
  handleInfoChange(e) {
    this.setState({info: e.target.value});
  }
  render() {
    return <div>
      <h1>Ticket</h1>
      <label>Your name
        <input type="text" onChange={this.handleNameChange} value={this.state.name} />
      </label>
      <label>Your info in 150 characters
        <textarea onChange={this.handleInfoChange} value={this.state.info}></textarea>
      </label>
    </div>;    
  }
}

function Agenda() {
  return <div>
    <h1>Agenda</h1>
    {[1,2,3,4,5,6].map( x => 
      <p>Long dummp text goes here. Long dummp text goes here. Long dummp text goes here. Long dummp text goes here. Long dummp text goes here. Long dummp text goes here. </p>
    )}
  </div>;
}

function Speakers(props) {  
  return <div>
    <h1>Speakers</h1>    
    <ul>
      { props.data.map( speaker => 
        <li key={speaker.name}>{speaker.name}</li>
      )}
    </ul>
  </div>;
}

class App extends React.Component {
  constructor(props) {
    super(props);
    this.props = props;
    this.state = {
      activeTab: "Ticket",
      // ticketInfo: props.ticket,      
    }
    
    this.makeAgendaActive = this.makeAgendaActive.bind(this);
    this.makeSpeakersActive = this.makeSpeakersActive.bind(this);
    this.makeTicketActive = this.makeTicketActive.bind(this);
  }
  makeAgendaActive() {
    console.log(this);
    this.setState({activeTab: "Agenda"});
  }
  makeSpeakersActive() {
    this.setState({activeTab: "Speakers"});
  }
  makeTicketActive() {
    this.setState({activeTab: "Ticket"});
  }
  render() {
    
    var currentView = <Agenda data={this.props.agenda} />;
    if (this.state.activeTab === "Speakers") {
      currentView = <Speakers data={this.props.speakers} />;
    }
    if (this.state.activeTab === "Ticket") {
      currentView = <Ticket data={this.props.ticket} />;
    }
    
    return <div id="app">
      <header>
        Fake Conference
      </header>
      <section>        
        
        {currentView}
      </section>
      <footer>
        <ul className="menu">
          <li><a href="#" onClick={this.makeAgendaActive}>Agenda</a></li>
          <li><a href="#" className="active" onClick={this.makeSpeakersActive}>Speakers</a></li>
          <li><a href="#" onClick={this.makeTicketActive}>Ticket</a></li>
        </ul>
      </footer>
    </div>;
  }
}

var data = {
  ticket: {price: "$300", status: "Price goes up in 14 hours."},
  agenda: [
    {time: "09:00", title: "Breakfast", description: "Chinese style cookies"},
    {time: "10:00", title: "Speakers", description: "Learn something new"},
    {time: "20:00", title: "Party", description: "Meet people"}
  ],
  speakers: [
    {
      image_url: "http://placehold.it/300x300&text=Thomas",
      name: "Thomas U",
      bio: "Thomas U is blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah...."
    },
    {
      image_url: "http://placehold.it/300x300&text=Steven",
      name: "Steven Mak",
      bio: "Steven Mak is blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah...."
    },
    {
      image_url: "http://placehold.it/300x300&text=John",
      name: "John Mak",
      bio: "John Mak is blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah.... blah blah blah...."
    }
  ]
};

ReactDOM.render(<App ticket={data.ticket} agenda={data.agenda} speakers={data.speakers} />, document.getElementById("app"));


              
            
!
999px

Console

Open Chat