0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-12 21:52:42 +00:00
Files
homebrewery/client/tpk/sheetRenderer/parts/skill/skill.jsx
Scott Tolksdorf 22a480871b 'Sheet
2016-05-16 22:42:22 -04:00

63 lines
1.3 KiB
JavaScript

var React = require('react');
var _ = require('lodash');
var cx = require('classnames');
var utils = require('../utils');
var Skill = React.createClass({
getDefaultProps: function() {
return {
name : 'skill',
defaultData : {
prof : false,
expert : false,
val : ''
},
id : '',
label : '',
sublabel : '',
showExpert : false
};
},
id : utils.id,
data : utils.data,
updateData : utils.updateData,
handleToggleProf : function(){
this.updateData({
prof : !this.data().prof
})
},
handleToggleExpert : function(){
this.updateData({
expert : !this.data().expert
})
},
handleValChange : function(e){
console.log('yo');
this.updateData({
val : e.target.value
})
},
renderExpert : function(){
if(this.props.showExpert){
return <input type="radio" className='expertToggle' onChange={this.handleToggleExpert} checked={this.data().expert} />
}
},
render : function(){
return <div className='skill'>
{this.renderExpert()}
<input type="radio" className='skillToggle' onChange={this.handleToggleProf} checked={this.data().prof} />
<input type='text' onChange={this.handleValChange} value={this.data().val} />
<label>
{this.props.label}
<small>{this.props.sublabel}</small>
</label>
</div>
}
});
module.exports = Skill;