Skip to content

Commit

Permalink
🍽 Improve styling of table and table legend (#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 authored Nov 30, 2023
1 parent 3426738 commit b6601f7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/dull-socks-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-to-react': patch
---

Add legend handler for containers
5 changes: 5 additions & 0 deletions .changeset/old-cherries-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'myst-to-react': patch
---

Table styles and classes added
16 changes: 12 additions & 4 deletions packages/myst-to-react/src/basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ type BasicNodeRenderers = {
listItem: NodeRenderer<spec.ListItem & { checked?: boolean }>;
container: NodeRenderer<spec.Container>;
caption: NodeRenderer<spec.Caption>;
legend: NodeRenderer<spec.Legend>;
blockquote: NodeRenderer<spec.Blockquote>;
thematicBreak: NodeRenderer<spec.ThematicBreak>;
subscript: NodeRenderer<spec.Subscript>;
Expand Down Expand Up @@ -229,6 +230,13 @@ const BASIC_RENDERERS: BasicNodeRenderers = {
</figcaption>
);
},
legend({ node }) {
return (
<figcaption className="text-sm">
<MyST ast={node.children} />
</figcaption>
);
},
blockquote({ node }) {
return (
<blockquote id={node.html_id}>
Expand All @@ -254,7 +262,7 @@ const BASIC_RENDERERS: BasicNodeRenderers = {
table({ node }) {
// TODO: actually render the tbody on the server if it isn't included here.
return (
<table>
<table className={node.class} style={node.style}>
<tbody>
<MyST ast={node.children} />
</tbody>
Expand All @@ -263,7 +271,7 @@ const BASIC_RENDERERS: BasicNodeRenderers = {
},
tableRow({ node }) {
return (
<tr>
<tr className={node.class} style={node.style}>
<MyST ast={node.children} />
</tr>
);
Expand All @@ -276,12 +284,12 @@ const BASIC_RENDERERS: BasicNodeRenderers = {
};
if (node.header)
return (
<th {...attrs}>
<th className={node.class} style={node.style} {...attrs}>
<MyST ast={node.children} />
</th>
);
return (
<td {...attrs}>
<td className={node.class} style={node.style} {...attrs}>
<MyST ast={node.children} />
</td>
);
Expand Down

0 comments on commit b6601f7

Please sign in to comment.