import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { defineMessages, injectIntl, FormattedMessage } from 'react-intl';
import browser from 'browser-detect';
import injectWbResizeEvent from '/imports/ui/components/presentation/resize-wrapper/component';
import Button from '/imports/ui/components/button/component';
import { HUNDRED_PERCENT, MAX_PERCENT, STEP } from '/imports/utils/slideCalcUtils';
import { styles } from './styles.scss';
import ZoomTool from './zoom-tool/component';
const intlMessages = defineMessages({
previousSlideLabel: {
id: 'app.presentation.presentationToolbar.prevSlideLabel',
description: 'Previous slide button label',
},
nextSlideLabel: {
id: 'app.presentation.presentationToolbar.nextSlideLabel',
description: 'Next slide button label',
},
goToSlide: {
id: 'app.presentation.presentationToolbar.goToSlide',
description: 'button for slide select',
},
fitToWidth: {
id: 'app.presentation.presentationToolbar.fitToWidth',
description: 'button for fit to width',
},
});
class PresentationToolbar extends Component {
static renderAriaLabelsDescs() {
return (
{/* Previous Slide button aria */}
{/* Next Slide button aria */}
{/* Skip Slide drop down aria */}
{/* Fit to width button aria */}
{/* Fit to screen button aria */}
{/* Zoom slider aria */}
);
}
constructor(props) {
super(props);
this.state = {
sliderValue: 100,
};
this.handleValuesChange = this.handleValuesChange.bind(this);
this.handleSkipToSlideChange = this.handleSkipToSlideChange.bind(this);
this.change = this.change.bind(this);
this.setInt = 0;
}
handleSkipToSlideChange(event) {
const requestedSlideNum = parseInt(event.target.value, 10);
this.props.actions.skipToSlideHandler(requestedSlideNum);
}
handleValuesChange(event) {
this.setState(
{ sliderValue: event.target.value },
() => this.handleZoom(this.state.sliderValue),
);
}
fitToScreenClickHandler() {
this.setState({
fitToScreenValue: 'not_implemented_yet',
});
}
change(value) {
this.props.zoomChanger(value);
}
renderSkipSlideOpts(numberOfSlides) {
// Fill drop down menu with all the slides in presentation
const { intl } = this.props;
const optionList = [];
for (let i = 1; i <= numberOfSlides; i += 1) {
optionList.push((
{
intl.formatMessage(intlMessages.goToSlide, { 0: i })
}
));
}
return optionList;
}
render() {
const {
currentSlideNum,
numberOfSlides,
actions,
intl,
zoom,
} = this.props;
const BROWSER_RESULTS = browser();
const isMobileBrowser = BROWSER_RESULTS.mobile ||
BROWSER_RESULTS.os.includes('Android');
return (
{PresentationToolbar.renderAriaLabelsDescs()}
{
1)}
color="default"
icon="left_arrow"
size="md"
onClick={actions.previousSlideHandler}
label={intl.formatMessage(intlMessages.previousSlideLabel)}
hideLabel
className={styles.prevSlide}
/>
has an implicit role of listbox, no need to define role="listbox" explicitly
id="skipSlide"
aria-labelledby="skipSlideLabel"
aria-describedby="skipSlideDesc"
aria-live="polite"
aria-relevant="all"
value={currentSlideNum}
onChange={actions.skipToSlideHandler}
className={styles.skipSlideSelect}
>
{this.renderSkipSlideOpts(numberOfSlides)}
}
{
!isMobileBrowser ?
: null
}
{/* Fit to screen button
*/}
);
}
}
PresentationToolbar.propTypes = {
// Number of current slide being displayed
currentSlideNum: PropTypes.number.isRequired,
// Total number of slides in this presentation
numberOfSlides: PropTypes.number.isRequired,
// Actions required for the presenter toolbar
actions: PropTypes.shape({
nextSlideHandler: PropTypes.func.isRequired,
previousSlideHandler: PropTypes.func.isRequired,
skipToSlideHandler: PropTypes.func.isRequired,
}).isRequired,
intl: PropTypes.shape({
formatMessage: PropTypes.func.isRequired,
}).isRequired,
};
export default injectWbResizeEvent(injectIntl(PresentationToolbar));