-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
447 lines (397 loc) · 16.6 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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
const menu = document.getElementById('menu');
const close = document.getElementById('close');
const openNav = document.getElementById('openNav');
const items = document.getElementsByClassName('item');
const audio = document.getElementById('audio');
const audio2 = document.getElementById('audio2');
const pors = document.getElementsByClassName('por');
const fas = document.getElementsByClassName('fa');
const languages = document.getElementById('languagesContainer');
const languagesPanel = document.getElementById('languagesPanel');
const frameworks = document.getElementById('frameworks');
const frameworksPanel = document.getElementById('frameworksPanel');
const databases = document.getElementById('databases');
const databasesPanel = document.getElementById('databasesPanel');
const skills = document.getElementById('skills');
const skillsPanel = document.getElementById('skillsPanel');
skillsPanel.addEventListener('click', () => {
if (skills.style.display === 'flex') {
skills.style.display = 'none';
} else {
skills.style.display = 'flex';
frameworks.style.display = 'none';
languages.style.display = 'none';
databases.style.display = 'none';
}
});
databasesPanel.addEventListener('click', () => {
if (databases.style.display === 'flex') {
databases.style.display = 'none';
} else {
databases.style.display = 'flex';
frameworks.style.display = 'none';
languages.style.display = 'none';
skills.style.display = 'none';
}
});
frameworksPanel.addEventListener(('click'), () => {
if (frameworks.style.display === 'flex') {
frameworks.style.display = 'none';
} else {
frameworks.style.display = 'flex';
languages.style.display = 'none';
databases.style.display = 'none';
skills.style.display = 'none';
}
});
languagesPanel.addEventListener('click', () => {
if (languages.style.display === 'flex') {
languages.style.display = 'none';
languages.style.opacity = 0;
} else {
languages.style.display = 'flex';
languages.style.opacity = '100%';
frameworks.style.display = 'none';
databases.style.display = 'none';
skills.style.display = 'none';
}
});
Array.from(fas).forEach((fa) => {
fa.addEventListener('mouseover', () => {
audio2.play();
});
});
Array.from(pors).forEach((por) => {
por.addEventListener('mouseover', () => {
audio.play();
});
});
menu.onclick = () => {
openNav.style.display = 'block';
openNav.style.transform = 'translateX(0)';
openNav.style.animation = 'slideIn ease-in-out 0.3s';
};
menu.onmouseover = () => {
document.body.style.cursor = 'hand';
};
close.onclick = () => {
openNav.style.animation = 'slideOut ease-in-out 0.3s';
openNav.style.transform = 'translateX(100%)';
};
const newItems = [...items];
newItems.forEach((item) => {
item.onclick = () => {
openNav.style.display = 'none';
};
});
const projects = [
{
name: 'Cash Guys',
details: ['Microverse', 'Ruby on Rails App', '2023'],
description: 'Cash Guys is a Ruby on Rails mobile web application that allows users to keep track of their expenses by adding categories and items to those categories.',
fullDescription: 'Cash Guys is a Ruby on Rails mobile web application that allows users to keep track of their expenses by adding categories and items to those categories. have a list of transactions associated with a category, so that the user can see how much money it spent and on what.',
image: './img/pic',
techs: ['HTML', 'CSS', 'Ruby_on_Rails', 'PostgreSQL'],
liveLink: 'https://rails-ah0l.onrender.com',
sourceLink: 'https://github.com/HabibPayenda/personal_badget',
},
{
name: 'Country Info',
details: ['Microverse', 'React App', '2022'],
description: 'Country Info is a web app that gets details about countries from an API and shows details about each country as name, flag, latitude, longitude, and population.',
fullDescription: 'Country Info is a web app that gets details about countries from an API and shows details about each country as name, flag, latitude, longitude, and population.',
image: './img/pic',
techs: ['CSS', 'JSX', 'AJAX', 'React', 'React_Router', 'Redux'],
liveLink: 'https://southaisacountries.netlify.app/',
sourceLink: 'https://github.com/HabibPayenda/Countries',
},
{
name: 'Book Store CMS',
details: ['Microverse', 'React App', '2022'],
description: 'A bookstore app that allows a user to add a book item and displays the added books. It also allows the user to delete a book.',
fullDescription: 'A bookstore app that allows a user to add a book item and displays the added books. It also allows the user to delete a book.',
image: './img/pic',
techs: ['CSS', 'JSX', 'AJAX', 'React', 'React_Router', 'Redux'],
liveLink: 'https://bookstorereact.onrender.com/',
sourceLink: 'https://github.com/HabibPayenda/BookStore',
},
{
name: 'Math Magicians',
details: ['Microverse', 'React App', '2022'],
description: 'A basic Calculator App built with React.js that solves basic arithmetic calculations.',
fullDescription: 'A basic Calculator App built with React.js that solves basic arithmetic calculations.',
image: './img/pic',
techs: ['CSS', 'JSX', 'AJAX', 'React', 'React_Router', 'Redux'],
liveLink: 'https://6324c2d62139ab0f678d36d3--endearing-sopapillas-233e38.netlify.app/',
sourceLink: 'https://github.com/HabibPayenda/mathMagicians',
},
];
const techInfo = {
CSS: {
img: './img/css.png',
info: 'CSS is the language we use to style an HTML document. CSS describes how HTML elements should be displayed.',
},
JSX: {
img: './img/jsx.png',
info: 'JSX stands for JavaScript XML. JSX allows us to write HTML in React. JSX makes it easier to write and add HTML in React.',
},
AJAX: {
img: './img/ajax.png',
info: 'AJAX allows web pages to be updated asynchronously by exchanging data with a web server behind the scenes.',
},
JS: {
img: './img/js.png',
info: 'JavaScript is the worlds most popular programming language. JavaScript is the programming language of the Web.',
},
React: {
img: './img/react logo.png',
info: 'React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It lets you compose complex UIs from small and isolated pieces.',
},
Redux: {
img: './img/redux.png',
info: 'Redux is a predictable state container designed to help you write JavaScript apps that behave consistently across client and server.',
},
React_Router: {
img: './img/reactrouter.png',
info: 'React Router is a standard library for routing in React. It enables the navigation among views of various components in a React Application',
},
Ruby_on_Rails: {
img: './img/rails.png',
info: 'Rails is a full-stack framework. It ships with all the tools needed to build amazing web apps on both the front and back end.',
},
HTML: {
img: './img/html.png',
info: 'HTML stands for Hyper Text Markup Language · HTML is the standard markup language for creating Web pages · HTML describes the structure of a Web page',
},
PostgreSQL: {
img: './img/postgresql.png',
info: 'PostgreSQL is a powerful, open source object-relational database system with over 35 years of active development.',
},
};
const worksSection = document.getElementById('Portfolio');
const modalContainer = document.getElementById('modalContainer');
/// //////ModalCreator
const modalCreator = (project, num) => {
const projectModal = document.createElement('div');
projectModal.classList.add('projectModal');
const closeIcon = document.createElement('i');
closeIcon.classList.add('fa-solid', 'fa-close', 'closeIcon2');
closeIcon.onclick = () => {
projectModal.style.display = 'none';
modalContainer.style.display = 'none';
};
const modalTitle = document.createElement('h2');
modalTitle.classList.add('main-title');
modalTitle.innerText = project.name;
const modalDetails = document.createElement('ul');
modalDetails.style.alignSelf = 'flex-start';
modalDetails.style.marginLeft = '16px';
modalDetails.style.marginTop = '22px';
project.details.forEach((detail) => {
const modalDetailLi = document.createElement('li');
modalDetailLi.classList.add('sub-item');
modalDetailLi.innerText = detail;
modalDetails.append(modalDetailLi);
});
const modalImage = document.createElement('div');
modalImage.classList.add('modal-card-img');
modalImage.style.backgroundImage = `url(${project.image}B${num}.png)`;
const modalText = document.createElement('p');
modalText.classList.add('modal-text');
modalText.innerText = project.fullDescription;
const modalTechUsed = document.createElement('ul');
modalTechUsed.classList.add('tech-used-modal');
modalTechUsed.style.alignSelf = 'flex-start';
modalTechUsed.style.marginLeft = '16px';
project.techs.forEach((item) => {
const modalTechItem = document.createElement('li');
modalTechItem.innerText = item;
modalTechUsed.append(modalTechItem);
});
const buttonContainer = document.createElement('div');
buttonContainer.style.display = 'flex';
buttonContainer.style.flexDirection = 'row';
buttonContainer.style.alignItems = 'center';
buttonContainer.style.justifyContent = 'center';
buttonContainer.style.marginTop = '25px';
const btnLive = document.createElement('div');
btnLive.classList.add('see-project', 'modal-see');
const btnSource = document.createElement('div');
btnSource.classList.add('see-project', 'modal-see');
const liveIcon = document.createElement('i');
liveIcon.classList.add('fas', 'fa', 'fa-external-link');
const sourceIcon = document.createElement('i');
sourceIcon.classList.add('fab', 'fa-github');
const modalSeeLive = document.createElement('a');
modalSeeLive.innerText = 'See Live';
modalSeeLive.setAttribute('href', project.liveLink);
modalSeeLive.setAttribute('target', '_blank');
btnLive.append(modalSeeLive, liveIcon);
const modalSeeSource = document.createElement('a');
modalSeeSource.innerText = 'See Source';
modalSeeSource.setAttribute('href', project.sourceLink);
modalSeeSource.setAttribute('target', '_blank');
btnSource.append(modalSeeSource, sourceIcon);
const modalDetailsContainer = document.createElement('div');
modalDetailsContainer.classList.add('modalDetailsContainer');
const leftContainer = document.createElement('div');
leftContainer.classList.add('modalTextContainer');
const rightContainer = document.createElement('div');
leftContainer.append(modalText);
buttonContainer.append(btnLive, btnSource);
rightContainer.append(modalTechUsed, buttonContainer);
modalDetailsContainer.append(leftContainer, rightContainer);
projectModal.append(closeIcon, modalTitle, modalDetails, modalImage, modalDetailsContainer);
modalContainer.append(projectModal);
};
for (let i = 0; i < projects.length; i += 1) {
const num = i + 1;
const card = document.createElement('div');
card.setAttribute('id', JSON.stringify(num));
card.classList.add('card', `card${num}`);
const cardImageContainer = document.createElement('div');
cardImageContainer.classList.add('cardImageContainer');
const cardImage = document.createElement('div');
cardImage.classList.add('card-img', `card-img-${num}`);
cardImage.style.backgroundImage = window.matchMedia('(min-width: 768px)') ? `url(${projects[i].image}B${num}.png)` : `url(${projects[i].image}${num}.png)`;
cardImageContainer.append(cardImage);
const detailsContainer = document.createElement('div');
detailsContainer.classList.add('details-container', 'card-details-1');
const mainTitle = document.createElement('h2');
mainTitle.classList.add('main-title');
mainTitle.innerText = projects[i].name;
const subDeatails = document.createElement('ul');
projects[i].details.forEach((detail) => {
const detailLi = document.createElement('li');
detailLi.classList.add('sub-item');
detailLi.innerText = detail;
subDeatails.append(detailLi);
});
const cardText = document.createElement('p');
cardText.classList.add('card-text');
cardText.innerText = projects[i].description;
const techUsed = document.createElement('ul');
techUsed.classList.add('tech-used');
projects[i].techs.forEach((item, index) => {
const techItemContainer = document.createElement('div');
techItemContainer.setAttribute('id', index);
techItemContainer.classList.add('techItemContainer');
const techItem = document.createElement('li');
techItem.innerText = item;
const techItemInfoContainer = document.createElement('div');
techItemInfoContainer.classList.add('techItemInfoContainer');
techItemInfoContainer.setAttribute('id', index);
const techItemInfo = document.createElement('div');
techItemInfo.setAttribute('id', index);
techItemInfo.classList.add('techInfo');
const techInfoImageContainer = document.createElement('div');
const techItemInfoImage = document.createElement('img');
techItemInfoImage.classList.add('techInfoImage');
// eslint-disable-next-line dot-notation
techItemInfoImage.setAttribute('src', techInfo[item].img);
techInfoImageContainer.append(techItemInfoImage);
techInfoImageContainer.classList.add('techInfoImageContainer');
techItemInfoImage.classList.add('techItemInfoImage');
const techInfoText = document.createElement('p');
techInfoText.classList.add('techInfoText');
techInfoText.innerText = techInfo[item].info;
techItemInfo.append(techInfoImageContainer, techInfoText);
techItemContainer.addEventListener('mouseover', () => {
if (techItemInfoContainer.id === techItemContainer.id) {
techItemInfoContainer.style.display = 'flex';
}
});
techItemContainer.addEventListener('mouseleave', () => {
techItemInfoContainer.style.display = 'none';
});
techItemInfoContainer.append(techItemInfo);
techItemContainer.append(techItem, techItemInfoContainer);
techUsed.append(techItemContainer);
});
const seeProject = document.createElement('a');
seeProject.classList.add('see-project');
seeProject.innerText = 'See Project';
seeProject.setAttribute('href', `#${JSON.stringify(num)}`);
seeProject.onclick = () => {
modalContainer.style.display = 'flex';
modalCreator(projects[i], i + 1);
// seeProject.parentElement.parentElement.setAttribute('id', 'clicked');
};
detailsContainer.append(mainTitle, subDeatails, cardText, techUsed, seeProject);
card.append(cardImageContainer, detailsContainer);
worksSection.append(card);
}
const form = document.getElementById('form');
const userName = document.getElementById('name');
const nameTag = document.getElementById('nameTag');
userName.addEventListener('focus', () => {
nameTag.style.display = 'block';
nameTag.style.transform = 'translateY(-10px)';
userName.placeholder = '';
});
userName.addEventListener('focusout', () => {
if (userName.value === '') {
nameTag.style.display = 'none';
nameTag.style.transform = 'translateY(0px)';
userName.placeholder = 'Enter Your Name:';
}
});
const email = document.getElementById('email');
const emailTag = document.getElementById('emailTag');
email.addEventListener('focus', () => {
emailTag.style.display = 'block';
emailTag.style.transform = 'translateY(-10px)';
email.placeholder = '';
});
email.addEventListener('focusout', () => {
if (userName.value === '') {
emailTag.style.display = 'none';
emailTag.style.transform = 'translateY(0px)';
email.placeholder = 'Enter Your Email:';
}
});
const emailText = document.getElementById('emailText');
const textTag = document.getElementById('textTag');
emailText.addEventListener('focus', () => {
textTag.style.display = 'block';
textTag.style.transform = 'translateY(-10px)';
emailText.innerText = '';
});
emailText.addEventListener('focusout', () => {
if (userName.value === '') {
textTag.style.display = 'none';
textTag.style.transform = 'translateY(0px)';
emailText.innerText = 'Write your message here!';
}
});
const userDataCheck = !!localStorage.getItem('userData');
if (userDataCheck) {
const data = JSON.parse(localStorage.getItem('userData'));
userName.value = data.userName;
email.value = data.email;
emailText.value = data.emailText;
}
const message = document.getElementById('email-text');
message.style.color = 'red';
message.innerText = 'Email should be lowercase!';
const checkEmail = () => {
const emailValue = email.value.trim();
if (emailValue.match(/[A-Z]/)) {
message.style.display = 'block';
return false;
}
message.style.display = 'none';
return true;
};
form.addEventListener('submit', (e) => {
e.preventDefault();
checkEmail();
});
form.addEventListener('submit', () => {
const userData = {
userName: userName.value,
email: email.value,
emailText: emailText.value,
};
localStorage.setItem('userData', JSON.stringify(userData));
});