Skip to content
This repository has been archived by the owner on Mar 23, 2022. It is now read-only.

Commit

Permalink
FIX - Color not applied in table header (#229)
Browse files Browse the repository at this point in the history
Signed-off-by: RaenonX <[email protected]>
  • Loading branch information
RaenonX committed Aug 2, 2021
1 parent 31285c5 commit 5f65390
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/elements/markdown/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {renderLink} from './components/link';
import {renderListItem} from './components/listItem';
import {renderParagraph} from './components/paragraph';
import {renderStrong} from './components/strong';
import {renderTable, renderTableCell, renderTableRow} from './components/table';
import {renderTable, renderTableCell, renderTableHeader, renderTableRow} from './components/table';


// Key correspondences:
Expand All @@ -25,6 +25,7 @@ export const components: Components = {
h6: renderHeading,
strong: renderStrong,
table: renderTable,
th: renderTableHeader,
tr: renderTableRow,
td: renderTableCell,
li: renderListItem,
Expand Down
8 changes: 8 additions & 0 deletions src/components/elements/markdown/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ export const renderTable = ({children, node}: MarkdownComponentProps) => {
return <table>{children}</table>;
};

export const renderTableHeader = ({children}: MarkdownComponentProps) => (
<th>
<TextChildren>
{children}
</TextChildren>
</th>
);

export const renderTableRow: TableRowComponent = ({children}) => {
idxCounter = 0;

Expand Down
10 changes: 10 additions & 0 deletions src/components/elements/markdown/main.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ describe('Markdown', () => {
});

it('colors text in table', async () => {
const markdown = 'head | ::[red]col 2::\n:---: | :---:\nX | Y';

renderReact(() => <Markdown>{markdown}</Markdown>);

const headCell = screen.getByText('col 2', {selector: 'span'});
expect(headCell).toHaveStyle({color: 'red'});
expect(headCell.parentElement?.tagName).toBe('TH');
});

it('colors text in table header', async () => {
const markdown = 'head | col 2\n:---: | :---:\nX | ::[red]Y::';

renderReact(() => <Markdown>{markdown}</Markdown>);
Expand Down

0 comments on commit 5f65390

Please sign in to comment.