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:
1 parent
2cd683f59d
commit
b4ea27e8c6
8 files changed
+61
-5
No files matched your search
@@ -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";
|
||||
Reference in new issue
Block a user