Skip to content

Commit 48898ee

Browse files
committed
Finished codealong with mondays lecture
1 parent ded93a5 commit 48898ee

File tree

5 files changed

+63
-2
lines changed

5 files changed

+63
-2
lines changed

code/Untitled-1.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
TODO:
2+
3+
1) fetch the repos and console log them
4+
2) get them in the browser
5+
3) FILTHER OUT THE Technogo repos
6+
4) test chart library

code/chart.js

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

44
//"Draw" the chart here 👇
5+
6+
console.log ('chart is heart')
7+
8+
9+
10+
const drawChart = (amount) => {
11+
const config = {
12+
type: 'doughnut',
13+
data: {
14+
labels: [
15+
'Finished Projects',
16+
'Projects Left'
17+
],
18+
datasets: [{
19+
label: 'My First Dataset',
20+
data: [amount, 20-amount],
21+
backgroundColor: [
22+
'rgb(255, 99, 132)',
23+
'rgb(54, 162, 235)'
24+
],
25+
hoverOffset: 4
26+
}]
27+
},
28+
};
29+
30+
const myChart = new Chart(ctx, config)
31+
}

code/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>Project GitHub Tracker</title>
88
<link rel="stylesheet" href="./style.css" />
9+
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
910
</head>
1011
<body>
1112
<h1>GitHub Tracker</h1>
@@ -17,5 +18,7 @@ <h2>Projects:</h2>
1718

1819
<script src="./script.js"></script>
1920
<script src="./chart.js"></script>
21+
<!-- <script src="./token.js"></script> -->
22+
2023
</body>
2124
</html>

code/script.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const USER = 'silvertejp89'
2+
const REPOS_URL = `https://api.github.com/users/${USER}/repos`
3+
const projectContainer = document.getElementById('projects')
4+
5+
const getRepos = () => {
6+
fetch(REPOS_URL)
7+
.then(response => response.json())
8+
.then(data => {
9+
console.log(data) //so we can see all the info
10+
// data.forEach(repo => console.log(repo.name)) //Only the names
11+
const forkedRepos = data.filter(repo => repo.fork && repo.name.startsWith('project-')) //could be written as for example repo.fork ... === true (or false) but if you write nothing is true.
12+
forkedRepos.forEach(repo => projectContainer.innerHTML += `<h3>${repo.name}</h3>`)
13+
drawChart(forkedRepos.length)
14+
15+
})
16+
}
17+
getRepos() //invoking it
18+
19+
20+
21+
22+
23+
24+

code/style.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
body {
2-
background: #FFECE9;
3-
}
2+
background: #e9f3ff;
3+
}
4+

0 commit comments

Comments
 (0)