content: import React from 'react'
  import ampersandMixin from 'ampersand-react-mixin'
  
  export default React.createClass({
    mixins : [ampersandMixin],
  
    getInitialState () {
      const { name, color } = this.props.label
  
      return { name, color }
    },
    
    onSubmit(event) {
      event.preventDefault()
      const {label} = this.props
      if (label.saved) {
        label.update(this.state)
      } else {
        label.save(this.state, {
          success : () => label.saved = true
        })
      }
      label.editing = false
    },
  
    onNameChange (event) {
      this.setState({
        name : event.target.value
      })
    },
  
    render() {
      const {label} = this.props
      const { color } = this.state
      const cssColor = "#" + color
      let content
  
      if(label.editing) {
        content = (
          <form onSubmit = {this.onSubmit} className='label'>
            <span style = {{backgroundColor: cssColor}} className='label-color avatar avatar-small avatar-rounded'>&nbsp;</span>
            <input name='name' onChange = { this.onNameChange } value = { this.state.name } />
            <input name='color' onChange = { (event) => this.setState({ color: event.target.value.slice(1)}) } value = {cssColor} />
            <button type='submit' className='button button-small'>Save</button>
            <button type='button' onClick = { () => this.props.label.editing = false } className='button button-small button-unstyled'>cancel</button>
          </form>
        )
      } else {
        content = (
          <div className='label'>
            <span className='label-color' style = {{backgroundColor: cssColor}}>&nbsp;</span>
            <span>{label.name}</span>
            <span onClick = { () => this.props.label.editing = true } className='octicon octicon-pencil'></span>
            <span onClick = { () => this.props.label.destroy(/*{ wait: true }*/) } className='octicon octicon-x'></span>
          </div>
        )
      }
      return <div>{content}</div>
    }
  })