@wordpress/components
Version:
UI components for WordPress.
55 lines (52 loc) • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = Media;
var _focalPointPickerStyle = require("./styles/focal-point-picker-style");
var _utils = require("./utils");
var _jsxRuntime = require("react/jsx-runtime");
/**
* External dependencies
*/
/**
* Internal dependencies
*/
function Media({
alt,
autoPlay,
src,
onLoad,
mediaRef,
// Exposing muted prop for test rendering purposes
// https://github.com/testing-library/react-testing-library/issues/470
muted = true,
...props
}) {
if (!src) {
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_focalPointPickerStyle.MediaPlaceholder, {
className: "components-focal-point-picker__media components-focal-point-picker__media--placeholder",
ref: mediaRef,
...props
});
}
const isVideo = (0, _utils.isVideoType)(src);
return isVideo ? /*#__PURE__*/(0, _jsxRuntime.jsx)("video", {
...props,
autoPlay: autoPlay,
className: "components-focal-point-picker__media components-focal-point-picker__media--video",
loop: true,
muted: muted,
onLoadedData: onLoad,
ref: mediaRef,
src: src
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
...props,
alt: alt,
className: "components-focal-point-picker__media components-focal-point-picker__media--image",
onLoad: onLoad,
ref: mediaRef,
src: src
});
}
//# sourceMappingURL=media.js.map