11import { CSSProperties } from "react" ;
2- import { ImageContainerProps } from "typings/ImageProps" ;
2+ import { ImageContainerProps , ImagePreviewProps } from "typings/ImageProps" ;
33
44function getHeightScale ( height : number , heightUnit : "pixels" | "percentage" | "viewport" ) : string {
55 return `${ height } ${ heightUnit === "pixels" ? "px" : heightUnit === "viewport" ? "vh" : "%" } ` ;
66}
77
8- export function constructStyleObject ( props : ImageContainerProps ) : CSSProperties {
8+ export function constructStyleObject ( props : ImageContainerProps | ImagePreviewProps ) : CSSProperties {
99 const { widthUnit, heightUnit, minHeightUnit, maxHeightUnit, width, height, minHeight, maxHeight } = props ;
1010
1111 const imageStyle : Pick < CSSProperties , "width" | "height" | "minHeight" | "maxHeight" | "maxWidth" > = { } ;
@@ -14,15 +14,15 @@ export function constructStyleObject(props: ImageContainerProps): CSSProperties
1414 if ( heightUnit === "auto" ) {
1515 imageStyle . height = "auto" ;
1616
17- if ( minHeightUnit !== "none" && minHeight > 0 ) {
18- imageStyle . minHeight = getHeightScale ( minHeight , minHeightUnit ) ;
17+ if ( minHeightUnit !== "none" && minHeight ! > 0 ) {
18+ imageStyle . minHeight = getHeightScale ( minHeight ! , minHeightUnit ) ;
1919 }
2020
21- if ( maxHeightUnit !== "none" && maxHeight > 0 ) {
22- imageStyle . maxHeight = getHeightScale ( maxHeight , maxHeightUnit ) ;
21+ if ( maxHeightUnit !== "none" && maxHeight ! > 0 ) {
22+ imageStyle . maxHeight = getHeightScale ( maxHeight ! , maxHeightUnit ) ;
2323 }
2424 } else {
25- imageStyle . height = getHeightScale ( height , heightUnit ) ;
25+ imageStyle . height = getHeightScale ( height ! , heightUnit ) ;
2626 }
2727
2828 return imageStyle ;
0 commit comments