Skip to content

Commit

Permalink
fix columnar alignment on tables
Browse files Browse the repository at this point in the history
  • Loading branch information
thedannywahl committed Mar 1, 2024
1 parent 5c0a593 commit 2efc5b1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion isp-site/src/components/mdtoui.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ const filterChildrenProps = (props) => {
);
};

const alignStr = (p) => {
return (
p?.style?.textAlign.replace(/\b(left|right)\b/, (s) =>
s === "left" ? "start" : "end",
) ?? "start"
);
};

const mdtoui = {
hr: ({ node, ...props }) => (
<View
Expand Down Expand Up @@ -180,6 +188,7 @@ const mdtoui = {
<Table.ColHeader
key={child.key}
id={child.key}
textAlign={alignStr(child.props)}
{...child.props}
/>
);
Expand All @@ -197,7 +206,12 @@ const mdtoui = {
return (
<Table.Row {...tbrProps}>
{Children.map(children, (child) => {
return <Table.Cell {...child.props} />;
return (
<Table.Cell
textAlign={alignStr(child.props)}
{...child.props}
/>
);
})}
</Table.Row>
);
Expand Down

0 comments on commit 2efc5b1

Please sign in to comment.