UNPKG

1.05 kBJSXView Raw
1/**
2 * apeman react package label component.
3 * @class ApLabel
4 */
5
6'use strict'
7
8import React, {PropTypes as types} from 'react'
9import classnames from 'classnames'
10import {ApTouchMixin} from 'apeman-react-mixin-touch'
11import {ApPureMixin} from 'apeman-react-mixin-pure'
12
13/** @lends ApLabel */
14const ApLabel = React.createClass({
15
16 // --------------------
17 // Specs
18 // --------------------
19
20 propTypes: {
21 htmlFor: types.string
22 },
23
24 mixins: [
25 ApPureMixin,
26 ApTouchMixin
27 ],
28
29 statics: {},
30
31 getInitialState () {
32 return {}
33 },
34
35 getDefaultProps () {
36 return {
37 htmlFor: null
38 }
39 },
40
41 render () {
42 const s = this
43 let { props } = s
44
45 return (
46 <label { ...props }
47 className={ classnames('ap-label', props.className) }
48 htmlFor={ props.htmlFor }
49 >{ props.children }</label>
50 )
51 },
52
53 // --------------------
54 // For ApTouchMixin
55 // --------------------
56 getTouchData () {
57 const s = this
58 let { props } = s
59 return props.data
60 }
61})
62
63export default ApLabel