UNPKG

pouncejs

Version:

A collection of UI components from Panther labs

42 lines (38 loc) 1.4 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; import React from 'react'; import Box from '../Box'; var NativeImg = /*#__PURE__*/React.forwardRef(function NativeImg( // eslint-disable-next-line @typescript-eslint/no-unused-vars _ref, ref) { var nativeWidth = _ref.nativeWidth, nativeHeight = _ref.nativeHeight, color = _ref.color, alt = _ref.alt, props = _objectWithoutPropertiesLoose(_ref, ["nativeWidth", "nativeHeight", "color", "alt"]); return /*#__PURE__*/React.createElement("img", _extends({}, props, { ref: ref, width: nativeWidth, height: nativeHeight, alt: alt })); }); /** * Extends Box * * Simple Img component for whenever you want to add an image to your app */ export var Img = /*#__PURE__*/React.forwardRef(function Img(props, ref) { if (props.width && !props.nativeWidth) { console.warn('A width was specified for an image without a `nativeWidth` being defined'); } if (props.height && !props.nativeHeight) { console.warn('A height was specified for an image without a `nativeHeight` being defined'); } return /*#__PURE__*/React.createElement(Box, _extends({ as: NativeImg, ref: ref, maxWidth: "100%", height: !props.nativeHeight ? 'auto' : undefined }, props)); }); export default Img;