Merge branch '14138-code-snippet'
[arvados-workbench2.git] / src / components / code-snippet / code-snippet.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import { StyleRulesCallback, WithStyles, Typography, withStyles, Theme } from '@material-ui/core';
7 import { ArvadosTheme } from '~/common/custom-theme';
8
9 type CssRules = 'root';
10
11 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
12     root: {
13         boxSizing: 'border-box',
14         width: '100%',
15         height: '550px',
16         overflow: 'scroll',
17         padding: theme.spacing.unit
18     }
19 });
20
21 export interface CodeSnippetDataProps {
22     lines: string[];
23 }
24
25 type CodeSnippetProps = CodeSnippetDataProps & WithStyles<CssRules>;
26
27 export const CodeSnippet = withStyles(styles)(
28     ({ classes, lines }: CodeSnippetProps) =>
29         <Typography component="div" className={classes.root}>
30             {
31                 lines.map((line: string, index: number) => {
32                     return <Typography key={index} component="div">{line}</Typography>;
33                 })
34             }
35         </Typography>
36     );