cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              
<script src="https://fb.me/react-0.14.7.js"></script>
<script src="https://fb.me/react-dom-0.14.7.js"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script type="text/javascript" src="//golden-layout.com/assets/js/goldenlayout.min.js"></script>
<link type="text/css" rel="stylesheet" href="//golden-layout.com/assets/css/goldenlayout-base.css" />
<link type="text/css" rel="stylesheet" href="//golden-layout.com/assets/css/goldenlayout-dark-theme.css" />
            
          
!
            
              .userlist *,
.userdetails{
    color: #fff;
    font: 12px Arial, sans-serif;
}
.userlist{
    margin: 0;
    padding: 0;
}
template{
  display:none;
}
.userlist li{
    padding: 10px;
    border-bottom: 1px solid #555;
    cursor: pointer;
    list-style-type: none;
}

.userlist li:hover{
    background: #666;
}

.userlist li.selected{
    background: orange;
    font-weight: bold;
}
.userdetails *{
  color: #fff;
}

.userdetails{
    padding: 10px;
    overflow: hidden;
}

.userdetails img{
    float: left;
    margin-right: 10px;
}

.userdetails h2{
    margin-top: 0;
}
            
          
!
            
              /***************************
* UserList Component
***************************/
var UserList = React.createClass({
	getInitialState: function() {
		return { users: [
            { name: 'Jackson Turner', street: '217 Tawny End', img: 'men_1.jpg' },
            { name: 'Megan Perry', street: '77 Burning Ramp', img: 'women_1.jpg' },
            { name: 'Ryan Harris', street: '12 Hazy Apple Route', img: 'men_2.jpg' },
            { name: 'Jennifer Edwards', street: '33 Maple Drive', img: 'women_2.jpg' },
            { name: 'Noah Jenkins', street: '423 Indian Pond Cape', img: 'men_3.jpg' }
        ]};
	},
	render: function() {
		var eventHub = this.props.glEventHub;
		return (
			<ul className="userlist">
				{this.state.users.map(function( user ){
					return <User
						key={user.name}
						userData={user}
						glEventHub={eventHub} />
				})}
			</ul>
		)
	}
});

/***************************
* User Component
***************************/
var User = React.createClass({
	getInitialState: function() {
		return this.props.userData;
	},
	selectUser: function() {
		this.props.glEventHub.emit( 'user-select', this.state );
	},
	render: function() {
		return (
			<li onClick={this.selectUser}>{this.state.name}</li>
		)
	}
});

/***************************
* UserDetail Component
***************************/
var UserDetail = React.createClass({
	componentWillMount: function() {
		this.props.glEventHub.on( 'user-select', this.setUser );
	},
	componentWillUnmount: function() {
		this.props.glEventHub.off( 'user-select', this.setUser );
	},
	setUser: function( userData ) {
		this.setState( userData );
	},
	render: function() {
		if( this.state ) {
			var imgUrl = 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/152047/' + this.state.img;
			return (
				<div className="userdetails">
					<img src={imgUrl} width="100" height="100" />
					<h2>{this.state.name}</h2>
					<p>{this.state.street}</p>
				</div>
			)
		} else {
			return (<div className="userdetails">No user selected</div>)
		}
	}
});

/***************************
* GoldenLayout Init
***************************/
var config = {
	content: [{
		type: 'row',
		content: [{
      title: 'Users',
			type:'react-component',
			component: 'user-list'
		},{
      title: 'User Detail',
			type:'react-component',
			component: 'user-detail'
		}]
	}]
};

var myLayout = new GoldenLayout( config );
myLayout.registerComponent( 'user-list', UserList );
myLayout.registerComponent( 'user-detail', UserDetail );
myLayout.init();
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console