2022-05-04 17:09:48 +01:00
|
|
|
/*
|
2024-08-28 08:44:39 -04:00
|
|
|
Copyright 2022-2024 New Vector Ltd
|
2022-05-04 17:09:48 +01:00
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
*/
|
2024-08-28 08:44:39 -04:00
|
|
|
import { ComponentPropsWithoutRef, 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;
|
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
|
|
|
|
|
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;
|
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
|
|
|
|
|
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;
|
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
|
|
|
|
2024-08-28 08:44:39 -04:00
|
|
|
export const EndCallButton: FC<ComponentPropsWithoutRef<"button">> = ({
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
2024-08-28 08:44:39 -04:00
|
|
|
export const SettingsButton: FC<ComponentPropsWithoutRef<"button">> = (
|
|
|
|
|
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
|
|
|
};
|