From 295c6e179ec0f14a10303e01fb6e5b5ef969db79 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sat, 21 Mar 2020 17:38:44 +0300
Subject: feat: add github avatars to users

---
 src/components/GithubAvatar/GithubAvatar.tsx | 35 ++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 src/components/GithubAvatar/GithubAvatar.tsx

(limited to 'src/components/GithubAvatar/GithubAvatar.tsx')

diff --git a/src/components/GithubAvatar/GithubAvatar.tsx b/src/components/GithubAvatar/GithubAvatar.tsx
new file mode 100644
index 0000000..6aab28e
--- /dev/null
+++ b/src/components/GithubAvatar/GithubAvatar.tsx
@@ -0,0 +1,35 @@
+import React from 'react';
+
+import {
+  Avatar,
+  Link,
+} from '@material-ui/core';
+
+interface PropTypes {
+  username: string;
+}
+
+const GithubAvatar: React.FC<PropTypes> = ({ username }) => {
+  if (username === 'anonymous') return <Avatar/>;
+
+  const githubUrl = `https://github.com/${username}`;
+  const avatarUrl = githubUrl + '.png';
+  const usernameTokens = username.split(/[ ,.\-_#@;]/g);
+  const altText = (
+    (usernameTokens.length > 1)?
+      (usernameTokens[0][0] + usernameTokens[1][0])
+    :
+      usernameTokens[0][0]
+  ).toUpperCase()
+
+  return (
+    <Link href={githubUrl}>
+      <Avatar>
+        <img src={avatarUrl} alt={altText} />
+      </Avatar>
+    </Link>
+  )
+};
+
+export default GithubAvatar;
+
-- 
cgit v1.2.3


From 5de3d6bc92a3dce752dad2ce2acc17071383b6fa Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sat, 21 Mar 2020 17:51:01 +0300
Subject: fix: bind link to developer name

---
 src/components/GithubAvatar/GithubAvatar.tsx | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

(limited to 'src/components/GithubAvatar/GithubAvatar.tsx')

diff --git a/src/components/GithubAvatar/GithubAvatar.tsx b/src/components/GithubAvatar/GithubAvatar.tsx
index 6aab28e..5daaac1 100644
--- a/src/components/GithubAvatar/GithubAvatar.tsx
+++ b/src/components/GithubAvatar/GithubAvatar.tsx
@@ -9,11 +9,14 @@ interface PropTypes {
   username: string;
 }
 
+const githubUrl = 'https://github.com/';
+const getUserGithubUrl = (username: string) => githubUrl + username;
+
 const GithubAvatar: React.FC<PropTypes> = ({ username }) => {
   if (username === 'anonymous') return <Avatar/>;
 
-  const githubUrl = `https://github.com/${username}`;
-  const avatarUrl = githubUrl + '.png';
+  const userGithubUrl = getUserGithubUrl(username);
+  const avatarUrl = userGithubUrl + '.png';
   const usernameTokens = username.split(/[ ,.\-_#@;]/g);
   const altText = (
     (usernameTokens.length > 1)?
@@ -23,7 +26,7 @@ const GithubAvatar: React.FC<PropTypes> = ({ username }) => {
   ).toUpperCase()
 
   return (
-    <Link href={githubUrl}>
+    <Link href={userGithubUrl}>
       <Avatar>
         <img src={avatarUrl} alt={altText} />
       </Avatar>
@@ -31,5 +34,6 @@ const GithubAvatar: React.FC<PropTypes> = ({ username }) => {
   )
 };
 
+export { getUserGithubUrl };
 export default GithubAvatar;
 
-- 
cgit v1.2.3


From c708ed105c580ed23bf27b6b5ed1e312ed139f57 Mon Sep 17 00:00:00 2001
From: eug-vs <eug-vs@keemail.me>
Date: Sat, 21 Mar 2020 17:59:30 +0300
Subject: fix: add missing return type

---
 src/components/GithubAvatar/GithubAvatar.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/components/GithubAvatar/GithubAvatar.tsx')

diff --git a/src/components/GithubAvatar/GithubAvatar.tsx b/src/components/GithubAvatar/GithubAvatar.tsx
index 5daaac1..32ac553 100644
--- a/src/components/GithubAvatar/GithubAvatar.tsx
+++ b/src/components/GithubAvatar/GithubAvatar.tsx
@@ -10,7 +10,7 @@ interface PropTypes {
 }
 
 const githubUrl = 'https://github.com/';
-const getUserGithubUrl = (username: string) => githubUrl + username;
+const getUserGithubUrl = (username: string): string => githubUrl + username;
 
 const GithubAvatar: React.FC<PropTypes> = ({ username }) => {
   if (username === 'anonymous') return <Avatar/>;
-- 
cgit v1.2.3

