2022-04-23 01:05:48 +00:00
|
|
|
import React from "react";
|
2022-04-29 00:44:50 +00:00
|
|
|
import classNames from "classnames";
|
2022-04-23 01:05:48 +00:00
|
|
|
import styles from "./PTTButton.module.css";
|
|
|
|
import { ReactComponent as MicIcon } from "../icons/Mic.svg";
|
|
|
|
import { Avatar } from "../Avatar";
|
|
|
|
|
2022-04-29 00:44:50 +00:00
|
|
|
export function PTTButton({
|
|
|
|
showTalkOverError,
|
|
|
|
activeSpeakerUserId,
|
|
|
|
activeSpeakerDisplayName,
|
|
|
|
activeSpeakerAvatarUrl,
|
|
|
|
activeSpeakerIsLocalUser,
|
|
|
|
size,
|
2022-04-29 17:56:17 +00:00
|
|
|
startTalking,
|
|
|
|
stopTalking,
|
2022-04-29 00:44:50 +00:00
|
|
|
}) {
|
2022-04-23 01:05:48 +00:00
|
|
|
return (
|
|
|
|
<button
|
|
|
|
className={classNames(styles.pttButton, {
|
2022-04-29 00:44:50 +00:00
|
|
|
[styles.talking]: activeSpeakerUserId,
|
|
|
|
[styles.error]: showTalkOverError,
|
2022-04-23 01:05:48 +00:00
|
|
|
})}
|
2022-04-29 17:56:17 +00:00
|
|
|
onMouseDown={startTalking}
|
|
|
|
onMouseUp={stopTalking}
|
2022-04-23 01:05:48 +00:00
|
|
|
>
|
2022-04-29 00:44:50 +00:00
|
|
|
{activeSpeakerIsLocalUser || !activeSpeakerUserId ? (
|
2022-04-23 01:05:48 +00:00
|
|
|
<MicIcon
|
2022-04-29 00:44:50 +00:00
|
|
|
className={styles.micIcon}
|
2022-04-23 01:05:48 +00:00
|
|
|
width={size / 3}
|
|
|
|
height={size / 3}
|
|
|
|
/>
|
|
|
|
) : (
|
|
|
|
<Avatar
|
2022-04-29 00:44:50 +00:00
|
|
|
key={activeSpeakerUserId}
|
2022-04-23 01:05:48 +00:00
|
|
|
style={{
|
2022-04-29 00:44:50 +00:00
|
|
|
width: size - 12,
|
|
|
|
height: size - 12,
|
|
|
|
borderRadius: size - 12,
|
|
|
|
fontSize: Math.round((size - 12) / 2),
|
2022-04-23 01:05:48 +00:00
|
|
|
}}
|
2022-04-29 00:44:50 +00:00
|
|
|
src={activeSpeakerAvatarUrl}
|
|
|
|
fallback={activeSpeakerDisplayName.slice(0, 1).toUpperCase()}
|
2022-04-23 01:05:48 +00:00
|
|
|
className={styles.avatar}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
}
|