bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/polling/component.jsx

66 lines
1.8 KiB
React
Raw Normal View History

2016-05-06 02:50:18 +08:00
import React from 'react';
2016-06-30 06:00:06 +08:00
import Button from '/imports/ui/components/button/component';
import styles from './styles.scss';
2016-05-06 02:50:18 +08:00
export default class PollingComponent extends React.Component {
constructor(props) {
super(props);
}
getStyles() {
const number = this.props.poll.answers.length + 1;
const buttonStyle =
{
width: `calc(75%/ ${number} )`,
marginLeft: `calc(25%/${number * 2})`,
marginRight: `calc(25%/${number * 2})`,
};
return buttonStyle;
}
2016-05-06 02:50:18 +08:00
render() {
const poll = this.props.poll;
const calculatedStyles = this.getStyles();
2016-05-06 02:50:18 +08:00
return (
2016-06-30 06:00:06 +08:00
<div className={styles.pollingContainer}>
<div className={styles.pollingTitle}>
<p>
Polling Options
</p>
</div>
2016-06-28 02:24:37 +08:00
{poll.answers.map((pollAnswer, index) =>
<div
key={index}
style={calculatedStyles}
className={styles.pollButtonWrapper}
>
<Button
2016-07-06 05:49:31 +08:00
className={styles.pollingButton}
label={pollAnswer.key}
size="lg"
color="primary"
onClick={() => this.props.handleVote(poll.pollId, pollAnswer)}
2016-07-06 05:49:31 +08:00
aria-labelledby={`pollAnswerLabel${pollAnswer.key}`}
aria-describedby={`pollAnswerDesc${pollAnswer.key}`}
/>
<div
className={styles.hidden}
id={`pollAnswerLabel${pollAnswer.key}`}
>
{`Poll answer ${pollAnswer.key}`}
</div>
<div
className={styles.hidden}
id={`pollAnswerDesc${pollAnswer.key}`}
>
2016-07-06 05:49:31 +08:00
{`Select this option to vote for ${pollAnswer.key}`}
</div>
</div>
2016-06-28 02:24:37 +08:00
)}
2016-05-06 02:50:18 +08:00
</div>
);
}
};