apeman-react-section
Version:
apeman react package for section components.
87 lines (69 loc) • 1.77 kB
JSX
/**
* Button for a header section.
* @class ApSectionHeaderButton
*/
import React, {PropTypes as types} from 'react'
import classnames from 'classnames'
import {shallowEqual} from 'asobj'
import {withTouch} from 'apeman-react-touchable'
import {ApIcon} from 'apeman-react-icon'
/** @lends ApSectionHeaderButton */
const ApSectionHeaderButton = React.createClass({
// --------------------
// Specs
// --------------------
propTypes: {
icon: types.string,
text: types.string
},
mixins: [
],
statics: {
EDIT_ICON: 'fa fa-edit'
},
getInitialState () {
return {}
},
getDefaultProps () {
return {
icon: null,
text: null
}
},
render () {
const s = this
let { props } = s
let className = classnames('ap-section-header-button', {
'ap-section-header-lined': props.lined
}, props.className)
return (
<a id={ props.id }
title={ props.title }
name={ props.name }
href={ props.href }
className={ className }
style={ Object.assign({}, props.style) }
>
<ApIcon className={ classnames(props.icon) }/>
<span className='apeman-section-header-button-text'>
{ props.text }
</span>
{ props.children }
</a>
)
},
// --------------------
// Lifecycle
// --------------------
shouldComponentUpdate (nextProps, nextState) {
const s = this
let { props, state } = s
return !shallowEqual(props, nextProps) || shallowEqual(state, nextState)
}
// --------------------
// Private
// --------------------
})
export default ApSectionHeaderButton // Dummy export for doc parser
export default withTouch(ApSectionHeaderButton)