-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
134 lines (128 loc) · 3.42 KB
/
index.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
const ourProjects = [
{
id: 1,
title: "Food Fusion",
category: "Website",
img: "./images/foodfusion.png",
description: "Food Fusion Restaurant landing page",
},
{
id: 2,
title: "MÚSICA",
category: "Mobile",
img: "./images/musica.svg",
description: "A mobile based media player UX/UI Design.",
},
{
id: 3,
title: "Color Lab",
category: "Website",
img: "./images/colorlabs.png",
description: "Color generator for Developers and Designers.",
},
{
id: 4,
title: "Trading Room",
category: "Website",
img: "./images/tr.png",
description: "A Trading room website template in bootstrap5",
},
{
id: 5,
title: "WindeployQt",
category: "Software",
img: "./images/WindeployQt.png",
description:
"A GUI Application for deploying Qt based applications to microsoft windows.",
},
{
id: 6,
title: "SEO Campaign",
category: "Seo",
img: "./images/seo.png",
description: "A SEO compaign website template.",
},
{
id: 7,
title: "Code Craft",
category: "Website",
img: "./images/codecraft.jpg",
description: "A UX/UI Designing and Research agency.",
},
{
id: 8,
title: "Button CSS Generator",
category: "Software",
img: "./images/btn_Css_view1.png",
description: "A GUI Application for generating css code for buttons.",
},
{
id: 9,
title: "VIVID Billing Solutions",
category: "Website",
img: "./images/vivid.png",
description: "A medical billing solutions website",
},
{
id: 10,
title: "Dial Cabbies",
category: "Seo",
img: "./images/dial.png",
description: "A taxi company in durham UK",
},
];
const section = document.querySelector(".projects");
const btn = document.querySelector(".btn-container");
window.addEventListener("DOMContentLoaded", function () {
displayButtons(ourProjects);
displayProjects(ourProjects);
});
function displayButtons(proj) {
const buttons = proj.reduce(
function (value, item) {
if (!value.includes(item.category)) {
value.push(item.category);
}
return value;
},
["all"]
);
const category = buttons
.map((item) => {
return `<button class="filter-btn btn btn-outline-success text-uppercase m-1 " data-id=${item}>${item}</button>`;
})
.join("");
btn.innerHTML = category;
const filterBtn = btn.querySelectorAll(".filter-btn");
filterBtn.forEach(function (btn) {
btn.addEventListener("click", function (e) {
const category = e.target.dataset.id;
const projectCategory = proj.filter(function (projCategory) {
if (projCategory.category === category) {
return projCategory;
}
});
if (category === "all") {
displayProjects(proj);
} else {
displayProjects(projectCategory);
}
});
});
}
function displayProjects(proj) {
let displayProj = proj.map((item) => {
return `<div class="col">
<div class="card h-100">
<img src="${item.img}" class="card-img-top" alt="${item.title}">
<div class="card-body">
<h5 class="card-title">${item.title}</h5>
<p class="card-text">${item.description}.</p>
</div>
</div>
</div>`
;
});
const data = displayProj.join("");
section.innerHTML = data;
}