import React from "react";
import dynamic from "next/dynamic";
import {
Checkbox as ChakraCheckbox,
Divider,
Code,
Heading as ChakraHeading,
Link as ChakraLink,
List as ChakraList,
ListItem as ChakraListItem,
Spinner,
Text as ChakraText
} from "@chakra-ui/core";
import CustomCodeBlock from "~/components/CodeBlock";
import { TableCell, TableHeader, Table } from "~/components/Table";
// Dynaimc Imports
const ReactMarkdown = dynamic(() => import("react-markdown"), { loading: Spinner });
const Checkbox = ({ checked, children }) => (
{children}
);
const List = ({ ordered, children }) => (
{children}
);
const ListItem = ({ checked, children }) =>
checked ? (
{children}
) : (
{children}
);
const Heading = ({ level, children }) => {
const levelMap = {
1: { as: "h1", size: "lg", fontWeight: "bold" },
2: { as: "h2", size: "lg", fontWeight: "normal" },
3: { as: "h3", size: "lg", fontWeight: "bold" },
4: { as: "h4", size: "md", fontWeight: "normal" },
5: { as: "h5", size: "md", fontWeight: "bold" },
6: { as: "h6", size: "sm", fontWeight: "bold" }
};
return {children};
};
const Link = ({ children, ...props }) => (
{children}
);
const CodeBlock = ({ value }) => {value};
const TableData = ({ isHeader, children, ...props }) => {
const Component = isHeader ? TableHeader : TableCell;
return {children};
};
const mdComponents = {
paragraph: ChakraText,
link: Link,
heading: Heading,
inlineCode: Code,
list: List,
listItem: ListItem,
thematicBreak: Divider,
code: CodeBlock,
table: Table,
tableCell: TableData
};
export default React.forwardRef(({ content }, ref) => (
));