bigbluebutton-Github/bigbluebutton-html5/imports/ui/components/common/button/button-emoji/ButtonEmoji.jsx

82 lines
1.5 KiB
React
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
2021-11-10 19:55:16 +08:00
import Styled from './styles';
import TooltipContainer from '/imports/ui/components/common/tooltip/container';
const propTypes = {
/**
* Defines the name of the emoji to be used, as defined in bbb-icons.css
* @type String
* @defaultValue ''
*/
emoji: PropTypes.string,
label: PropTypes.string,
onClick: PropTypes.func,
onKeyDown: PropTypes.func,
onFocus: PropTypes.func,
tabIndex: PropTypes.number,
hideLabel: PropTypes.bool,
className: PropTypes.string,
};
const defaultProps = {
emoji: '',
label: '',
onKeyDown: null,
onFocus: null,
tabIndex: -1,
hideLabel: false,
2021-08-17 20:57:23 +08:00
onClick: null,
className: '',
};
const ButtonEmoji = (props) => {
const {
hideLabel,
className,
hidden,
...newProps
} = props;
const {
emoji,
label,
tabIndex,
onClick,
} = newProps;
2021-11-10 19:55:16 +08:00
const IconComponent = (<Styled.EmojiButtonIcon iconName={emoji} />);
return (
<span>
2021-12-10 22:55:37 +08:00
<Styled.EmojiButtonSpace hidden={hidden} />
<TooltipContainer title={label}>
2021-11-10 19:55:16 +08:00
<Styled.EmojiButton
type="button"
tabIndex={tabIndex}
{...newProps}
aria-label={label}
onClick={onClick}
>
2021-11-10 19:55:16 +08:00
<Styled.Label>
{ !hideLabel && label }
{ IconComponent }
2021-11-10 19:55:16 +08:00
</Styled.Label>
</Styled.EmojiButton>
</TooltipContainer>
</span>
);
};
export default ButtonEmoji;
ButtonEmoji.propTypes = propTypes;
ButtonEmoji.defaultProps = defaultProps;