/**
 * @class ApListMoreButton
 */
'use strict'

import React, { PropTypes as types } from 'react'
import classnames from 'classnames'
import { shallowEqual } from 'asobj'
import { withTouch } from 'apeman-react-touchable'

const ApListMoreButton = React.createClass({
  // --------------------
  // Specs
  // --------------------

  propTypes: {
    text: types.string,
    enabled: types.bool
  },

  mixins: [],

  statics: {},

  getInitialState () {
    return {}
  },

  getDefaultProps () {
    return {
      text: 'Load More',
      enabled: false
    }
  },

  render () {
    const s = this
    let { state, props } = s
    let className = classnames('ap-list-more-button', {
      'ap-list-more-button-enabled': props.enabled
    }, props.className)
    return (
      <a className={ className }
         style={ Object.assign({}, props.style) }>
        { props.text }
        { props.children }
      </a>
    )
  },

  // --------------------
  // Lifecycle
  // --------------------

  shouldComponentUpdate (nextProps, nextState) {
    const s = this
    let { props, state } = s
    return !shallowEqual(props, nextProps) || shallowEqual(state, nextState)
  }
})

export default withTouch(ApListMoreButton)

