Created
June 30, 2016 23:53
-
-
Save adamkpurdy/9d38a3cd742357a55c0989ff030eaf3e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from 'react'; | |
| import classnames from 'classnames'; | |
| export default class ProfileSummary extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { | |
| editable: false, | |
| }; | |
| } | |
| setEdit() { | |
| this.setState({ editable: !this.state.editable }); | |
| } | |
| render() { | |
| let classes = classnames('profile-summary', { editable: this.state.editable }); | |
| let editBtnText = (this.state.editable) ? 'done' : 'edit'; | |
| return ( | |
| <div className={classes}> | |
| <button | |
| className="btn" | |
| onClick={() => this.setEdit()} | |
| >{editBtnText}</button> | |
| <img | |
| src="http://placehold.it/140x140" alt="Profile" className="avatar" | |
| /> | |
| <input | |
| id="fullName" className="profile-input" disabled={!this.state.editable} | |
| name="fullName" type="text" defaultValue="Todd Jason" | |
| /> | |
| <input | |
| id="location" className="profile-input" disabled={!this.state.editable} | |
| name="location" type="text" defaultValue="San Francisco, CA" | |
| /> | |
| </div> | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment