-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement most of the remaining layout changes
Includes the mobile UX optimizations and the tweaks we've made to cut down on wasted space, but does not yet include the change to embed the spotlight tile within the grid.
- Loading branch information
Showing
25 changed files
with
761 additions
and
497 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd | ||
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. | ||
*/ | ||
|
||
.layer { | ||
block-size: 100%; | ||
} | ||
|
||
.spotlight { | ||
block-size: 100%; | ||
inline-size: 100%; | ||
} | ||
|
||
.pip { | ||
position: absolute; | ||
inline-size: 180px; | ||
block-size: 135px; | ||
inset: var(--cpd-space-4x); | ||
} | ||
|
||
.pip[data-block-alignment="start"] { | ||
inset-block-end: unset; | ||
} | ||
|
||
.pip[data-block-alignment="end"] { | ||
inset-block-start: unset; | ||
} | ||
|
||
.pip[data-inline-alignment="start"] { | ||
inset-inline-end: unset; | ||
} | ||
|
||
.pip[data-inline-alignment="end"] { | ||
inset-inline-start: unset; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd | ||
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. | ||
*/ | ||
|
||
import { forwardRef, useCallback, useMemo } from "react"; | ||
import { useObservableEagerState } from "observable-hooks"; | ||
|
||
import { SpotlightExpandedLayout as SpotlightExpandedLayoutModel } from "../state/CallViewModel"; | ||
import { CallLayout, GridTileModel, SpotlightTileModel } from "./CallLayout"; | ||
import { DragCallback } from "./Grid"; | ||
import styles from "./SpotlightExpandedLayout.module.css"; | ||
import { useReactiveState } from "../useReactiveState"; | ||
|
||
export const makeSpotlightExpandedLayout: CallLayout< | ||
SpotlightExpandedLayoutModel | ||
> = ({ minBounds, pipAlignment }) => ({ | ||
scrollingOnTop: true, | ||
|
||
fixed: forwardRef(function SpotlightExpandedLayoutFixed( | ||
{ model, Slot }, | ||
ref, | ||
) { | ||
const { width, height } = useObservableEagerState(minBounds); | ||
|
||
const [generation] = useReactiveState<number>( | ||
(prev) => (prev === undefined ? 0 : prev + 1), | ||
[width, height], | ||
); | ||
|
||
const spotlightTileModel: SpotlightTileModel = useMemo( | ||
() => ({ type: "spotlight", vms: model.spotlight, maximised: true }), | ||
[model.spotlight], | ||
); | ||
|
||
return ( | ||
<div ref={ref} data-generation={generation} className={styles.layer}> | ||
<Slot | ||
className={styles.spotlight} | ||
id="spotlight" | ||
model={spotlightTileModel} | ||
/> | ||
</div> | ||
); | ||
}), | ||
|
||
scrolling: forwardRef(function SpotlightExpandedLayoutScrolling( | ||
{ model, Slot }, | ||
ref, | ||
) { | ||
const { width, height } = useObservableEagerState(minBounds); | ||
const pipAlignmentValue = useObservableEagerState(pipAlignment); | ||
|
||
const [generation] = useReactiveState<number>( | ||
(prev) => (prev === undefined ? 0 : prev + 1), | ||
[width, height, model.pip === undefined, pipAlignmentValue], | ||
); | ||
|
||
const pipTileModel: GridTileModel | undefined = useMemo( | ||
() => model.pip && { type: "grid", vm: model.pip }, | ||
[model.pip], | ||
); | ||
|
||
const onDragPip: DragCallback = useCallback( | ||
({ xRatio, yRatio }) => | ||
pipAlignment.next({ | ||
block: yRatio < 0.5 ? "start" : "end", | ||
inline: xRatio < 0.5 ? "start" : "end", | ||
}), | ||
[], | ||
); | ||
|
||
return ( | ||
<div ref={ref} data-generation={generation} className={styles.layer}> | ||
{pipTileModel && ( | ||
<Slot | ||
className={styles.pip} | ||
id="pip" | ||
model={pipTileModel} | ||
onDrag={onDragPip} | ||
data-block-alignment={pipAlignmentValue.block} | ||
data-inline-alignment={pipAlignmentValue.inline} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
Copyright 2024 New Vector Ltd | ||
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. | ||
*/ | ||
|
||
.layer { | ||
block-size: 100%; | ||
display: grid; | ||
--gap: 20px; | ||
gap: var(--gap); | ||
--grid-slot-width: 180px; | ||
grid-template-columns: 1fr var(--grid-slot-width); | ||
grid-template-rows: minmax(1fr, auto); | ||
padding-inline: var(--gap); | ||
} | ||
|
||
.spotlight { | ||
container: spotlight / size; | ||
display: grid; | ||
place-items: center; | ||
} | ||
|
||
/* CSS makes us put a condition here, even though all we want to do is | ||
unconditionally select the container so we can use cq units */ | ||
@container spotlight (width > 0) { | ||
.spotlight > .slot { | ||
inline-size: min(100cqi, 100cqb * (17 / 9)); | ||
block-size: min(100cqb, 100cqi / (4 / 3)); | ||
} | ||
} | ||
|
||
.grid { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: var(--gap); | ||
justify-content: center; | ||
align-content: center; | ||
} | ||
|
||
.grid > .slot { | ||
inline-size: 180px; | ||
block-size: 135px; | ||
} |
Oops, something went wrong.