forked from amyyalex/simple-contribution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
50 lines (40 loc) · 1.69 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// initialization of cardDetailsArray
let cardDetailsArray;
function createCard(details) {
const cardTemplate = document.getElementById("contributor-card");
const cardClone = cardTemplate.content.cloneNode(true);
cardClone.querySelector(".card-details h1").textContent = details.name;
cardClone.querySelector(".card-details h5").textContent = details.profession;
cardClone.querySelector(".card-details p").innerHTML = details.quote;
const socialIcons = cardClone.querySelector(".social-icon");
// Define the social media platforms and their corresponding icons
//if you have any other in mind add it here and test it out for icons
const socialMedia = [
{ key: "twitter", icon: "uil uil-twitter" },
{ key: "github", icon: "uil uil-github" },
{ key: "linkedin", icon: "uil uil-linkedin" },
{ key: "dribbble", icon: "uil uil-dribbble" },
{ key: "behance", icon: "uil uil-behance" },
{ key: "email", icon: "uil uil-envelope" },
{ key: "instagram", icon: "uil uil-instagram" },
];
// Iterate through the social media platforms and add icons if links are provided
for (const platform of socialMedia) {
if (details[platform.key]) {
socialIcons.innerHTML += `<a href="${details[platform.key]
}" target="_blank"><i class="${platform.icon}"></i></a>`;
}
}
return cardClone;
}
const cardsContainer = document.querySelector(".cards");
fetch('./cardDetails.json')
.then(response => response.json())
.then(data => {
cardDetailsArray = data.cardDetails
for (const details of cardDetailsArray) {
const card = createCard(details);
cardsContainer.appendChild(card);
}
})
.catch(error => console.error('Error fetching JSON:', error));