-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: use markdown renderer to show terms (#428)
* refactor: use markdown render to show terms * style: improve ui and markdown syntax --------- Co-authored-by: Tejasv Sharma <tejasvonly@gmail.com>
- Loading branch information
1 parent
c832848
commit dca3c4a
Showing
8 changed files
with
412 additions
and
1,837 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
66 changes: 66 additions & 0 deletions
66
cysync/src/designSystem/designComponents/textComponents/Markdown.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import Box from '@mui/material/Box'; | ||
import Link from '@mui/material/Link'; | ||
import Typography from '@mui/material/Typography'; | ||
import { shell } from 'electron'; | ||
import ReactMarkdown from 'markdown-to-jsx'; | ||
import * as React from 'react'; | ||
|
||
function MarkdownListItem(props: any) { | ||
return <Box component="li" sx={{ typography: 'body1' }} {...props} />; | ||
} | ||
|
||
const openExternalLink = (event: React.SyntheticEvent, link: string) => { | ||
event.preventDefault(); | ||
shell.openExternal(link); | ||
}; | ||
|
||
const ExternalLink: React.FC = ({ children }) => ( | ||
<Link | ||
href="#" | ||
onClick={e => openExternalLink(e, children.toString())} | ||
color="secondary" | ||
underline="hover" | ||
> | ||
{children} | ||
</Link> | ||
); | ||
|
||
const options = { | ||
overrides: { | ||
h1: { | ||
component: Typography, | ||
props: { | ||
color: 'textPrimary', | ||
variant: 'h3', | ||
gutterBottom: true, | ||
style: { fontWeight: 700, marginTop: '1.5rem' } | ||
} | ||
}, | ||
h2: { | ||
component: Typography, | ||
props: { | ||
color: 'textPrimary', | ||
variant: 'h5', | ||
gutterBottom: true, | ||
style: { fontWeight: 600, marginTop: '1rem' } | ||
} | ||
}, | ||
p: { | ||
component: Typography, | ||
props: { | ||
color: 'textPrimary', | ||
paragraph: true | ||
} | ||
}, | ||
a: { | ||
component: ExternalLink | ||
}, | ||
li: { | ||
component: MarkdownListItem | ||
} | ||
} | ||
}; | ||
|
||
export default function Markdown(props: any) { | ||
return <ReactMarkdown options={options} {...props} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.