diff options
author | eug-vs <eug-vs@keemail.me> | 2020-03-21 17:51:01 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-03-21 17:51:56 +0300 |
commit | 5de3d6bc92a3dce752dad2ce2acc17071383b6fa (patch) | |
tree | 75aca58fa856364abce367fa9c928b40adfb9dd6 /src | |
parent | 295c6e179ec0f14a10303e01fb6e5b5ef969db79 (diff) | |
download | chrono-cube-ui-5de3d6bc92a3dce752dad2ce2acc17071383b6fa.tar.gz |
fix: bind link to developer name
Diffstat (limited to 'src')
-rw-r--r-- | src/components/GithubAvatar/GithubAvatar.tsx | 10 | ||||
-rw-r--r-- | src/pages/Contribute/Contribute.tsx | 4 |
2 files changed, 9 insertions, 5 deletions
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; diff --git a/src/pages/Contribute/Contribute.tsx b/src/pages/Contribute/Contribute.tsx index 77228a1..67f2b8a 100644 --- a/src/pages/Contribute/Contribute.tsx +++ b/src/pages/Contribute/Contribute.tsx @@ -15,7 +15,7 @@ import BugReportIcon from '@material-ui/icons/BugReport'; import NewReleasesIcon from '@material-ui/icons/NewReleases'; import { Window, ContentSection } from 'react-benzin'; -import GithubAvatar from '../../components/GithubAvatar/GithubAvatar'; +import GithubAvatar, { getUserGithubUrl } from '../../components/GithubAvatar/GithubAvatar'; import developers from '../../developers.json'; @@ -116,7 +116,7 @@ const Contribute: React.FC = () => { <ListItem> <GithubAvatar username={developer.username} /> <div> - <Link href="#">{developer.username}</Link> + <Link href={getUserGithubUrl(developer.username)}>{developer.username}</Link> <Typography component="div" color="textSecondary"> {developer.role} </Typography> |