generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
201 lines (192 loc) · 8.67 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
window.onload = function () {
const hamburgerMenu = document.querySelector('#menu-button');
const menu = document.querySelector('#menu');
const closeMenu = document.querySelector('#closeButton');
const closeNavLink = document.querySelectorAll('li > a.Personal-information');
const openAndClose = function () {
menu.classList.toggle('visible');
};
hamburgerMenu.addEventListener('click', openAndClose);
closeMenu.addEventListener('click', openAndClose);
closeNavLink.forEach((element) => {
element.addEventListener('click', openAndClose);
});
// ----------------------------------------------Array of projects
const arrOfProjects = [
{
image: 'assets/awesome-books-1.png',
title: 'Awesome Books',
languages: ['CSS3', 'HTML', 'bootstrap', 'Ruby'],
description: 'We created an app to store, display and remove books from localStorage and UI. This project has been built with the help of modern CSS3 and ES6. Check the live demo to try.',
linkLiveVersion: 'https://carloshs1994.github.io/AwesomeBooks/',
linkToSource: 'https://github.com/carloshs1994/AwesomeBooks',
},
{
image: 'assets/market-overview.png',
title: 'Market Overview',
languages: ['React', 'Redux', 'SASS'],
description: 'Market Overview is a website designed to showcase the US stock market. You could find details about the stock of choice and improve your strategies. Built using React, Redux, SASS, and tested using React testing library.',
linkLiveVersion: 'https://carloshs1994.github.io/market-overview/',
linkToSource: 'https://github.com/carloshs1994/market-overview',
},
{
image: 'assets/SnapshootPortfolio.svg',
title: 'Profesional Art Printing Data-2',
languages: ['html', 'bootstrap', 'Ruby'],
description: "A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry's standard",
linkLiveVersion: '#',
linkToSource: '#',
},
{
image: 'assets/SnapshootPortfolio.svg',
title: 'Profesional Art Printing Data-3',
languages: ['html', 'bootstrap', 'Ruby'],
description: "A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry's standard",
linkLiveVersion: '#',
linkToSource: '#',
},
{
image: 'assets/SnapshootPortfolio.svg',
title: 'Profesional Art Printing Data-4',
languages: ['html', 'bootstrap', 'Ruby'],
description: "A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry's standard",
linkLiveVersion: '#',
linkToSource: '#',
},
{
image: 'assets/SnapshootPortfolio.svg',
title: 'Profesional Art Printing Data-5',
languages: ['html', 'bootstrap', 'Ruby'],
description: "A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry's standard",
linkLiveVersion: '#',
linkToSource: '#',
},
{
image: 'assets/SnapshootPortfolio.svg',
title: 'Profesional Art Printing Data-6',
languages: ['html', 'bootstrap', 'Ruby'],
description: "A daily selection of privately personalized reads; no accounts or sign-ups required. has been the industry's standard",
linkLiveVersion: '#',
linkToSource: '#',
},
];
const projects = arrOfProjects.map((element, index) => {
const card = document.createElement('article');
if (index === 0) {
card.className = 'card principal-card';
card.innerHTML = `
<div class="feat-img-principal-card"></div>
<div class="description-principal-card">
<h3 class="description-title">${element.title}</h3>
<p class="supporting-text-principal-card">${element.description}</p>
<ul class="tag-holder">
<li class="tag"><p class="css">${element.languages[0]}</p></li>
<li class="tag"><p class="html">${element.languages[1]}</p></li>
<li class="tag"><p class="bootstrap">${element.languages[2]}</p></li>
<li class="tag"><p class="rubi">${element.languages[3]}</p></li>
</ul>
<button class="see-project main-button project-link" type="button">See Project</button>
</div>
`;
} else {
card.className = `card-${index} second-card`;
card.innerHTML = `
<div class="mask-group">
<h4>${element.title}</h4>
<p class="supporting-text-secondary-card">${element.description}</p>
<ul class="tag-holder secondary-tag-holder">
<li class="secondary-tag"><p class="html">${element.languages[0]}</p></li>
<li class="secondary-tag"><p class="bootstrap">${element.languages[1]}</p></li>
<li class="secondary-tag"><p class="rubi">${element.languages[2]}</p></li>
</ul>
</div>
<button class="see-project secondary-button project-link">See Project</button>
`;
}
return card;
});
const projectsSection = document.getElementById('works-section-id');
for (let i = 0; i < projects.length; i += 1) {
projectsSection.appendChild(projects[i]);
}
// ------------------------------------------------Modal
const modalContainer = document.querySelector('.modal-container');
const modal = document.getElementById('modal');
const closeModal = () => {
modal.innerHTML = '';
modalContainer.setAttribute('style', 'display = none');
};
const openModal = (e) => {
let currentTitle;
if (e.target.classList[1] === 'main-button') {
currentTitle = e.target.parentNode.children[0].innerHTML;
} else {
currentTitle = e.target.parentNode.children[0].children[0].innerHTML;
}
const project = arrOfProjects.filter((pro) => pro.title === currentTitle)[0];
const modalHeader = document.createElement('div');
const modalTop = document.createElement('div');
const modalLanguages = document.createElement('ul');
const modalWrap = document.createElement('div');
modalTop.className = 'top';
modalTop.innerHTML = `<h1 class="display-2">${project.title}</h1>
<span id="close_modal" class="close-modal">x</span>`;
modalLanguages.className = 'modal-languages';
for (let i = 0; i < project.languages.length; i += 1) {
const listElement = document.createElement('li');
listElement.className = 'modal-language';
listElement.innerHTML = project.languages[i];
modalLanguages.appendChild(listElement);
}
modalHeader.className = 'modal-header';
modalHeader.append(modalTop, modalLanguages);
const imageWrapper = document.createElement('div');
imageWrapper.className = 'image-wrap';
imageWrapper.innerHTML = `<img src="${project.image}" alt="${project.title}" class="modal-image">`;
const modalBody = document.createElement('div');
modalBody.className = 'modal-body';
modalBody.innerHTML = `
<p class="par">${project.description}</p>
<div class="go-to-wrapper">
<a href="${project.linkLiveVersion}" class="see-project">See live<i class="fas fa-external-link-alt"></i></a>
<a href="${project.linkToSource}" class="see-project">See source<i class="fab fa-github"></i></a>
</div>
`;
modalWrap.className = 'body-wrap';
modalWrap.append(imageWrapper, modalBody);
modal.className = 'modal';
modal.append(modalHeader, modalWrap);
const closeModalButton = document.querySelector('#close_modal');
closeModalButton.addEventListener('click', closeModal);
modalContainer.setAttribute('style', 'display: flex');
};
const projectButtons = document.querySelectorAll('.project-link');
projectButtons.forEach((button) => {
button.addEventListener('click', openModal);
});
const form = document.getElementById('form');
const email = document.getElementById('email');
const closeError = ({ target }) => {
document.getElementById('form-button').disabled = false;
document.querySelector('body').removeChild(target.parentNode);
};
const showError = (message) => {
const error = document.createElement('div');
error.className = 'error';
error.innerHTML = `<span id="close_error" class="close-error">x</span>
<p class="supporting-text">${message}</p>
<button id="ok_error" class="see-project">Ok</button>
`;
document.querySelector('body').appendChild(error);
document.querySelector('#close_error').addEventListener('click', closeError);
document.querySelector('#ok_error').addEventListener('click', closeError);
};
form.addEventListener('submit', (e) => {
if (email.value !== email.value.toLowerCase()) {
showError('The email should be lower-case!');
e.preventDefault();
e.target[3].disabled = true;
}
e.preventDefault();
});
};