-
Notifications
You must be signed in to change notification settings - Fork 131
Week 7 github-tracker #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
a710eec
49f7f4d
7d69e8d
9bae354
df420f1
0ffb520
6efe3fb
51a9115
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,11 @@ | ||
| # GitHub Tracker | ||
|
|
||
| Replace this readme with your own information about your project. | ||
|
|
||
| Start by briefly describing the assignment in a sentence or two. Keep it short and to the point. | ||
| This weeks project where a deep dive into more APIs and to start using npm,unit tests and chart.js. | ||
|
|
||
| ## The problem | ||
|
|
||
| Describe how you approached to problem, and what tools and techniques you used to solve it. How did you plan? What technologies did you use? If you had more time, what would be next? | ||
| I started this weeks projects as usuals, looking through all information and reading the instructions.After that I did start the project by fecthing API from my gitHub repositories etc. It was hard for me to grasp what the assignment was and what I was suppose to do! So I spent a lot of time googling on the wrong search words and just trying to understand the instructions and trying to wrap my head around the task. I asked my teammates for help. | ||
|
|
||
| ## View it live | ||
|
|
||
| Every project should be deployed somewhere. Be sure to include the link to the deployed project so that the viewer can click around and see what it's all about. | ||
| https://tracker-bootcamp2022.netlify.app/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,21 @@ | ||
| //DOM-selector for the canvas 👇 | ||
| const ctx = document.getElementById('chart').getContext('2d') | ||
| const ctx = document.getElementById("chart").getContext("2d"); | ||
|
|
||
| //"Draw" the chart here 👇 | ||
| const drawChart = (amount) => { | ||
| const data = { | ||
| labels: ["completed projects", "projects left"], | ||
| datasets: [ | ||
| { | ||
| backgroundColor: ["grey", "black"], | ||
| data: [amount, 19 - amount], | ||
| hoverOffSet: 4, | ||
| }, | ||
| ], | ||
| }; | ||
| const config = { | ||
| type: "doughnut", | ||
| data: data, | ||
| }; | ||
| const myChart = new Chart(ctx, config); | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,38 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Project GitHub Tracker</title> | ||
| <link rel="stylesheet" href="./style.css" /> | ||
| </head> | ||
| <body> | ||
| <h1>GitHub Tracker</h1> | ||
| <h2>Projects:</h2> | ||
| <main id="projects"></main> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>Project GitHub Tracker</title> | ||
| <link rel="stylesheet" href="./style.css" /> | ||
| <script src="https://cdn.jsdelivr.net/npm/chart.js@3.7.1/dist/chart.min.js"></script> | ||
| </head> | ||
| <body> | ||
| <h1>GitHub Tracker</h1> | ||
|
|
||
| <!-- This will be used to draw the chart 👇 --> | ||
| <canvas id="chart"></canvas> | ||
| <section class="flex"> | ||
| <!-- This will be used to draw the chart 👇 --> | ||
| <canvas | ||
| id="chart" | ||
| class="chart" | ||
| style=" | ||
| display: flex; | ||
| width: 100%; | ||
| max-width: 500px; | ||
| height: 100%; | ||
| max-height: 500px; | ||
| " | ||
| ></canvas> | ||
| <div id="profile" class="profile"></div> | ||
| </section> | ||
| <main class="container" id="container"> | ||
| <section id="projects" class="projects"></section> | ||
| </main> | ||
|
|
||
| <script src="./script.js"></script> | ||
| <script src="./chart.js"></script> | ||
| </body> | ||
| </html> | ||
| <footer>Created by Terese Claesson</footer> | ||
|
|
||
| <script src="./chart.js"></script> | ||
| <script src="./script.js"></script> | ||
| </body> | ||
| </html> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| //DOM selectors | ||
| const profileInfo = document.getElementById("profile"); | ||
| const allProjects = document.getElementById("projects"); | ||
|
|
||
| const username = "TereseClaesson"; | ||
| const API_PROFILE = `https://api.github.com/users/${username}`; | ||
| const API_URL_REPOS = `https://api.github.com/users/${username}/repos`; | ||
|
|
||
| //Functions to get the username and profilepicture | ||
| const userProfile = () => { | ||
| fetch(API_PROFILE) | ||
| .then((res) => res.json()) | ||
| .then((profileData) => { | ||
| profileInfo.innerHTML += ` | ||
| <img src = "${profileData.avatar_url}"> | ||
| <h3>${profileData.name}</h3> | ||
| <h4> <a href = ${profileData.html_url}> ${profileData.login}</h4> | ||
| `; | ||
| }); | ||
| }; | ||
|
|
||
| //Repos | ||
| const repositories = () => { | ||
| fetch(API_URL_REPOS) | ||
| .then((res) => res.json()) | ||
| .then((allRepos) => { | ||
| const forkedRepos = allRepos.filter( | ||
| (repo) => repo.fork && repo.name.startsWith("project-") | ||
| ); | ||
| forkedRepos.forEach((repo) => { | ||
| allProjects.innerHTML += ` | ||
| <div> | ||
| <h3> Project name: ${repo.name} </h3> | ||
| <p> Latest push: ${new Date(repo.pushed_at).toLocaleString("en-GB", { | ||
| dateStyle: "short", | ||
| })} </p> | ||
| <p> Default branch: ${repo.default_branch}</p> | ||
| <a href = ${repo.html_url}>${repo.name}</a> | ||
| <p id ="pull-${repo.name}"></p> | ||
| <p id ="commit-${repo.name}">Commits:</p> | ||
| </div> | ||
| `; | ||
| commits(repo.commits_url, repo.name); | ||
| }); | ||
| getPullRequest(forkedRepos); | ||
| drawChart(forkedRepos.length); | ||
| }); | ||
| }; | ||
|
|
||
| const getPullRequest = (forkedRepos) => { | ||
| forkedRepos.forEach((repo) => { | ||
| const PULL_URL = `https://api.github.com/repos/Technigo/${repo.name}/pulls?per_page=100`; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good thing that you added |
||
|
|
||
| fetch(PULL_URL) | ||
| .then((res) => res.json()) | ||
| .then((pullReqs) => { | ||
| let groupProject = true; | ||
| pullReqs.forEach((pull) => { | ||
| if (pull.user.login === username) { | ||
| groupProject = false; | ||
| document.getElementById(`pull-${repo.name}`).innerHTML = ` | ||
| <a href = ${pull.html_url}> Go to pull request </a> | ||
| `; | ||
| } | ||
| }); | ||
|
|
||
| if (groupProject === true) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You found a good solution for the projects where you weren't the one creating the pull request. |
||
| document.getElementById(`pull-${repo.name}`).innerHTML = ` | ||
| <p> No pull request, group project </p> | ||
| `; | ||
| } | ||
| }); | ||
| }); | ||
| }; | ||
|
|
||
| const commits = (myCommits, repoName) => { | ||
| let commitUrl = myCommits.replace("{/sha}", ""); | ||
| fetch(commitUrl) | ||
| .then((res) => res.json()) | ||
| .then((commitNumber) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if the use of |
||
| document.getElementById(`commit-${repoName}`).innerHTML += | ||
| commitNumber.length; | ||
| }); | ||
| }; | ||
|
|
||
| userProfile(); | ||
| repositories(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,137 @@ | ||
| body { | ||
| background: #FFECE9; | ||
| } | ||
| margin: 0; | ||
| background: #e3ded9; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A tip about colors: adding color variables in your CSS would make it really easy to use your colors at many places in the file. It would help you to keep consistency (it's currently saving my life in the portfolio project). You add this at the beginning or your CSS (with your colors and variable names of course): And when you use the colors, you just type |
||
| box-sizing: border-box; | ||
| } | ||
|
|
||
| h1 { | ||
| text-align: center; | ||
| font-size: 3em; | ||
| } | ||
|
|
||
| .flex { | ||
| display: flex; | ||
| flex-direction: column; | ||
| } | ||
|
|
||
| .profile { | ||
| display: flex; | ||
| align-content: space-between; | ||
| flex-direction: column; | ||
| text-align: center; | ||
| margin: 3rem; | ||
| } | ||
|
|
||
| .chart { | ||
| margin: 1rem; | ||
| } | ||
|
|
||
| .profile h3 { | ||
| font-size: 2rem; | ||
| } | ||
|
|
||
| .profile img { | ||
| border-radius: 50%; | ||
| max-height: 30rem; | ||
| max-height: 30rem; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line repeated twice. |
||
| } | ||
|
|
||
| .projects { | ||
| display: flex; | ||
| flex-wrap: wrap; | ||
| flex-direction: column; | ||
| } | ||
|
|
||
| .projects div { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe adding a |
||
| flex-direction: column; | ||
| flex-wrap: wrap; | ||
| border: 0.2rem solid black; | ||
| text-align: center; | ||
| margin: 1rem; | ||
| border-radius: 1rem; | ||
| background-color: #8aa4ab; | ||
| color: #e3ded9; | ||
| } | ||
|
|
||
| .projects div:hover { | ||
| background-color: #416270; | ||
| } | ||
|
|
||
| footer { | ||
| text-align: center; | ||
| margin: 2rem; | ||
| font-size: 1em; | ||
| } | ||
|
|
||
| @media screen and (min-width: 678px) and (max-width: 1024px) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you remove the |
||
| .body h1 { | ||
| font-size: 6em; | ||
| } | ||
|
|
||
| .flex { | ||
| background-color: #416270; | ||
| display: flex; | ||
| flex-direction: column; | ||
|
Comment on lines
+73
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to repeat it here, since it's not a change from the mobile version (already written at the beginning). |
||
| align-content: space-around; | ||
| } | ||
|
|
||
| .profile { | ||
| display: flex; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to repeat it here, since it's not a change from the mobile version (already written at the beginning). |
||
| align-items: center; | ||
| color: #e3ded9; | ||
| margin: 1rem; | ||
| } | ||
|
|
||
| .profile h3 { | ||
| font-size: 2.5rem; | ||
| } | ||
|
|
||
| .chart { | ||
| margin: 10rem; | ||
| } | ||
|
|
||
| .projects { | ||
| display: flex; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to repeat it here, since it's not a change from the mobile version (already written at the beginning). |
||
| flex-direction: row; | ||
| flex-wrap: wrap; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to repeat it here, since it's not a change from the mobile version (already written at the beginning). |
||
| justify-content: space-around; | ||
| } | ||
|
|
||
| .projects div { | ||
| padding: 2rem; | ||
| } | ||
| } | ||
|
|
||
| @media screen and (min-width: 1025px) { | ||
| .flex { | ||
| background-color: #416270; | ||
| display: flex; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to repeat it here, since it's not a change from the mobile version (already written at the beginning). |
||
| flex-direction: row; | ||
| justify-content: space-around; | ||
| align-items: center; | ||
| } | ||
|
|
||
| .profile { | ||
| display: flex; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to repeat it here, since it's not a change from the mobile version (already written at the beginning). |
||
| padding: 3rem; | ||
| text-align: center; | ||
| font-size: 1.5em; | ||
|
Comment on lines
+116
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if there's a reason why you used both |
||
| color: #e3ded9; | ||
| } | ||
|
|
||
| .profile h3 { | ||
| font-size: 3rem; | ||
| } | ||
|
|
||
| .projects { | ||
| display: flex; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to repeat it here, since it's not a change from the mobile version (already written at the beginning). |
||
| flex-direction: row; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to repeat it here, since it's not a change from the tablet version (already written in this section). |
||
| flex-wrap: wrap; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to repeat it here, since it's not a change from the mobile version (already written at the beginning). |
||
| justify-content: space-around; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need to repeat it here, since it's not a change from the tablet version (already written in this section). |
||
| } | ||
|
|
||
| .projects div { | ||
| padding: 1.5rem; | ||
| font-size: 1.6rem; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great that you created a function and called it here, because it makes your code clearer.