From 363f2340a0ae367cb569663cbcdf4a52f856a7bd Mon Sep 17 00:00:00 2001 From: Robert Long Date: Thu, 28 Apr 2022 17:44:50 -0700 Subject: [PATCH] Finish basic ptt implemenation --- src/input/Toggle.jsx | 36 +++++++++++ src/input/Toggle.module.css | 46 +++++++++++++ src/room/GroupCallView.jsx | 9 +-- src/room/PTTButton.jsx | 40 ++++++------ src/room/PTTButton.module.css | 14 +++- src/room/PTTCallView.jsx | 97 ++++++++++++++++++++++------ src/room/PTTCallView.module.css | 5 ++ src/room/Timer.jsx | 37 +++++++++++ src/room/usePTT.js | 111 ++++++++++++++++++++++++++++++++ 9 files changed, 350 insertions(+), 45 deletions(-) create mode 100644 src/input/Toggle.jsx create mode 100644 src/input/Toggle.module.css create mode 100644 src/room/Timer.jsx create mode 100644 src/room/usePTT.js diff --git a/src/input/Toggle.jsx b/src/input/Toggle.jsx new file mode 100644 index 00000000..3f5208b9 --- /dev/null +++ b/src/input/Toggle.jsx @@ -0,0 +1,36 @@ +import React, { useRef } from "react"; +import styles from "./Toggle.module.css"; +import { useToggleButton } from "@react-aria/button"; +import { useToggleState } from "@react-stately/toggle"; +import classNames from "classnames"; +import { Field } from "./Input"; + +export function Toggle({ id, label, className, ...rest }) { + const buttonRef = useRef(); + const state = useToggleState(rest); + const { buttonProps, isPressed } = useToggleButton(rest, state, buttonRef); + + return ( + + + + + ); +} diff --git a/src/input/Toggle.module.css b/src/input/Toggle.module.css new file mode 100644 index 00000000..8e2dad50 --- /dev/null +++ b/src/input/Toggle.module.css @@ -0,0 +1,46 @@ +.toggle { + align-items: center; + margin-bottom: 20px; +} + +.button { + position: relative; + padding: 0; + transition: background-color 0.20s ease-out 0.1s; + width: 44px; + height: 24px; + border: none; + border-radius: 21px; + background-color: #6F7882; + cursor: pointer; + margin-right: 8px; +} + +.ball { + transition: left 0.15s ease-out 0.1s; + position: absolute; + width: 20px; + height: 20px; + border-radius: 21px; + background-color: #15191E; + left: 2px; + top: 2px; +} + +.label { + padding: 10px 8px; + line-height: 24px; + color: #6F7882; +} + +.toggle.on .button { + background-color: #0DBD8B; +} + +.toggle.on .ball { + left: 22px; +} + +.toggle.on .label { + color: #ffffff; +} \ No newline at end of file diff --git a/src/room/GroupCallView.jsx b/src/room/GroupCallView.jsx index e4780a3f..b8052d6b 100644 --- a/src/room/GroupCallView.jsx +++ b/src/room/GroupCallView.jsx @@ -77,18 +77,15 @@ export function GroupCallView({ if (groupCall.isPtt) { return ( ); } else { diff --git a/src/room/PTTButton.jsx b/src/room/PTTButton.jsx index d943ae48..1e0ba2fd 100644 --- a/src/room/PTTButton.jsx +++ b/src/room/PTTButton.jsx @@ -1,41 +1,41 @@ -import classNames from "classnames"; import React from "react"; +import classNames from "classnames"; import styles from "./PTTButton.module.css"; import { ReactComponent as MicIcon } from "../icons/Mic.svg"; import { Avatar } from "../Avatar"; -export function PTTButton({ client, activeSpeaker }) { - const size = 232; - - const isLocal = client.userId === activeSpeaker; - const avatarUrl = activeSpeaker?.user?.avatarUrl; - +export function PTTButton({ + showTalkOverError, + activeSpeakerUserId, + activeSpeakerDisplayName, + activeSpeakerAvatarUrl, + activeSpeakerIsLocalUser, + size, +}) { return (