2022-05-04 17:09:48 +01:00
|
|
|
/*
|
2024-09-06 10:22:13 +02:00
|
|
|
Copyright 2022-2024 New Vector Ltd.
|
2026-01-12 15:35:21 +01:00
|
|
|
Copyright 2026 Element Creations Ltd.
|
2022-05-04 17:09:48 +01:00
|
|
|
|
2025-02-18 17:59:58 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
2024-09-06 10:22:13 +02:00
|
|
|
Please see LICENSE in the repository root for full details.
|
2022-05-04 17:09:48 +01:00
|
|
|
*/
|
2024-12-11 09:27:55 +00:00
|
|
|
import { type ComponentPropsWithoutRef, type FC } from "react";
|
2021-12-07 11:59:57 -08:00
|
|
|
import classNames from "classnames";
|
2022-10-10 09:19:10 -04:00
|
|
|
import { useTranslation } from "react-i18next";
|
2024-08-28 08:44:39 -04:00
|
|
|
import { Button as CpdButton, Tooltip } from "@vector-im/compound-web";
|
2024-07-25 13:15:45 -04:00
|
|
|
import {
|
|
|
|
|
MicOnSolidIcon,
|
|
|
|
|
MicOffSolidIcon,
|
|
|
|
|
VideoCallSolidIcon,
|
|
|
|
|
VideoCallOffSolidIcon,
|
|
|
|
|
EndCallIcon,
|
|
|
|
|
ShareScreenSolidIcon,
|
|
|
|
|
SettingsSolidIcon,
|
|
|
|
|
} from "@vector-im/compound-design-tokens/assets/web/icons";
|
2022-06-11 23:21:20 +02:00
|
|
|
|
2021-12-07 11:59:57 -08:00
|
|
|
import styles from "./Button.module.css";
|
|
|
|
|
|
2024-08-28 08:44:39 -04:00
|
|
|
interface MicButtonProps extends ComponentPropsWithoutRef<"button"> {
|
|
|
|
|
muted: boolean;
|
2026-03-09 14:40:13 +01:00
|
|
|
size?: "sm" | "lg";
|
2022-06-11 23:21:20 +02:00
|
|
|
}
|
2023-12-19 11:00:33 -05:00
|
|
|
|
2024-08-28 08:44:39 -04:00
|
|
|
export const MicButton: FC<MicButtonProps> = ({ muted, ...props }) => {
|
2022-10-10 09:19:10 -04:00
|
|
|
const { t } = useTranslation();
|
2023-09-08 15:39:49 -04:00
|
|
|
const Icon = muted ? MicOffSolidIcon : MicOnSolidIcon;
|
2023-11-20 13:38:01 +00:00
|
|
|
const label = muted
|
|
|
|
|
? t("unmute_microphone_button_label")
|
|
|
|
|
: t("mute_microphone_button_label");
|
2022-10-10 09:19:10 -04:00
|
|
|
|
2021-12-07 11:59:57 -08:00
|
|
|
return (
|
2023-09-08 15:39:49 -04:00
|
|
|
<Tooltip label={label}>
|
2024-08-28 08:44:39 -04:00
|
|
|
<CpdButton
|
|
|
|
|
iconOnly
|
2026-01-09 12:00:45 +01:00
|
|
|
aria-label={label}
|
2024-08-28 08:44:39 -04:00
|
|
|
Icon={Icon}
|
|
|
|
|
kind={muted ? "primary" : "secondary"}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
2023-08-30 21:58:29 -04:00
|
|
|
</Tooltip>
|
2021-12-07 11:59:57 -08:00
|
|
|
);
|
2023-09-22 18:05:13 -04:00
|
|
|
};
|
2021-12-07 11:59:57 -08:00
|
|
|
|
2024-08-28 08:44:39 -04:00
|
|
|
interface VideoButtonProps extends ComponentPropsWithoutRef<"button"> {
|
2022-07-02 21:20:53 +02:00
|
|
|
muted: boolean;
|
2026-03-09 14:40:13 +01:00
|
|
|
size?: "sm" | "lg";
|
2024-08-28 08:44:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const VideoButton: FC<VideoButtonProps> = ({ muted, ...props }) => {
|
2022-10-10 09:19:10 -04:00
|
|
|
const { t } = useTranslation();
|
2023-10-30 10:43:59 -04:00
|
|
|
const Icon = muted ? VideoCallOffSolidIcon : VideoCallSolidIcon;
|
2023-11-20 13:38:01 +00:00
|
|
|
const label = muted
|
|
|
|
|
? t("start_video_button_label")
|
|
|
|
|
: t("stop_video_button_label");
|
2022-10-10 09:19:10 -04:00
|
|
|
|
2021-12-07 11:59:57 -08:00
|
|
|
return (
|
2023-09-08 15:39:49 -04:00
|
|
|
<Tooltip label={label}>
|
2024-08-28 08:44:39 -04:00
|
|
|
<CpdButton
|
|
|
|
|
iconOnly
|
2026-01-09 12:00:45 +01:00
|
|
|
aria-label={label}
|
2024-08-28 08:44:39 -04:00
|
|
|
Icon={Icon}
|
|
|
|
|
kind={muted ? "primary" : "secondary"}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
2023-08-30 21:58:29 -04:00
|
|
|
</Tooltip>
|
2021-12-07 11:59:57 -08:00
|
|
|
);
|
2023-09-22 18:05:13 -04:00
|
|
|
};
|
2021-12-07 11:59:57 -08:00
|
|
|
|
2024-08-28 08:44:39 -04:00
|
|
|
interface ShareScreenButtonProps extends ComponentPropsWithoutRef<"button"> {
|
2022-07-02 21:20:53 +02:00
|
|
|
enabled: boolean;
|
2026-03-04 16:47:15 +01:00
|
|
|
size: "sm" | "lg";
|
2024-08-28 08:44:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const ShareScreenButton: FC<ShareScreenButtonProps> = ({
|
|
|
|
|
enabled,
|
|
|
|
|
...props
|
|
|
|
|
}) => {
|
2022-10-10 09:19:10 -04:00
|
|
|
const { t } = useTranslation();
|
2023-11-20 13:38:01 +00:00
|
|
|
const label = enabled
|
|
|
|
|
? t("stop_screenshare_button_label")
|
|
|
|
|
: t("screenshare_button_label");
|
2022-10-10 09:19:10 -04:00
|
|
|
|
2021-12-07 11:59:57 -08:00
|
|
|
return (
|
2023-09-08 15:39:49 -04:00
|
|
|
<Tooltip label={label}>
|
2024-08-28 08:44:39 -04:00
|
|
|
<CpdButton
|
|
|
|
|
iconOnly
|
|
|
|
|
Icon={ShareScreenSolidIcon}
|
|
|
|
|
kind={enabled ? "primary" : "secondary"}
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
2023-08-30 21:58:29 -04:00
|
|
|
</Tooltip>
|
2021-12-07 11:59:57 -08:00
|
|
|
);
|
2023-09-22 18:05:13 -04:00
|
|
|
};
|
2021-12-07 11:59:57 -08:00
|
|
|
|
2026-03-04 16:47:15 +01:00
|
|
|
interface EndCallButtonProps extends ComponentPropsWithoutRef<"button"> {
|
2026-03-09 14:40:13 +01:00
|
|
|
size?: "sm" | "lg";
|
2026-03-04 16:47:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const EndCallButton: FC<EndCallButtonProps> = ({
|
2024-08-28 08:44:39 -04:00
|
|
|
className,
|
|
|
|
|
...props
|
|
|
|
|
}) => {
|
2022-10-10 09:19:10 -04:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
2021-12-07 11:59:57 -08:00
|
|
|
return (
|
2023-11-20 13:00:43 +00:00
|
|
|
<Tooltip label={t("hangup_button_label")}>
|
2024-08-28 08:44:39 -04:00
|
|
|
<CpdButton
|
|
|
|
|
className={classNames(className, styles.endCall)}
|
|
|
|
|
iconOnly
|
2026-01-09 12:00:45 +01:00
|
|
|
aria-label={t("hangup_button_label")}
|
2024-08-28 08:44:39 -04:00
|
|
|
Icon={EndCallIcon}
|
|
|
|
|
destructive
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
2023-08-30 21:58:29 -04:00
|
|
|
</Tooltip>
|
2021-12-07 11:59:57 -08:00
|
|
|
);
|
2023-09-22 18:05:13 -04:00
|
|
|
};
|
2022-04-27 16:47:23 -07:00
|
|
|
|
2026-03-09 13:42:28 +01:00
|
|
|
interface SettingsButtonProps extends ComponentPropsWithoutRef<"button"> {
|
2026-03-09 14:40:13 +01:00
|
|
|
size?: "sm" | "lg";
|
2026-03-09 13:42:28 +01:00
|
|
|
}
|
|
|
|
|
export const SettingsButton: FC<SettingsButtonProps> = (props) => {
|
2022-10-10 09:19:10 -04:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
2022-04-27 16:47:23 -07:00
|
|
|
return (
|
2023-11-20 11:05:18 +00:00
|
|
|
<Tooltip label={t("common.settings")}>
|
2024-08-28 08:44:39 -04:00
|
|
|
<CpdButton
|
|
|
|
|
iconOnly
|
|
|
|
|
Icon={SettingsSolidIcon}
|
|
|
|
|
kind="secondary"
|
|
|
|
|
{...props}
|
|
|
|
|
/>
|
2023-08-30 21:58:29 -04:00
|
|
|
</Tooltip>
|
2022-04-27 16:47:23 -07:00
|
|
|
);
|
2023-09-22 18:05:13 -04:00
|
|
|
};
|