@shopify/hydrogen-react
Version:
React components, hooks, and utilities for creating custom Shopify storefronts
58 lines (57 loc) • 1.7 kB
JavaScript
import { Image } from "./Image.mjs";
import { Video } from "./Video.mjs";
import { ExternalVideo } from "./ExternalVideo.mjs";
import { ModelViewer } from "./ModelViewer.mjs";
import { jsx } from "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__ */ jsx(Image, {
...passthroughProps,
...mediaOptions == null ? void 0 : mediaOptions.image,
data: data.image
});
}
case "Video": {
return /* @__PURE__ */ jsx(Video, {
...passthroughProps,
...mediaOptions == null ? void 0 : mediaOptions.video,
data
});
}
case "ExternalVideo": {
return /* @__PURE__ */ jsx(ExternalVideo, {
...passthroughProps,
...mediaOptions == null ? void 0 : mediaOptions.externalVideo,
data
});
}
case "Model3d": {
return /* @__PURE__ */ jsx(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);
}
}
}
}
export {
MediaFile
};
//# sourceMappingURL=MediaFile.mjs.map