var CoursePlanLabel, React, twix;
React = require('react');
twix = require('twix');
CoursePlanLabel = React.createClass({
displayName: 'CoursePlanLabel',
propTypes: {
rangeDuration: React.PropTypes.instanceOf(twix).isRequired,
plan: React.PropTypes.shape({
title: React.PropTypes.string.isRequired,
durationLength: React.PropTypes.number.isRequired,
opensAt: React.PropTypes.string
}).isRequired,
offsetFromPlanStart: React.PropTypes.number.isRequired,
index: React.PropTypes.number.isRequired,
offset: React.PropTypes.number.isRequired
},
calcPercentOfPlanLength: function(partLength) {
return partLength / this.props.plan.durationLength * 100 + '%';
},
render: function() {
var index, label, labelClass, offset, offsetFromPlanStart, opensAt, plan, planLabelStyle, planRangeLength, rangeDuration, ref, title;
ref = this.props, rangeDuration = ref.rangeDuration, plan = ref.plan, index = ref.index, offset = ref.offset, offsetFromPlanStart = ref.offsetFromPlanStart;
opensAt = plan.opensAt, title = plan.title;
planRangeLength = rangeDuration.length('days');
planLabelStyle = {
width: this.calcPercentOfPlanLength(planRangeLength),
marginLeft: this.calcPercentOfPlanLength(offsetFromPlanStart)
};
Iif (index !== 0) {
labelClass = 'continued';
}
return label = React.createElement("label", {
"data-opens-at": opensAt,
"data-title": title,
"style": planLabelStyle,
"className": labelClass
}, title);
}
});
module.exports = CoursePlanLabel;
|