-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
206 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import React from 'react' | ||
import Ajax from '../../service/Ajax' | ||
import './GitRepos.scss' | ||
|
||
const gitUser = 'nntrn' | ||
|
||
const git = { | ||
user: 'nntrn', | ||
repo: 'react-mini-projects' | ||
} | ||
|
||
const api = { | ||
userRepos: `https://api.github.com/repos/${git.user}`, | ||
commits: `https://api.github.com/repos/${git.user}/${git.repo}/commits`, | ||
contents: `https://api.github.com/repos/${git.user}/${git.repo}/contents`, | ||
contributiors: `https://api.github.com/repos/${git.user}/${git.repo}/contributors` | ||
} | ||
|
||
function Avi(props) { | ||
return ( | ||
<div | ||
className={'flex before'} | ||
title={`${props.contributions} contributions by ${props.name} value=${props.contributions}`} | ||
> | ||
<div | ||
className={'avi'} | ||
style={props.img} | ||
name={props.name} | ||
contributions={props.contributions} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
class Repos extends React.Component { | ||
render() { | ||
const { repoName } = this.props | ||
|
||
const config = data => { | ||
return ( | ||
<div> | ||
{data.map((e, i) => { | ||
return ( | ||
<Avi | ||
key={i} | ||
url={e.avatar_url} | ||
img={{ backgroundImage: `url(${e.avatar_url})` }} | ||
name={e.login} | ||
contributions={e.contributions} | ||
/> | ||
) | ||
})} | ||
</div> | ||
) | ||
} | ||
return ( | ||
<Ajax | ||
url={`https://api.github.com/repos/${gitUser}/${repoName}/contributors`} | ||
config={config} | ||
/> | ||
) | ||
} | ||
} | ||
|
||
const parseDate = str => { | ||
return new Date(Date.parse(str)).toLocaleDateString() | ||
} | ||
|
||
class Github extends React.Component { | ||
render() { | ||
const { url } = this.props | ||
|
||
const config = data => { | ||
return ( | ||
<div id="github-activity"> | ||
<h2 className="project-title">github repo API</h2> | ||
{Object.entries(data).map((e, i) => { | ||
return ( | ||
<div key={e[0]} className="my"> | ||
<h3> | ||
<a href={data[i]['html_url']}>{data[i]['name']}</a> | ||
</h3> | ||
<div>{e[1].description}</div> | ||
<div className="before green" value="last updated: "> | ||
{parseDate(data[i]['updated_at'])} | ||
</div> | ||
<Repos repoName={data[i]['name']} /> | ||
</div> | ||
) | ||
})} | ||
</div> | ||
) | ||
} | ||
|
||
return <Ajax url={url} config={config} /> | ||
} | ||
} | ||
|
||
class GitRepos extends React.Component { | ||
render() { | ||
return <Github url="//api.github.com/users/nntrn/repos?sort=created" /> | ||
} | ||
} | ||
|
||
export default GitRepos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
$base: #222; | ||
$primary: #444; | ||
|
||
#github-activity { | ||
.section { | ||
margin: 1rem; | ||
border: 1px solid $base; | ||
} | ||
|
||
h3 { | ||
margin: 0; | ||
} | ||
|
||
.flex, | ||
.avi { | ||
display: inline-flex; | ||
flex-wrap: wrap; | ||
font-size: 0.8em; | ||
flex-direction: row; | ||
} | ||
|
||
.contributions { | ||
display: flex; | ||
flex-wrap: wrap; | ||
flex-direction: row; | ||
margin: 1rem 0; | ||
} | ||
|
||
.avi { | ||
border-radius: 50%; | ||
border: 2px solid lighten($base, 60%); | ||
margin: 0 0.25rem; | ||
width: 20px; | ||
height: 20px; | ||
background-position: center; | ||
background-repeat: no-repeat; | ||
background-size: cover; | ||
position: relative; | ||
display: flex; | ||
justify-content: center; | ||
align-content: center; | ||
align-items: center; | ||
|
||
&:hover:after { | ||
content: attr(name); | ||
position: absolute; | ||
font-size: 11px; | ||
bottom: 50%; | ||
line-height: 1; | ||
white-space: pre; | ||
color: white; | ||
background: black; | ||
padding: 0 0.25rem; | ||
z-index: 100; | ||
} | ||
} | ||
|
||
.repo-list { | ||
width: 250px; | ||
white-space: pre-wrap; | ||
|
||
.repo-name { | ||
color: $base; | ||
font-weight: bold; | ||
} | ||
|
||
.last-updated { | ||
color: $primary; | ||
} | ||
} | ||
|
||
.my { | ||
margin: 1rem 0.5rem; | ||
} | ||
|
||
:before { | ||
content: attr(value); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,8 @@ | |
} | ||
} | ||
} | ||
|
||
.project-title { | ||
display: flex; | ||
justify-content: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,9 @@ table { | |
border: 1px solid #ddd; | ||
} | ||
} | ||
|
||
.json { | ||
display: block; | ||
height: 40vh; | ||
overflow: scroll; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters