2020-04-16 10:47:10 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React from 'react';
|
2020-05-20 10:57:03 +00:00
|
|
|
|
2020-05-07 07:42:55 +00:00
|
|
|
import { Icon, IconArrowDown } from '../../../base/icons';
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
const classNameByType = {
|
|
|
|
primary: 'prejoin-btn--primary',
|
|
|
|
secondary: 'prejoin-btn--secondary',
|
|
|
|
text: 'prejoin-btn--text'
|
|
|
|
};
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Text of the button.
|
|
|
|
*/
|
|
|
|
children: React$Node,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Text css class of the button.
|
|
|
|
*/
|
|
|
|
className?: string,
|
|
|
|
|
2020-05-19 07:52:57 +00:00
|
|
|
/**
|
|
|
|
* If the button is disabled or not.
|
|
|
|
*/
|
|
|
|
disabled?: boolean,
|
|
|
|
|
2020-05-07 07:42:55 +00:00
|
|
|
/**
|
|
|
|
* If the button has options.
|
|
|
|
*/
|
|
|
|
hasOptions?: boolean,
|
|
|
|
|
2020-04-16 10:47:10 +00:00
|
|
|
/**
|
|
|
|
* The type of th button: primary, secondary, text.
|
|
|
|
*/
|
|
|
|
type: string,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* OnClick button handler.
|
|
|
|
*/
|
|
|
|
onClick: Function,
|
2020-05-07 07:42:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Click handler for options.
|
|
|
|
*/
|
|
|
|
onOptionsClick?: Function
|
2020-04-16 10:47:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Button used for prejoin actions: Join/Join without audio/Join by phone.
|
|
|
|
*
|
|
|
|
* @returns {ReactElement}
|
|
|
|
*/
|
2020-05-19 07:52:57 +00:00
|
|
|
function ActionButton({ children, className, disabled, hasOptions, type, onClick, onOptionsClick }: Props) {
|
|
|
|
let ownClassName = 'prejoin-btn';
|
|
|
|
let clickHandler = onClick;
|
|
|
|
let optionsClickHandler = onOptionsClick;
|
|
|
|
|
|
|
|
if (disabled) {
|
|
|
|
clickHandler = null;
|
|
|
|
optionsClickHandler = null;
|
|
|
|
ownClassName = `${ownClassName} prejoin-btn--disabled`;
|
|
|
|
} else {
|
|
|
|
ownClassName = `${ownClassName} ${classNameByType[type]}`;
|
|
|
|
}
|
2020-04-16 10:47:10 +00:00
|
|
|
const cls = className ? `${className} ${ownClassName}` : ownClassName;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className = { cls }
|
2020-05-19 07:52:57 +00:00
|
|
|
onClick = { clickHandler }>
|
2020-04-16 10:47:10 +00:00
|
|
|
{children}
|
2020-05-07 07:42:55 +00:00
|
|
|
{hasOptions && <div
|
|
|
|
className = 'prejoin-btn-options'
|
2020-05-19 07:52:57 +00:00
|
|
|
onClick = { optionsClickHandler }>
|
2020-05-07 07:42:55 +00:00
|
|
|
<Icon
|
|
|
|
className = 'prejoin-btn-icon'
|
|
|
|
size = { 14 }
|
|
|
|
src = { IconArrowDown } />
|
|
|
|
</div>
|
|
|
|
}
|
2020-04-16 10:47:10 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ActionButton;
|