Skip to content

Commit 5aaa9dd

Browse files
committed
feat: add githu api
1 parent 1bb7feb commit 5aaa9dd

File tree

2 files changed

+70
-18
lines changed

2 files changed

+70
-18
lines changed

index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ <h2 class="text-primary">Our Vision</h2>
8787
</div>
8888
</header>
8989
<main>
90+
91+
<div class="flex-col-2" id="githubprojects">
92+
<!-- GitHub Projects from scripts.js goes here -->
93+
</div>
9094
<section id="projects" class="projects">
9195
<h2>Projects</h2>
9296
<div class="flex-items">

src/assets/javascript/script.js

Lines changed: 66 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,71 @@
11
//Navbar toggle
22
const navToggle = () => {
3-
const burger = document.querySelector('.burger');
4-
const navList = document.querySelector('.nav-list');
5-
const navLinks = document.querySelectorAll('.nav-list li');
6-
7-
burger.addEventListener('click', () => {
8-
// Toggle Navbar
9-
navList.classList.toggle('active');
10-
burger.classList.toggle('toggle');
11-
12-
// Animate Links
13-
navLinks.forEach((link, index) => {
14-
if(link.style.animation) {
15-
link.style.animation = '';
16-
} else {
17-
link.style.animation = `navLinkFade 0.5s ease forwards ${index / 7 + 0.2}s`;
18-
}
19-
});
3+
const burger = document.querySelector('.burger');
4+
const navList = document.querySelector('.nav-list');
5+
const navLinks = document.querySelectorAll('.nav-list li');
6+
7+
burger.addEventListener('click', () => {
8+
// Toggle Navbar
9+
navList.classList.toggle('active');
10+
burger.classList.toggle('toggle');
11+
12+
// Animate Links
13+
navLinks.forEach((link, index) => {
14+
if (link.style.animation) {
15+
link.style.animation = '';
16+
} else {
17+
link.style.animation = `navLinkFade 0.5s ease forwards ${
18+
index / 7 + 0.2
19+
}s`;
20+
}
21+
});
22+
});
23+
};
24+
25+
navToggle();
26+
27+
// GitHub Projects
28+
// ##############################################
29+
30+
var githubprojectsdomelement = document.getElementById('githubprojects');
31+
32+
let githubprojects = [
33+
{
34+
name: 'chryz-hub/chryz-hub.github.io',
35+
icon: 'description',
36+
},
37+
{
38+
name: 'chryz-hub/chryz-hub.github.io',
39+
icon: 'article',
40+
},
41+
{
42+
name: 'chryz-hub/chryz-hub.github.io',
43+
icon: 'person',
44+
},
45+
// Here can be added some more projets if needed
46+
];
47+
48+
githubprojects.forEach((project) => {
49+
getproject(project.name, project.icon);
50+
});
51+
52+
function getproject(project, icon) {
53+
fetch(`https://api.github.com/repos/${project}`)
54+
.then((response) => {
55+
return response.json();
56+
})
57+
.then((project) => {
58+
// we add the project card directly to the html dom
59+
githubprojectsdomelement.innerHTML += createprojectcard(project, icon);
2060
});
2161
}
2262

23-
navToggle();
63+
function createprojectcard(project, icon) {
64+
// removing github emojis cause they are not usable in html
65+
project.description = project.description.replace(/:[^}]*:/, '');
66+
67+
// TODO: add Project Card
68+
let projectcard = ``;
69+
return projectcard;
70+
}
71+

0 commit comments

Comments
 (0)