2019-01-08 02:12:28 +08:00
|
|
|
import React from 'react';
|
2019-02-08 01:47:28 +08:00
|
|
|
import { defineMessages, injectIntl, intlShape } from 'react-intl';
|
2019-01-08 02:12:28 +08:00
|
|
|
import Button from '/imports/ui/components/button/component';
|
2019-01-15 21:13:55 +08:00
|
|
|
import cx from 'classnames';
|
2019-02-08 01:47:28 +08:00
|
|
|
import PropTypes from 'prop-types';
|
2019-01-25 21:06:17 +08:00
|
|
|
import { styles } from './styles';
|
2019-01-08 02:12:28 +08:00
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
fullscreenButton: {
|
|
|
|
id: 'app.fullscreenButton.label',
|
|
|
|
description: 'Fullscreen label',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-02-08 01:47:28 +08:00
|
|
|
const propTypes = {
|
|
|
|
intl: intlShape.isRequired,
|
2019-04-24 22:20:53 +08:00
|
|
|
fullscreenRef: PropTypes.instanceOf(Element),
|
2019-02-08 01:47:28 +08:00
|
|
|
dark: PropTypes.bool,
|
|
|
|
elementName: PropTypes.string,
|
2019-04-14 05:22:47 +08:00
|
|
|
className: PropTypes.string,
|
2019-04-24 22:20:53 +08:00
|
|
|
handleToggleFullScreen: PropTypes.func.isRequired,
|
2019-02-08 01:47:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const defaultProps = {
|
|
|
|
dark: false,
|
|
|
|
elementName: '',
|
2019-04-14 05:22:47 +08:00
|
|
|
className: '',
|
2019-04-24 22:20:53 +08:00
|
|
|
fullscreenRef: null,
|
2019-02-08 01:47:28 +08:00
|
|
|
};
|
|
|
|
|
2019-02-07 05:12:59 +08:00
|
|
|
const FullscreenButtonComponent = ({
|
2019-03-12 00:21:12 +08:00
|
|
|
intl,
|
|
|
|
dark,
|
|
|
|
elementName,
|
2019-03-13 01:05:32 +08:00
|
|
|
tooltipDistance,
|
2019-04-14 05:22:47 +08:00
|
|
|
className,
|
2019-04-24 22:20:53 +08:00
|
|
|
fullscreenRef,
|
|
|
|
handleToggleFullScreen,
|
2019-06-17 23:55:53 +08:00
|
|
|
isIphone,
|
2019-02-07 05:12:59 +08:00
|
|
|
}) => {
|
2019-06-17 23:55:53 +08:00
|
|
|
if (isIphone) return null;
|
|
|
|
|
2019-02-07 05:12:59 +08:00
|
|
|
const formattedLabel = intl.formatMessage(
|
|
|
|
intlMessages.fullscreenButton,
|
2019-02-28 22:24:14 +08:00
|
|
|
({ 0: elementName || '' }),
|
2019-02-07 05:12:59 +08:00
|
|
|
);
|
|
|
|
|
2019-03-12 00:21:12 +08:00
|
|
|
const wrapperClassName = cx({
|
|
|
|
[styles.wrapper]: true,
|
|
|
|
[styles.dark]: dark,
|
|
|
|
[styles.light]: !dark,
|
|
|
|
});
|
|
|
|
|
2019-02-07 05:12:59 +08:00
|
|
|
return (
|
2019-03-12 00:21:12 +08:00
|
|
|
<div className={wrapperClassName}>
|
2019-02-07 05:12:59 +08:00
|
|
|
<Button
|
|
|
|
color="default"
|
|
|
|
icon="fullscreen"
|
|
|
|
size="sm"
|
2019-04-24 22:20:53 +08:00
|
|
|
onClick={() => handleToggleFullScreen(fullscreenRef)}
|
2019-02-07 05:12:59 +08:00
|
|
|
label={formattedLabel}
|
|
|
|
hideLabel
|
2019-04-14 05:22:47 +08:00
|
|
|
className={cx(styles.button, styles.fullScreenButton, className)}
|
2019-03-08 03:00:01 +08:00
|
|
|
tooltipDistance={tooltipDistance}
|
2019-06-22 04:11:05 +08:00
|
|
|
data-test="presentationFullscreenButton"
|
2019-02-07 05:12:59 +08:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2019-01-08 02:12:28 +08:00
|
|
|
|
2019-02-08 01:47:28 +08:00
|
|
|
FullscreenButtonComponent.propTypes = propTypes;
|
|
|
|
FullscreenButtonComponent.defaultProps = defaultProps;
|
|
|
|
|
2019-01-08 02:12:28 +08:00
|
|
|
export default injectIntl(FullscreenButtonComponent);
|