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() {
|
2019-12-03 04:41:10 +00:00
|
|
|
return (
|
|
|
|
|
<StyledImage
|
|
|
|
|
className={this.props.isLoading ? "bp3-skeleton" : ""}
|
|
|
|
|
{...this.props}
|
|
|
|
|
>
|
|
|
|
|
{}
|
|
|
|
|
</StyledImage>
|
|
|
|
|
);
|
2019-11-05 05:09:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface ImageComponentProps extends ComponentProps {
|
|
|
|
|
imageUrl: string;
|
|
|
|
|
defaultImageUrl: string;
|
2019-12-03 04:41:10 +00:00
|
|
|
isLoading: boolean;
|
2019-11-05 05:09:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ImageComponent;
|