Skip to content

Commit

Permalink
Create DirectoryInformation component with docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Oct 12, 2020
1 parent 29a5340 commit e503d26
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/components/DirectoryInformation/DirectoryInformation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from "react";
import PropTypes from "prop-types";
import { TableContainer, Table, TableRow, TableCell, makeStyles } from "@material-ui/core";

export default function DirectoryInformation({ section }) {

const useStyles = makeStyles(() => ({
breakWord: {
wordBreak: "break-word",
}
}));
const classes = useStyles();

return (
<TableContainer>
<Table size="small" >
{Object.keys(section).map((key) => (
key === "type" ? "" :
<TableRow>
<TableCell variant="head">{key}</TableCell>
<TableCell classes={{ root: classes.breakWord }}>{section[key]}</TableCell>
</TableRow>
))}
</Table>
</TableContainer>
);
};

DirectoryInformation.propTypes = {
/** The object containing directory information. */
"section": PropTypes.object
};

DirectoryInformation.defaultProps = {
"section": {}
};
31 changes: 31 additions & 0 deletions src/components/DirectoryInformation/DirectoryInformation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Displays the directory information as a table.


```jsx
import { Paper } from "@material-ui/core";
import DirectoryInformation from "./DirectoryInformation";

const example_directory_data = {
"type": "directory_information",
"Name": "Heyi Feng",
"Login": "feng293",
"Computer": "civil4147pc2.ecn",
"Location": "HAMP 4147",
"Email": "feng293@purdue.edu",
"Phone": "5039154835",
"Office": "",
"UNIX Dir": "None",
"Zero Dir": "U=\\\\myhome.itap.purdue.edu\\myhome\\%username%",
"User ECNDB": "http://eng.purdue.edu/jump/2e29495",
"Host ECNDB": "http://eng.purdue.edu/jump/2eccc3f",
"Subject": "Upgrade system and Abaqus"
};

<Paper>
<DirectoryInformation section={example_directory_data} />
</Paper>
```

```jsx static
<DirectoryInformation section={example_directory_data} />
```
1 change: 1 addition & 0 deletions src/components/DirectoryInformation/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "./DirectoryInformation";

0 comments on commit e503d26

Please sign in to comment.