Skip to content

Commit

Permalink
feat: add avatar component (#127)
Browse files Browse the repository at this point in the history
Add avatar component with default letter avatar story
  • Loading branch information
amalv authored Dec 11, 2019
1 parent 19df3aa commit 73040ca
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ module.exports = {
typescript: {},
},
},

rules: {
"import/extensions": [
"error",
"always",
{
ts: "never",
tsx: "never",
},
],
"react/jsx-filename-extension": [
2,
{ extensions: [".js", ".jsx", ".ts", ".tsx"] },
Expand Down
8 changes: 8 additions & 0 deletions src/components/Avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import * as React from "react";
import { Avatar } from "./Avatar";

export default {
title: "Avatar",
};

export const Default: React.FC = () => <Avatar />;
17 changes: 17 additions & 0 deletions src/components/Avatar.styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import styled from "styled-components";
import MaterialUIAvatar from "@material-ui/core/Avatar";
import { deepOrange } from "@material-ui/core/colors";

interface BaseButtonProps {
textcolor?: string | undefined;
backgroundcolor?: string | undefined;
bordercolor?: string | undefined;
}

export const AvatarStyled = styled(MaterialUIAvatar)<BaseButtonProps>`
width: 83px;
height: 83px;
border: 3px solid #985eff;
background-color: ${({ backgroundcolor }): string => backgroundcolor || deepOrange[500]};
color: ${({ textcolor }): string => textcolor || "white"};
`;
9 changes: 9 additions & 0 deletions src/components/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as React from "react";
import { StylesProvider } from "@material-ui/core/styles";
import { AvatarStyled } from "./Avatar.styles";

export const Avatar: React.FC = () => (
<StylesProvider injectFirst>
<AvatarStyled>CB</AvatarStyled>
</StylesProvider>
);

1 comment on commit 73040ca

@vercel
Copy link

@vercel vercel bot commented on 73040ca Dec 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.