Adapt to breaking changes in Compound

This commit is contained in:
Robin
2024-08-02 15:27:49 -04:00
parent 86e3c346a4
commit b503056673
6 changed files with 76 additions and 94 deletions

View File

@@ -151,7 +151,7 @@ export const MicButton: FC<{
return ( return (
<Tooltip label={label}> <Tooltip label={label}>
<Button variant="toolbar" {...rest} on={muted}> <Button variant="toolbar" {...rest} on={muted}>
<Icon aria-label={label} width={24} height={24} /> <Icon aria-hidden width={24} height={24} />
</Button> </Button>
</Tooltip> </Tooltip>
); );
@@ -171,7 +171,7 @@ export const VideoButton: FC<{
return ( return (
<Tooltip label={label}> <Tooltip label={label}>
<Button variant="toolbar" {...rest} on={muted}> <Button variant="toolbar" {...rest} on={muted}>
<Icon aria-label={label} width={24} height={24} /> <Icon aria-hidden width={24} height={24} />
</Button> </Button>
</Tooltip> </Tooltip>
); );
@@ -191,7 +191,7 @@ export const ScreenshareButton: FC<{
return ( return (
<Tooltip label={label}> <Tooltip label={label}>
<Button variant="toolbar" {...rest} on={enabled}> <Button variant="toolbar" {...rest} on={enabled}>
<ShareScreenSolidIcon aria-label={label} width={24} height={24} /> <ShareScreenSolidIcon aria-hidden width={24} height={24} />
</Button> </Button>
</Tooltip> </Tooltip>
); );
@@ -211,11 +211,7 @@ export const HangupButton: FC<{
className={classNames(styles.hangupButton, className)} className={classNames(styles.hangupButton, className)}
{...rest} {...rest}
> >
<EndCallIcon <EndCallIcon aria-hidden width={24} height={24} />
aria-label={t("hangup_button_label")}
width={24}
height={24}
/>
</Button> </Button>
</Tooltip> </Tooltip>
); );
@@ -231,11 +227,7 @@ export const SettingsButton: FC<{
return ( return (
<Tooltip label={t("common.settings")}> <Tooltip label={t("common.settings")}>
<Button variant="toolbar" {...rest}> <Button variant="toolbar" {...rest}>
<SettingsSolidIcon <SettingsSolidIcon aria-hidden width={24} height={24} />
aria-label={t("common.settings")}
width={24}
height={24}
/>
</Button> </Button>
</Tooltip> </Tooltip>
); );

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2023 New Vector Ltd Copyright 2023-2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@@ -34,13 +34,13 @@ export const EncryptionLock: FC<Props> = ({ encrypted }) => {
const label = encrypted ? t("common.encrypted") : t("common.unencrypted"); const label = encrypted ? t("common.encrypted") : t("common.unencrypted");
return ( return (
<Tooltip label={label} side="right" isTriggerInteractive={false}> <Tooltip label={label} placement="right" isTriggerInteractive={false}>
<Icon <Icon
width={16} width={16}
height={16} height={16}
className={styles.lock} className={styles.lock}
data-encrypted={encrypted} data-encrypted={encrypted}
aria-label={label} aria-hidden
/> />
</Tooltip> </Tooltip>
); );

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2023 New Vector Ltd Copyright 2023-2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@@ -21,22 +21,15 @@ limitations under the License.
background: var(--cpd-color-bg-canvas-default); background: var(--cpd-color-bg-canvas-default);
box-shadow: 0px 0px 40px 0px rgba(0, 0, 0, 0.5); box-shadow: 0px 0px 40px 0px rgba(0, 0, 0, 0.5);
display: flex; display: flex;
position: relative;
} }
.toggle input { .toggle input {
appearance: none; appearance: none;
/* /* Safari puts a margin on these, which is not removed via appearance: none */
* Safari puts a margin on these, which is not removed via appearance: none
* mobile safari also has them take up space in the DOM, so set width 0
*/
margin: 0; margin: 0;
width: 0; block-size: var(--cpd-space-11x);
outline: none !important; inline-size: var(--cpd-space-11x);
}
.toggle label {
display: block;
padding: calc(2.5 * var(--cpd-space-1x));
cursor: pointer; cursor: pointer;
border-radius: var(--cpd-radius-pill-effect); border-radius: var(--cpd-radius-pill-effect);
color: var(--cpd-color-icon-primary); color: var(--cpd-color-icon-primary);
@@ -44,41 +37,52 @@ limitations under the License.
box-shadow: var(--small-drop-shadow); box-shadow: var(--small-drop-shadow);
} }
.toggle svg {
display: block;
position: absolute;
padding: calc(2.5 * var(--cpd-space-1x));
pointer-events: none;
color: var(--cpd-color-icon-primary);
}
.toggle svg:nth-child(2) {
inset-inline-start: 2px;
}
.toggle svg:nth-child(4) {
inset-inline-end: 2px;
}
@media (hover: hover) { @media (hover: hover) {
.toggle label:hover { .toggle input:hover {
background: var(--cpd-color-bg-action-secondary-hovered); background: var(--cpd-color-bg-action-secondary-hovered);
box-shadow: none; box-shadow: none;
} }
} }
.toggle label:active { .toggle input:active {
background: var(--cpd-color-bg-action-secondary-hovered); background: var(--cpd-color-bg-action-secondary-hovered);
box-shadow: none; box-shadow: none;
} }
.toggle input:checked + label { .toggle input:checked {
color: var(--cpd-color-icon-on-solid-primary);
background: var(--cpd-color-bg-action-primary-rest); background: var(--cpd-color-bg-action-primary-rest);
} }
.toggle input:checked + svg {
color: var(--cpd-color-icon-on-solid-primary);
}
@media (hover: hover) { @media (hover: hover) {
.toggle input:checked + label:hover { .toggle input:checked:hover {
background: var(--cpd-color-bg-action-primary-hovered); background: var(--cpd-color-bg-action-primary-hovered);
} }
} }
.toggle input:checked + label:active { .toggle input:checked:active {
background: var(--cpd-color-bg-action-primary-hovered); background: var(--cpd-color-bg-action-primary-hovered);
} }
.toggle label > svg { .toggle input:first-child {
display: block; margin-inline-end: 5px;
}
.toggle label:last-child {
margin-inline-start: 5px;
}
.toggle input:focus-visible + label {
outline: auto;
} }

View File

@@ -1,5 +1,5 @@
/* /*
Copyright 2023 New Vector Ltd Copyright 2023-2024 New Vector Ltd
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { ChangeEvent, FC, useCallback, useId } from "react"; import { ChangeEvent, FC, useCallback } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Tooltip } from "@vector-im/compound-web"; import { Tooltip } from "@vector-im/compound-web";
import { import {
@@ -41,45 +41,28 @@ export const LayoutToggle: FC<Props> = ({ layout, setLayout, className }) => {
[setLayout], [setLayout],
); );
const spotlightId = useId();
const gridId = useId();
return ( return (
<div className={classNames(styles.toggle, className)}> <div className={classNames(styles.toggle, className)}>
<input
id={spotlightId}
type="radio"
name="layout"
value="spotlight"
checked={layout === "spotlight"}
onChange={onChange}
/>
<Tooltip label={t("layout_spotlight_label")}> <Tooltip label={t("layout_spotlight_label")}>
<label htmlFor={spotlightId}> <input
<SpotlightIcon type="radio"
aria-label={t("layout_spotlight_label")} name="layout"
width={24} value="spotlight"
height={24} checked={layout === "spotlight"}
/> onChange={onChange}
</label> />
</Tooltip> </Tooltip>
<input <SpotlightIcon aria-hidden width={24} height={24} />
id={gridId}
type="radio"
name="layout"
value="grid"
checked={layout === "grid"}
onChange={onChange}
/>
<Tooltip label={t("layout_grid_label")}> <Tooltip label={t("layout_grid_label")}>
<label htmlFor={gridId}> <input
<GridIcon type="radio"
aria-label={t("layout_grid_label")} name="layout"
width={24} value="grid"
height={24} checked={layout === "grid"}
/> onChange={onChange}
</label> />
</Tooltip> </Tooltip>
<GridIcon aria-hidden width={24} height={24} />
</div> </div>
); );
}; };

View File

@@ -90,10 +90,12 @@ const UserMediaTile = forwardRef<HTMLDivElement, UserMediaTileProps>(
const videoEnabled = useObservableEagerState(vm.videoEnabled); const videoEnabled = useObservableEagerState(vm.videoEnabled);
const speaking = useObservableEagerState(vm.speaking); const speaking = useObservableEagerState(vm.speaking);
const cropVideo = useObservableEagerState(vm.cropVideo); const cropVideo = useObservableEagerState(vm.cropVideo);
const onChangeFitContain = useCallback(() => vm.toggleFitContain(), [vm]);
const onSelectFitContain = useCallback( const onSelectFitContain = useCallback(
(e: Event) => e.preventDefault(), (e: Event) => {
[], e.preventDefault();
vm.toggleFitContain();
},
[vm],
); );
const MicIcon = audioEnabled ? MicOnSolidIcon : MicOffSolidIcon; const MicIcon = audioEnabled ? MicOnSolidIcon : MicOffSolidIcon;
@@ -106,7 +108,6 @@ const UserMediaTile = forwardRef<HTMLDivElement, UserMediaTileProps>(
Icon={ExpandIcon} Icon={ExpandIcon}
label={t("video_tile.change_fit_contain")} label={t("video_tile.change_fit_contain")}
checked={cropVideo} checked={cropVideo}
onChange={onChangeFitContain}
onSelect={onSelectFitContain} onSelect={onSelectFitContain}
/> />
{menuEnd} {menuEnd}
@@ -176,11 +177,10 @@ const LocalUserMediaTile = forwardRef<HTMLDivElement, LocalUserMediaTileProps>(
const alwaysShow = useObservableEagerState(vm.alwaysShow); const alwaysShow = useObservableEagerState(vm.alwaysShow);
const latestAlwaysShow = useLatest(alwaysShow); const latestAlwaysShow = useLatest(alwaysShow);
const onSelectAlwaysShow = useCallback( const onSelectAlwaysShow = useCallback(
(e: Event) => e.preventDefault(), (e: Event) => {
[], e.preventDefault();
); vm.setAlwaysShow(!latestAlwaysShow.current);
const onChangeAlwaysShow = useCallback( },
() => vm.setAlwaysShow(!latestAlwaysShow.current),
[vm, latestAlwaysShow], [vm, latestAlwaysShow],
); );
@@ -194,7 +194,6 @@ const LocalUserMediaTile = forwardRef<HTMLDivElement, LocalUserMediaTileProps>(
Icon={VisibilityOnIcon} Icon={VisibilityOnIcon}
label={t("video_tile.always_show")} label={t("video_tile.always_show")}
checked={alwaysShow} checked={alwaysShow}
onChange={onChangeAlwaysShow}
onSelect={onSelectAlwaysShow} onSelect={onSelectAlwaysShow}
/> />
} }
@@ -224,8 +223,13 @@ const RemoteUserMediaTile = forwardRef<
const { t } = useTranslation(); const { t } = useTranslation();
const locallyMuted = useObservableEagerState(vm.locallyMuted); const locallyMuted = useObservableEagerState(vm.locallyMuted);
const localVolume = useObservableEagerState(vm.localVolume); const localVolume = useObservableEagerState(vm.localVolume);
const onChangeMute = useCallback(() => vm.toggleLocallyMuted(), [vm]); const onSelectMute = useCallback(
const onSelectMute = useCallback((e: Event) => e.preventDefault(), []); (e: Event) => {
e.preventDefault();
vm.toggleLocallyMuted();
},
[vm],
);
const onChangeLocalVolume = useCallback( const onChangeLocalVolume = useCallback(
(v: number) => vm.setLocalVolume(v), (v: number) => vm.setLocalVolume(v),
[vm], [vm],
@@ -244,7 +248,6 @@ const RemoteUserMediaTile = forwardRef<
Icon={MicOffIcon} Icon={MicOffIcon}
label={t("video_tile.mute_for_me")} label={t("video_tile.mute_for_me")}
checked={locallyMuted} checked={locallyMuted}
onChange={onChangeMute}
onSelect={onSelectMute} onSelect={onSelectMute}
/> />
{/* TODO: Figure out how to make this slider keyboard accessible */} {/* TODO: Figure out how to make this slider keyboard accessible */}

View File

@@ -103,14 +103,14 @@ export const MediaView = forwardRef<HTMLDivElement, Props>(
{unencryptedWarning && ( {unencryptedWarning && (
<Tooltip <Tooltip
label={t("common.unencrypted")} label={t("common.unencrypted")}
side="bottom" placement="bottom"
isTriggerInteractive={false} isTriggerInteractive={false}
> >
<ErrorIcon <ErrorIcon
width={20} width={20}
height={20} height={20}
aria-label={t("common.unencrypted")}
className={styles.errorIcon} className={styles.errorIcon}
aria-hidden
/> />
</Tooltip> </Tooltip>
)} )}