generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodal-window.js
167 lines (152 loc) · 5.27 KB
/
modal-window.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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
const cardsContainer = document.getElementById('portfolio');
let cards = [
{
img: 'work1.png',
project_title: 'ICST4',
company: 'Microverse',
dev_title: 'FrontEndDev',
date: '2022',
description:
'A landing webpage for the fourth International Conference on Science and Technology in awbari city Libya.',
skills: ['html', 'css', 'Javascript'],
livelink: 'https://hammaazarok.github.io/icst4/',
sourcecode: 'https://github.com/hammaazarok/icst4',
},
{
img: 'work2.png',
project_title: 'AirQuality',
company: 'Microverse',
dev_title: 'FrontEndDev',
date: '2022',
description:
'A web app that provides users with air quality rates and pollutant concentration',
skills: ['React', 'Redux', 'SCSS'],
livelink: 'https://air-quality-ha.netlify.app/',
sourcecode: 'https://github.com/hammaazarok/air-quality',
disabled: false,
},
{
img: 'work3.png',
project_title: 'AMAZON CLONE',
company: 'Microverse',
dev_title: 'FullStackDev',
date: '2022',
description:
' a web app that provides users with products that they can add to their carts and buy using stripe gateway',
skills: ['React', 'ContextAPI', 'FireBase', 'Express js'],
livelink: 'https://amaz-on-clone-ha.web.app/',
sourcecode: 'https://github.com/hammaazarok/amazon-clone',
},
{
img: 'work4.png',
project_title: 'RecipeApp',
company: 'Microverse',
dev_title: 'FullStackDev',
date: '2022',
description: 'app that allows user to manage recipes created by them or the community.',
skills: ['Ruby', 'Ruby on rails', 'Javascript', 'Tailwind CSS'],
livelink: 'https://tranquil-crag-64773.herokuapp.com/',
sourcecode: 'https://github.com/hammaazarok/recipe-app',
},
];
cards = cards.reverse();
function loadCards(cards) {
let cardHtml = '';
for (let cardIndex = 0; cardIndex < cards.length; cardIndex += 1) {
const html = `<div class="work-card work-card${cardIndex + 1}">
<div class="card-img">
<img src="img/works/${cards[cardIndex].img}" alt="work1">
</div>
<div class="card-details">
<h2 class="work-title">${cards[cardIndex].project_title}</h2>
<div class="work-info">
<p class="first">${cards[cardIndex].company}</p>
<p class="second">• ${cards[cardIndex].dev_title}</p>
<p class="second">• ${cards[cardIndex].date}</p>
</div>
<div class="word-desc">
<p>${cards[cardIndex].description}</p>
</div>
<div class="work-lang">
<ul>
<li>
<p class="lang-text">${cards[cardIndex].skills[0]}</p>
</li>
<li>
<p class="lang-text">${cards[cardIndex].skills[1]}</p>
</li>
<li>
<p class="lang-text">${cards[cardIndex].skills[2]}</p>
</li>
</ul>
</div>
<button type="button" class="work-btn btn">See Project</button>
</div>
</div>`;
cardHtml += html;
}
cardsContainer.innerHTML = cardHtml;
}
loadCards(cards);
const trigger = document.querySelectorAll('.work-btn');
const loadModal = function (id, cards) {
const modelHtml = `
<div class="work-card work-card${id + 1} flex-c work-card-pop">
<div class="modal-head">
<div class="title"> <h2 class="work-title">${
cards[id].project_title
}</h2></div>
<i class="fas fa-times close-button"></i>
</div>
<div class="work-info">
<p class="first">${cards[id].company}</p>
<p class="second">• ${cards[id].dev_title}</p>
<p class="second">• ${cards[id].date}</p>
</div>
<div class="card-img-model">
<img src="img/works/${cards[id].img}" alt="work1">
</div>
<div class="card-details-pop">
<div class="word-desc word-desc-pop">
<p>${cards[id].description}</p>
</div>
<div class="work-lang work-lang-pop">
<ul>
<li>
<p class="lang-text">${cards[id].skills[0]}</p>
</li>
<li>
<p class="lang-text">${cards[id].skills[1]}</p>
</li>
<li>
<p class="lang-text">${cards[id].skills[2]}</p>
</li>
</ul>
<div class="button-frame">
<button class="btn" onclick="window.open('${cards[id].livelink}', '_blank');">See Live <i class="fa-regular fa-circle-up"></i></button>${cards[id].disabled ? '<button type="button" class="btn" disabled>Not Available</button>' : `<button class="btn" onclick="window.open('${cards[id].sourcecode}', '_blank')">See Source <i class="fab fa-github"></i></button>`}
</div>
</div>
</div>
</div>`;
const bodyContainer = document.getElementById('modal');
bodyContainer.innerHTML = modelHtml;
const closeButton = document.querySelector('.close-button');
closeButton.addEventListener('click', Toggle);
};
const modal = document.querySelector('.modal');
function Toggle() {
modal.classList.toggle('show-modal');
}
function winOnClick(event) {
if (event.target === modal) {
Toggle();
}
}
trigger.forEach((element, i) => {
element.addEventListener('click', () => {
console.log(i);
Toggle();
loadModal(i, cards);
});
});
window.addEventListener('click', winOnClick);