@shopify/hydrogen-react
Version:
React components, hooks, and utilities for creating custom Shopify storefronts
45 lines (44 loc) • 1.35 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const imageSize = require("./image-size.js");
const require$$0 = require("react");
const jsxRuntime = require("react/jsx-runtime");
function Video(props) {
var _a, _b;
const {
data,
previewImageOptions,
id = data.id,
playsInline = true,
controls = true,
sourceProps = {},
...passthroughProps
} = props;
const posterUrl = imageSize.shopifyImageLoader({
src: (_b = (_a = data.previewImage) == null ? void 0 : _a.url) != null ? _b : "",
...previewImageOptions
});
if (!data.sources) {
throw new Error(`<Video/> requires a 'data.sources' array`);
}
return /* @__PURE__ */ jsxRuntime.jsx("video", {
...passthroughProps,
id,
playsInline,
controls,
poster: posterUrl,
children: data.sources.map((source) => {
if (!((source == null ? void 0 : source.url) && (source == null ? void 0 : source.mimeType))) {
throw new Error(`<Video/> needs 'source.url' and 'source.mimeType'`);
}
return /* @__PURE__ */ require$$0.createElement("source", {
...sourceProps,
key: source.url,
src: source.url,
type: source.mimeType
});
})
});
}
exports.Video = Video;
//# sourceMappingURL=Video.js.map