Files
element-call/src/grid/SpotlightLandscapeLayout.tsx
T

79 lines
2.1 KiB
TypeScript
Raw Normal View History

2024-05-17 16:38:00 -04:00
/*
Copyright 2024 New Vector Ltd.
2024-05-17 16:38:00 -04:00
SPDX-License-Identifier: AGPL-3.0-only
Please see LICENSE in the repository root for full details.
2024-05-17 16:38:00 -04:00
*/
2024-11-06 04:36:48 -05:00
import { forwardRef } from "react";
2024-05-17 16:38:00 -04:00
import { useObservableEagerState } from "observable-hooks";
import classNames from "classnames";
2024-05-17 16:38:00 -04:00
2024-11-06 04:36:48 -05:00
import { CallLayout } from "./CallLayout";
import { SpotlightLandscapeLayout as SpotlightLandscapeLayoutModel } from "../state/CallViewModel";
import styles from "./SpotlightLandscapeLayout.module.css";
2024-07-25 12:50:28 -04:00
import { useUpdateLayout } from "./Grid";
2024-05-17 16:38:00 -04:00
2024-07-18 11:33:20 -04:00
/**
* An implementation of the "spotlight landscape" layout, in which the spotlight
* tile takes up most of the space on the left, and the grid of participants is
* shown as a scrolling rail on the right.
*/
export const makeSpotlightLandscapeLayout: CallLayout<
SpotlightLandscapeLayoutModel
> = ({ minBounds }) => ({
scrollingOnTop: false,
2024-05-17 16:38:00 -04:00
fixed: forwardRef(function SpotlightLandscapeLayoutFixed(
{ model, Slot },
ref,
) {
2024-07-25 12:50:28 -04:00
useUpdateLayout();
2024-07-24 16:57:20 -04:00
useObservableEagerState(minBounds);
2024-05-17 16:38:00 -04:00
return (
2024-07-24 16:57:20 -04:00
<div ref={ref} className={styles.layer}>
<div className={styles.spotlight}>
2024-11-06 04:36:48 -05:00
<Slot
className={styles.slot}
id="spotlight"
model={model.spotlight}
/>
2024-05-17 16:38:00 -04:00
</div>
<div className={styles.grid} />
</div>
);
}),
2024-05-17 16:38:00 -04:00
scrolling: forwardRef(function SpotlightLandscapeLayoutScrolling(
{ model, Slot },
ref,
) {
2024-07-25 12:50:28 -04:00
useUpdateLayout();
2024-07-24 16:57:20 -04:00
useObservableEagerState(minBounds);
2024-11-06 04:36:48 -05:00
const withIndicators =
useObservableEagerState(model.spotlight.media).length > 1;
2024-05-17 16:38:00 -04:00
return (
2024-07-24 16:57:20 -04:00
<div ref={ref} className={styles.layer}>
2024-05-17 16:38:00 -04:00
<div
className={classNames(styles.spotlight, {
2024-11-06 04:36:48 -05:00
[styles.withIndicators]: withIndicators,
})}
/>
<div className={styles.grid}>
2024-11-06 04:36:48 -05:00
{model.grid.map((m) => (
<Slot
2024-11-06 04:36:48 -05:00
key={m.id}
className={styles.slot}
2024-11-06 04:36:48 -05:00
id={m.id}
model={m}
2024-11-06 04:36:48 -05:00
onVisibilityChange={m.setVisible}
/>
))}
2024-05-17 16:38:00 -04:00
</div>
</div>
);
}),
2024-05-17 16:38:00 -04:00
});