Skip to content

Commit

Permalink
fix: updated action-button on long-press
Browse files Browse the repository at this point in the history
  • Loading branch information
malmen237 committed Apr 17, 2024
1 parent 88fdd12 commit 309afd6
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/components/production-line/long-press-to-talk-button.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import { useEffect, useState } from "react";
import styled from "@emotion/styled";
import { ActionButton } from "../landing-page/form-elements";
import { Spinner } from "../loader/loader";
import { PulseLoader } from "../loader/loader";
import { isMobile } from "../../bowser";

type TLongPressToTalkButton = {
micMute: boolean;
setMicMute: (input: boolean) => void;
};

const Button = styled(ActionButton)`
position: relative;
&:active {
color: rgba(255, 255, 255, 0);
}
&.mobile {
user-select: none;
}
`;

export const LongPressToTalkButton = ({
micMute,
setMicMute,
Expand All @@ -33,7 +47,7 @@ export const LongPressToTalkButton = ({
case "pointerdown":
timeoutId = setTimeout(() => {
setMicMute(false);
}, 800);
}, 600);
setLongPressTimeout(timeoutId);
break;
case "pointerup":
Expand All @@ -46,8 +60,8 @@ export const LongPressToTalkButton = ({
};

return (
<ActionButton
className={!micMute ? "submit" : ""}
<Button
className={isMobile ? "mobile" : ""}
type="button"
onPointerDown={(e) => {
toggleMuteAfterTimeout(e);
Expand All @@ -57,7 +71,7 @@ export const LongPressToTalkButton = ({
}}
>
Press to Talk
{!micMute && <Spinner className="push-to-talk" />}
</ActionButton>
{!micMute && <PulseLoader />}
</Button>
);
};

0 comments on commit 309afd6

Please sign in to comment.