-
Notifications
You must be signed in to change notification settings - Fork 0
/
portfolio.js
165 lines (146 loc) · 6.05 KB
/
portfolio.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
const body = document.querySelector('body');
const menuDiv = document.createElement('div');
menuDiv.className = 'menu-content';
menuDiv.style.display = 'none';
const htmlContent = `<img class="x-menu" src="images/Icon-Cancel.svg" alt="cancel image">
<ul class="menu-list-item">
<li class="portfolio"><a class="menu-list-items" href="#portfolio">Portfolio</a></li>
<li class="about"><a class="menu-list-items" href="#about">About</a></li>
<li class="contact"><a class="menu-list-items" href="#contact">Contact</a></li>
</ul>`;
menuDiv.innerHTML = htmlContent;
body.appendChild(menuDiv);
const cancelImage = menuDiv.querySelector('img');
cancelImage.className = 'x-menu';
cancelImage.src = 'images/Icon-Cancel.svg';
cancelImage.alt = 'cancel image';
const menuIcon = document.querySelector('.menu');
menuIcon.addEventListener('click', () => {
menuDiv.style.display = 'flex';
document.getElementById('header').style.filter = 'blur(0.3125rem)';
});
cancelImage.addEventListener('click', () => {
menuDiv.style.display = 'none';
document.getElementById('header').style.filter = 'none';
});
const itemLists = document.querySelectorAll('.menu-list-items');
itemLists.forEach((item) => {
item.addEventListener('click', () => {
menuDiv.style.display = 'none';
document.getElementById('header').style.filter = 'none';
});
});
const myProjects = [
{
name: 'Tonic',
description: `A daily selection of privately'personalized reads; no accounts or sign-ups
required.`,
featuredImage: './images/SnapshootDesktopPortfolioA.svg',
technology: ['html', 'css', 'javascript', 'github', 'ruby', 'bootstrap'],
liveVersion: 'https://github.com/',
sourceCode: 'http://127.0.0.1:5501/index.html',
},
{
name: 'Multi-Post Stories',
description: `Experimental content creation feature that allows users to add
to an existing story over the course of a day without
spamming their friends.`,
featuredImage: './images/SnapshootDesktopPortfolioB.svg',
technology: ['html', 'css', 'javascript', 'github', 'ruby', 'bootstrap'],
liveVersion: 'https://github.com/',
sourceCode: 'http://127.0.0.1:5501/index.html',
},
{
name: 'Facebook 360',
description: 'Exploring the future of media in Facebook\'s first Virtual Reality app; a place to discover and enjoy 360 photos and videos on Gear VR',
featuredImage: './images/SnapshootDesktopPortfolioC.svg',
technology: ['html', 'css', 'javascript', 'github', 'ruby', 'bootstrap'],
liveVersion: 'https://github.com/',
sourceCode: 'http://127.0.0.1:5501/index.html',
},
{
name: 'Uber Navigation',
description: 'A smart assistant to make driving more safe, efficient, and fun by unlocking your most expensive computer: your car.',
featuredImage: './images/SnapshootDesktopPortfolioD.svg',
technology: ['html', 'css', 'javascript', 'github', 'ruby', 'bootstrap'],
liveVersion: 'https://github.com/',
sourceCode: 'http://127.0.0.1:5501/index.html',
},
];
const seeProjectBtn = document.querySelectorAll('.see-project');
seeProjectBtn.forEach((item, i) => {
item.addEventListener('click', () => {
const project = myProjects[i];
const modalMenu = document.querySelector('.modal-container');
const projectTitle = modalMenu.querySelector('.modal-card-title');
projectTitle.textContent = project.name;
const projectDesc = modalMenu.querySelectorAll('.modal-primary-text');
const [mobileDesc, desktopDesc] = projectDesc;
mobileDesc.textContent = project.description;
desktopDesc.textContent = project.description;
projectDesc.textContent = project.description;
const projectMobileImage = modalMenu.querySelector('.mobile-image');
projectMobileImage.src = project.featuredImage;
const projectDesktopImage = modalMenu.querySelector('.desktop-image');
projectDesktopImage.src = project.featuredImage;
const liveLink = document.querySelector('.live-link');
liveLink.href = project.liveVersion;
const liveSourceCode = document.querySelector('.source-code');
liveSourceCode.href = project.sourceCode;
const allTech = document.querySelectorAll('.modal-tag');
allTech.forEach((item, i) => {
item.textContent = project.technology[i];
});
modalMenu.style.display = 'flex';
});
});
const modalCancelBtn = document.querySelector('.modal-cancel-image');
modalCancelBtn.addEventListener('click', () => {
const removeModalContainer = document.querySelector('.modal-container');
removeModalContainer.style.display = 'none';
});
const form = document.getElementById('contact-form');
const emailInput = document.getElementById('email');
const errorMessage = document.querySelector('.error-message');
form.addEventListener('submit', (e) => {
if (emailInput.value.toLowerCase() !== emailInput.value) {
e.preventDefault();
errorMessage.style.cssText = 'color: black; background: white; border-radius: 1px solid black';
errorMessage.textContent = 'Please, use lowercase letters for your email address';
} else {
errorMessage.style.display = 'none';
}
});
function storageAvailable(type) {
let storage;
try {
storage = window[type];
const x = '__storage_test__';
storage.setItem(x, x);
storage.removeItem(x);
return true;
} catch (e) {
return e instanceof DOMException && (
e.code === 22
|| e.code === 1014
|| e.name === 'QuotaExceededError'
|| e.name === 'NS_ERROR_DOM_QUOTA_REACHED')
&& (storage && storage.length !== 0);
}
}
if (storageAvailable('localStorage')) {
let formDetails = { name: '', email: '', message: '' };
if (window.localStorage.getItem('profile')) {
const getProfile = window.localStorage.getItem('profile');
formDetails = JSON.parse(getProfile);
form.username.value = formDetails.name;
form.email.value = formDetails.email;
form.message.value = formDetails.message;
}
form.addEventListener('input', () => {
formDetails.name = form.username.value;
formDetails.email = form.email.value;
formDetails.message = form.message.value;
window.localStorage.setItem('profile', JSON.stringify(formDetails));
});
}