2019-11-05 05:09:50 +00:00
|
|
|
import * as React from "react";
|
|
|
|
|
import { ComponentProps } from "./BaseComponent";
|
2019-11-13 07:00:25 +00:00
|
|
|
import { StyledContainer, StyledContainerProps } from "./StyledContainer";
|
2019-11-05 05:09:50 +00:00
|
|
|
import styled from "styled-components";
|
|
|
|
|
|
2019-11-14 17:06:32 +00:00
|
|
|
export interface StyledImageProps extends StyledContainerProps {
|
|
|
|
|
defaultImageUrl: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const StyledImage = styled(StyledContainer)<StyledImageProps>`
|
2019-11-05 05:09:50 +00:00
|
|
|
background-image: url("${props => {
|
2019-11-14 17:06:32 +00:00
|
|
|
return props.imageUrl || props.defaultImageUrl;
|
2019-11-05 05:09:50 +00:00
|
|
|
}}");
|
|
|
|
|
background-position: center;
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
background-size: contain;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
class ImageComponent extends React.Component<ImageComponentProps> {
|
|
|
|
|
render() {
|
|
|
|
|
return <StyledImage {...this.props}>{}</StyledImage>;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ImageComponentProps extends ComponentProps {
|
|
|
|
|
imageUrl: string;
|
|
|
|
|
defaultImageUrl: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ImageComponent;
|