Skip to content

Commit 31bb464

Browse files
committed
Put a switch camera button on the local user's tile
1 parent f53558c commit 31bb464

File tree

3 files changed

+56
-15
lines changed

3 files changed

+56
-15
lines changed

src/tile/GridTile.module.css

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,25 @@ borders don't support gradients */
8383
.volumeSlider {
8484
width: 100%;
8585
}
86+
87+
.tile .switchCamera {
88+
opacity: 1;
89+
background: var(--cpd-color-bg-action-secondary-rest);
90+
border: 1px solid var(--cpd-color-border-interactive-secondary);
91+
}
92+
93+
.tile .switchCamera > svg {
94+
color: var(--cpd-color-icon-primary);
95+
}
96+
97+
@media (hover) {
98+
.tile .switchCamera:hover {
99+
background: var(--cpd-color-bg-subtle-secondary);
100+
border-color: var(--cpd-color-border-interactive-hovered);
101+
}
102+
}
103+
104+
.tile .switchCamera:active {
105+
background: var(--cpd-color-bg-subtle-primary);
106+
border-color: var(--cpd-color-border-interactive-hovered);
107+
}

src/tile/GridTile.tsx

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
UserProfileIcon,
2929
ExpandIcon,
3030
VolumeOffSolidIcon,
31+
SwitchCameraSolidIcon,
3132
} from "@vector-im/compound-design-tokens/assets/web/icons";
3233
import {
3334
ContextMenu,
@@ -64,6 +65,7 @@ interface UserMediaTileProps extends TileProps {
6465
vm: UserMediaViewModel;
6566
mirror: boolean;
6667
locallyMuted: boolean;
68+
primaryButton?: ReactNode;
6769
menuStart?: ReactNode;
6870
menuEnd?: ReactNode;
6971
}
@@ -73,6 +75,7 @@ const UserMediaTile: FC<UserMediaTileProps> = ({
7375
vm,
7476
showSpeakingIndicators,
7577
locallyMuted,
78+
primaryButton,
7679
menuStart,
7780
menuEnd,
7881
className,
@@ -159,20 +162,22 @@ const UserMediaTile: FC<UserMediaTileProps> = ({
159162
}
160163
displayName={displayName}
161164
primaryButton={
162-
<Menu
163-
open={menuOpen}
164-
onOpenChange={setMenuOpen}
165-
title={displayName}
166-
trigger={
167-
<button aria-label={t("common.options")}>
168-
<OverflowHorizontalIcon aria-hidden width={20} height={20} />
169-
</button>
170-
}
171-
side="left"
172-
align="start"
173-
>
174-
{menu}
175-
</Menu>
165+
primaryButton ?? (
166+
<Menu
167+
open={menuOpen}
168+
onOpenChange={setMenuOpen}
169+
title={displayName}
170+
trigger={
171+
<button aria-label={t("common.options")}>
172+
<OverflowHorizontalIcon aria-hidden width={20} height={20} />
173+
</button>
174+
}
175+
side="left"
176+
align="start"
177+
>
178+
{menu}
179+
</Menu>
180+
)
176181
}
177182
raisedHandTime={handRaised ?? undefined}
178183
currentReaction={reaction ?? undefined}
@@ -207,6 +212,8 @@ const LocalUserMediaTile: FC<LocalUserMediaTileProps> = ({
207212
const { t } = useTranslation();
208213
const mirror = useObservableEagerState(vm.mirror$);
209214
const alwaysShow = useObservableEagerState(vm.alwaysShow$);
215+
const switchCamera = useObservableEagerState(vm.switchCamera$);
216+
210217
const latestAlwaysShow = useLatest(alwaysShow);
211218
const onSelectAlwaysShow = useCallback(
212219
(e: Event) => {
@@ -222,6 +229,17 @@ const LocalUserMediaTile: FC<LocalUserMediaTileProps> = ({
222229
vm={vm}
223230
locallyMuted={false}
224231
mirror={mirror}
232+
primaryButton={
233+
switchCamera === null ? undefined : (
234+
<button
235+
className={styles.switchCamera}
236+
aria-label={t("switch_camera")}
237+
onClick={switchCamera}
238+
>
239+
<SwitchCameraSolidIcon aria-hidden width={20} height={20} />
240+
</button>
241+
)
242+
}
225243
menuStart={
226244
<ToggleMenuItem
227245
Icon={VisibilityOnIcon}

src/tile/MediaView.module.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ unconditionally select the container so we can use cqmin units */
8585

8686
.nameTag {
8787
grid-area: nameTag;
88+
place-self: end start;
8889
padding: var(--cpd-space-1x);
8990
padding-block: var(--cpd-space-1x);
9091
color: var(--cpd-color-text-primary);
@@ -173,7 +174,7 @@ unconditionally select the container so we can use cqmin units */
173174
}
174175

175176
.fg > button:active {
176-
background: var(--cpd-color-bg-action-primary-pressed) !important;
177+
background: var(--cpd-color-bg-action-primary-pressed);
177178
}
178179

179180
.fg > button[data-state="open"] {

0 commit comments

Comments
 (0)