@shopify/hydrogen-react
Version:
React components, hooks, and utilities for creating custom Shopify storefronts
58 lines (57 loc) • 1.92 kB
JavaScript
;
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Image = require("./Image.js");
const Video = require("./Video.js");
const ExternalVideo = require("./ExternalVideo.js");
const ModelViewer = require("./ModelViewer.js");
const jsxRuntime = require("react/jsx-runtime");
function MediaFile({
data,
mediaOptions,
...passthroughProps
}) {
switch (data.__typename) {
case "MediaImage": {
if (!data.image) {
const noDataImage = `<MediaFile/>: 'data.image' does not exist for __typename of 'MediaImage'; rendering 'null' by default.`;
{
throw new Error(noDataImage);
}
}
return /* @__PURE__ */ jsxRuntime.jsx(Image.Image, {
...passthroughProps,
...mediaOptions == null ? void 0 : mediaOptions.image,
data: data.image
});
}
case "Video": {
return /* @__PURE__ */ jsxRuntime.jsx(Video.Video, {
...passthroughProps,
...mediaOptions == null ? void 0 : mediaOptions.video,
data
});
}
case "ExternalVideo": {
return /* @__PURE__ */ jsxRuntime.jsx(ExternalVideo.ExternalVideo, {
...passthroughProps,
...mediaOptions == null ? void 0 : mediaOptions.externalVideo,
data
});
}
case "Model3d": {
return /* @__PURE__ */ jsxRuntime.jsx(ModelViewer.ModelViewer, {
...passthroughProps,
...mediaOptions == null ? void 0 : mediaOptions.modelViewer,
data
});
}
default: {
const typenameMissingMessage = `<MediaFile /> requires the '__typename' property to exist on the 'data' prop in order to correctly render the correct component for this media. Rendering 'null' by default`;
{
throw new Error(typenameMissingMessage);
}
}
}
}
exports.MediaFile = MediaFile;
//# sourceMappingURL=MediaFile.js.map