@shopify/hydrogen-react
Version:
React components, hooks, and utilities for creating custom Shopify storefronts
56 lines (55 loc) • 1.6 kB
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const RichTextComponents = {
root: Root,
heading: Heading,
paragraph: Paragraph,
text: Text,
link: RichTextLink,
list: List,
"list-item": ListItem
};
function Root({
node
}) {
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: node.children });
}
function Heading({
node
}) {
return React.createElement(`h${node.level ?? "1"}`, null, node.children);
}
function Paragraph({
node
}) {
return /* @__PURE__ */ jsxRuntime.jsx("p", { children: node.children });
}
function Text({
node
}) {
if (node.bold && node.italic)
return /* @__PURE__ */ jsxRuntime.jsx("em", { children: /* @__PURE__ */ jsxRuntime.jsx("strong", { children: node.value }) });
if (node.bold) return /* @__PURE__ */ jsxRuntime.jsx("strong", { children: node.value });
if (node.italic) return /* @__PURE__ */ jsxRuntime.jsx("em", { children: node.value });
return node.value;
}
function RichTextLink({
node
}) {
return /* @__PURE__ */ jsxRuntime.jsx("a", { href: node.url, title: node.title, target: node.target, children: node.children });
}
function List({
node
}) {
const List2 = node.listType === "unordered" ? "ul" : "ol";
return /* @__PURE__ */ jsxRuntime.jsx(List2, { children: node.children });
}
function ListItem({
node
}) {
return /* @__PURE__ */ jsxRuntime.jsx("li", { children: node.children });
}
exports.RichTextComponents = RichTextComponents;
//# sourceMappingURL=RichText.components.js.map