aboutsummaryrefslogtreecommitdiff
path: root/packages/bun-framework-next/next-image-polyfill.tsx
blob: edc3775d7a91467262562b7b71c7bf1355d59359 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;