2016-12-25 19:00:21 +01:00
|
|
|
import React from 'react'
|
|
|
|
import input from '../../config/input.js'
|
|
|
|
import colors from '../../config/colors.js'
|
|
|
|
import { margins, fontSizes } from '../../config/scales.js'
|
|
|
|
|
|
|
|
export default class DocLabel extends React.Component {
|
|
|
|
static propTypes = {
|
|
|
|
label: React.PropTypes.string.isRequired,
|
|
|
|
doc: React.PropTypes.string.isRequired,
|
|
|
|
style: React.PropTypes.object,
|
2017-01-09 22:54:30 +01:00
|
|
|
cursorTargetStyle: React.PropTypes.object,
|
2016-12-25 19:00:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
|
|
|
this.state = { showDoc: false }
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return <label
|
|
|
|
style={{
|
|
|
|
...input.label,
|
|
|
|
position: 'relative',
|
2017-01-09 22:09:15 +01:00
|
|
|
verticalAlign: 'top',
|
|
|
|
...this.props.style,
|
2016-12-25 19:00:21 +01:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
onMouseOver={e => this.setState({showDoc: true})}
|
|
|
|
onMouseOut={e => this.setState({showDoc: false})}
|
|
|
|
style={{
|
|
|
|
cursor: 'help',
|
2017-01-09 22:54:30 +01:00
|
|
|
...this.props.cursorTargetStyle,
|
2016-12-25 19:00:21 +01:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
{this.props.label}
|
|
|
|
</span>
|
|
|
|
<div style={{
|
|
|
|
backgroundColor: colors.gray,
|
|
|
|
padding: margins[1],
|
2016-12-29 22:41:39 +01:00
|
|
|
fontSize: 10,
|
2016-12-25 19:00:21 +01:00
|
|
|
position: 'absolute',
|
|
|
|
top: 20,
|
|
|
|
left: 0,
|
2016-12-29 22:41:39 +01:00
|
|
|
width: 120,
|
2016-12-25 19:00:21 +01:00
|
|
|
display: this.state.showDoc ? null : 'none',
|
|
|
|
zIndex: 3,
|
|
|
|
}}>
|
|
|
|
{this.props.doc}
|
|
|
|
</div>
|
|
|
|
</label>
|
|
|
|
}
|
|
|
|
}
|