2021-05-10 19:58:52 +08:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2021-11-10 19:55:16 +08:00
|
|
|
import Styled from './styles';
|
2022-02-16 02:07:09 +08:00
|
|
|
import TooltipContainer from '/imports/ui/components/common/tooltip/container';
|
2021-05-10 19:58:52 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
/**
|
|
|
|
* Defines the name of the emoji to be used, as defined in bbb-icons.css
|
|
|
|
* @type String
|
|
|
|
* @defaultValue ''
|
|
|
|
*/
|
|
|
|
emoji: PropTypes.string,
|
|
|
|
|
2021-05-13 03:43:48 +08:00
|
|
|
label: PropTypes.string,
|
|
|
|
|
2021-05-10 19:58:52 +08:00
|
|
|
onClick: PropTypes.func,
|
|
|
|
|
|
|
|
onKeyDown: PropTypes.func,
|
|
|
|
|
|
|
|
onFocus: PropTypes.func,
|
2021-08-17 11:18:49 +08:00
|
|
|
|
|
|
|
tabIndex: PropTypes.number,
|
|
|
|
|
|
|
|
hideLabel: PropTypes.bool,
|
2021-10-22 01:29:44 +08:00
|
|
|
|
|
|
|
className: PropTypes.string,
|
2022-07-04 23:27:46 +08:00
|
|
|
|
|
|
|
rotate: PropTypes.bool,
|
2021-05-10 19:58:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const ButtonEmoji = (props) => {
|
2021-08-30 22:41:58 +08:00
|
|
|
const {
|
2024-06-11 21:05:08 +08:00
|
|
|
hideLabel = false,
|
|
|
|
className = '',
|
2021-10-26 20:19:43 +08:00
|
|
|
hidden,
|
2024-06-11 21:05:08 +08:00
|
|
|
rotate = false,
|
2021-08-30 22:41:58 +08:00
|
|
|
...newProps
|
|
|
|
} = props;
|
|
|
|
|
2021-05-10 19:58:52 +08:00
|
|
|
const {
|
2024-06-11 21:05:08 +08:00
|
|
|
emoji = '',
|
|
|
|
label = '',
|
|
|
|
tabIndex = -1,
|
|
|
|
onClick = null,
|
|
|
|
onKeyDown = null,
|
|
|
|
onFocus = null,
|
2021-08-30 22:41:58 +08:00
|
|
|
} = newProps;
|
2021-05-10 19:58:52 +08:00
|
|
|
|
2022-07-04 23:27:46 +08:00
|
|
|
const IconComponent = (<Styled.EmojiButtonIcon iconName={emoji} rotate={rotate} />);
|
2021-05-10 19:58:52 +08:00
|
|
|
|
|
|
|
return (
|
2021-06-26 22:37:21 +08:00
|
|
|
<span>
|
2021-12-10 22:55:37 +08:00
|
|
|
<Styled.EmojiButtonSpace hidden={hidden} />
|
2021-05-13 03:43:48 +08:00
|
|
|
<TooltipContainer title={label}>
|
2021-11-10 19:55:16 +08:00
|
|
|
<Styled.EmojiButton
|
2021-08-30 22:41:58 +08:00
|
|
|
type="button"
|
2021-08-17 11:18:49 +08:00
|
|
|
tabIndex={tabIndex}
|
2021-08-30 22:41:58 +08:00
|
|
|
{...newProps}
|
2021-08-17 11:18:49 +08:00
|
|
|
aria-label={label}
|
|
|
|
onClick={onClick}
|
2024-06-11 21:05:08 +08:00
|
|
|
onKeyDown={onKeyDown}
|
|
|
|
onFocus={onFocus}
|
|
|
|
className={className}
|
2021-05-13 03:43:48 +08:00
|
|
|
>
|
2021-11-10 19:55:16 +08:00
|
|
|
<Styled.Label>
|
2021-08-17 11:18:49 +08:00
|
|
|
{ !hideLabel && label }
|
2021-05-13 03:43:48 +08:00
|
|
|
{ IconComponent }
|
2021-11-10 19:55:16 +08:00
|
|
|
</Styled.Label>
|
|
|
|
</Styled.EmojiButton>
|
2021-05-13 03:43:48 +08:00
|
|
|
</TooltipContainer>
|
|
|
|
</span>
|
2021-05-10 19:58:52 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default ButtonEmoji;
|
|
|
|
|
|
|
|
ButtonEmoji.propTypes = propTypes;
|