cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

Code Indentation

     

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.

            
              /*
 * A simple React component
 */
var tabs = [{title:'Tab One',content:' Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry',image:'http://placehold.it/200x200'},{title:'Tab Two',content:'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry',image:'http://placehold.it/200x200'},{title:'Tab One',content:'Lorem Ipsum is simply dummy text of the printing and typesetting industry.  Ipsum has been the industry',image:'http://placehold.it/200x200'},{title:'Tab Two',content:' Ipsumsimply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry',image:'http://placehold.it/200x200'}]
class Application extends React.Component {
  constructor(props){
    super(props)
  }
  render() {
    return <div>
     <Tabs tabs={tabs}/>
    </div>;
  }
}
class TabBody extends React.Component{
  constructor(props){
    super(props)
    
  }
  render(){
    return(
    <div style={{border:'1px solid tomato',display:'flex',flexDirection:'row',flex:1,alignItems:'center',alignContent:'center'}}>
        <div style={{display:'flex',flexDirection:'row',alignItems:'center',alignContent:'center',flex:1}}>
          <div style={{display:'flex', flex:'0 0 50%'}}>{this.props.tab.content}</div>
      <img style={{height:'200',width:'200'}} src={this.props.tab.image} />
        </div>
    </div>
    )
  }
}
class TabHeader extends React.Component {
  constructor(props){
    super(props)
  }
  render() {
    var isActive;
    var toReturn;
    if(this.props.active === this.props.which){
      isActive = true;
    }else{
      isActive = false;
    }
//     if(isActive){
//        toReturn = (<div>
//       <div>{this.props.tab.content}</div>
//       <img src={this.props.tab.image} />

//     </div>)
//     }else{
//       toReturn = null
//     }
    return <div style={{flex:1,display:'flex',cursor:'pointer'}}> 
      <div onClick={this.props.handleTabClick.bind(this, this.props.which)} style={{flex:1,transition:'all .2s ease',display:'flex',alignItems:'center',alignContent:'center',padding:5,background:this.props.active === this.props.which ?  'tomato' : 'white' ,cursor:'pointer'}}><div style={{margin:'auto'}}>{this.props.tab.title}</div></div>
</div>;
  }
}
class Tabs extends React.Component {
  constructor(props){
    super(props)
    this.state={active:0}
  }
  handleTabClick(active){
    this.setState({
      active
    })
  }
  render() {
    var toReturnTabHeaders = this.props.tabs.map((tab, i) =>{
      return(<TabHeader handleTabClick={this.handleTabClick.bind(this)} active={this.state.active} key={i} which={i} tab={tab}/>)
    })
     var toReturnTabs = this.props.tabs.map((tab, i) =>{
       if(this.state.active === i){
          return(<TabBody which={i} tab={tab}/>)
       }
    })
    return <div style={{display:'flex',flexDirection:'column',flex:1}}>
      <div style={{display:'flex',flexDirection:'row',flex:'0 0 50px'}}>{toReturnTabHeaders}</div>
      <div style={{display:'flex',flexDirection:'column'}}>{toReturnTabs}</div>
    </div>;
  }
}

/*
 * Render the above component into the div#app
 */
React.render(<Application />, document.getElementById('app'));
            
          
!
999px
Loading ..................

Console