Newer
Older
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
<script setup lang="ts">
import AuthorizationForm from '@/modules/authorization/AuthorizationForm.vue';
import { useWebsocketStore } from '@/app/stores/websocket';
const websocketStore = useWebsocketStore();
const formData = ref({
nick_name: '',
email: '',
password: '',
first_name: '',
middle_name: '',
last_name: '',
favorite_color: ''
});
const signUp = () => {
if (!formData.value.favorite_color) {
console.log('Выберите любимый цвет');
return;
}
console.log('signUp!');
// создание юзера в бд
const favoriteColor = formData.value.favorite_color;
delete formData.value.favorite_color;
const userData = { ...formData.value, settings: { favorite_color: favoriteColor } };
const dataCreateUser = {
event: 'createUser',
body: userData
};
websocketStore.sendData(dataCreateUser);
};
const colors = [
'white',
'slate',
'blue',
'sky',
'teal',
'lime',
'green',
'yellow',
'orange',
'pink',
'fuchsia',
'purple',
'indigo',
'rose',
'red'
];
</script>
<template>
<AuthorizationForm>
<h2 class="text-center text-3xl font-bold mb-8 select-none">Register</h2>
<form class="flex gap-24">
<section>
<label class="block redStar mb-1 pl-1 pointer-events-none select-none" for="nickName"
>Nick name</label
>
<input
id="nickName"
v-model="formData.nick_name"
style="border-width: 1px"
class="input block p-1 px-2 mb-4 border-solid border-blue-300 rounded-md transition-all"
type="text"
placeholder="Enter your nick name"
required
/>
<label class="block redStar mb-1 pl-1 pointer-events-none select-none" for="email"
>Email</label
>
<input
id="email"
v-model="formData.email"
style="border-width: 1px"
class="input block p-1 px-2 mb-4 border-solid border-blue-300 rounded-md transition-all"
type="text"
placeholder="Enter your email"
required
/>
<label class="block redStar mb-1 pl-1 pointer-events-none select-none" for="password"
>Password</label
>
<input
id="password"
v-model="formData.password"
style="border-width: 1px"
class="input block p-1 px-2 mb-4 border-solid border-blue-300 rounded-md transition-all"
type="password"
placeholder="Enter your password"
required
/>
</section>
<section>
<label class="block mb-1 pl-1 pointer-events-none select-none" for="firstName"
>First name</label
>
<input
id="firstName"
v-model="formData.first_name"
style="border-width: 1px"
class="input block p-1 px-2 mb-4 border-solid border-blue-300 rounded-md transition-all"
type="text"
placeholder="Enter your first name"
/>
<label class="block mb-1 pl-1 pointer-events-none select-none" for="middleName"
>Middle name</label
>
<input
id="middleName"
v-model="formData.middle_name"
style="border-width: 1px"
class="input block p-1 px-2 mb-4 border-solid border-blue-300 rounded-md transition-all"
type="text"
placeholder="Enter your middle name"
/>
<label class="block mb-1 pl-1 pointer-events-none select-none" for="lastName"
>Last name</label
>
<input
id="lastName"
v-model="formData.last_name"
style="border-width: 1px"
class="input block p-1 px-2 mb-4 border-solid border-blue-300 rounded-md transition-all"
type="text"
placeholder="Enter your last name"
/>
</section>
<section class="w-64 relative">
<h3 class="font-bold w-full text-xl mb-4 select-none">Choose your favorite color:</h3>
<ul class="grid grid-cols-5 gap-4 mb-6">
<li
v-for="item of colors"
:key="item"
:style="`background-color: ${item !== 'white' ? `var(--${item}-500)` : 'white'}`"
:class="[
`size-10 rounded-md border-2 border-${item === 'white' ? 'gray' : item}-100 border-solid cursor-pointer`,
{
'border-blue-800 border-4': formData.favorite_color === item
}
]"
@click.prevent="formData.favorite_color = item"
></li>
</ul>
<button
class="absolute -right-10 -bottom-12 px-6 py-2 font-bold text-2xl bg-blue-700 border-2 border-solid border-blue-100 rounded-lg select-none"
@click.prevent="signUp"
>
Sign up
</button>
</section>
</form>
</AuthorizationForm>
</template>
<style scoped>
.input:hover {
border-color: var(--blue-500);
}
.input:focus {
border-color: var(--blue-700);
}
.redStar::after {
position: relative;
right: -4px;
top: 0;
content: '*';
font-weight: bold;
color: var(--red-500);
}
</style>