-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tweak(triptych): Do not render slots outside the viewport when using …
…the 3-slot split layout
- Loading branch information
1 parent
2862d86
commit e854b39
Showing
4 changed files
with
56 additions
and
32 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 was deleted.
Oops, something went wrong.
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,51 @@ | ||
import React, { ComponentType } from "react"; | ||
|
||
import EvergreenContent from "../evergreen_content"; | ||
import useIsOnScreen from "Hooks/v2/use_is_on_screen"; | ||
import { imagePath } from "Util/util"; | ||
import { TRIPTYCH_VERSION } from "./version"; | ||
import { usePlayerName } from "Hooks/outfront"; | ||
import { TriptychPane, getTriptychPane } from "Util/outfront"; | ||
|
||
const isInViewport = (thisComponentsPane: TriptychPane) => { | ||
const triptychPane = getTriptychPane(); | ||
if (triptychPane == null) { | ||
// Viewport is not limited/shifted, we're showing all 3 in a browser tab. | ||
return true; | ||
} else { | ||
return thisComponentsPane == triptychPane; | ||
} | ||
}; | ||
|
||
/** | ||
* Differences from standard evergreen content component: | ||
* - allows showing identifiers (version, player name) over content | ||
* - does not render content outside the viewport at all, besides identifiers, to save on work | ||
*/ | ||
const TriptychEvergreenContent: ComponentType<{ | ||
asset_url: string; | ||
show_identifiers: boolean; | ||
triptychPane: TriptychPane; | ||
}> = ({ | ||
asset_url: assetUrl, | ||
show_identifiers: showIdentifiers, | ||
triptychPane, | ||
}) => { | ||
const dupReadyUrl = imagePath(assetUrl); | ||
const isPlaying = useIsOnScreen(); | ||
const playerName = usePlayerName(); | ||
let identifiers = `${TRIPTYCH_VERSION} ${playerName ? playerName : ""}`; | ||
|
||
return ( | ||
<> | ||
{isInViewport(triptychPane) && ( | ||
<EvergreenContent asset_url={dupReadyUrl} isPlaying={isPlaying} /> | ||
)} | ||
{showIdentifiers && ( | ||
<div className="evergreen-content__identifiers">{identifiers}</div> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default TriptychEvergreenContent; |
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