generated from microverseinc/readme-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
popup.js
170 lines (170 loc) · 7.65 KB
/
popup.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
const projects = {
p15: {
name: 'Tonic',
description:
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry',
img: './Images/Desktop-version/nature.png',
technolgies: ['React', 'Redux', 'HTML', 'CSS', 'JavaScript'],
linkToLiveVersion: '#',
linkToSource: 'https://github.com/FaranoshAmini',
generalInf: ['CANOPY', 'Back End Dev', 2015],
},
p16: {
name: 'Tonic',
description:
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry',
img: './Images/Desktop-version/nature.png',
technolgies: ['React', 'Redux', 'HTML', 'CSS', 'JavaScript'],
linkToLiveVersion: '#',
linkToSource: 'https://github.com/FaranoshAmini',
generalInf: ['CANOPY', 'Back End Dev', 2015],
},
p17: {
name: 'Tonic',
description:
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it 1960s with the releaLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry',
img: './Images/Desktop-version/nature.png',
technolgies: ['React', 'Redux', 'HTML', 'CSS', 'JavaScript'],
linkToLiveVersion: '#',
linkToSource: 'https://github.com/FaranoshAmini',
generalInf: ['CANOPY', 'Back End Dev', 2015],
},
};
const myWork = document.querySelector('#work');
function createMobileProjectCard(key) {
const projectSection = document.createElement('div');
const img = document.createElement('img');
const general = document.createElement('div');
const infGeneral = document.createElement('div');
const title = document.createElement('h3');
const inf = document.createElement('p');
const description = document.createElement('p');
const techns = document.createElement('ul');
const btnLoad = document.createElement('a');
const footer = document.createElement('footer');
const externalLink = document.createElement('div');
const descriptionList = projects[key].description.split(' ');
const descriptionNbrWords = descriptionList.length;
externalLink.appendChild(btnLoad);
externalLink.classList.add('external_link');
footer.appendChild(techns);
footer.appendChild(externalLink);
general.appendChild(title);
general.appendChild(infGeneral);
general.appendChild(description);
general.appendChild(footer);
general.classList.add('general');
infGeneral.appendChild(inf);
infGeneral.id = 'general_inf';
projectSection.appendChild(img);
img.src = projects[key].img;
img.alt = 'Image project';
img.classList.add('project_image');
projectSection.appendChild(general);
title.innerHTML = projects[key].name;
inf.innerHTML = `${projects[key].generalInf[0]} • ${projects[key].generalInf[1]} • ${projects[key].generalInf[2]}`;
inf.classList.add('title');
description.innerHTML = descriptionList
.slice(0, Math.min(17, Math.floor(0.4 * descriptionNbrWords)))
.join(' ');
description.innerHTML += '...';
description.classList.add('project_description');
projects[key].technolgies.forEach((element) => {
techns.innerHTML = `${techns.innerHTML}<li>${element} </li>`;
});
techns.classList.add('skills');
btnLoad.innerHTML = 'See Project';
btnLoad.href = '#';
projectSection.appendChild(general);
projectSection.key = key;
projectSection.className = 'project';
return projectSection;
}
Object.keys(projects).forEach((key) => {
myWork.appendChild(createMobileProjectCard(key));
});
const popUpBtn = document.querySelectorAll('.external_link');
const btnSource = document.createElement('a');
const btnLive = document.createElement('a');
const externalButton = document.createElement('div');
const wrapper = document.createElement('div');
const home = document.querySelector('.home-page');
const about = document.querySelector('.headline');
const head = document.querySelector('#nav');
const wwork = document.querySelector('#work');
const cancelBtn = document.createElement('img');
const imgWrapper = document.createElement('div');
const header = document.createElement('div');
const title = document.createElement('h3');
const infos = document.createElement('p');
const image = document.createElement('img');
const description = document.createElement('p');
const skills = document.createElement('ul');
imgWrapper.classList.add('pop-header-div');
cancelBtn.src = './Images/Icon.svg';
imgWrapper.appendChild(cancelBtn);
btnSource.target = '_blank';
btnLive.target = '_blank';
description.classList.add('project_description');
infos.classList.add('inf');
const bottom = document.createElement('div');
const mobilePart = document.createElement('div');
title.classList.add('pop-header-h3');
header.appendChild(title);
header.appendChild(imgWrapper);
header.classList.add('pop-header');
btnSource.innerHTML = '<img src="Images/gitbutton.png" alt="Live version"> ';
btnLive.innerHTML = '<img src="Images/livebutton.png" alt="Live version"> ';
externalButton.appendChild(btnLive);
externalButton.appendChild(btnSource);
bottom.appendChild(skills);
bottom.appendChild(externalButton);
mobilePart.appendChild(description);
mobilePart.appendChild(bottom);
mobilePart.classList.add('mobile-part-class');
mobilePart.querySelector('p').classList.add('pop-header-description');
image.classList.add('project_image');
image.classList.add('pop-header-img');
wrapper.appendChild(header);
wrapper.appendChild(infos);
wrapper.appendChild(image);
wrapper.appendChild(mobilePart);
wrapper.style.zIndex = '999';
wrapper.style.position = 'absolute';
wrapper.style.top = '0';
wrapper.classList.add('pop-window');
wrapper.style.visibility = 'hidden';
home.appendChild(wrapper);
popUpBtn.forEach((btn) => {
btn.addEventListener('click', () => {
const parentId = btn.parentElement.parentElement.parentElement.key;
title.innerHTML = projects[parentId].name;
infos.innerHTML = `${projects[parentId].generalInf[0]} • ${projects[parentId].generalInf[1]} • ${projects[parentId].generalInf[2]}`;
image.src = projects[parentId].img;
description.innerHTML = projects[parentId].description;
skills.innerHTML = '';
projects[parentId].technolgies.forEach((element) => {
skills.innerHTML = `${skills.innerHTML}<li>${element} </li>`;
});
btnSource.href = projects[parentId].linkToSource;
btnLive.href = projects[parentId].linkToLiveVersion;
skills.classList.add('skills');
skills.classList.add('techns');
home.style.backgroundColor = 'rgba(193, 199, 208, 0.7)';
about.style.backgroundColor = 'rgba(193, 199, 208, 0.7)';
head.style.backgroundColor = 'rgba(193, 199, 208, 0.7)';
wwork.style.backgroundColor = 'rgba(193, 199, 208, 0.7)';
wrapper.style.visibility = 'visible';
wrapper.style.position = 'fixed';
wrapper.style.overflow = 'scroll';
});
});
const cancel = document.querySelector('.pop-header-div');
cancel.addEventListener('click', () => {
document.querySelector('.pop-window').style.visibility = 'hidden';
home.style.backgroundColor = '#fff';
about.style.backgroundColor = '#fff';
head.style.backgroundColor = '#fff';
wwork.style.backgroundColor = '#E5E5E5';
wrapper.style.position = 'hidden';
});