-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
401 lines (356 loc) · 14.6 KB
/
Copy pathindex.html
File metadata and controls
401 lines (356 loc) · 14.6 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
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
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>Мобильный Мессенджер</title>
<script src="https://cdn.tailwindcss.com"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;900&display=swap');
body {
font-family: 'Inter', sans-serif;
background-color: #ffffff;
margin: 0;
padding: 0;
overflow-x: hidden;
}
/* Общие стили из макетов */
.custom-input-container {
background-color: #cccccc;
border-radius: 50px;
padding: 12px 25px;
margin-bottom: 15px;
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
}
.custom-label {
font-weight: 900;
font-style: italic;
font-size: 14px;
margin-bottom: 2px;
color: #000;
}
.custom-input {
background: transparent;
border: none;
border-bottom: 2px solid #555;
width: 100%;
outline: none;
text-align: center;
font-weight: bold;
}
.header-banner {
background-color: #cccccc;
border-radius: 50px;
padding: 15px;
width: 100%;
text-align: center;
margin-bottom: 30px;
}
.header-text {
font-weight: 900;
font-style: italic;
font-size: 28px;
text-transform: lowercase;
}
.btn-primary {
background-color: #0a0a45;
color: white;
border-radius: 50px;
padding: 15px;
width: 100%;
font-weight: 900;
font-style: italic;
font-size: 24px;
margin-top: 20px;
transition: opacity 0.2s;
}
.btn-primary:disabled {
opacity: 0.5;
cursor: not-allowed;
}
/* Стили экрана "Чаты" */
.chats-container {
background-color: #cccccc;
border-radius: 30px;
width: 100%;
padding: 20px 10px;
display: flex;
flex-direction: column;
flex-grow: 1;
margin-bottom: 20px;
}
.chat-item {
display: flex;
align-items: center;
padding: 12px 10px;
border-bottom: 1.5px solid #888;
cursor: pointer;
}
.chat-item:last-child {
border-bottom: none;
}
.chat-avatar-blue {
width: 45px;
height: 45px;
background-color: #0a0a45;
border-radius: 50%;
margin-right: 15px;
flex-shrink: 0;
}
.search-area {
margin-top: auto;
padding: 15px;
display: flex;
align-items: center;
gap: 15px;
}
.search-text {
font-weight: 900;
font-style: italic;
font-size: 22px;
border-bottom: 2px solid #555;
flex-grow: 1;
background: transparent;
outline: none;
}
.search-icon-circle {
width: 45px;
height: 45px;
background-color: #0a0a45;
border-radius: 50%;
}
/* Навигация экранов */
.screen {
display: none;
min-height: 100vh;
padding: 40px 20px;
}
.screen.active {
display: flex;
flex-direction: column;
}
.center-items {
align-items: center;
}
/* Чат */
.chat-header {
background: #0a0a45;
color: white;
width: 100%;
padding: 15px;
position: fixed;
top: 0;
z-index: 10;
display: flex;
align-items: center;
gap: 15px;
}
.message {
max-width: 80%;
padding: 10px 15px;
border-radius: 20px;
margin-bottom: 8px;
}
.message.sent {
align-self: flex-end;
background-color: #0a0a45;
color: white;
border-bottom-right-radius: 2px;
}
.message.received {
align-self: flex-start;
background-color: #eeeeee;
border-bottom-left-radius: 2px;
}
.error-msg {
color: #ff0000;
font-size: 12px;
font-weight: bold;
margin-top: -10px;
margin-bottom: 10px;
display: none;
}
.avatar-preview-circle {
width: 90px;
height: 90px;
background-color: #ccc;
border-radius: 50%;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
position: relative;
cursor: pointer;
}
.avatar-img {
width: 100%;
height: 100%;
object-cover: cover;
display: none;
}
</style>
</head>
<body>
<!-- Экран Входа -->
<div id="login-screen" class="screen active center-items">
<div class="header-banner">
<h1 class="header-text">добрый день!</h1>
</div>
<div class="custom-input-container">
<label class="custom-label">юзернейм</label>
<input type="text" id="login-user" class="custom-input">
</div>
<div class="custom-input-container">
<label class="custom-label">пароль</label>
<input type="password" id="login-pass" class="custom-input">
</div>
<div id="login-error" class="error-msg">Заполните все поля!</div>
<button class="btn-primary" onclick="tryLogin()">Войти</button>
<p class="mt-6 text-sm font-bold cursor-pointer" onclick="navigateTo('register-screen')">Зарегистрироваться</p>
</div>
<!-- Экран Регистрации -->
<div id="register-screen" class="screen center-items">
<div class="header-banner">
<h1 class="header-text">добрый день!</h1>
</div>
<div class="flex w-full gap-4 mb-4 items-center">
<div class="avatar-preview-circle" onclick="document.getElementById('avatar-input').click()">
<span id="avatar-placeholder" class="text-[10px] font-black italic text-center p-2">аватарка</span>
<img id="reg-avatar-img" class="avatar-img">
<input type="file" id="avatar-input" hidden accept="image/*" onchange="previewAvatar(this)">
</div>
<div class="flex-1">
<div class="custom-input-container !mb-2">
<label class="custom-label">имя/фамилия</label>
<input type="text" id="reg-name" class="custom-input">
</div>
<div class="custom-input-container !mb-0">
<label class="custom-label">юзернейм</label>
<input type="text" id="reg-user" class="custom-input">
</div>
</div>
</div>
<div class="flex w-full gap-4">
<div class="custom-input-container"><label class="custom-label">пароль</label><input type="password" id="reg-pass" class="custom-input"></div>
<div class="custom-input-container"><label class="custom-label">повтор</label><input type="password" id="reg-confirm" class="custom-input"></div>
</div>
<div id="reg-error" class="error-msg">Все поля должны быть заполнены!</div>
<button class="btn-primary" onclick="tryRegister()">зарегистрироваться</button>
</div>
<!-- Экран Списка Чатов -->
<div id="chats-screen" class="screen">
<div class="flex justify-between items-center mb-6">
<h2 class="text-3xl font-black italic">Чаты</h2>
<!-- Аватарка в кружке вверху -->
<div id="top-avatar-circle" class="w-10 h-10 bg-[#ccc] rounded-full overflow-hidden flex items-center justify-center">
<img id="top-avatar-img" class="w-full h-full object-cover hidden">
</div>
</div>
<div class="chats-container">
<div class="chat-item" onclick="openChat('Алексей')"><div class="chat-avatar-blue"></div><span class="font-bold italic">Алексей</span></div>
<div class="chat-item" onclick="openChat('Мария')"><div class="chat-avatar-blue"></div><span class="font-bold italic">Мария</span></div>
<div class="chat-item" onclick="openChat('Дизайн Группа')"><div class="chat-avatar-blue"></div><span class="font-bold italic">Дизайн Группа</span></div>
<div class="chat-item" onclick="openChat('Разработка')"><div class="chat-avatar-blue"></div><span class="font-bold italic">Разработка</span></div>
<div class="chat-item" onclick="openChat('Мама')"><div class="chat-avatar-blue"></div><span class="font-bold italic">Мама</span></div>
<div class="chat-item" onclick="openChat('Иван')"><div class="chat-avatar-blue"></div><span class="font-bold italic">Иван</span></div>
<div class="chat-item" onclick="openChat('Поддержка')"><div class="chat-avatar-blue"></div><span class="font-bold italic">Поддержка</span></div>
<div class="chat-item" onclick="openChat('Заметки')"><div class="chat-avatar-blue"></div><span class="font-bold italic">Заметки</span></div>
<div class="search-area">
<input type="text" class="search-text" placeholder="поиск">
<div class="search-icon-circle"></div>
</div>
</div>
</div>
<!-- Экран Сообщений -->
<div id="messages-screen" class="screen !p-0">
<div class="chat-header">
<button onclick="navigateTo('chats-screen')" class="text-2xl">←</button>
<div class="w-10 h-10 bg-gray-400 rounded-full"></div>
<span class="font-bold italic" id="chat-title">Чат</span>
</div>
<div class="flex flex-col p-4 pt-20 pb-20" id="messages-list">
<div class="message received">Привет! Это сообщение из списка чатов.</div>
<div class="message sent">Дизайн полностью соответствует макету.</div>
</div>
<div class="fixed bottom-0 w-full bg-white p-4 border-t flex gap-2">
<input type="text" id="msgInput" placeholder="Сообщение..." class="flex-1 bg-gray-100 rounded-full px-4 outline-none">
<button onclick="sendMsg()" class="bg-[#0a0a45] text-white rounded-full w-10 h-10 flex items-center justify-center">></button>
</div>
</div>
<script>
let currentUserAvatar = null;
function navigateTo(id) {
document.querySelectorAll('.screen').forEach(s => s.classList.remove('active'));
document.getElementById(id).classList.add('active');
// Если переходим на экран чатов, ставим аватарку
if (id === 'chats-screen' && currentUserAvatar) {
const img = document.getElementById('top-avatar-img');
img.src = currentUserAvatar;
img.classList.remove('hidden');
}
window.scrollTo(0,0);
}
// Превью аватарки при регистрации
function previewAvatar(input) {
if (input.files && input.files[0]) {
const reader = new FileReader();
reader.onload = function(e) {
currentUserAvatar = e.target.result;
document.getElementById('reg-avatar-img').src = e.target.result;
document.getElementById('reg-avatar-img').style.display = 'block';
document.getElementById('avatar-placeholder').style.display = 'none';
}
reader.readAsDataURL(input.files[0]);
}
}
function tryLogin() {
const user = document.getElementById('login-user').value.trim();
const pass = document.getElementById('login-pass').value.trim();
const error = document.getElementById('login-error');
if (user === '' || pass === '') {
error.style.display = 'block';
return;
}
error.style.display = 'none';
navigateTo('chats-screen');
}
function tryRegister() {
const name = document.getElementById('reg-name').value.trim();
const user = document.getElementById('reg-user').value.trim();
const pass = document.getElementById('reg-pass').value.trim();
const confirm = document.getElementById('reg-confirm').value.trim();
const error = document.getElementById('reg-error');
if (name === '' || user === '' || pass === '' || confirm === '') {
error.textContent = "Все поля должны быть заполнены!";
error.style.display = 'block';
return;
}
if (pass !== confirm) {
error.textContent = "Пароли не совпадают!";
error.style.display = 'block';
return;
}
error.style.display = 'none';
navigateTo('login-screen');
}
function openChat(name) {
document.getElementById('chat-title').innerText = name;
navigateTo('messages-screen');
}
function sendMsg() {
const input = document.getElementById('msgInput');
if(!input.value) return;
const list = document.getElementById('messages-list');
const div = document.createElement('div');
div.className = 'message sent';
div.innerText = input.value;
list.appendChild(div);
input.value = '';
window.scrollTo(0, document.body.scrollHeight);
}
</script>
</body>
</html>