From 1aeb5e71d7f8d9fb84d0f2446cac6a04b2d77203 Mon Sep 17 00:00:00 2001 From: Mitchell McCaffrey Date: Wed, 1 Jul 2020 16:28:46 +1000 Subject: [PATCH] Added table support for markdown component --- src/components/Markdown.js | 62 ++++++++++++++++++++++++++++++++++++++ src/theme.js | 24 ++------------- 2 files changed, 64 insertions(+), 22 deletions(-) diff --git a/src/components/Markdown.js b/src/components/Markdown.js index 6cef620..12d0416 100644 --- a/src/components/Markdown.js +++ b/src/components/Markdown.js @@ -11,6 +11,7 @@ function Heading({ level, ...props }) { return ( + {children} + + ); +} + +function TableHead(props) { + return ( + tr": { borderBottomWidth: "2px" } }} + {...props} + /> + ); +} + +function TableBody(props) { + return ( + tr": { borderBottomWidth: "1px" } }} + {...props} + /> + ); +} + +function TableRow({ children }) { + return ( + + {children} + + ); +} + +function TableCell({ children }) { + return ( + + {children} + + ); +} + function Markdown({ source }) { const renderers = { paragraph: Paragraph, @@ -44,6 +101,11 @@ function Markdown({ source }) { link: Link, listItem: ListItem, inlineCode: Code, + table: Table, + tableHead: TableHead, + tableBody: TableBody, + tableRow: TableRow, + tableCell: TableCell, }; return ; } diff --git a/src/theme.js b/src/theme.js index 471e16c..679607b 100644 --- a/src/theme.js +++ b/src/theme.js @@ -9,6 +9,7 @@ export default { muted: "hsla(230, 20%, 0%, 20%)", gray: "hsl(0, 0%, 70%)", overlay: "hsla(230, 25%, 18%, 0.8)", + border: "hsla(210, 50%, 96%, 0.5)", modes: { light: { text: "hsl(10, 20%, 20%)", @@ -18,6 +19,7 @@ export default { highlight: "hsl(260, 20%, 40%)", muted: "hsla(230, 20%, 60%, 20%)", overlay: "hsla(230, 100%, 97%, 0.8)", + border: "hsla(10, 20%, 20%, 0.5)", }, }, }, @@ -133,28 +135,6 @@ export default { color: "secondary", bg: "muted", }, - table: { - width: "100%", - my: 4, - borderCollapse: "separate", - borderSpacing: 0, - "th,td": { - textAlign: "left", - py: "4px", - pr: "4px", - pl: 0, - borderColor: "muted", - borderBottomStyle: "solid", - }, - }, - th: { - verticalAlign: "bottom", - borderBottomWidth: "2px", - }, - td: { - verticalAlign: "top", - borderBottomWidth: "1px", - }, hr: { border: 0, borderBottom: "1px solid",