Skip to content

Commit

Permalink
Create UserAvatar component w/ docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Sep 21, 2020
1 parent 6d9126b commit e8bd3db
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/components/UserAvatar/UserAvatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { useState, useEffect } from "react";
import PropTypes from "prop-types";
import { Avatar } from "@material-ui/core";

export default function UserAvatar({userName, userAlias}){

return(
<Avatar>
{userName === "" ? null : userName.charAt(0)}
</Avatar>
);
};

UserAvatar.propTypes = {
/** The name of the user. */
"userName": PropTypes.string
};

UserAvatar.defaultProps = {
"userName": ""
};
23 changes: 23 additions & 0 deletions src/components/UserAvatar/UserAvatar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
The UserAvatar displays a graphical representation of a person and is meant to be used in conjunction with other identifiers like names or emails.

---

The UserAvatar will the first letter of the `userName` prop.
```jsx
import UserAvatar from "./UserAvatar";
<UserAvatar userName="Justin Campbell" />
```

```jsx static
<UserAvatar userName="Justin Campbell" />
```

If no value, a null value, or an empty string is passed to the UserAvatar, it will fall back to a generic icon.
```jsx
import UserAvatar from "./UserAvatar";
<UserAvatar />
```

```jsx static
<UserAvatar />
```
3 changes: 3 additions & 0 deletions src/components/UserAvatar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import UserAvatar from "./UserAvatar";

export default UserAvatar;

0 comments on commit e8bd3db

Please sign in to comment.