Skip to content

Commit

Permalink
Create Assignment component w/ docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Oct 13, 2020
1 parent 08e2672 commit fe2ebf8
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/components/Assignment/Assignment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react";
import PropTypes from "prop-types";
import { Typography } from "@material-ui/core";
import RelativeTime from "react-relative-time";

export default function Assignment({ by, to, datetime }){
return (
<Typography>
<b>{by}</b> assigned this to <b>{to}</b> <RelativeTime value={new Date(datetime)} />
</Typography>
);
}

Assignment.propTypes = {
/** The person who changed the assignment. */
"by": PropTypes.string.isRequired,
/** The person the item was assigned to. */
"to": PropTypes.string.isRequired,
/** The time the assignment was changed in ISO 8601 format. */
"datetime": PropTypes.string.isRequired
}
26 changes: 26 additions & 0 deletions src/components/Assignment/Assignment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Renders a string representation of an assignment with a relative time.

```jsx
import Assignment from "./Assignment";

const example_assignment = {
"type": "assignment",
"datetime": "2020-06-23T13:27:00-0400",
"by": "campb303",
"to": "campb303"
};

<Assignment {...example_assignment} />

```

```jsx static
const example_assignment = {
"type": "assignment",
"datetime": "2020-06-23T13:27:00-0400",
"by": "campb303",
"to": "campb303"
};

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

0 comments on commit fe2ebf8

Please sign in to comment.