Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# GitHub Tracker

Replace this readme with your own information about your project.

Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.
The assignment was to make a github-tracker, a page which shows your profile picture, username and information about your projects, pullrequests and commits. We also learned how to incorporate charts in our work.

## The problem

Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next?

Fortunately I have a couple of people I study with, who help me a lot when I'm stuck. I started by watching the videos by our teachers, and then the recordings of our classes. This helped since I could rewind and watch again if something was unclear. I've also used StackOverflow for some guidance.

This week I've used a page to help me with the colorschemes for my page and this is the link: https://coolors.co/
I've also learned how to do shading in css which was cool. Hopefully my javascript aha-moment is just a couple of weeks away!


## View it live

Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about.
https://githubtracker-ninaalejandra.netlify.app/
10 changes: 10 additions & 0 deletions code/TODO-list:
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TODO-list:

1) fetch the repos and console log them x
2) get them in the browser x
3) filter out the technigo repos x
4) test chart library x
5) add pullrequests x
6) add profile pic x
7) add commits x
8) style x
22 changes: 22 additions & 0 deletions code/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,25 @@
const ctx = document.getElementById('chart').getContext('2d')

//"Draw" the chart here 👇
const drawChart = (amount) => {
const config = {
type: 'doughnut',
data: {
labels: [
'Finished Projects',
'Projects Left'
],
datasets: [{
label: 'My First Dataset',
data: [amount, 20-amount],
backgroundColor: [
'#AD5D4E',
'#218380'
],
hoverOffset: 4
}]
},
}

const myChart = new Chart(ctx, config)
}
24 changes: 19 additions & 5 deletions code/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,28 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Project GitHub Tracker</title>
<link rel="stylesheet" href="./style.css" />
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Gemunu+Libre:wght@300&display=swap" rel="stylesheet">
</head>

<body>
<h1>GitHub Tracker</h1>
<h2>Projects:</h2>
<main id="projects"></main>
<header>
<h1>GitHub Tracker</h1>
</header>

<div class="profile" id="profile">
</div>

<main class="Projects">
<h2 id="projects"></h2>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

it doesn't seem like this h2 is visible in the page? is it maybe behind some object or just invisible? 🤔

<list id="list"></list>
</main>

<!-- This will be used to draw the chart 👇 -->
<canvas id="chart"></canvas>
<div class="chart-class">
<canvas id="chart"></canvas>
</div>

<script src="./script.js"></script>
<script src="./chart.js"></script>
Expand Down
70 changes: 70 additions & 0 deletions code/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//DOM-selectors
const profileInfo = document.getElementById("profile")
const list = document.getElementById("list")

//Github
const USER = 'NinaAlejandra'
const REPOS_URL = `https://api.github.com/users/${USER}/repos`
const API_MY_PROFILE = 'https://api.github.com/users/NinaAlejandra'

//User
const getUser = () => {
fetch(API_MY_PROFILE)
.then((response) => response.json())
.then((data) => {
profileInfo.innerHTML =
`<img src="https://github.com/NinaAlejandra.png" alt="Profile picture">
<h4> ${data.name}</h4>
<h4> <a href="${data.html_url}">${data.login}</a></h4>`
})
}

//Fetches
const getRepos = () => {
fetch(REPOS_URL)
.then(response => response.json())
.then(data => {
const forkedRepos = data.filter(repo => repo.fork && repo.name.startsWith('project-'))
const forkedSortedRepos = forkedRepos.sort(sortingFunctionFromStackOverflow)
forkedSortedRepos.forEach(repo => list.innerHTML += `
<div class="projects">
<h3><a href="${repo.html_url}">${repo.name}
with default branch ${repo.default_branch}</h3></a>
<p>Recent push: ${new Date(repo.pushed_at).toDateString()}</p>
<p id="pull-request-${repo.name}"></p>
<p id="commits-${repo.name}"></p>
</div>`)
drawChart(forkedSortedRepos.length)
fetchPullRequest(forkedSortedRepos)
addCommits(forkedSortedRepos)
})
}

const fetchPullRequest = (allRepos) => {
allRepos.forEach(repo => {
fetch(`https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100`)
.then((res) => res.json())
.then((data) => {
const myPullRequests = data.filter((pullRequest) => pullRequest.user.login === USER)
document.getElementById(`pull-request-${repo.name}`).innerHTML = `Pull Requests: ${myPullRequests.length}`
})
})
}

const addCommits = (allRepos) => {
allRepos.forEach(repo => {
fetch(`https://api.github.com/repos/${USER}/${repo.name}/commits`)
.then((res) => res.json())
.then((data) => {
document.getElementById(`commits-${repo.name}`).innerHTML = `Commits: ${data.length}`
})
})
}

function sortingFunctionFromStackOverflow(a, b) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is a very nice function! I forgot to use it, I really should add it. 😊

return new Date(a.created_at) - new Date(b.created_at)
}

//invoking functions
getUser()
getRepos()
85 changes: 83 additions & 2 deletions code/style.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,84 @@
body {
background: #FFECE9;
}
background: #F7D4BC;
font-family: 'Gemunu Libre', sans-serif;
}

header {
text-align: center;
font-size: 30px;
}

.profile {
align-items: center;
justify-content: center;
display: flex;
text-align:center;
color: #218380;
margin:auto;
width: 100%;
flex-direction: column;
}

img {
border-radius: 50%;
width: 200px;
margin: 15px;
box-shadow: -30px 30px 30px rgba(0, 0, 0, 0.3);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It's nice that you added a shadow to your profile image! the shadow looks a little bit "off" from the shape of the image, a suggestion is to play around a little with the value-numbers of the shadows. I also worked a while to figure out the numbers to make the shadow, its tricky! 😊

}

p {
color: #AD5D4E;
}

.projects {
flex-direction: column;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I like your responsiveness of the project-boxes! Since it seems like you have already declared the .projectbox to be display: flex I think that the display: block doesn't do anything in this part? I tried to remove it in the inspector and it seems to no change anything. just a suggestion of you want to have a little bit less code 😊

display: block;
border-style: solid;
color: #AD5D4E;
margin: 5px;
text-align: center;
}

.chart-class {
width: 50%;
display: flex;
align-items: center;
justify-content: center;
Comment on lines +42 to +46

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The chart was very tricky to style because it doesn't really listen to whatever you style it to like other element, I also tried to style it with flex and with different align-item and justify-content etc but nothing actually happened. The only thing that seems to work is the margin: auto; that you have, the other properties could actually be removed I think. (could be worth try to remove it to have a cleaner code) I also just set a width in % and then align-self: center to make it centered and not being huge, that worked for me at least 🙂

margin: auto;
cursor: pointer;
}

h4 {
font-size: 25px;
margin: 5px;
font-weight: bolder;
}

a {
font-size: 18px;
color: #218380;
}

a:hover {
color:#74a09f;
}

@media (min-width: 668px){

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you have great responsiveness in mobile and tablet but I think it would be great to add another media query for desktops and bigger, it works as it is but the project boxes becomes a little bit too stretched and the chart is huge 😄

main {
text-align: center;
flex-direction: row;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It seems like this one get overwritten in the inspector tool by the display: block element so it doesn't actually serve anything. tips is to check the inspector and try to remove and add to see if anything happens 😊

}

.projects {
display: inline-block;
text-align: center;
padding: 5px;
width: 33%;
height: 50%;
}

.chart-class {
width: 40%;
margin-top: 20px;
}
}