jiti-meet/react/features/prejoin/components/buttons/ActionButton.js

89 lines
1.9 KiB
JavaScript
Raw Normal View History

2020-04-16 10:47:10 +00:00
// @flow
import React from 'react';
2020-05-20 10:57:03 +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,
/**
* If the button is disabled or not.
*/
disabled?: boolean,
/**
* 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,
/**
* 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}
*/
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 }
onClick = { clickHandler }>
2020-04-16 10:47:10 +00:00
{children}
{hasOptions && <div
className = 'prejoin-btn-options'
onClick = { optionsClickHandler }>
<Icon
className = 'prejoin-btn-icon'
size = { 14 }
src = { IconArrowDown } />
</div>
}
2020-04-16 10:47:10 +00:00
</div>
);
}
export default ActionButton;