Накатил человеческий дизайн

This commit is contained in:
mi
2026-07-21 16:01:24 +03:00
parent 9cfc157124
commit 627371b221
35 changed files with 2415 additions and 293 deletions
@@ -1,11 +1,22 @@
phoneTitle=Вход по номеру телефона
phoneTitle=Вход в HAN
authBrandSubtitle=Персональный консультант мигранта
phoneWelcome=Добро пожаловать
phoneIntro=Введите номер телефона — отправим код подтверждения
phoneLabel=Номер телефона
phoneHelp=Укажите российский или международный номер. Мы используем его только для входа.
phoneCountry=Россия · Код страны +7
phoneLegalPrefix=Нажимая «Получить код», вы соглашаетесь с
termsOfUse=условиями использования
phoneLegalAnd=и
privacyPolicy=политикой конфиденциальности
sendOtp=Получить код
otpTitle=Подтверждение телефона
otpLabel=Код подтверждения
otpSent=Код подтверждения подготовлен для номера {0}
verifyOtp=Войти
otpHeading=Введите код
otpSent=Отправили SMS на номер {0}
otpDigit=Цифра кода {0}
otpResendCountdown=Отправить повторно через
otpResend=Отправить код снова
authBack=Назад
verifyOtp=Подтвердить
mockMode=Тестовый режим отправки кода
phoneInvalid=Проверьте формат номера телефона.
otpInvalid=Код неверен, истёк или уже использован.
@@ -1,16 +1,50 @@
<#import "template.ftl" as layout>
<@layout.registrationLayout displayMessage=true; section>
<@layout.registrationLayout displayMessage=false; section>
<#if section = "header">${msg("otpTitle")}
<#elseif section = "form">
<form id="kc-otp-form" action="${url.loginAction}" method="post">
<p class="han-help">${msg("otpSent", maskedPhone!"***")}</p>
<p class="han-test-mode">${msg("mockMode")}</p>
<div class="form-group">
<label for="otp">${msg("otpLabel")}</label>
<input id="otp" name="otp" type="password" inputmode="numeric" autocomplete="one-time-code"
minlength="4" maxlength="12" required autofocus/>
<link rel="stylesheet" href="${url.resourcesPath}/css/han-login.css?v=4"/>
<div class="han-auth-screen han-otp-screen">
<button class="han-back-button" type="button" onclick="window.history.back()">
<span aria-hidden="true">←</span>
<span>${msg("authBack")}</span>
</button>
<div class="han-auth-heading han-otp-heading">
<h1>${msg("otpHeading")}</h1>
<p>${msg("otpSent", maskedPhone!"***")}</p>
</div>
<button class="pf-c-button pf-m-primary pf-m-block" type="submit">${msg("verifyOtp")}</button>
</form>
<form id="kc-otp-form" action="${url.loginAction}" method="post">
<input id="otp" name="otp" type="hidden" value=""/>
<div id="han-otp-inputs" class="han-otp-inputs <#if message?has_content>han-shake</#if>">
<#list 0..5 as index>
<input class="han-otp-digit" type="text" inputmode="numeric" maxlength="1"
aria-label="${msg("otpDigit", index + 1)}"
<#if index == 0>autocomplete="one-time-code" autofocus</#if>
aria-invalid="<#if message?has_content>true<#else>false</#if>"/>
</#list>
</div>
<#if message?has_content>
<div class="han-error han-otp-error" role="alert">
<span class="han-error-icon">!</span>
<span>${kcSanitize(message.summary)?no_esc}</span>
</div>
</#if>
<div class="han-resend">
<p id="han-resend-countdown">${msg("otpResendCountdown")} <strong>0:59</strong></p>
<button id="han-resend-button" type="button" hidden onclick="window.history.back()">
<span aria-hidden="true">↻</span>
<span>${msg("otpResend")}</span>
</button>
</div>
<button id="han-otp-submit" class="han-primary-button" type="submit" disabled>
${msg("verifyOtp")}
</button>
</form>
</div>
<script src="${url.resourcesPath}/js/han-login.js?v=3"></script>
</#if>
</@layout.registrationLayout>
@@ -1,16 +1,51 @@
<#import "template.ftl" as layout>
<@layout.registrationLayout displayMessage=true; section>
<@layout.registrationLayout displayMessage=false; section>
<#if section = "header">${msg("phoneTitle")}
<#elseif section = "form">
<form id="kc-phone-form" action="${url.loginAction}" method="post">
<div class="form-group">
<label for="phone">${msg("phoneLabel")}</label>
<input id="phone" name="phone" type="tel" inputmode="tel" autocomplete="tel"
placeholder="+7 900 123-45-67" required autofocus
aria-invalid="<#if messagesPerField.existsError('phone')>true<#else>false</#if>"/>
<link rel="stylesheet" href="${url.resourcesPath}/css/han-login.css?v=4"/>
<div class="han-auth-screen han-phone-screen">
<div class="han-auth-main">
<div class="han-wordmark" aria-label="HAN">
<span class="han-wordmark-text">HAN</span>
<span class="han-wordmark-dot"></span>
</div>
<p class="han-brand-subtitle">${msg("authBrandSubtitle")}</p>
<div class="han-auth-heading">
<h1>${msg("phoneWelcome")}</h1>
<p>${msg("phoneIntro")}</p>
</div>
<form id="kc-phone-form" action="${url.loginAction}" method="post">
<div class="han-field">
<label for="phone">${msg("phoneLabel")}</label>
<input id="phone" name="phone" type="tel" inputmode="numeric" autocomplete="tel"
placeholder="+7 (___) ___ __ __" required autofocus
aria-invalid="<#if message?has_content>true<#else>false</#if>"/>
<p class="han-field-hint">${msg("phoneCountry")}</p>
</div>
<#if message?has_content>
<div class="han-error" role="alert">
<span class="han-error-icon">!</span>
<span>${kcSanitize(message.summary)?no_esc}</span>
</div>
</#if>
<button id="han-phone-submit" class="han-primary-button" type="submit" disabled>
<span>${msg("sendOtp")}</span>
<span class="han-button-arrow" aria-hidden="true">→</span>
</button>
</form>
</div>
<p class="han-help">${msg("phoneHelp")}</p>
<button class="pf-c-button pf-m-primary pf-m-block" type="submit">${msg("sendOtp")}</button>
</form>
<p class="han-legal">
${msg("phoneLegalPrefix")}
<span>${msg("termsOfUse")}</span>
${msg("phoneLegalAnd")}
<span>${msg("privacyPolicy")}</span>
</p>
</div>
<script src="${url.resourcesPath}/js/han-login.js?v=3"></script>
</#if>
</@layout.registrationLayout>
@@ -1,18 +1,409 @@
:root {
--han-primary: #246bfd;
--han-text: #172033;
--han-primary: #030213;
--han-text: #252525;
--han-muted: #717182;
--han-border: rgba(0, 0, 0, 0.12);
--han-surface: #ffffff;
--han-input: #f3f3f5;
--han-error: #d4183d;
}
body { color: var(--han-text); }
.pf-c-button.pf-m-primary { background: var(--han-primary); border-radius: 10px; min-height: 44px; }
input[type="tel"], input[name="otp"] {
* {
box-sizing: border-box;
width: 100%;
min-height: 44px;
margin-top: 8px;
padding: 10px 12px;
border: 1px solid #9aa6bd;
border-radius: 8px;
}
.han-help { color: #596780; font-size: .9rem; }
.han-test-mode { color: #7a4b00; background: #fff3cd; padding: 8px 10px; border-radius: 8px; }
html,
body,
body.login-pf {
min-height: 100%;
margin: 0;
background: var(--han-surface);
color: var(--han-text);
font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.login-pf-page,
.pf-v5-c-login,
.pf-c-login {
width: 100%;
min-height: 100vh;
padding: 0;
background: var(--han-surface);
}
.login-pf-page {
display: flex;
justify-content: center;
}
.pf-v5-c-login__container,
.pf-c-login__container {
display: grid;
width: 100%;
min-height: 100vh;
grid-template-areas: "main";
grid-template-columns: minmax(0, 390px);
justify-content: center;
margin: 0 auto;
}
.login-pf-page .card-pf,
.pf-v5-c-login__main,
.pf-c-login__main {
grid-area: main;
width: 100%;
max-width: 390px;
min-height: 100vh;
margin: 0 auto;
padding: 0;
border: 0;
border-radius: 0;
background: var(--han-surface);
box-shadow: none;
}
#kc-header,
#kc-header-wrapper,
#kc-page-title {
display: none;
}
#kc-content,
#kc-content-wrapper,
#kc-form,
#kc-form-wrapper {
width: 100%;
max-width: none;
margin: 0;
}
.han-auth-screen {
display: flex;
width: 100%;
min-height: 100vh;
flex-direction: column;
padding: 56px 24px 32px;
background: var(--han-surface);
}
.han-phone-screen {
justify-content: space-between;
}
.han-auth-main {
display: flex;
flex: 1;
flex-direction: column;
}
.han-wordmark {
display: flex;
align-items: flex-end;
gap: 4px;
margin-bottom: 8px;
}
.han-wordmark-text {
color: var(--han-text);
font-size: 36px;
font-weight: 700;
letter-spacing: -1.5px;
line-height: 1;
}
.han-wordmark-dot {
width: 8px;
height: 8px;
margin-bottom: 5px;
border-radius: 50%;
background: var(--han-primary);
}
.han-brand-subtitle {
margin: 0 0 48px;
color: var(--han-muted);
font-size: 14px;
line-height: 1.5;
}
.han-auth-heading {
margin-bottom: 32px;
}
.han-auth-heading h1 {
margin: 0 0 8px;
color: var(--han-text);
font-size: 24px;
font-weight: 600;
line-height: 1.3;
}
.han-auth-heading p {
margin: 0;
color: var(--han-muted);
font-size: 14px;
line-height: 1.5;
}
.han-auth-heading p strong,
.han-auth-heading p span {
color: var(--han-text);
font-weight: 500;
}
.han-field {
margin-bottom: 16px;
}
.han-field label {
display: block;
margin-bottom: 6px;
color: var(--han-text);
font-size: 14px;
font-weight: 500;
}
.han-field input {
appearance: none;
width: 100%;
height: 56px;
padding: 0 16px;
border: 1px solid var(--han-border);
border-radius: 12px;
outline: none;
background: var(--han-input);
color: var(--han-text);
font-size: 16px;
transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.han-field input::placeholder {
color: rgba(113, 113, 130, 0.6);
}
.han-field input:focus {
border-color: rgba(3, 2, 19, 0.5);
box-shadow: 0 0 0 3px rgba(3, 2, 19, 0.12);
}
.han-field input[aria-invalid="true"] {
border-color: var(--han-error);
}
.han-field-hint {
margin: 6px 4px 0;
color: var(--han-muted);
font-size: 12px;
}
.han-primary-button {
display: flex;
width: 100%;
height: 56px;
align-items: center;
justify-content: center;
gap: 10px;
border: 0;
border-radius: 12px;
background: var(--han-primary);
color: #ffffff;
cursor: pointer;
font-size: 15px;
font-weight: 500;
transition: opacity 0.15s ease, transform 0.1s ease;
}
.han-primary-button:hover {
opacity: 0.9;
}
.han-primary-button:active {
transform: scale(0.98);
}
.han-primary-button:focus-visible,
.han-back-button:focus-visible,
.han-resend button:focus-visible {
outline: 3px solid rgba(3, 2, 19, 0.18);
outline-offset: 2px;
}
.han-primary-button:disabled {
cursor: not-allowed;
opacity: 0.4;
}
.han-button-arrow {
font-size: 20px;
line-height: 1;
}
.han-legal {
margin: 32px 0 0;
color: var(--han-muted);
font-size: 12px;
line-height: 1.5;
text-align: center;
}
.han-legal span {
color: rgba(37, 37, 37, 0.7);
text-decoration: underline;
text-underline-offset: 2px;
}
.han-error {
display: flex;
align-items: flex-start;
gap: 10px;
margin: 0 0 16px;
padding: 12px 16px;
border: 1px solid rgba(212, 24, 61, 0.25);
border-radius: 12px;
background: rgba(212, 24, 61, 0.08);
color: var(--han-error);
font-size: 14px;
font-weight: 500;
line-height: 1.4;
}
.han-error-icon {
display: inline-flex;
width: 17px;
height: 17px;
flex: 0 0 17px;
align-items: center;
justify-content: center;
margin-top: 1px;
border: 1.5px solid currentColor;
border-radius: 50%;
font-size: 11px;
font-weight: 700;
}
.han-otp-screen {
padding-top: 52px;
}
.han-back-button {
display: inline-flex;
align-self: flex-start;
align-items: center;
gap: 6px;
margin: 0 0 40px -4px;
padding: 4px;
border: 0;
background: transparent;
color: var(--han-muted);
cursor: pointer;
font-size: 14px;
}
.han-back-button:hover {
color: var(--han-text);
}
.han-otp-heading {
margin-bottom: 40px;
}
.han-otp-inputs {
display: grid;
grid-template-columns: repeat(6, minmax(0, 1fr));
gap: 10px;
margin-bottom: 16px;
}
.han-otp-digit {
appearance: none;
width: 100%;
min-width: 0;
height: 56px;
padding: 0;
border: 1px solid var(--han-border);
border-radius: 12px;
outline: none;
background: var(--han-input);
color: var(--han-text);
font-size: 20px;
font-weight: 600;
text-align: center;
transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.han-otp-digit:focus {
border-color: rgba(3, 2, 19, 0.55);
box-shadow: 0 0 0 3px rgba(3, 2, 19, 0.12);
}
.han-otp-digit.han-filled {
background: rgba(3, 2, 19, 0.05);
}
.han-otp-digit[aria-invalid="true"] {
border-color: var(--han-error);
background: rgba(212, 24, 61, 0.05);
color: var(--han-error);
}
.han-otp-error {
margin-top: 0;
}
.han-resend {
display: flex;
min-height: 40px;
align-items: center;
justify-content: center;
margin: 0 0 24px;
color: var(--han-muted);
font-size: 14px;
}
.han-resend p {
margin: 0;
}
.han-resend strong {
color: var(--han-text);
font-weight: 500;
font-variant-numeric: tabular-nums;
}
.han-resend button {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px;
border: 0;
background: transparent;
color: var(--han-primary);
cursor: pointer;
font-size: 14px;
font-weight: 500;
}
.han-shake {
animation: han-shake 0.4s ease;
}
@keyframes han-shake {
0%, 100% { transform: translateX(0); }
15% { transform: translateX(-6px); }
30% { transform: translateX(6px); }
45% { transform: translateX(-5px); }
60% { transform: translateX(5px); }
75% { transform: translateX(-3px); }
90% { transform: translateX(3px); }
}
@media (max-width: 360px) {
.han-auth-screen {
padding-right: 18px;
padding-left: 18px;
}
.han-otp-inputs {
gap: 7px;
}
}
@@ -0,0 +1,103 @@
(function () {
function initPhoneForm() {
var input = document.getElementById("phone");
var submit = document.getElementById("han-phone-submit");
if (!input || !submit) return;
function formatPhone(value) {
var digits = value.replace(/\D/g, "");
if (!digits) return "";
if (digits.indexOf("8") === 0) digits = "7" + digits.slice(1);
else if (digits.indexOf("7") !== 0) digits = "7" + digits;
digits = digits.slice(0, 11);
var result = "+7";
if (digits.length > 1) result += " (" + digits.slice(1, 4);
if (digits.length >= 4) result += ") " + digits.slice(4, 7);
if (digits.length >= 7) result += " " + digits.slice(7, 9);
if (digits.length >= 9) result += " " + digits.slice(9, 11);
return result;
}
function updatePhone() {
input.value = formatPhone(input.value);
submit.disabled = input.value.replace(/\D/g, "").length !== 11;
}
input.addEventListener("input", updatePhone);
updatePhone();
}
function initOtpForm() {
var fields = Array.prototype.slice.call(document.querySelectorAll(".han-otp-digit"));
var hidden = document.getElementById("otp");
var submit = document.getElementById("han-otp-submit");
if (!fields.length || !hidden || !submit) return;
function syncOtp() {
fields.forEach(function (field) {
field.classList.toggle("han-filled", Boolean(field.value));
});
hidden.value = fields.map(function (field) { return field.value; }).join("");
submit.disabled = hidden.value.length !== fields.length;
}
fields.forEach(function (field, index) {
field.addEventListener("input", function () {
var entered = field.value.replace(/\D/g, "");
if (entered.length > 1) {
entered.slice(0, fields.length).split("").forEach(function (digit, digitIndex) {
fields[digitIndex].value = digit;
});
fields[Math.min(entered.length, fields.length) - 1].focus();
} else {
field.value = entered.slice(-1);
if (field.value && index < fields.length - 1) fields[index + 1].focus();
}
syncOtp();
});
field.addEventListener("keydown", function (event) {
if (event.key === "Backspace" && !field.value && index > 0) {
fields[index - 1].value = "";
fields[index - 1].focus();
syncOtp();
}
if (event.key === "ArrowLeft" && index > 0) fields[index - 1].focus();
if (event.key === "ArrowRight" && index < fields.length - 1) fields[index + 1].focus();
});
field.addEventListener("paste", function (event) {
event.preventDefault();
var pasted = event.clipboardData.getData("text").replace(/\D/g, "").slice(0, fields.length);
fields.forEach(function (otpField) { otpField.value = ""; });
pasted.split("").forEach(function (digit, digitIndex) {
fields[digitIndex].value = digit;
});
if (pasted.length) fields[Math.min(pasted.length, fields.length) - 1].focus();
syncOtp();
});
});
syncOtp();
var seconds = 59;
var countdown = document.getElementById("han-resend-countdown");
var countdownValue = countdown && countdown.querySelector("strong");
var resend = document.getElementById("han-resend-button");
if (!countdown || !countdownValue || !resend) return;
var timer = window.setInterval(function () {
seconds -= 1;
countdownValue.textContent = "0:" + String(seconds).padStart(2, "0");
if (seconds <= 0) {
window.clearInterval(timer);
countdown.hidden = true;
resend.hidden = false;
}
}, 1000);
}
initPhoneForm();
initOtpForm();
})();