2019-11-05 05:09:50 +00:00
|
|
|
import * as React from "react";
|
|
|
|
|
import { ComponentProps } from "./BaseComponent";
|
|
|
|
|
import styled from "styled-components";
|
|
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
export interface StyledImageProps {
|
2019-11-14 17:06:32 +00:00
|
|
|
defaultImageUrl: string;
|
2020-03-27 09:02:11 +00:00
|
|
|
imageUrl?: string;
|
|
|
|
|
backgroundColor?: string;
|
2019-11-14 17:06:32 +00:00
|
|
|
}
|
|
|
|
|
|
2020-03-27 09:02:11 +00:00
|
|
|
export const StyledImage = styled.div<StyledImageProps>`
|
|
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: "row";
|
|
|
|
|
background: ${props => props.backgroundColor};
|
|
|
|
|
background-image: url("${props => {
|
2020-04-02 22:01:31 +00:00
|
|
|
return props.imageUrl;
|
|
|
|
|
}}"), url("${props => {
|
|
|
|
|
return props.defaultImageUrl;
|
|
|
|
|
}}");
|
2020-03-27 09:02:11 +00:00
|
|
|
background-position: center;
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
background-size: contain;
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
2019-11-05 05:09:50 +00:00
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
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}
|
2020-03-27 09:02:11 +00:00
|
|
|
></StyledImage>
|
2019-12-03 04:41:10 +00:00
|
|
|
);
|
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;
|