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

76 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 OR LicenseRef-Element-Commercial
Please see LICENSE in the repository root for full details.
2024-05-17 16:38:00 -04:00
*/
2025-06-23 22:48:37 -04:00
import { type ReactNode } 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
import { type CallLayout } from "./CallLayout";
import { type SpotlightLandscapeLayout as SpotlightLandscapeLayoutModel } from "../state/layout-types.ts";
import styles from "./SpotlightLandscapeLayout.module.css";
import { useUpdateLayout, useVisibleTiles } 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
2025-06-23 22:48:37 -04:00
fixed: function SpotlightLandscapeLayoutFixed({
ref,
2025-06-23 22:48:37 -04:00
model,
Slot,
}): ReactNode {
2024-07-25 12:50:28 -04:00
useUpdateLayout();
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>
);
2025-06-23 22:48:37 -04:00
},
2024-05-17 16:38:00 -04:00
2025-06-23 22:48:37 -04:00
scrolling: function SpotlightLandscapeLayoutScrolling({
ref,
2025-06-23 22:48:37 -04:00
model,
Slot,
}): ReactNode {
2024-07-25 12:50:28 -04:00
useUpdateLayout();
useVisibleTiles(model.setVisibleTiles);
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 key={m.id} className={styles.slot} id={m.id} model={m} />
))}
2024-05-17 16:38:00 -04:00
</div>
</div>
);
2025-06-23 22:48:37 -04:00
},
2024-05-17 16:38:00 -04:00
});