@sitestudio/atomic.aspect-ratio-image
Advanced tools
Comparing version 0.0.73 to 0.0.74
import { jsx as _jsx } from "react/jsx-runtime"; | ||
import { useState } from 'react'; | ||
export function AspectRatioImage({ src, borderRadius, alt, }) { | ||
const [aspectRatio, setAspectRatio] = useState('1/1'); | ||
return (_jsx("div", { className: "relative w-full h-full", style: { aspectRatio }, children: src && ( | ||
// eslint-disable-next-line react/jsx-no-undef | ||
// <Image | ||
// src={src} | ||
// layout="fill" | ||
// objectFit="contain" | ||
// style={{ borderRadius }} | ||
// onLoad={({ target }) => { | ||
// const { naturalWidth, naturalHeight } = target as HTMLImageElement; | ||
// setAspectRatio(`${naturalWidth} / ${naturalHeight}`); | ||
// }} | ||
// alt={alt || ''} | ||
// /> | ||
_jsx("img", { src: src, style: { borderRadius }, onLoad: ({ target }) => { | ||
const [aspectRatio, setAspectRatio] = useState(undefined); | ||
return (_jsx("div", { className: "relative w-full h-full", style: aspectRatio ? { aspectRatio } : undefined, children: src && (_jsx("img", { src: src, style: { borderRadius }, onLoad: ({ target }) => { | ||
const { naturalWidth, naturalHeight } = target; | ||
setAspectRatio(`${naturalWidth} / ${naturalHeight}`); | ||
}, alt: alt || '' })) })); | ||
}, alt: alt || '', className: "w-full h-full object-cover" // Ensure proper scaling | ||
})) })); | ||
} | ||
//# sourceMappingURL=aspect-ratio-image.js.map |
{ | ||
"name": "@sitestudio/atomic.aspect-ratio-image", | ||
"version": "0.0.73", | ||
"version": "0.0.74", | ||
"homepage": "https://bit.cloud/sitestudio/atomic/aspect-ratio-image", | ||
@@ -9,3 +9,3 @@ "main": "dist/index.js", | ||
"name": "aspect-ratio-image", | ||
"version": "0.0.73" | ||
"version": "0.0.74" | ||
}, | ||
@@ -12,0 +12,0 @@ "dependencies": {}, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8148
212