-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostit.html
More file actions
317 lines (279 loc) · 8.42 KB
/
Copy pathpostit.html
File metadata and controls
317 lines (279 loc) · 8.42 KB
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
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<!-- Configurações básicas da página -->
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Post-it Público</title>
<!-- Importação das fontes do Google -->
<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=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<!-- Importação dos ícones do Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<style>
/* 🎨 Variáveis de cores do tema */
:root {
--primary-color: #2c3e50; /* Cor principal - azul escuro */
--secondary-color: #0aa069; /* Cor secundária - verde */
--accent-color: #e74c3c; /* Cor de destaque - vermelho */
--text-color: #ecf0f1; /* Cor do texto - branco suave */
--background-color: #1a1a1a; /* Cor de fundo - preto suave */
}
/* 📝 Configurações gerais de fonte */
* {
font-family: 'Poppins', sans-serif;
}
/* 🎯 Estilos do corpo da página */
body {
margin: 0;
padding: 0;
background-color: var(--background-color);
color: var(--text-color);
line-height: 1.6;
font-weight: 300;
}
/* 📌 Estilos dos títulos */
h1, h2, h3, h4, h5, h6 {
font-weight: 600;
}
/* 📦 Container principal */
.container {
max-width: 1200px;
margin: 0 auto;
padding: 2rem;
}
/* 🎭 Cabeçalho da página */
header {
text-align: center;
padding: 4rem 0;
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}
/* 🏆 Título principal */
h1 {
font-size: 3.5em;
margin: 0;
color: var(--text-color);
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}
/* 📌 Subtítulo */
.subtitle {
font-size: 1.5em;
margin-top: 1rem;
color: rgba(255,255,255,0.9);
}
/* 📝 Descrição */
#descricao {
margin: 1rem 0;
font-size: 1.1rem;
color: var(--text-color);
text-align: center;
}
/* 🎮 Controles de visualização */
.view-controls {
display: none;
}
/* 📝 Formulário de entrada */
form {
display: flex;
gap: 10px;
margin: 2rem auto;
max-width: 800px;
position: relative;
align-items: center;
}
/* 📦 Wrapper do input */
.input-wrapper {
position: relative;
flex: 1;
display: flex;
align-items: center;
}
/* ✏️ Campo de texto */
input[type="text"] {
width: 100%;
padding: 12px 80px 12px 12px;
font-size: 1rem;
border: 1px solid rgba(255,255,255,0.1);
border-radius: 5px;
background-color: rgba(255,255,255,0.05);
color: var(--text-color);
box-sizing: border-box;
}
/* 🔢 Contador de caracteres */
.char-count {
position: absolute;
right: 12px;
color: rgba(255,255,255,0.5);
font-size: 0.8rem;
pointer-events: none;
}
/* 🎯 Botão de envio */
button {
padding: 12px 24px;
font-size: 1rem;
background-color: var(--secondary-color);
border: none;
border-radius: 5px;
cursor: pointer;
color: var(--text-color);
transition: background-color 0.3s ease;
}
/* 🎯 Efeito hover no botão */
button:hover {
background-color: #0b8c5d;
}
/* 📑 Grid de post-its */
#postits {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 15px;
max-width: 1200px;
margin: 0 auto;
}
/* 📱 Responsividade - Telas grandes */
@media (max-width: 1200px) {
#postits {
grid-template-columns: repeat(3, 1fr);
}
}
/* 📱 Responsividade - Telas médias */
@media (max-width: 900px) {
#postits {
grid-template-columns: repeat(2, 1fr);
}
}
/* 📱 Responsividade - Telas pequenas */
@media (max-width: 600px) {
#postits {
grid-template-columns: 1fr;
}
}
/* 📝 Estilo individual do post-it */
.postit {
background: rgba(255,255,255,0.1);
border: 1px solid rgba(255,255,255,0.1);
padding: 15px;
border-radius: 10px;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
transition: transform 0.3s ease;
aspect-ratio: 1;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
word-break: break-word;
}
/* 🎯 Efeito hover no post-it */
.postit:hover {
transform: translateY(-2px);
}
/* 🏠 Botão de retorno */
.return-button {
display: inline-flex;
align-items: center;
padding: 0.6rem 1.0rem;
background-color: var(--secondary-color);
color: var(--text-color);
text-decoration: none;
border-radius: 50px;
font-weight: 500;
font-size: 0.95rem;
transition: all 0.3s ease;
box-shadow: 0 4px 15px rgba(13, 165, 5, 0.3);
border: 2px solid var(--secondary-color);
text-align: center;
margin-right: 1rem;
}
/* 🎯 Efeito hover no botão de retorno */
.return-button:hover {
transform: translateY(-3px);
box-shadow: 0 6px 20px rgba(13, 165, 5, 0.4);
background-color: transparent;
}
/* 🎯 Ícone do botão de retorno */
.return-button i {
margin-right: 6px;
}
</style>
</head>
<body>
<!-- 🎭 Cabeçalho da página -->
<header>
<h1>MBernard</h1>
<div class="subtitle">Desenvolvedor Full Stack</div>
</header>
<!-- 📦 Container principal -->
<div class="container">
<!-- 📝 Formulário de entrada -->
<form id="postit-form">
<!-- 🏠 Botão de retorno -->
<a href="index.html" class="return-button">
<i class="fas fa-home"></i>
Voltar
</a>
<!-- 📦 Wrapper do input -->
<div class="input-wrapper">
<input type="text" id="texto" placeholder="Escreva seu post-it aqui..." maxlength="100" required />
<span class="char-count">0/100</span>
</div>
<button type="submit">Enviar</button>
</form>
<!-- 📑 Container dos post-its -->
<div id="postits"></div>
</div>
<script>
// 🔗 URL da API
const API_URL = "https://5fyex1o1ec.execute-api.sa-east-1.amazonaws.com/postit-api";
const MAX_CHARS = 100;
// 🔢 Configuração do contador de caracteres
const textoInput = document.getElementById('texto');
const charCount = document.querySelector('.char-count');
// 👂 Listener para atualizar o contador de caracteres
textoInput.addEventListener('input', () => {
const currentLength = textoInput.value.length;
charCount.textContent = `${currentLength}/${MAX_CHARS}`;
});
// 📥 Função para carregar os post-its
async function carregarPostits() {
try {
const res = await fetch(API_URL);
if (!res.ok) throw new Error("Erro ao buscar post-its");
const postits = await res.json();
const container = document.getElementById('postits');
container.innerHTML = '';
postits.forEach(p => {
const div = document.createElement('div');
div.className = 'postit';
div.textContent = p.texto;
container.appendChild(div);
});
} catch (e) {
alert(e.message);
}
}
// 📝 Listener do formulário de envio
document.getElementById('postit-form').addEventListener('submit', async e => {
e.preventDefault();
const texto = document.getElementById('texto').value.trim();
if (!texto) return alert("Digite algo.");
if (texto.length > MAX_CHARS) return alert(`O texto não pode ter mais que ${MAX_CHARS} caracteres.`);
try {
const res = await fetch(API_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ texto })
});
if (!res.ok) throw new Error("Erro ao criar post-it");
document.getElementById('texto').value = '';
charCount.textContent = '0/100';
carregarPostits();
} catch (e) {
alert(e.message);
}
});
// 🚀 Carrega os post-its ao iniciar a página
carregarPostits();
</script>
</body>
</html>