Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# api keys
/src/javascript/config.js

# misc
.DS_Store
3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
# GitHub Tracker

Replace this readme with your own information about your project.
This project was built to track all of the repositories that I have created during my time at Technigo. The main
purpose of this project is to display information about the projects that I have built using Githubs API.

Start by briefly describing the assignment in a sentence or two. Keep it short and to the point.
## The project

## The problem
I started off this project by fetching all of my repositories and data from GitHubs API. Once I had all the data
that I needed I dispayed it on multiple pages. One page focusing on displaying the repository data and the other to
display the commits data. This project also include a visualization of how many projects I have done so far, compared
to how many I will in total using Chart.js. Lastly, I styled the pages similar to the GitHubs page layout, with the
mind set of mobile first.

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?
If I had more time I would add a page for my pull requests data and I would like to add a search input so that users
can search for a specific repositiory. Also to include a dropdown button that allows users to filter through repos
based off of the language they are written in.

## Demo

https://savannah-github-tracker.netlify.app/

## 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.
4 changes: 0 additions & 4 deletions code/chart.js

This file was deleted.

21 changes: 0 additions & 21 deletions code/index.html

This file was deleted.

Empty file removed code/script.js
Empty file.
3 changes: 0 additions & 3 deletions code/style.css

This file was deleted.

54 changes: 54 additions & 0 deletions commits.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GitHub Tracker</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous"
rel="stylesheet">
<link rel="stylesheet" href="./src/stylesheets/commits.css" />
<link rel="stylesheet" href="./src/stylesheets/style.css" />
</head>

<body>
<header id="header" class="header"></header>
<main class="body-wrapper">
<div class="aside-chart">
<aside class="aside" id="aside"></aside>
<hr>
<div class="chart-wrapper">
<canvas class="chart" id="chart">
<p>Your browser does not support the canvas element.</p>
</canvas>
</div>
</div>

<section class="commits" id="commits">
<div class="html-links">
<a href="index.html" class="links">
<img src="./images/book.png" class="icons" alt="book icon"> Repositories
</a>
<a href="commits.html" class="links bold-link">
<img src="./images/box.png" class="icons" alt="box icon"> Contributions
</a>
</div>
<hr>
</section>
</main>

<hr>
<footer id="footer" class="footer footer-flex"></footer>

<script src="./src/javascript/chart.js"></script>
<script src="./src/javascript/config.js"></script>
<script src="./src/javascript/index.js"></script>
<script src="./src/javascript/commits.js"></script>
</body>

</html>
Binary file added images/book.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/box.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/fork.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/group.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/location.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/me.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/pr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>GitHub Tracker</title>
<link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin="anonymous"
rel="stylesheet">
<link rel="stylesheet" href="./src/stylesheets/repos.css" />
<link rel="stylesheet" href="./src/stylesheets/style.css" />
</head>

<body>
<header id="header" class="header"></header>
<main class="body-wrapper">
<aside class="aside" id="aside"></aside>
<section class="projects" id="projects">

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice use of semantic tags

<div class="html-links">
<a href="index.html" class="links bold-link">
<img src="./images/book.png" class="icons" alt="book icon"/> Repositories
</a>
<a href="commits.html" class="links">
<img src="./images/box.png" class="icons" alt="box icon"> Contributions
</a>
</div>
<hr>
</section>
</main>
<hr>
<footer id="footer" class="footer footer-flex"></footer>

<script src="./src/javascript/config.js"></script>
<script src="./src/javascript/index.js"></script>
<script src="./src/javascript/repos.js"></script>
</body>

</html>
36 changes: 36 additions & 0 deletions src/javascript/chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const displayChart = (projects) => {
const ctx = document.getElementById('chart');

const labels = [
'Projects completed',
'Projects left',
];

const data = {
labels: labels,
datasets: [{
label: 'My Projects at Technigo',
data: [projects, 19 - projects],
backgroundColor: [
'rgb(142, 85, 255)',
'rgb(142, 85, 255, 0.3)',
],
hoverOffset: 4
}]
};

const configuration = {
type: 'doughnut',
data: data,
options: {}
};

const myChart = new Chart(
ctx,
configuration
);
}




72 changes: 72 additions & 0 deletions src/javascript/commits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const commitsSection = document.getElementById("commits");

const fetchRepositories = (repositories) => {
const myRepos = repositories.filter((repo) => repo.fork && repo.name !== "unit-tests").length;
repositories.filter(repo => {
if (repo.fork && repo.name !== "unit-tests") {
fetchCommits(repo)
}
});
displayChart(myRepos);
};

const fetchCommitMessages = (commits, repository) => {
const repositoryName = repository.name;
const newCommits = commits.filter(commits => commits.commit.author.date.includes("2022"));

document.addEventListener("click", (event) => {
if (event.target.id === repositoryName) {
const repoClassname = `.${repositoryName}`;
document.querySelectorAll(repoClassname).forEach(name => {
if (name.style.display === "none") {
name.style.display = "block";
} else {
name.style.display = "none";
}
})
};
});

commitsSection.innerHTML += `
<div class="commits__text">
<div><p><a href="${repository.html_url}/commits" target="_blank">${username}/${repositoryName}</a></p></div>
<div class="progress">
<div class="progress-bar bg-success" role="progressbar" style="width: ${newCommits.length * 3}%"
aria-valuenow="${newCommits.length}" aria-valuemin="0" aria-valuemax="100">
</div>
</div>
<div>
<button type="button" id=${repositoryName} class="btn btn-secondary btn-sm dropdown-toggle"
data-bs-toggle="dropdown" aria-expanded="false">${newCommits.length} commits
</button>
</div>
</div>
`

for (let i = 0; i < newCommits.length; i++) {
const { message, committer, author } = newCommits[i].commit;
const { avatar_url } = newCommits[i].author;
const date = new Date(committer.date);
const formattedDate = date.toDateString().split(' ').slice(1).join(' ');

commitsSection.innerHTML += `
<div id="messageWrapper" class=${repositoryName} style="display: none">
<p class="text">${message}</p>
<p class="subtext"><img class="icons circle" src=${avatar_url} alt=${author.name}>
<span class="bold-text">${author.name} </span> <span class="hide-text">committed on ${formattedDate}</span></p>
</div>
`
}
};

fetch(REPOS_URL, options)
.then(res => res.json())
.then(data => fetchRepositories(data))
.catch(error => console.log(error))

const fetchCommits = (repo) => {
fetch(`${COMMITS_URL}${repo.name}/commits`, options)
.then(res => res.json())
.then(data => fetchCommitMessages(data, repo))
.catch(error => console.log(error))
};
71 changes: 71 additions & 0 deletions src/javascript/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
const profileDetails = document.getElementById("aside");
const header = document.getElementById("header");
const footer = document.getElementById("footer");

const username = "savannah-hayes";
const USER_URL = `https://api.github.com/users/${username}`;
const REPOS_URL = `https://api.github.com/users/${username}/repos`;
const COMMITS_URL = `https://api.github.com/repos/${username}/`;

const options = {
method: "GET",
headers: {
Authorization: `token ${API_TOKEN}`
}
};

const displayHeaderAndFooter = () => {
header.innerHTML = `
<div class="hamburger-wrapper">
<span class="hamburger"></span>
<span class="hamburger"></span>
<span class="hamburger"></span>
</div>
<h1>GitHub Tracker</h1>
<img src="./images/me.png" class="header__image" alt="small image of savannah hayes">
`

footer.innerHTML = `
<p class="footer__text footer-flex">
<img src="./images/github.png" class="footer__icon" alt="github icon">GitHub Tracker
</p>
<ul class="footer__links footer-flex">
<li class="footer__link footer-flex">Terms</li>
<li class="footer__link footer-flex">Privacy</li>
<li class="footer__link footer-flex">Security</li>
<li class="footer__link footer-flex footer__link--hide">About</li>
</ul>
`
};

const displayProfileData = (profileData) => {
const { avatar_url, name, login, bio, followers, following, location } = profileData;

@jjwwkkmm jjwwkkmm Mar 2, 2022

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice with destructuring! I guess it's to make these data available outside of this function as well as "props"?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Oh I get it now! These are values from the data retrieved in the fetch, so you reused them to simply display in the html. This was so clever.


profileDetails.innerHTML = `
<section class="aside__header">
<img src="${avatar_url}" class="aside__image" alt="image of ${name}"></img>
<div class="aside__text">
<h2 class="aside__title">${name}</h2>
<p class="aside__sub-title">${login}</p>
</div>
</section>
<section class="aside-content">
<p class="aside-content__paragraph aside-content__paragraph--top">${bio}</p>
<p class="aside-content__paragraph aside-content__paragraph--grey">
<img class="icons icons-left" src="./images/group.png" alt="three people icon">
<span class="aside-content__paragraph--bold">${followers}</span> followers ·
<span class="aside-content__paragraph--bold">${following}</span> following</p>
<p class="aside-content__paragraph">
<img class="icons icons-left" src="./images/location.png" alt="location pin icon">
</img> ${location}
</p>
</section>
`;
};

displayHeaderAndFooter();

fetch(USER_URL, options)
.then(res => res.json())
.then(data => displayProfileData(data))
.catch(error => console.log(error))
Loading