All files / lib/CallControl index.js

100% Statements 5/5
76.92% Branches 10/13
100% Functions 1/1
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180                                            19x   19x                                             89x                                         89x                       89x                                                                                                                                                                                                      
import React from 'react';
import PropTypes from 'prop-types';
import { Button, Icon } from '@collab-ui/react';
 
/**
 * @category controls
 * @component call-control
 * @variations collab-ui-react
 */
 
class CallControl extends React.PureComponent {
  render() {
    const {
      active,
      ariaLabel,
      className,
      disabled,
      iconColor,
      iconSize,
      onClick,
      type,
      ...otherHTMLProps
    } = this.props;
 
    return (
      <Button
        ariaLabel={ariaLabel || type}
        circle
        className={
          'cui-call-control' +
          `${(type === 'cancel' && ` cui-call-control--cancel`) || ''}` +
          `${(active && ` cui-call-control--active`) || ''}` +
          `${(className && ` ${className}`) || ''}`
        }
        disabled={disabled}
        onClick={onClick}
        {...otherHTMLProps}
      >
        <Icon 
          name={`${type}_${iconSize}`} 
          {...iconColor && { color: iconColor }}
        />
      </Button>
    );
  }
}
 
CallControl.propTypes = {
  /** @prop Sets active css styling | false */
  active: PropTypes.bool,
  /** @prop Text to display for blindness accessibility features | '' */
  ariaLabel: PropTypes.string,
  /** @prop Optional css class string | '' */
  className: PropTypes.string,
  /** @prop Sets the attribute disabled to the CallControl button | false */
  disabled: PropTypes.bool,
  /** @prop Optional icon color prop | null */
  iconColor: PropTypes.string,
  /** @prop Optional numeric icon size prop | 24 */
  iconSize: PropTypes.number,
  /** @prop Handler to be called when the user taps the CallControl button | null */
  onClick: PropTypes.func,
  /** @prop Optional numeric size prop for CallControl button | 56 */
  size: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
  /** @prop Optional predefined CallControl prop type | '' */
  type: PropTypes.oneOf(['activities', 'camera', 'camera-muted', 'cancel', 'handset', 'microphone-muted', 'more', 'participant-list', 'share-screen', 'speaker', 'view-list']),
};
 
CallControl.defaultProps = {
  active: false,
  ariaLabel: '',
  className: '',
  disabled: false,
  iconColor: null,
  iconSize: 24,
  onClick: null,
  size: 56,
  type: '',
};
 
CallControl.displayName = 'CallControl';
 
export default CallControl;
 
/**
* @component call-control
* @section default
* @react
import { CallControl } from '@collab-ui/react';
 
export default function CallControlDefault() {
  return(
      <div className='row'>
        <div className="docs-example docs-example--spacing">
          <CallControl
            type='microphone-muted'
            ariaLabel='For the Win'
            size={20}
            iconSize={10}
          />
        </div>
 
        <div className="docs-example docs-example--spacing">
          <CallControl
            type='microphone-muted'
            ariaLabel='For the Win'
            size={40}
            iconSize={16}
          />
        </div>
 
        <div className="docs-example docs-example--spacing">
          <CallControl
            type='microphone-muted'
            ariaLabel='For the Win'
          />
        </div>
      </div>
  );
}
 
**/
 
/**
* @component call-control
* @section active
* @react
import { CallControl } from '@collab-ui/react';
 
export default function CallControlActive() {
  return(
    <CallControl
      type='microphone-muted'
      active
      onClick={() => { }}
      ariaLabel='For the Win'
    />
  );
}
 
**/
 
/**
* @component call-control
* @section disable
* @react
import { CallControl } from '@collab-ui/react';
 
export default function CallControlDisabled() {
  return(
    <CallControl
      type='microphone-muted'
      disabled
      onClick={() => { }}
      ariaLabel='For the Win'
    />
  );
}
 
**/
 
/**
* @component call-control
* @section cancel
* @react
import { CallControl } from '@collab-ui/react';
 
export default function CallControlCancel() {
  return(
    <CallControl
      type='cancel'
      active
      onClick={() => {}}
      ariaLabel='For the Win'
    />
  );
}
 
**/