@@ -3,30 +3,21 @@ import { styled } from 'styled-components';
33import remarkGFM from 'remark-gfm' ;
44import { Button } from '../Button' ;
55import { truncateMarkdown } from '../../helpers/markdown' ;
6- import { useState } from 'react' ;
6+ import { FC , useState } from 'react' ;
77
88type Props = {
99 text : string ;
10- /**
11- * By default, all bottom Markdown elements have some margin (e.g. the last
12- * paragraph). If you set noMargin, this is corrected.
13- */
14- noMargin ?: boolean ;
1510 renderGFM ?: boolean ;
1611 /**
1712 * If this is set, and the markdown is more characters than this number, the
1813 * text will be truncated and a button will be shown
1914 */
2015 maxLength ?: number ;
16+ className ?: string ;
2117} ;
2218
2319/** Renders a markdown value */
24- function Markdown ( {
25- text,
26- noMargin,
27- renderGFM,
28- maxLength,
29- } : Props ) : JSX . Element | null {
20+ const Markdown : FC < Props > = ( { text, renderGFM, maxLength, className } ) => {
3021 const [ collapsed , setCollapsed ] = useState ( true ) ;
3122
3223 maxLength = maxLength || 5000 ;
@@ -36,7 +27,7 @@ function Markdown({
3627 }
3728
3829 return (
39- < MarkdownWrapper noMargin = { noMargin } >
30+ < MarkdownWrapper className = { className } >
4031 < ReactMarkdown remarkPlugins = { renderGFM ? [ remarkGFM ] : [ ] } >
4132 { collapsed ? truncateMarkdown ( text , maxLength ) : text }
4233 </ ReactMarkdown >
@@ -47,19 +38,14 @@ function Markdown({
4738 ) }
4839 </ MarkdownWrapper >
4940 ) ;
50- }
41+ } ;
5142
5243Markdown . defaultProps = {
5344 renderGFM : true ,
5445} ;
5546
56- interface MarkdownWrapperProps {
57- noMargin ?: boolean ;
58- }
59-
60- const MarkdownWrapper = styled . div < MarkdownWrapperProps > `
47+ const MarkdownWrapper = styled . div `
6148 /* Corrects the margin added by <p> and other HTML elements */
62- margin-bottom: -${ p => ( p . noMargin ? p . theme . margin : 0 ) } rem;
6349
6450 width: 100%;
6551 overflow-x: hidden;
0 commit comments