Skip to content

Commit 07f830c

Browse files
committed
modified background image + footer and hard coded the fetch for commits for Project Chatbot
1 parent 7095832 commit 07f830c

File tree

4 files changed

+28
-32
lines changed

4 files changed

+28
-32
lines changed

code/chart.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const drawChart = (amount) => {
1010
],
1111
datasets: [{
1212
label: 'Technigo progress',
13-
data: [amount, 20-amount],
13+
data: [amount, 19-amount],
1414
backgroundColor: [
1515
'#F59B99',
1616
'#FAECD2'

code/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h3 class="header-text">GitHub Tracker</h3>
3434
</div>
3535
</div>
3636

37-
<footer class="footer">Made by Elsa Carlström<br>Frontend developer student @Technigo 2021</footer>
37+
<footer class="footer">Made by Frontend developer student Elsa Carlström @Technigo 2021</footer>
3838

3939
<script src="./script.js"></script>
4040
<script src="./chart.js"></script>

code/script.js

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
let repoName = 'project-weather-app'
2-
3-
const API_REPOS = `https://api.github.com/users/elsisco/repos`
4-
const API_USER = `https://api.github.com/users/elsisco`
5-
const API_PR = `https://api.github.com/repos/technigo/${repoName}/pulls`
1+
const USER = 'elsisco'
2+
let repoName = 'project-weather-app' // Default value
63

4+
const API_REPOS = `https://api.github.com/users/${USER}/repos`
5+
const API_USER = `https://api.github.com/users/${USER}`
76

87
const projectsContainer = document.getElementById('projects')
98
const profileContainer = document.getElementById('profile')
109

10+
// Fetch content for profile section
1111
const getUser = () => {
1212
fetch(API_USER)
1313
.then(res => res.json())
@@ -31,26 +31,26 @@ const getUser = () => {
3131
})
3232
}
3333

34+
// Fetch content for projects section
3435
const getRepos = () => {
3536
fetch(API_REPOS)
3637
.then(res => res.json())
3738
.then(data => {
3839
// Filtering the Technigo project repos
3940
const forkedRepos = data.filter(repo => repo.fork && repo.name.startsWith('project-'))
40-
41-
// Sort array in alphabetical order
42-
const sortedRepos = forkedRepos.sort()
4341

44-
sortedRepos.forEach(repo =>
45-
fetch(`https://api.github.com/repos/elsisco/${repo.name}/commits`)
42+
forkedRepos.forEach(repo =>
43+
fetch(`https://api.github.com/repos/${USER}/${repo.name}/commits`)
4644
.then(res => res.json())
4745
.then(data => {
4846
// Formatting the title of projects to start all words with capital letter
4947
let projectName = `${repo.name}`
48+
5049
const formattedProjectName = projectName.split("-")
5150
for (let i = 0; i < formattedProjectName.length; i++) {
5251
formattedProjectName[i] = formattedProjectName[i][0].toUpperCase() + formattedProjectName[i].substr(1);
5352
}
53+
5454
let newProjectName = formattedProjectName.join(" ")
5555

5656
// Date for most recent update of project
@@ -66,9 +66,7 @@ const getRepos = () => {
6666
<p id="commits-${repo.name}" class="text">(commits yet to be displayed)</p>
6767
<div class="languages">
6868
<p class="small-headline">Languages</p>
69-
70-
<div id="progress-${repo.name}" class="progress"></div>
71-
69+
<div id="progress-${repo.name}" class="progress"></div>
7270
<section class="the-languages">
7371
<div class="html-wrapper">
7472
<div class="language-dot" style="background-color:#56B093;"></div>
@@ -94,9 +92,9 @@ const getRepos = () => {
9492
})
9593
}
9694

97-
// A calculator for language percentage per project
95+
// A calculator for percentage of language per project
9896
const calculateLanguagePercentage = (repo) => {
99-
fetch(`https://api.github.com/repos/elsisco/${repo.name}/languages`)
97+
fetch(`https://api.github.com/repos/${USER}/${repo.name}/languages`)
10098
.then(res => res.json())
10199
.then(language => {
102100
const html = language.HTML || 0;
@@ -116,23 +114,20 @@ const calculateLanguagePercentage = (repo) => {
116114
})
117115
}
118116

117+
// Fetch all pull requests per project
119118
const fetchPullRequestsArray = (allRepositories) => {
120119
allRepositories.forEach(repo => {
121120
fetch(`https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100`)
122121
.then(res => res.json())
123122
.then((data) => {
124-
const myPullRequests = data.find((pull) => pull.user.login === repo.owner.login)
123+
// Hard coded the || below to get the commits for Project Chatbot for which I was not a collaborator
124+
const myPullRequests = data.find((pull) => pull.user.login === repo.owner.login || pull.user.login === 'Svempolin' && pull.number === 67)
125125
fetchCommits(myPullRequests.commits_url, repo.name)
126-
// if (myPullRequests) {
127-
// fetchCommits(myPullRequests.commits_url, repo.name)
128-
// } else {
129-
// document.getElementById(`commit-${repo.name}`).innerHTML +=
130-
// 'No commits yet';
131-
// }
132126
})
133127
})
134128
}
135129

130+
// Fetching all the commits connected to the username
136131
const fetchCommits = (myCommitsUrl, myRepoName) => {
137132
fetch(myCommitsUrl)
138133
.then(res => res.json())
@@ -142,5 +137,4 @@ const fetchCommits = (myCommitsUrl, myRepoName) => {
142137
}
143138

144139
getUser()
145-
146140
getRepos()

code/style.css

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ body {
44
width: 100%;
55
height: 100%;
66
margin: 0;
7+
background-image: url('./assets/background.png');
8+
background-repeat: no-repeat;
9+
background-attachment: fixed;
10+
background-size: cover;
711
}
812

913
a {
@@ -76,10 +80,6 @@ a:hover {
7680
}
7781

7882
.main-wrapper {
79-
background-image: url('./assets/background.png');
80-
background-repeat: no-repeat;
81-
background-attachment: fixed;
82-
background-size: cover;
8383
max-width: 1024px;
8484
margin: 0 auto;
8585
padding-bottom: 20px;
@@ -99,7 +99,7 @@ a:hover {
9999

100100
.profile {
101101
width: 55%;
102-
border-right: 2px lightgray solid;
102+
border-right: 1px lightgray solid;
103103
text-align: left;
104104
padding: 3%;
105105
}
@@ -138,6 +138,8 @@ chart {
138138

139139
.avatar-wrapper {
140140
width: 100%;
141+
max-width: 220px;
142+
margin: 0 auto;
141143
display: flex;
142144
align-items: center;
143145
justify-content: center;
@@ -221,11 +223,11 @@ chart {
221223

222224

223225
.footer {
226+
width: 100%;
224227
background-color: #56B093;
225228
color: white;
226-
max-width: 1024px;
227229
margin: 0 auto;
228-
padding: 8px;
230+
padding: 10px;
229231
text-align: center;
230232
font-size: 11px;
231233
line-height: 1.5;

0 commit comments

Comments
 (0)