25b65c3fb7
* feat(wip): add basic feed operations * ci: bump checks * ci: bump checks * feat: rework stamps and add feed functionalities * refactor: polish and fixes * feat(wip): add formulas * feat: show bzz.link for websites * feat: add stamp empty states and formatBzz * feat: add feed download * chore: update manifest-js version * feat: dev mode support with bee-js 3.1.0 (#273) * feat: dev mode support with bee-js 3.1.0 * fix: added missing package-lock.json file * build: remove PR preview * style: work on design * feat: add TroubleshootConnectionCard * build: remove depcheck Co-authored-by: Attila Gazso <agazso@gmail.com>
39 lines
797 B
TypeScript
39 lines
797 B
TypeScript
import { createStyles, makeStyles, Theme } from '@material-ui/core'
|
|
import { ReactElement } from 'react'
|
|
|
|
interface Props {
|
|
children: string
|
|
prettify?: boolean
|
|
}
|
|
|
|
const useStyles = makeStyles((theme: Theme) =>
|
|
createStyles({
|
|
wrapper: {
|
|
overflow: 'scroll',
|
|
background: '#ffffff',
|
|
},
|
|
pre: {
|
|
maxHeight: '6em',
|
|
padding: theme.spacing(2),
|
|
},
|
|
}),
|
|
)
|
|
|
|
function prettifyString(string: string): string {
|
|
try {
|
|
return JSON.stringify(JSON.parse(string), null, 4)
|
|
} catch {
|
|
return string
|
|
}
|
|
}
|
|
|
|
export function Code({ children, prettify }: Props): ReactElement {
|
|
const classes = useStyles()
|
|
|
|
return (
|
|
<div className={classes.wrapper}>
|
|
<pre className={classes.pre}>{prettify ? prettifyString(children) : children}</pre>
|
|
</div>
|
|
)
|
|
}
|