ISSUE-004 - Saving progress. Have two options for image display.

BackgroundImage uses <img> and can be centered with VideoFeedFrame, but cannot be shrunk when the window becomes narrow.
BackgroundImageDiv uses div and a background image property, but cannot be centered with VideoFeedFrame.
This commit is contained in:
Kyle Geib committed 2021-12-21 21:17:38 -05:00
1 parent 2cd683f59d
commit b4ea27e8c6
8 files changed
+61 -5

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>F1 World Broadcast Emulator Project</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
+2 -3
View File
@@ -1,4 +1,5 @@
import { MockupBlock } from "../../Common/MockupBlock.styled";
import VideoFeed from "../VideoFeed/VideoFeed";
import { LayoutGrid, LayoutGridItem } from "./styles";
type LayoutProps = {
@@ -16,9 +17,7 @@ export function Layout({ headerHeight }: LayoutProps) {
</LayoutGridItem>
<LayoutGridItem column={2} row={1} columnSpan={5} rowSpan={6} >
<MockupBlock
color="#c5c5c5"
>Video Feed</MockupBlock>
<VideoFeed />
</LayoutGridItem>
<LayoutGridItem column={1} row={7} rowSpan={3}>
@@ -0,0 +1,10 @@
import { VideoFeedFrame, BackgroundImage, BackgroundImageDiv } from "./styles";
import bg from "../../../public/images/misc/bg-standin.jpg";
export default function VideoFeed() {
return <VideoFeedFrame centered={true}>
{/* <BackgroundImage src={bg} alt="formula one cars on track" /> */}
<BackgroundImageDiv src={bg} />
</VideoFeedFrame>;
}
@@ -0,0 +1 @@
export * from "./VideoFeed";
@@ -0,0 +1,45 @@
import styled, { css } from "styled-components";
type VideoFeedFrameProps = {
centered?: boolean,
};
export const VideoFeedFrame = styled.div<VideoFeedFrameProps>`
height: 100%;
width: 100%;
background-color: ${p => p.theme.colors.videoFrameBG};
overflow: hidden;
${({ centered = false }) => centered && css`
display: flex;
/* flex-direction: column; */
align-items: center;
justify-content: center;
/* > * {
left: 10px;
} */
`}
`;
VideoFeedFrame.displayName = "VideoFeedFrame";
export const BackgroundImage = styled.img`
height: 100%;
object-fit: contain;
`;
BackgroundImage.displayName = "BackgroundImage";
/**
* A slight improvement to using a simple img in that we can resize the image
* (the video) to shrink slightly in the video feed frame if the browser window
* is too narrow.
*/
type BackgroundImageDivProps = {
src: string,
}
export const BackgroundImageDiv = styled.div<BackgroundImageDivProps>`
height: 100%;
width: 100%;
background-image: ${({ src }) => `url("${src}")`};
background-size: contain;
background-repeat: no-repeat;
`;
BackgroundImageDiv.displayName = "BackgroundImageDiv";
Binary file not shown.

After

Width:  |  Height:  |  Size: 487 KiB

+1 -1
View File
@@ -14,7 +14,7 @@ export default function Broadcast() {
});
return (
<FullScreenContainer minHeight={728} minWidth={1200}>
<FullScreenContainer minHeight={400} minWidth={600}>
<RouteHeader ref={ref} title="Broadcast Page" />
<Layout headerHeight={height} />
</FullScreenContainer>
+1
View File
@@ -10,6 +10,7 @@ export const theme = {
blue: "#387af5",
pink: "#eb57a3",
grey: "#aaa",
videoFrameBG: "#333",
},
};