Skip to content

Commit 5a9c8dc

Browse files
committed
first commit, fecth API, set up html-structure, script.js and chart.js
1 parent ded93a5 commit 5a9c8dc

4 files changed

Lines changed: 68 additions & 3 deletions

File tree

code/chart.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,26 @@
22
const ctx = document.getElementById('chart').getContext('2d')
33

44
//"Draw" the chart here 👇
5+
6+
const config = {
7+
type: 'doughnut',
8+
data: {
9+
labels: [
10+
'Red',
11+
'Blue',
12+
'Yellow'
13+
],
14+
datasets: [{
15+
label: 'My First Dataset',
16+
data: [300, 50, 100],
17+
backgroundColor: [
18+
'rgb(255, 99, 132)',
19+
'rgb(54, 162, 235)',
20+
'rgb(255, 205, 86)'
21+
],
22+
hoverOffset: 4
23+
}]
24+
}
25+
};
26+
27+
const myChart = new Chart (ctx, config);

code/index.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
<!DOCTYPE html>
22
<html lang="en">
3+
34
<head>
45
<meta charset="UTF-8">
56
<meta http-equiv="X-UA-Compatible" content="IE=edge">
67
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<title>Project GitHub Tracker</title>
8+
<title>Mamites GitHub Tracker</title>
89
<link rel="stylesheet" href="./style.css" />
910
</head>
11+
1012
<body>
11-
<h1>GitHub Tracker</h1>
12-
<h2>Projects:</h2>
13+
<header id="header">
14+
<h1>GitHub Tracker</h1>
15+
<h2>Projects:</h2>
16+
</header>
1317
<main id="projects"></main>
1418

1519
<!-- This will be used to draw the chart 👇 -->
1620
<canvas id="chart"></canvas>
1721

22+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
1823
<script src="./script.js"></script>
1924
<script src="./chart.js"></script>
25+
26+
2027
</body>
28+
2129
</html>

code/script.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const USER = 'mamite100'
2+
const REPOS_URL = `https://api.github.com/users/${USER}/repos`
3+
const projectsContainer = document.getElementById('projects')
4+
5+
6+
const getRepos = () => {
7+
fetch (REPOS_URL)
8+
.then(res => res.json())
9+
.then(data => {
10+
console.log(data)
11+
// data.forEach( repo => console.log (repo.name))
12+
const forkedRepos = data.filter(repo => repo.fork && repo.name.startsWith('project-') && ! repo.name.endsWith('github-tracker'))
13+
forkedRepos.forEach(repo =>
14+
projectsContainer.innerHTML +=`<h3> ${repo.name}</h3>`)
15+
})
16+
17+
}
18+
getRepos()
19+
20+
//Endpoint to get all PRs from a Technigo repo `https://api.github.com/repos/technigo/${reponame}/pulls`
21+
22+
//To get the comments from a PR, you need to get the URL from the `review_comments_url` property in the PR json object. It might look something like this: `https://api.github.com/repos/Technigo/project-news-site/pulls/247/comments`
23+
//and then do a fetch with that url.
24+
25+
//To get the commits from a PR, you need to get the URL from the `commits_url` property in the PR json object. It might look something like this:
26+
//`https://api.github.com/repos/Technigo/project-news-site/pulls/227/commits`
27+
// and then do a fetch with that url.

code/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
body {
22
background: #FFECE9;
3+
}
4+
5+
.project-grid {
6+
display: grid;
7+
border: 1px solid black;
8+
grid-template-columns: repeat(6, 1fr);
9+
310
}

0 commit comments

Comments
 (0)