bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/fullscreen-button/component.jsx
Anton Georgiev 6f60324a4e
Merge pull request #10585 from hiroshisuga/fix-undo-fs-label
Fix undo-presentation-fullscreen button label
2020-10-07 15:49:48 -04:00

94 lines
2.2 KiB
JavaScript
Executable File

import React from 'react';
import { defineMessages, injectIntl } from 'react-intl';
import Button from '/imports/ui/components/button/component';
import cx from 'classnames';
import PropTypes from 'prop-types';
import { styles } from './styles';
const intlMessages = defineMessages({
fullscreenButton: {
id: 'app.fullscreenButton.label',
description: 'Fullscreen label',
},
fullscreenUndoButton: {
id: 'app.fullscreenUndoButton.label',
description: 'Undo fullscreen label',
},
});
const propTypes = {
intl: PropTypes.object.isRequired,
fullscreenRef: PropTypes.instanceOf(Element),
dark: PropTypes.bool,
bottom: PropTypes.bool,
isIphone: PropTypes.bool,
isFullscreen: PropTypes.bool,
elementName: PropTypes.string,
className: PropTypes.string,
handleToggleFullScreen: PropTypes.func.isRequired,
};
const defaultProps = {
dark: false,
bottom: false,
isIphone: false,
isFullscreen: false,
elementName: '',
className: '',
fullscreenRef: null,
};
const FullscreenButtonComponent = ({
intl,
dark,
bottom,
elementName,
className,
fullscreenRef,
handleToggleFullScreen,
isIphone,
isFullscreen,
}) => {
if (isIphone) return null;
const formattedLabel = (isFullscreen) => {
return(isFullscreen ?
intl.formatMessage(
intlMessages.fullscreenUndoButton,
({ 0: elementName || '' }),
) :
intl.formatMessage(
intlMessages.fullscreenButton,
({ 0: elementName || '' }),
));
};
const wrapperClassName = cx({
[styles.wrapper]: true,
[styles.dark]: dark,
[styles.light]: !dark,
[styles.top]: !bottom,
[styles.bottom]: bottom,
});
return (
<div className={wrapperClassName}>
<Button
color="default"
icon={!isFullscreen ? 'fullscreen' : 'exit_fullscreen'}
size="sm"
onClick={() => handleToggleFullScreen(fullscreenRef)}
label={formattedLabel(isFullscreen)}
hideLabel
className={cx(styles.button, styles.fullScreenButton, className)}
data-test="presentationFullscreenButton"
/>
</div>
);
};
FullscreenButtonComponent.propTypes = propTypes;
FullscreenButtonComponent.defaultProps = defaultProps;
export default injectIntl(FullscreenButtonComponent);