fix: use backstage theme for MarkdownContent

This commit is contained in:
Jesko Steinberg
2020-10-30 12:08:36 +01:00
parent ef8e3c20ac
commit bbc15f5112
2 changed files with 29 additions and 10 deletions
+6
View File
@@ -7,3 +7,9 @@ Adds the MarkdownContent component to render and display markdown input.
```
<MarkdownContent content={markdown} />
```
Render and display the github flavored markdown [GFM](https://github.github.com/gfm/) input:
```
<MarkdownContent content={markdownGithubFlavored} enableGfm />
```
@@ -18,35 +18,48 @@ import { makeStyles } from '@material-ui/core';
import ReactMarkdown from 'react-markdown';
import gfm from 'remark-gfm';
import React from 'react';
import { BackstageTheme } from '@backstage/theme';
const useStyles = makeStyles(theme => ({
const useStyles = makeStyles<BackstageTheme>(theme => ({
markdown: {
'& table': {
borderCollapse: 'collapse',
border: '1px solid #dfe2e5',
color: 'rgb(36, 41, 46)',
border: `1px solid ${theme.palette.border}`,
},
'& th, & td': {
border: '1px solid #dfe2e5',
border: `1px solid ${theme.palette.border}`,
padding: theme.spacing(1),
},
'& td': {
wordBreak: 'break-word',
overflow: 'hidden',
verticalAlign: 'middle',
lineHeight: '1',
margin: 0,
padding: theme.spacing(3, 2, 3, 2.5),
borderBottom: 0,
},
'& th': {
backgroundColor: theme.palette.background.paper,
},
'& tr': {
backgroundColor: '#fff',
backgroundColor: theme.palette.background.paper,
},
'& tr:nth-child(2n)': {
backgroundColor: '#f6f8fa',
'& tr:nth-child(odd)': {
backgroundColor: theme.palette.background.default,
},
'& pre': {
padding: '16px',
overflow: 'auto',
fontSize: '85%',
lineHeight: 1.45,
backgroundColor: '#f6f8fa',
backgroundColor: theme.palette.code.background,
borderRadius: '6px',
color: 'rgba(0, 0, 0, 0.87)',
color: theme.palette.code.text,
},
'& a': {
color: '#2E77D0',
color: theme.palette.link,
},
'& img': {
maxWidth: '100%',