import { makeStyles } from "@material-ui/core/styles" import { FC, Fragment, ReactElement } from "react" import { MONOSPACE_FONT_FAMILY } from "../../theme/constants" import { combineClasses } from "../../util/combineClasses" export interface CodeBlockProps { lines: string[] ctas?: ReactElement[] className?: string } export const CodeBlock: FC = ({ lines, ctas, className = "" }) => { const styles = useStyles() return ( <>
{lines.map((line, idx) => (
{line}
))}
{ctas && ctas.length && (
{ctas.map((cta, i) => { return {cta} })}
)} ) } const useStyles = makeStyles((theme) => ({ root: { minHeight: 156, maxHeight: 240, overflowY: "scroll", background: theme.palette.background.default, color: theme.palette.text.primary, fontFamily: MONOSPACE_FONT_FAMILY, fontSize: 13, wordBreak: "break-all", padding: theme.spacing(2), borderRadius: theme.shape.borderRadius, }, line: { whiteSpace: "pre-wrap", }, ctaBar: { display: "flex", justifyContent: "space-between", }, }))