diff options
author | 2021-09-09 23:33:34 -0700 | |
---|---|---|
committer | 2021-09-09 23:33:34 -0700 | |
commit | fc907e2f81698d89502fb2ee0375e6d98a492c13 (patch) | |
tree | e775c2479b334ec901f61b5c0ccfab0102ff679e /packages/bun-framework-next/next-image-polyfill.tsx | |
parent | 8a02ad48a5eb1319c1bf3e9eb97e013924db875f (diff) | |
download | bun-fc907e2f81698d89502fb2ee0375e6d98a492c13.tar.gz bun-fc907e2f81698d89502fb2ee0375e6d98a492c13.tar.zst bun-fc907e2f81698d89502fb2ee0375e6d98a492c13.zip |
currentjarred/fetch-experiment
Diffstat (limited to 'packages/bun-framework-next/next-image-polyfill.tsx')
-rw-r--r-- | packages/bun-framework-next/next-image-polyfill.tsx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/packages/bun-framework-next/next-image-polyfill.tsx b/packages/bun-framework-next/next-image-polyfill.tsx new file mode 100644 index 000000000..edc3775d7 --- /dev/null +++ b/packages/bun-framework-next/next-image-polyfill.tsx @@ -0,0 +1,36 @@ +function NextImagePolyfill({ + src, + width, + height, + objectFit, + style, + layout, + ...otherProps +}) { + var _style = style; + if (layout === "fit") { + objectFit = "contain"; + } else if (layout === "fill") { + objectFit = "cover"; + } + + if (objectFit) { + if (!_style) { + _style = { objectFit: objectFit }; + } else { + _style.objectFit = objectFit; + } + } + + return ( + <img + src={src} + width={width} + height={height} + style={_style} + {...otherProps} + /> + ); +} + +export default NextImagePolyfill; |