From e5c06776c22871af3ca6a7285091c9663ea348db Mon Sep 17 00:00:00 2001
From: Nadia Lefebvre <95084122+nadialefebvre@users.noreply.github.com>
Date: Thu, 17 Feb 2022 14:04:18 +0100
Subject: [PATCH 01/28] updated readme
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 1613a3b0..26648795 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# GitHub Tracker
+# Week 7: GitHub tracker
Replace this readme with your own information about your project.
From 4e5ccbfc899fd4b12501fa7e1accd133f92f4f80 Mon Sep 17 00:00:00 2001
From: Nadia Lefebvre <95084122+nadialefebvre@users.noreply.github.com>
Date: Thu, 17 Feb 2022 17:50:15 +0100
Subject: [PATCH 02/28] added first fetch requests
---
code/script.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++
code/style.css | 6 ++++++
2 files changed, 53 insertions(+)
diff --git a/code/script.js b/code/script.js
index e69de29b..4f6b9f42 100644
--- a/code/script.js
+++ b/code/script.js
@@ -0,0 +1,47 @@
+const projects = document.getElementById('projects')
+const API_REPOS = 'https://api.github.com/users/nadialefebvre/repos'
+
+const options = {
+ method: 'GET',
+ headers: {
+ Authorization: 'token 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'
+ }
+}
+
+fetch(API_REPOS, options) // options object is passed as 2nd argument to fetch() function.
+ .then(res => res.json())
+ .then(data => {
+ console.log(data)
+ projects.innerHTML = `
+
+
Username: ${data[0].owner.login}
+ ` + const filteredRepos = data.filter(repo => repo.fork === true && repo.name.startsWith('project')) + console.log(filteredRepos) + filteredRepos.forEach((repo) => { + fetch(`https://api.github.com/repos/nadialefebvre/${repo.name}`, options) + .then(res => res.json()) + .then(data => { + console.log(data) + console.log(repo.pushed_at) + const options = { day: 'numeric', month: 'long', year: 'numeric' } + projects.innerHTML += ` +Repo name: ${repo.name}
+Repo URL: ${repo.html_url}
+Default branch: ${repo.default_branch}
+Repo last push: ${new Date(repo.pushed_at).toLocaleDateString('en-GB', options)}
+Number of commits: ${data.length}
+ ` + }) + }) + }) diff --git a/code/style.css b/code/style.css index 7c8ad447..0bd4c055 100644 --- a/code/style.css +++ b/code/style.css @@ -1,3 +1,9 @@ body { background: #FFECE9; +} + +.repo { + border: solid 1px red; + padding: 10px; + margin-bottom: 10px; } \ No newline at end of file From b1bf1a53d470e9ba485c0caa9b918cbedec5aff1 Mon Sep 17 00:00:00 2001 From: Nadia Lefebvre <95084122+nadialefebvre@users.noreply.github.com> Date: Fri, 18 Feb 2022 17:17:49 +0100 Subject: [PATCH 03/28] added a basic graph with projects --- code/chart.js | 61 +++++++++++++++++++++++++ code/index.html | 16 +++++-- code/script.js | 115 +++++++++++++++++++++++++++++++++--------------- 3 files changed, 154 insertions(+), 38 deletions(-) diff --git a/code/chart.js b/code/chart.js index 92e85a30..6b64feff 100644 --- a/code/chart.js +++ b/code/chart.js @@ -2,3 +2,64 @@ const ctx = document.getElementById('chart').getContext('2d') //"Draw" the chart here 👇 + + +// what's not working below is commented out +// global options +// Chart.defaults.global.defaultFontFamily = 'Lato'; +// Chart.defaults.global.defaultFontSize = 18; +// Chart.defaults.global.defaultFontColor = 'grey'; + +const drawProjectsChart = (amount) => { + new Chart(ctx, { + type: 'bar', // bar, horizontalBar, pie, line, doughnut, radar, polarArea + data: { + labels: ['Completed', 'To do'], + datasets: [{ + barPercentage: 1, + barThickness: 100, + maxBarThickness: 200, + minBarLength: 2, + label: 'Projects', + data: [ + amount, + 19 - amount + ], + backgroundColor: [ + 'red', + 'green' + ], + borderWidth: 2, + borderColor: 'black', + hoverBorderWidth: 5, + hoverBorderColor: 'brown' + } + ] + } + // options: { + // title: { + // display: true, + // text: 'Largest Cities in Massachussets', + // fontSize:24 + // }, + // legend:{ + // display:false, + // position:'right', + // labels:{ + // fontColor:'black' + // } + // layout: { + // padding: { + // left: 0, + // right: 0, + // bottom: 0, + // top: 0 + // } + // }, + // tooltips:{ + // enabled:false + // } + // } + }) +} + diff --git a/code/index.html b/code/index.html index 2fb5e0ae..63e6a1e9 100644 --- a/code/index.html +++ b/code/index.html @@ -1,21 +1,31 @@ +Username: ${data[0].owner.login}
- ` - const filteredRepos = data.filter(repo => repo.fork === true && repo.name.startsWith('project')) - console.log(filteredRepos) - filteredRepos.forEach((repo) => { - fetch(`https://api.github.com/repos/nadialefebvre/${repo.name}`, options) - .then(res => res.json()) - .then(data => { - console.log(data) - console.log(repo.pushed_at) - const options = { day: 'numeric', month: 'long', year: 'numeric' } - projects.innerHTML += ` + + + + + + + +const createRepoCard = () => { + fetch(API_REPOS) // options object is passed as 2nd argument to fetch() function. // TO REMOVE BEFORE GIT PUSH + .then(res => res.json()) + .then(data => { + const filteredRepos = data.filter(repo => repo.fork === true && repo.name.startsWith('project-')) + drawProjectsChart(filteredRepos.length) + filteredRepos.forEach(repo => { + const options = { day: 'numeric', month: 'long', year: 'numeric' } + projects.innerHTML += `Repo name: ${repo.name}
-Repo URL: ${repo.html_url}
+Repo URL: ${repo.name}
Default branch: ${repo.default_branch}
Repo last push: ${new Date(repo.pushed_at).toLocaleDateString('en-GB', options)}
Number of commits: ${data.length}
- ` - }) + fetch(`https://api.github.com/repos/${username}/${repo.name}/commits`) + .then(res => res.json()) + .then(data => { + console.log(data) + const userCommits = data.filter((item) => item.commit.author.name === 'Nadia Lefebvre') + + document.getElementById(repo.name).innerHTML += ` +Number of commits from the user: ${userCommits.length} on a total of ${data.length}
+Commit messages:
+ ` + userCommits.forEach(item => { + document.getElementById(repo.name).innerHTML += ` +Number of commits from the user: ${userCommits.length} on a total of ${data.length}
+ //Commit messages:
+ // ` + + // TEST + document.getElementById(`${repo.name}-repoInfos`).innerHTML += ` +Number of commits from the user: ${userCommits.length} on a total of ${data.length}
+ ` + + + const userFiveLastCommits = userCommits.slice(1, 5) + console.log(userFiveLastCommits) + userFiveLastCommits.forEach(item => { + // document.getElementById(repo.name).innerHTML += ` + //Comments from PR: ${comment.body}
+ // ` + // TEST + document.getElementById(`${repo.name}-repoPullComments`).innerHTML = ` +Name: ${repo.name}
+ //URL: ${repo.name}
+ //Default branch: ${repo.default_branch}
+ //Last push: ${new Date(repo.pushed_at).toLocaleDateString('en-GB', options)}
+ //Repo name: ${repo.name}
-Repo URL: ${repo.name}
-Default branch: ${repo.default_branch}
-Repo last push: ${new Date(repo.pushed_at).toLocaleDateString('en-GB', options)}
+Number of commits from the user: ${userCommits.length} on a total of ${data.length}
-Commit messages:
- ` - userCommits.forEach(item => { - document.getElementById(repo.name).innerHTML += ` -URL: ${repo.name}
+Default branch : ${repo.default_branch}
+Last push: ${new Date(repo.pushed_at).toLocaleDateString('en-GB', options)}
+ ` + + // Get the element with id="defaultOpen" and click on it + document.getElementById(`${repo.name}-defaultOpen`).click() + + + + + + addCommits(repo) + addPullComments(repo) + addLanguageChart(repo) + + }) }) } -createProfile() -createRepoCard() -//Remember to pass along your filtered repos as an argument when -//you are calling this function -const getPullRequests = (repos) => { - //Get all the PRs for each project. - repos.forEach(repo => { - fetch('https://api.github.com/repos/technigo/' + repo.name + '/pulls') - .then(res => res.json()) - .then(data => { - //TODO - //1. Find only the PR that you made by comparing pull.user.login - // with repo.owner.login - //2. Now you're able to get the commits for each repo by using - // the commits_url as an argument to call another function - //3. You can also get the comments for each PR by calling - // another function with the review_comments_url as argument - }) - }) - } +createProfile() +createRepoCard() diff --git a/code/style.css b/code/style.css index 0bd4c055..498f475d 100644 --- a/code/style.css +++ b/code/style.css @@ -2,8 +2,80 @@ body { background: #FFECE9; } +img { + max-width: 50px; +} + .repo { border: solid 1px red; padding: 10px; margin-bottom: 10px; +} + +.chart-container { + width: 50%; + min-width: 100px; + max-width: 200px; +} + +.chart-container.main { + width: 100%; + min-width: 100px; + max-width: 400px; + +} + +.projects { + display: flex; + flex-direction: column; +} + + + +* {box-sizing: border-box} +body {font-family: "Lato", sans-serif;} + +/* Style the tab */ +.tab { + float: left; + border: 1px solid #ccc; + background-color: #f1f1f1; + width: 30%; + height: 300px; +} + +/* Style the buttons inside the tab */ +.tab button { + display: block; + background-color: inherit; + color: black; + padding: 22px 16px; + width: 100%; + border: none; + outline: none; + text-align: left; + cursor: pointer; + transition: 0.3s; + font-size: 17px; +} + +/* Change background color of buttons on hover */ +.tab button:hover { + background-color: #ddd; +} + +/* Create an active/current "tab button" class */ +.tab button.active { + background-color: #ccc; +} + +/* Style the tab content */ +.tabcontent { + float: left; + background-color: #f1f1f1; + padding: 0px 12px; + border: 1px solid #ccc; + width: 70%; + border-left: none; + height: 300px; } \ No newline at end of file From 77ca55ecb26a256d88d4e950a2c9d2487ad24529 Mon Sep 17 00:00:00 2001 From: Nadia Lefebvre <95084122+nadialefebvre@users.noreply.github.com> Date: Sun, 20 Feb 2022 18:00:48 +0100 Subject: [PATCH 05/28] added some sorting options --- code/script.js | 269 +++++++++++++++++++++++-------------------------- code/style.css | 4 +- 2 files changed, 131 insertions(+), 142 deletions(-) diff --git a/code/script.js b/code/script.js index 2d2ecf70..e3898f15 100644 --- a/code/script.js +++ b/code/script.js @@ -1,34 +1,30 @@ const username = 'nadialefebvre' const API_USER = `https://api.github.com/users/${username}` -const API_REPOS = `https://api.github.com/users/${username}/repos` // const or let ? +const API_REPOS = `https://api.github.com/users/${username}/repos` const profile = document.getElementById('profile') const projects = document.getElementById('projects') -const projects2 = document.getElementById('projects2') -function openCity(evt, cityName) { - var i, tabcontent, tablinks - tabcontent = document.getElementsByClassName("tabcontent") - for (i = 0; i < tabcontent.length; i++) { - tabcontent[i].style.display = "none" +const openTab = (event, tabName) => { + let i + let tabContent = event.currentTarget.parentNode.parentNode.getElementsByClassName("tab-content") + for (i = 0; i < tabContent.length; i++) { + tabContent[i].style.display = "none" } - tablinks = document.getElementsByClassName("tablinks") - for (i = 0; i < tablinks.length; i++) { - tablinks[i].className = tablinks[i].className.replace(" active", "") + let tabButton = event.currentTarget.parentNode.getElementsByClassName("tab-button") + for (i = 0; i < tabButton.length; i++) { + tabButton[i].className = tabButton[i].className.replace(" active", "") } - document.getElementById(cityName).style.display = "block" - evt.currentTarget.className += " active" + document.getElementById(tabName).style.display = "block" + event.currentTarget.className += " active" } - - - const createProfile = () => { fetch(API_USER, options) .then(res => res.json()) @@ -40,38 +36,84 @@ const createProfile = () => { }) } -const addCommits = (repo) => { - fetch(`https://api.github.com/repos/${username}/${repo.name}/commits`, options) +const createRepoCard = () => { + fetch(API_REPOS, options) // options object is passed as 2nd argument to fetch() function. // TO REMOVE BEFORE GIT PUSH .then(res => res.json()) .then(data => { - const userCommits = data.filter((item) => item.commit.author.name === 'Nadia Lefebvre') - // document.getElementById(repo.name).innerHTML += ` - //Number of commits from the user: ${userCommits.length} on a total of ${data.length}
- //Commit messages:
- // ` + const filteredRepos = data.filter(repo => repo.fork === true && repo.name.startsWith('project-')) +console.log(filteredRepos) + // sortByDate(filteredRepos) + // sortByReverseDate(filteredRepos) + // sortByReverseName(filteredRepos) + // sortByCommits() - // TEST - document.getElementById(`${repo.name}-repoInfos`).innerHTML += ` -Number of commits from the user: ${userCommits.length} on a total of ${data.length}
- ` + drawProjectsChart(filteredRepos.length) + filteredRepos.forEach(repo => { + const options = { day: 'numeric', month: 'long', year: 'numeric' } + projects.innerHTML += ` +URL: ${repo.name}
+Default branch : ${repo.default_branch}
+Last push: ${new Date(repo.pushed_at).toLocaleDateString('en-GB', options)}
+ ` + // Get the element with id="defaultOpen" and click on it + document.getElementById(`${repo.name}-defaultOpen`).click() + addCommits(repo) + fetchPullRequest(repo) + addLanguageChart(repo) + }) + }) +} +const addCommits = (repo) => { + fetch(`https://api.github.com/repos/${username}/${repo.name}/commits`, options) + .then(res => res.json()) + .then(data => { + // why item.author.login === username doesn't work here?? + const userCommits = data.filter((item) => item.commit.author.name === 'Nadia Lefebvre') + + document.getElementById(`${repo.name}-repoInfos`).innerHTML += ` +Number of commits from the user: ${userCommits.length} on a total of ${data.length}
+ ` + + const userFiveLastCommits = userCommits.slice(1, 5) + userFiveLastCommits.forEach(item => { + document.getElementById(`${repo.name}-repoCommitMessages`).innerHTML += ` +Comments from PR: ${comment.body}
- // ` - - - // TEST - document.getElementById(`${repo.name}-repoPullComments`).innerHTML = ` -Name: ${repo.name}
- //URL: ${repo.name}
- //Default branch: ${repo.default_branch}
- //Last push: ${new Date(repo.pushed_at).toLocaleDateString('en-GB', options)}
- //URL: ${repo.name}
-Default branch : ${repo.default_branch}
-Last push: ${new Date(repo.pushed_at).toLocaleDateString('en-GB', options)}
- ` - - // Get the element with id="defaultOpen" and click on it - document.getElementById(`${repo.name}-defaultOpen`).click() - - - - - - addCommits(repo) - addPullComments(repo) - addLanguageChart(repo) - - - }) + document.getElementById(`${repo.name}-repoPullComments`).innerHTML = ` +${data.body}
+ + ` }) } +const sortByDate = (filteredRepos) => { + filteredRepos.sort(function (a, b) { + return new Date(a.created_at) - new Date(b.created_at) + }) +} +const sortByReverseDate = (filteredRepos) => { + filteredRepos.sort(function (a, b) { + return new Date(b.created_at) - new Date(a.created_at) + }) +} +const sortByReverseName = (filteredRepos) => { + filteredRepos.sort(function (a, b) { + var nameA = a.name.toUpperCase() // ignore upper and lowercase + var nameB = b.name.toUpperCase() // ignore upper and lowercase + if (nameA > nameB) { + return -1 + } + if (nameA < nameB) { + return 1 + } + // names must be equal + return 0 + }) +} +// const sortByCommits = () => { +// fetch(`https://api.github.com/repos/${username}/${repo.name}/commits`, options) +// .then(res => res.json()) +// .then(data => { +// // why item.author.login === username doesn't work here?? +// const userCommits = data.filter((item) => item.commit.author.name === 'Nadia Lefebvre') +// console.log(userCommits.length) - +// userCommits.sort(function (a, b) { +// return a.length - b.length +// }) +// }) +// } createProfile() -createRepoCard() +createRepoCard() \ No newline at end of file diff --git a/code/style.css b/code/style.css index 498f475d..7d69bdbf 100644 --- a/code/style.css +++ b/code/style.css @@ -42,6 +42,7 @@ body {font-family: "Lato", sans-serif;} background-color: #f1f1f1; width: 30%; height: 300px; + margin-bottom: 20px; } /* Style the buttons inside the tab */ @@ -70,7 +71,7 @@ body {font-family: "Lato", sans-serif;} } /* Style the tab content */ -.tabcontent { +.tab-content { float: left; background-color: #f1f1f1; padding: 0px 12px; @@ -78,4 +79,5 @@ body {font-family: "Lato", sans-serif;} width: 70%; border-left: none; height: 300px; + overflow: auto; } \ No newline at end of file From af62a90ecdc522aaba8d6cbbeaacc0db031ae54f Mon Sep 17 00:00:00 2001 From: Nadia Lefebvre <95084122+nadialefebvre@users.noreply.github.com> Date: Sun, 20 Feb 2022 21:02:40 +0100 Subject: [PATCH 06/28] added a dropdown for selecting sorting option --- code/index.html | 7 +++ code/script.js | 112 +++++++++++++++++++++++++++++++++++------------- 2 files changed, 90 insertions(+), 29 deletions(-) diff --git a/code/index.html b/code/index.html index 5407a61b..1ba1bf1b 100644 --- a/code/index.html +++ b/code/index.html @@ -27,6 +27,13 @@Number of commits from the user: ${userCommits.length} on a total of ${data.length}
` - const userFiveLastCommits = userCommits.slice(1, 5) - userFiveLastCommits.forEach(item => { + // const userFiveLastCommits = userCommits.slice(1, 5) + // userFiveLastCommits.forEach(item => { + userCommits.forEach(item => { document.getElementById(`${repo.name}-repoCommitMessages`).innerHTML += `URL: ${repo.name}
Default branch : ${repo.default_branch}
Last push: ${new Date(repo.pushed_at).toLocaleDateString('en-GB', options)}
` - // Get the element with id="defaultOpen" and click on it document.getElementById(`${repo.name}-defaultOpen`).click() @@ -118,6 +87,38 @@ const createRepoCard = (reposToUse = null) => { }) } +const setRepoCardStructure = (repo) => { + projects.innerHTML += ` +Number of commits from the user: ${userCommits.length} on a total of ${data.length}
+Number of commits for this fork: ${userCommits.length} on a total of ${data.length}
` // const userFiveLastCommits = userCommits.slice(1, 5) @@ -145,23 +146,20 @@ const addLanguageChart = (repo) => { fetch(`https://api.github.com/repos/${username}/${repo.name}/languages`, options) .then(res => res.json()) .then(languages => { - // many variables for percentage calculation : needs to find a way to add % now... + // variables so data will be 0 and not undefined if = 0 const html = languages.HTML === undefined ? 0 : languages.HTML const css = languages.CSS === undefined ? 0 : languages.CSS const js = languages.JavaScript === undefined ? 0 : languages.JavaScript - const htmlPercentage = Math.round(html / (html + css + js) * 1000) / 10 - const cssPercentage = Math.round(css / (html + css + js) * 1000) / 10 - const jsPercentage = Math.round(js / (html + css + js) * 1000) / 10 const idChart = `${repo.name}Chart` document.getElementById(`${repo.name}-repoLanguages`).innerHTML += ` -${data.body}
- + ` }) } const sortByNameAZ = (filteredRepos) => { - filteredRepos.sort(function(a, b) { + filteredRepos.sort(function (a, b) { const nameA = a.name.toLowerCase() // ignore upper and lowercase const nameB = b.name.toLowerCase() // ignore upper and lowercase if (nameA < nameB) { @@ -212,7 +210,7 @@ const sortByNameAZ = (filteredRepos) => { } const sortByNameZA = (filteredRepos) => { - filteredRepos.sort(function(a, b) { + filteredRepos.sort(function (a, b) { const nameA = a.name.toLowerCase() // ignore upper and lowercase const nameB = b.name.toLowerCase() // ignore upper and lowercase if (nameA > nameB) { @@ -227,33 +225,19 @@ const sortByNameZA = (filteredRepos) => { } const sortByDateRecentOld = (filteredRepos) => { - filteredRepos.sort(function(a, b) { + filteredRepos.sort(function (a, b) { return new Date(b.created_at) - new Date(a.created_at) }) } const sortByDateOldRecent = (filteredRepos) => { - filteredRepos.sort(function(a, b) { + filteredRepos.sort(function (a, b) { return new Date(a.created_at) - new Date(b.created_at) }) } -// const selectSorting = (filteredRepos) => { -// console.log(sortMenu.value) -// if (sortMenu.value === 'Z to A') { -// sortByNameZA(filteredRepos) -// } else if (sortMenu.value === 'Recent to old') { -// sortByDateRecentOld(filteredRepos) -// } else if (sortMenu.value === 'Old to recent') { -// sortByDateOldRecent(filteredRepos) -// } else { -// sortByNameAZ(filteredRepos) -// } -// } - - -createProfile() +createHeader() createRepoCard() diff --git a/code/style.css b/code/style.css index 7d69bdbf..1c7c011d 100644 --- a/code/style.css +++ b/code/style.css @@ -1,55 +1,107 @@ +* { + box-sizing: border-box; +} + body { - background: #FFECE9; + font-family: "Lato", sans-serif; + background-color: #112d4e; + color: white; + padding: 20px; } -img { - max-width: 50px; +a { + color: #3f72af; + font-weight: bold; + text-decoration: none; } -.repo { - border: solid 1px red; - padding: 10px; - margin-bottom: 10px; +.main-page { + display: flex; + flex-direction: column; + justify-content: center; } -.chart-container { - width: 50%; - min-width: 100px; - max-width: 200px; +.header-box { + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: center; } -.chart-container.main { - width: 100%; - min-width: 100px; - max-width: 400px; +.header-box .title { + background-color: #DBE2EF; + padding: 20px; + color: #3f72af; + border-radius: 4px; +} +.user-profile { + text-align: center; } -.projects { +.user-profile img { + max-width: 200px; + border-radius: 50%; +} + +.sorting-dropdown { display: flex; - flex-direction: column; + flex-direction: row; + justify-content: flex-end; } +select { + display: flex; + align-self: center; + border: transparent; + border-radius: 2px; + outline: none; + font-size: inherit; + color: #112d4e; + width: fit-content; + text-align: center; + margin-bottom: 20px; +} + +.languages-chart { + width: 75%; + /* min-width: 250px; + max-width: 300px; */ +} + +.projects-chart { + width: 275px; + /* width: auto; */ + margin-bottom: 20px; +} +.projects { + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content: space-evenly; + color: #112d4e; +} -* {box-sizing: border-box} -body {font-family: "Lato", sans-serif;} +.tab-card { + margin: 20px; + width: 500px; +} /* Style the tab */ .tab { float: left; - border: 1px solid #ccc; - background-color: #f1f1f1; + /* border: 1px solid #3f72af; */ + background-color: #f9f7f7; width: 30%; height: 300px; - margin-bottom: 20px; } /* Style the buttons inside the tab */ .tab button { display: block; background-color: inherit; - color: black; + color: #112d4e; padding: 22px 16px; width: 100%; border: none; @@ -62,22 +114,46 @@ body {font-family: "Lato", sans-serif;} /* Change background color of buttons on hover */ .tab button:hover { - background-color: #ddd; + background-color: #dbe2ef; } /* Create an active/current "tab button" class */ .tab button.active { - background-color: #ccc; + background-color: #3f72af; + color: white; } /* Style the tab content */ .tab-content { float: left; - background-color: #f1f1f1; + background-color: #f9f7f7; padding: 0px 12px; - border: 1px solid #ccc; + /* border: 1px solid #3f72af; */ width: 70%; border-left: none; height: 300px; overflow: auto; +} + +@media only screen and (min-width: 800px) { + .header-box { + flex-direction: row; + justify-content: space-between; + /* align-items: center; */ + } + + .header-box .title { + width: 175px; +text-align: center; + } + + .user-profile { + width: 275px; + } + + .projects-chart { + width: 275px; + } + + } \ No newline at end of file From 8b11f88ab50967f1a449876f0acd5df6205050ed Mon Sep 17 00:00:00 2001 From: Nadia Lefebvre <95084122+nadialefebvre@users.noreply.github.com> Date: Tue, 22 Feb 2022 09:41:42 +0100 Subject: [PATCH 08/28] working on the styling --- code/chart.js | 16 ---------------- code/script.js | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/code/chart.js b/code/chart.js index 0dd17d03..c5fbc6b4 100644 --- a/code/chart.js +++ b/code/chart.js @@ -155,22 +155,6 @@ const drawLanguagesChart = (html, css, js, idChart) => { weight: '700' }, cornerRadius: 4 - // callbacks: { - // body: titleTooltip - - // // label: function(context) { - // // let label = context.dataset.label || ''; - - // // if (label) { - // // label += ': '; - // // } - // // if (context.parsed.y !== null) { - // // label += new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(context.parsed.y); - // // } - // // return label; - // // } - // } - } } } diff --git a/code/script.js b/code/script.js index 86463659..358bb821 100644 --- a/code/script.js +++ b/code/script.js @@ -28,10 +28,17 @@ const openTab = (event, tabName) => { +// TO REMOVE BEFORE GIT PUSH +// TO REMOVE BEFORE GIT PUSH + + + + + const createHeader = () => { - fetch(API_USER, options) + fetch(API_USER) .then(res => res.json()) .then(data => { userProfile.innerHTML = ` @@ -42,7 +49,7 @@ const createHeader = () => { } const createRepoCard = (reposToUse = null) => { - fetch(API_REPOS, options) // options object is passed as 2nd argument to fetch() function. // TO REMOVE BEFORE GIT PUSH + fetch(API_REPOS) // options object is passed as 2nd argument to fetch() function. // TO REMOVE BEFORE GIT PUSH .then(res => res.json()) .then(data => { const selectSorting = () => { @@ -121,7 +128,7 @@ const setRepoCardStructure = (repo) => { } const addCommits = (repo) => { - fetch(`https://api.github.com/repos/${username}/${repo.name}/commits`, options) + fetch(`https://api.github.com/repos/${username}/${repo.name}/commits`) .then(res => res.json()) .then(data => { // why item.author.login === username doesn't work here?? @@ -143,7 +150,7 @@ const addCommits = (repo) => { const addLanguageChart = (repo) => { - fetch(`https://api.github.com/repos/${username}/${repo.name}/languages`, options) + fetch(`https://api.github.com/repos/${username}/${repo.name}/languages`) .then(res => res.json()) .then(languages => { // variables so data will be 0 and not undefined if = 0 @@ -166,7 +173,7 @@ const addLanguageChart = (repo) => { const fetchPullRequest = (repo) => { // fix it because only 1 page of 30 PR is fetched, link: https://docs.github.com/en/rest/reference/pulls#list-pull-requests (added ?per_page=100&page=1 to URL, but it doesn't fix the problem for when the PR will go to page 2-3-4...) - fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls?per_page=100&page=1`, options) + fetch(`https://api.github.com/repos/technigo/${repo.name}/pulls?per_page=100&page=1`) .then(res => res.json()) .then(data => { const userPulls = data.filter((item) => item.user.login === username) From 5483f47fc975428fd71250bdcf3f0e2a18b08fae Mon Sep 17 00:00:00 2001 From: Nadia Lefebvre <95084122+nadialefebvre@users.noreply.github.com> Date: Tue, 22 Feb 2022 15:40:47 +0100 Subject: [PATCH 09/28] still on styling --- code/chart.js | 13 +++-- code/favicon.ico | Bin 0 -> 15406 bytes code/index.html | 40 ++++++++++++---- code/script.js | 64 ++++++++++++------------- code/style.css | 120 ++++++++++++++++++++++++++++++----------------- 5 files changed, 149 insertions(+), 88 deletions(-) create mode 100644 code/favicon.ico diff --git a/code/chart.js b/code/chart.js index c5fbc6b4..30e6611c 100644 --- a/code/chart.js +++ b/code/chart.js @@ -1,16 +1,16 @@ //DOM-selector for the canvas 👇 -const projectsChart = document.getElementById('projectsChart').getContext('2d') +const reposChart = document.getElementById('reposChart').getContext('2d') //"Draw" the chart here 👇 // what's not working below is commented out // global options -Chart.defaults.font.family = 'Lato' +Chart.defaults.font.family = 'Roboto' Chart.defaults.font.size = 18 Chart.defaults.color = 'white' -const drawProjectsChart = (amount) => { - new Chart(projectsChart, { +const drawReposChart = (amount) => { + new Chart(reposChart, { type: 'bar', // bar, horizontalBar, pie, line, doughnut, radar, polarArea data: { labels: ['Done', 'To do'], @@ -129,11 +129,14 @@ const drawLanguagesChart = (html, css, js, idChart) => { }, legend: { display: true, - position: 'left', + position: 'top', labels: { color: '#112D4E', usePointStyle: true, pointStyle: 'rect', + font: { + size: 12 + } }, // removes on click event: not able to strike through a label by clicking on it onClick: null, diff --git a/code/favicon.ico b/code/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..db384e627f6627bdaac40ce526190706d96b3b0f GIT binary patch literal 15406 zcmeHNU2qgd5FV9x;lcMjQ9SbGYYwISDNBn7m6D1|iKhH13*(6p2{8fui3L$pgdjqK z;t$5c3l|cTaJl0M`5`D3^9L6q5H%N~MBpSLm*lSPo@6(>d%N6T_Po6_GgWi5JJUV= zO>a-%_D(Z)7rTcoUCOY{VlOXY?0&{rR@UtOie-#dV&BS@bK}byYrBuJ6-a|D$T8cG zjc)lNFT2q7W_B1WBv`{1cqLgXxpmu~fX1C`r7_-mN}dDvmWTOuURL: ${repo.name}
Default branch : ${repo.default_branch}
@@ -95,32 +91,33 @@ const createRepoCard = (reposToUse = null) => { } const setRepoCardStructure = (repo) => { - projects.innerHTML += ` -