-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
214 lines (189 loc) · 5.05 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Amatic+SC:wght@700&family=Major+Mono+Display&display=swap" rel="stylesheet">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
html, body {
height: 99%;
}
.container {
background-color: #eeeeec;
font-family: 'Major Mono Display', monospace;
color: #333333;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100%;
}
#personContainer {
position: relative;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);
width: 350px;
height: 500px;
border-radius: 20px;
background-color: #fefefc;
}
.header {
position: relative;
}
.rounded {
border-top-left-radius: 20px;
border-top-right-radius: 20px;
}
.transitionText:hover {
color: #ddd;
transition: 0.3s;
}
.headerImage {
z-index: 0;
width: 100%;
min-height: 70%;
}
.shadow {
z-index: 1;
position: absolute;
height: 120px;
width: 100%;
background-image: linear-gradient(to bottom, rgb(14, 14, 14), rgba(255, 0, 0, 0));
top: 0;
}
.content {
position: absolute;
bottom: 0;
padding-bottom: 20px;
color: white;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
height: 30%;
width: 100%;
display: flex;
align-items: center;
}
.name {
z-index: 2;
position: absolute;
top: 24px;
left: 24px;
font-size: 32px;
font-weight: bold;
color: #fefefc;
width: 90%;
cursor: pointer
}
span {
font-size: 16px;
font-weight: bold;
text-align: right;
width: 100%;
display: inline-block;
cursor: pointer
}
#email {
text-decoration: underline;
font-size: 22px;
background-color: black;
width: 100%;
inline-size: 100%;
overflow-wrap: break-word;
cursor: pointer;
}
.bottomHeader {
z-index: 2;
position: absolute;
bottom: 0;
font-weight: bold;
color: #fefefc;
padding: 10px 0 15px 0;
}
.anotherBtn {
background-color: #333333;
color: #fefefc;
border-radius: 0;
border: 0;
font-size: 14px;
padding: 8px;
}
</style>
<title>PeopleGen</title>
</head>
<body>
<div class="container">
<div id="personContainer">
<div class="header">
<img class="rounded headerImage" src="https://picsum.photos/500"/>
<div id="name" class="name transitionText"></div>
<div class="rounded shadow"></div>
<div class="bottomHeader">
<span id="cpf" class="transitionText"></span>
<span id="cnpj" class="transitionText"></span>
</div>
</div>
<div class="content">
<div id="email" class="transitionText"></div>
</div>
</div>
<button id="anotherBtn" class="anotherBtn">another</button>
</div>
<script type="application/javascript">
const newPerson = clb => {
const xhr = new XMLHttpRequest();
xhr.responseType = 'json';
xhr.open('POST', '/graphql');
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Accept', 'application/json');
xhr.onload = () => clb(xhr.response.data.person);
const query = `{
person {
name
email
cpf
cnpj
credits
}
}`;
xhr.send(JSON.stringify({query}));
};
const $ = (id) => {
return document.getElementById(id)
}
const newContent = (id, val) => {
$(id).innerHTML = val;
}
const personFiller = person => {
// fill up the screen
newContent('name', person.name);
newContent('email', person.email);
newContent('cpf', `CPF: ${person.cpf}`);
newContent('cnpj', `CNPJ: ${person.cnpj}`);
// applying random colors
let _1 = `${Math.random() * 151}`;
let _2 = `${Math.random() * 151}`;
let _3 = `${Math.random() * 151}`;
const mainColor = `rgb(${_1}, ${_2}, ${_3}, 1)`;
$('personContainer').style.backgroundColor = mainColor;
document.getElementsByClassName('bottomHeader')[0].style.backgroundColor = `rgb(${_1}, ${_2}, ${_3}, 0.6)`;
// setting up events
['name', 'email', 'cpf', 'cnpj'].forEach(text => {
$(text).onclick = () => {
if (navigator.clipboard) {
navigator.clipboard.writeText(person[text])
$(text).style.color = mainColor;
console.log(`${person[text]} to clipboard`);
setTimeout(function() {
$(text).style = {}
}, 250);
} else {
alert('only available in https');
}
}
})
};
newPerson(personFiller);
$('anotherBtn').onclick = () => newPerson(personFiller)
</script>
</body>
</html>