1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 07:16:36 +01:00
metamask-extension/ui/components/app/snaps/snap-ui-markdown/snap-ui-markdown.js
Dhruv a10fb75f35
replacing deprecated components and consts (#19563)
Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2023-07-25 13:22:26 -07:00

38 lines
824 B
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import ReactMarkdown from 'react-markdown';
import {
TextVariant,
OverflowWrap,
} from '../../../../helpers/constants/design-system';
import { Text } from '../../../component-library';
const Paragraph = (props) => (
<Text
{...props}
variant={TextVariant.bodyMd}
className="snap-ui-markdown__text"
overflowWrap={OverflowWrap.BreakWord}
/>
);
export const SnapUIMarkdown = ({ children, markdown }) => {
if (markdown === false) {
return <Paragraph>{children}</Paragraph>;
}
return (
<ReactMarkdown
allowedElements={['p', 'strong', 'em']}
components={{ p: Paragraph }}
>
{children}
</ReactMarkdown>
);
};
SnapUIMarkdown.propTypes = {
children: PropTypes.string,
markdown: PropTypes.bool,
};