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.

            
              
<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
Loading ..................

Console