-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.js
380 lines (358 loc) · 11.8 KB
/
main.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
/* data for projects*/
const projects = [
{
projectType: 'javascript',
github: 'https://github.com/GuaciG/tesla-landing-clone',
live: 'https://jazzy-haupia-293b11.netlify.app/',
title: 'Tesla Clone',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1687457208/Proyectos/Tesla%20clone/tesla-preview_wsg3im.jpg',
details: 'Astro / JavaScript / Tailwindcss / Netlify',
isPrivate: false,
isFinished: true
},
{
projectType: 'nextjs',
github: 'mailto:[email protected]',
live: 'https://airbnb-clone-project-red.vercel.app/',
title: 'Airbnb Clone',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1670596218/Proyectos/Airbnb%20clone/airbnb-preview_rmzc6u.jpg',
details: 'Nextjs / Tailwindcss / Vercel',
isPrivate: true,
isFinished: true
},
{
projectType: 'react',
github: 'mailto:[email protected]',
live: '#',
title: 'Netflix Clone',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667651502/Proyectos/Netflix%20clone/netflix-preview_xnstdg.jpg',
details: 'React / Redux / TMDB Api / Firebase',
isPrivate: true,
isFinished: false
},
{
projectType: 'javascript',
github: 'https://github.com/GuaciG/rock-paper-scissors-game',
live: 'https://guacig.github.io/rock-paper-scissors-game/',
title: 'Rock-Paper-Scissors Game',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667651660/Proyectos/Rock-Paper-Scissors/rock-paper-scissors-game-app-preview_tcfgll.jpg',
details: 'JavaScript',
isPrivate: false,
isFinished: true
},
{
projectType: 'javascript',
github: 'https://github.com/GuaciG/techiesgirls-website',
live: 'https://guacig.github.io/techiesgirls-website/',
title: 'TechiesGIRLS Website',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667651580/Proyectos/TechiesGIRLS-website/techies-girls-preview_hy5rqn.jpg',
details: 'JavaScript',
isPrivate: false,
isFinished: true
},
{
projectType: 'react',
github: 'https://github.com/GuaciG/todo-list-react-app',
live: 'https://guacig.github.io/todo-list-react-app/',
title: 'ToDo List React App',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667922766/Proyectos/To-Do%20List/todo-list-app-preview_ti0bg6.jpg',
details: 'React Hooks',
isPrivate: false,
isFinished: true
},
{
projectType: 'javascript',
github: 'https://github.com/GuaciG/tic-tac-toe-game',
live: 'https://guacig.github.io/tic-tac-toe-game/',
title: 'Tic Tac Toe Game',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667651628/Proyectos/TicTacToe/tic-tac-toe-game-app-preview_e3k157.jpg',
details: 'JavaScript',
isPrivate: false,
isFinished: true
},
{
projectType: 'javascript',
github: 'https://github.com/GuaciG/local-weather-app',
live: 'https://guacig.github.io/local-weather-app/',
title: 'Local Weather App',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667922826/Proyectos/Weather/local-weather-app-preview_hpcglg.jpg',
details: 'JavaScript / Openweather API',
isPrivate: false,
isFinished: true
},
{
projectType: 'react',
github: 'https://github.com/GuaciG/pomodoro-timer',
live: 'https://guacig.github.io/pomodoro-timer/',
title: 'Pomodoro Clock',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667922881/Proyectos/Pomodoro%20Clock/pomodoro-clock-app-preview_dvikgy.jpg',
details: 'React',
isPrivate: false,
isFinished: true
},
{
projectType: 'javascript',
github: 'https://github.com/GuaciG/calculator',
live: 'https://guacig.github.io/calculator/',
title: 'JavaScript Calculator',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667651312/Proyectos/Calculator/calculator-app-preview_zertq3.jpg',
details: 'JavaScript',
isPrivate: false,
isFinished: true
},
{
projectType: 'javascript',
github: 'https://github.com/GuaciG/drum-machine',
live: 'https://guacig.github.io/drum-machine/',
title: 'Drum Machine',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667922649/Proyectos/Drum%20Machine/drum-machine-app-preview_y5dvml.jpg',
details: 'JavaScript',
isPrivate: false,
isFinished: true
},
{
projectType: 'javaScript',
github: 'https://github.com/GuaciG/landing-page-travel',
live: 'https://guacig.github.io/landing-page-travel/',
title: 'Travel Single Page',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667651532/Proyectos/Product%20Landing%20Page/travel-single-page-preview_wqhyrj.jpg',
details: 'JavaScript',
isPrivate: false,
isFinished: true
},
{
projectType: 'react',
github: 'https://github.com/GuaciG/random-quote-machine',
live: 'https://guacig.github.io/random-quote-machine/',
title: 'Random Quote Machine',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667922941/Proyectos/Random%20Quote%20Machine/random-quote-machine-app-preview_sbuilt.jpg',
details: 'React',
isPrivate: false,
isFinished: true
},
{
projectType: 'javascript',
github: 'https://github.com/GuaciG/product-landing-page',
live: 'https://guacig.github.io/product-landing-page/',
title: 'Product Landing Page',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667651558/Proyectos/Product%20Landing%20Page%20Cookies/cookies-preview_efqcko.jpg',
details: 'JavaScript',
isPrivate: false,
isFinished: true
},
{
projectType: 'react',
github: 'https://github.com/GuaciG/markdown-previewer',
live: 'https://guacig.github.io/markdown-previewer/',
title: 'Markdown Previewer',
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1667651474/Proyectos/Markdown%20Previewer/markdown-previewer-preview_zx6mqs.jpg',
details: 'React',
isPrivate: false,
isFinished: true
}
]
/* data for languages or tools logos */
const toolsLogos = [
{
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1600885808/iconos/html5_l9uaty.png',
alt: 'html'
},
{
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1600885808/iconos/css_sa8yg3.png',
alt: 'css'
},
{
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1618478985/iconos/JavaScript_ehfdft.jpg',
alt: 'javascript'
},
{
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1600885809/iconos/sass_ytfiqd.png',
alt: 'sass'
},
{
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1613751254/iconos/jquery_qflxqt.png',
alt: 'jquery'
},
{
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1600885809/iconos/react_uras0m.png',
alt: 'react'
},
{
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1670597946/iconos/nextjs-logo_ye7rad.png',
alt: 'nextJs'
},
{
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1670597946/iconos/tailwindcss-logo_fuzeii.png',
alt: 'tailwindCss'
},
{
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1600885808/iconos/bootstrap_smrtex.png',
alt: 'bootstrap'
},
{
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1600885808/iconos/git_dvm9dx.png',
alt: 'git'
},
{
src: 'https://res.cloudinary.com/drpcjt13x/image/upload/v1600885808/iconos/github_gf0t2u.png',
alt: 'github'
}
]
/* JavaScript Template Literals to create projects and tools-logos sections */
/* Template Literals for projects section */
const projectTemplate = project => {
return `
<div class="project-tile ${project.projectType}">
<img
src=${project.src}
alt=${project.title}
/>
<div class="overlay">
<div class='overlay-info'>
<strong>${project.title}</strong>
<br />
<p class="details">
${project.details}
</p>
<br />
<p class="private">
${project.isPrivate ? 'GitHub repo upon request' : ''}
</p>
<br />
<p class="finished">
${project.isFinished ? '' : 'UPDATING'}
</p>
<div class='overlay-links'>
<a
href=${project.github}
title=${project.title}
target="_blank"
>
GitHub
</a>
${
project.isFinished
? `<a
href=${project.live}
title=${project.title}
target="_blank"
>
Preview
</a>`
: ''
}
</div>
</div>
</div>
</div>
`
}
document.getElementById('display-proyects').innerHTML = `
<div class="projects-box-wrapper">
<div class="projects-box">
${projects.map(projectTemplate).join('')}
</div>
</div>
`
/* Template Literals for tools-logos section */
const toolsTemplate = tool => {
return `
<img
src=${tool.src}
alt=${tool.alt}
/>
`
}
document.getElementById('display-tools').innerHTML = `
<div class="combo">
${toolsLogos.map(toolsTemplate).join('')}
</div>
`
/* add an event listener to the document, when the page finishes loading,
runs the functions: filterProjects and typeWriter */
document.addEventListener(
'DOMContentLoaded',
function () {
filterProjects('all')
typeWriter()
},
false
)
/* filterProjects function to display projects based on the button clicked. */
function filterProjects(selection) {
let i
const projects = document.getElementsByClassName('project-tile')
if (selection == 'all') selection = ''
/* Add the "show" class to the filtered elements,
and remove the "show" class from the elements that are not selected */
for (i = 0; i < projects.length; i++) {
removeClass(projects[i], 'show')
if (projects[i].className.indexOf(selection) > -1)
addClass(projects[i], 'show')
}
}
// Show filtered elements
function addClass(element, name) {
let i
let arr1 = element.className.split(' ')
let arr2 = name.split(' ')
for (i = 0; i < arr2.length; i++) {
if (arr1.indexOf(arr2[i]) == -1) {
element.className += ' ' + arr2[i]
}
}
}
// Hide elements that are not selected
function removeClass(element, name) {
let i
let arr1 = element.className.split(' ')
let arr2 = name.split(' ')
for (i = 0; i < arr2.length; i++) {
while (arr1.indexOf(arr2[i]) > -1) {
arr1.splice(arr1.indexOf(arr2[i]), 1)
}
}
element.className = arr1.join(' ')
}
// Add 'highlighted' class to the current control button (highlight it)
const btnContainer = document.getElementById('btns-wrapper')
const btns = btnContainer.getElementsByClassName('btn')
for (let i = 0; i < btns.length; i++) {
btns[i].addEventListener('click', function () {
let current = document.getElementsByClassName('highlighted')
current[0].className = current[0].className.replace(' highlighted', '')
this.className += ' highlighted'
})
}
/* Animation typeWriter in title */
const H3 = document.getElementById('role')
const txt = 'Front-End Developer.'
const speed = 200
let letter = 0
function typeWriter() {
//if letter < txt.length writes in h3 the character in that position
if (letter < txt.length) {
H3.innerHTML += txt.charAt(letter)
letter++
setTimeout(typeWriter, speed)
}
}
/* navigation-scroll to specific section via navbar links */
const sections = document.querySelectorAll('section')
const navLi = document.querySelectorAll('.nav-content .nav-links li a')
window.addEventListener('scroll', () => {
let current = ''
sections.forEach(section => {
const sectionTop = section.offsetTop
const sectionHeight = section.clientHeight
if (scrollY >= sectionTop) {
current = section.getAttribute('id')
}
})
navLi.forEach(a => {
a.classList.remove('active')
if (a.classList.contains(current)) {
a.classList.add('active')
}
})
})