Skip to content

Commit 0f8b8ed

Browse files
Camilla HallbergCamilla Hallberg
authored andcommitted
final touches, cleaned the code and removed console logs
1 parent d492f23 commit 0f8b8ed

3 files changed

Lines changed: 40 additions & 32 deletions

File tree

code/index.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,16 @@ <h1>GitHub Tracker</h1>
2727

2828
<section class="user-data" id="userData"></section>
2929

30-
<!-- behöver eventuellt inte klassen här-->
31-
<section class="project-headline">
30+
<section>
3231
<h2>&#128071;&#127997; Technigo Projects &#128071;&#127997;</h2>
3332
</section>
3433

3534
<section class="projects-wrapper" id="projects"></section>
3635

3736
<!-- This will be used to draw the chart 👇 -->
38-
<div id="canvas" class="chart-container">
37+
<section class="chart-container" id="canvas">
3938
<canvas id="chart"></canvas>
40-
</div>
39+
</section>
4140

4241
<footer class="made-by">
4342
<p>Made by Camilla Hallberg @ Technigo Bootcamp Spring 2022 <span style='font-size:16px;'>&#129302;</span></p>

code/script.js

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,59 @@
1-
// const userData = document.getElementsById('userData')
1+
// DOM selectors
2+
const projectsContainer = document.getElementById('projects')
3+
24
const username = 'CamillaHallberg'
35
let reponame = ''
46

7+
// Authentication
58
const API_TOKEN = TOKEN || process.env.API_KEY;
6-
7-
// API's
8-
const API_USER = `https://api.github.com/users/${username}`
9-
const API_URL_REPO = `https://api.github.com/users/${username}/repos`
10-
11-
const projectsContainer = document.getElementById('projects')
12-
139
const options = {
1410
method: 'GET',
1511
headers: {
1612
Authorization: `${API_TOKEN}`
1713
}
1814
}
15+
// API's
16+
const API_USER = `https://api.github.com/users/${username}`
17+
const API_URL_REPO = `https://api.github.com/users/${username}/repos`
1918

19+
// Function to fetch my user data
2020
const getUser = () => {
21-
fetch(API_USER, options)
22-
.then(res => res.json())
23-
.then(user => {
24-
console.log(user, 'my user');
21+
fetch(API_USER, options)
22+
.then(res => res.json())
23+
.then(user => {
2524
userData.innerHTML = `
2625
<div class="avatar">
27-
<img class="img" src="${user.avatar_url}" alt="user image">
26+
<img class="img" src="${user.avatar_url}" alt="user image">
2827
</div>
2928
<div class="info">
30-
<h3>${user.login}</h3>
31-
<h4>${user.bio}</h4>
32-
<h4>Location: ${user.location}</h4>
29+
<h3>${user.login}</h3>
30+
<h4>${user.bio}</h4>
31+
<h4>Location: ${user.location}</h4>
3332
</div>`
3433
})
3534
}
3635
getUser()
3736

37+
// Function to fetch my repositories
3838
const getRepos = () => {
3939
fetch(API_URL_REPO, options)
4040
.then(res => res.json())
4141
.then(data => {
42-
console.log(data, 'my repos')
43-
44-
// Filtering to get only my forked repos from Technigo
42+
// Filter to get only my forked repos from Technigo
4543
const forkedRepos = data.filter((repo) => repo.fork && repo.name.startsWith('project-'))
46-
console.log(forkedRepos, 'forked repos')
47-
44+
4845
forkedRepos.forEach((repo) => {
4946
// Creating unique ID for each forked repo
5047
let projectID = repo.id
51-
console.log(repo)
48+
5249
projectsContainer.innerHTML += `
5350
<div class="projects-card" id="${projectID}">
5451
<h3><a href="${repo.html_url}">${repo.name}</a></h3>
5552
<p class="default-branch">Branch: ${repo.default_branch}</p>
5653
<p>Latest push: ${new Date(repo.pushed_at).toDateString()}</p>
57-
</div>
58-
`
54+
</div>`
55+
56+
// Invoking function to get the number of commits for the projects
5957
getCommits(repo, projectID)
6058
})
6159
getPullRequests(forkedRepos)
@@ -84,6 +82,4 @@ const getCommits = (projectsContainer, projectID) => {
8482
})
8583
}
8684

87-
getRepos()
88-
89-
// Kom ihåg att städa i koden + ta bort alla loggar
85+
getRepos()

code/style.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ a {
6565
color: black;
6666
}
6767

68-
/* --- FOOTER --- */
68+
.chart-container {
69+
padding: 20px;
70+
}
71+
72+
/* --- Footer --- */
6973
.made-by {
7074
font-family: 'Shippori Antique B1', sans-serif;
7175
font-size: 12px;
@@ -147,4 +151,13 @@ a {
147151
h2 {
148152
font-size: 48px;
149153
}
154+
155+
.chart-container {
156+
position: relative;
157+
left: 0;
158+
right: 0;
159+
margin: auto;
160+
width: 600px;
161+
padding: 100px;
162+
}
150163
}

0 commit comments

Comments
 (0)