1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { StyleRulesCallback, WithStyles, Typography, withStyles } from '@material-ui/core';
7 import { ArvadosTheme } from '~/common/custom-theme';
8 import classNames from 'classnames';
10 type CssRules = 'root' | 'space';
12 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
14 boxSizing: 'border-box',
16 padding: theme.spacing.unit
23 export interface CodeSnippetDataProps {
26 apiResponse?: boolean;
29 type CodeSnippetProps = CodeSnippetDataProps & WithStyles<CssRules>;
31 export const CodeSnippet = withStyles(styles)(
32 ({ classes, lines, className, apiResponse }: CodeSnippetProps) =>
35 className={classNames(classes.root, className)}>
37 lines.map((line: string, index: number) => {
38 return <Typography key={index} className={apiResponse ? classes.space : className} component="pre">{line}</Typography>;