Skip to content

Commit beea044

Browse files
Camilla HallbergCamilla Hallberg
authored andcommitted
list of repos, most recent push, default branch, url to repo added
1 parent b503989 commit beea044

3 files changed

Lines changed: 53 additions & 29 deletions

File tree

code/index.html

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
<meta charset="UTF-8">
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<title>Camillas GitHub Tracker</title>
87
<link rel="stylesheet" href="./style.css" />
8+
<!-- Google Fonts -->
99
<link rel="preconnect" href="https://fonts.googleapis.com">
1010
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
1111
<link href="https://fonts.googleapis.com/css2?family=Shippori+Antique+B1&family=Shizuru&display=swap" rel="stylesheet">
12+
<title>GitHub Tracker by Camilla</title>
1213
</head>
14+
1315
<body>
1416
<header>
1517
<h1>GitHub Tracker</h1>
@@ -18,22 +20,14 @@ <h1>GitHub Tracker</h1>
1820
<section class="userData" id="userData"></section>
1921

2022
<main id="projects">
21-
<h2>Projects</h2>
23+
<h2>&#128071;&#127997; Projects &#128071;&#127997;</h2>
2224
</main>
23-
24-
25-
26-
27-
28-
25+
2926
<!-- This will be used to draw the chart 👇 -->
3027
<canvas id="chart"></canvas>
3128

32-
33-
<footer class="footer">
34-
<div class="made-by">
29+
<footer class="made-by">
3530
<p>Made by Camilla Hallberg @ Technigo Bootcamp Spring 2022 <span style='font-size:16px;'>&#129302;</span></p>
36-
</div>
3731
</footer>
3832

3933
<script src="./chart.js"></script>

code/script.js

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
const username = 'CamillaHallberg'
33
let reponame = ''
44

5+
const API_TOKEN = TOKEN || process.env.API_KEY;
6+
// console.log(TOKEN)
7+
58
// API's
69
const API_USER = `https://api.github.com/users/${username}`
710
const API_URL_REPO = `https://api.github.com/users/${username}/repos`
8-
const API_URL_PR = `https://api.github.com/repos/Technigo/${reponame}/pulls`
911

10-
// my token
11-
const API_TOKEN = TOKEN;
12-
// console.log(TOKEN)
12+
const projectsContainer = document.getElementById('projects')
13+
1314

1415
const options = {
1516
method: 'GET',
@@ -40,8 +41,21 @@ const getRepos = () => {
4041
.then(data => {
4142
console.log(data, 'my repos')
4243

44+
// Filtering to get only my forked repos
4345
const forkedRepos = data.filter((repo) => repo.fork && repo.name.startsWith('project-'))
4446
console.log(forkedRepos, 'forked repos')
47+
48+
forkedRepos.forEach((repo) => {
49+
projectsContainer.innerHTML += `
50+
<div class="projects-card" id="${repo.id}">
51+
<h3><a href="${repo.html_url}">${repo.name}</a> - ${repo.default_branch}</h3>
52+
<p>Latest push: ${new Date(repo.pushed_at).toDateString()}</p>
53+
<p id="commit_${repo.name}">Number of commits:</p>
54+
<p>Main language: ${repo.language}</p>
55+
</div>
56+
`
57+
})
58+
4559
getPullRequests(forkedRepos)
4660
})
4761
}
@@ -51,11 +65,22 @@ const getPullRequests = (forkedRepos) => {
5165
fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls?per_page=150`, options)
5266
.then(res => res.json())
5367
.then(data => {
54-
// console.log(data, 'all pull requests on the projects')
55-
68+
const commits = document.getElementById(`commit-${repo.name}`)
69+
5670
const pulls = data.find((pull) => pull.user.login === repo.owner.login)
57-
console.log(pulls, 'my pull requests')
71+
72+
getCommits(pulls.commits_url, repo.name)
73+
console.log(pulls.commits_url)
5874
})
5975
})
6076
}
61-
getRepos()
77+
78+
const getCommits = (myCommitsURL, myReposName) => {
79+
fetch(myCommitsURL, options)
80+
.then(res => res.json())
81+
.then(data => {
82+
document.getElementById(`commit-${myReposName}`).innerHTML += data.length
83+
})
84+
}
85+
86+
getRepos()

code/style.css

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ body {
44

55
h1 {
66
font-family: 'Shizuru', cursive;
7-
font-size: 48px;
7+
font-size: 72px;
88
color:palevioletred;
99
text-align: center;
10+
cursor: pointer;
1011
}
1112

1213
h2 {
@@ -16,27 +17,31 @@ h2 {
1617
text-align: center;
1718
}
1819

19-
.img {
20-
width: 96px;
21-
border-radius: 50%;
22-
border: 8px solid floralwhite;
23-
}
24-
2520
h3 {
2621
font-family: 'Shippori Antique B1', sans-serif;
2722
font-size: 18px;
2823
color: #886F6F;
29-
text-align: center;
3024
}
3125

3226
h4 {
3327
font-family: 'Shippori Antique B1', sans-serif;
3428
font-size: 14px;
3529
color: whitesmoke;
30+
}
31+
32+
.info {
33+
display: flex;
34+
flex-direction: column;
3635
text-align: center;
3736
}
3837

39-
/* Footer styling */
38+
.img {
39+
width: 96px;
40+
border-radius: 50%;
41+
border: 8px solid floralwhite;
42+
}
43+
44+
/* Footer Styling */
4045
.made-by {
4146
font-family: 'Shippori Antique B1', sans-serif;
4247
font-size: 12px;

0 commit comments

Comments
 (0)