Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
178 changes: 178 additions & 0 deletions a11y/role-form/demos/custom-form-landmark/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<title>Кастомный ориентир формы — form — Дока</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap">
<style>
*, *::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}

html {
color-scheme: dark;
}

body {
min-height: 100vh;
padding: 50px;
display: flex;
align-items: center;
justify-content: center;
background-color: #18191C;
color: #FFFFFF;
font-family: "Roboto", sans-serif;
}

.container {
display: flex;
flex-direction: column;
gap: 20px;
}

.input-container {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}

.label {
margin-right: 55px;
font-size: 24px;
font-weight: 500;
line-height: 1;
}

.input {
width: 300px;
border: 1px solid #FFFFFF;
border-radius: 6px;
padding: 10px 15px;
background-color: transparent;
color: #FFFFFF;
font-size: 18px;
font-weight: 300;
font-family: inherit;
-webkit-appearance: none;
appearance: none;
}

.input:focus {
border-color: #10F3AF;
outline: none;
}

.button {
display: flex;
justify-content: center;
display: flex;
align-self: end;
min-width: 210px;
border: 2px solid transparent;
border-radius: 6px;
padding: 9px 15px;
color: #000000;
font-size: 18px;
font-weight: 300;
font-family: inherit;
transition: background-color 0.2s linear;
}

.button-aqua {
background-color: #10F3AF;
}

.button:hover {
background-color: #FFFFFF;
cursor: pointer;
transition: background-color 0.2s linear;
}

.button:focus-visible {
border: 2px solid #FFFFFF;
outline: none;
}

.button:focus {
border: 2px solid #FFFFFF;
outline: none;
}

.form-message {
margin-top: 10px;
min-height: 30px;
text-align: center;
}

.input, .button {
width: 350px;
}

@media (max-width: 768px) {
body {
padding: 30px;
}

.input-container {
flex-direction: column;
}

.label {
margin-right: 0;
margin-bottom: 10px;
}

.input, .button {
width: 100%;
}
}
</style>
</head>
<body>
<div role="form" class="container" id="custom-form" aria-label="Подписка на рассылку">
<div class="input-container">
<label class="label" for="email">Электронная почта:</label>
<input class="input" type="text" id="email" name="email" autocomplete="email" spellcheck="false">
</div>
<button class="button button-aqua" id="subscribe-btn" type="submit">Подписаться</button>
<span class="form-message" id="status-message" aria-live="polite"></span>
</div>

<script>
const form = document.getElementById('custom-form')
const input = document.getElementById('email')
const button = document.getElementById('subscribe-btn')
const statusMessage = document.getElementById('status-message')

function submitForm(event) {
event.preventDefault()
const email = input.value.trim()

if (email) {
fetch('/subscribe', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email })
})
.then(response => response.ok
? 'Ура, вы подписаны на нашу рассылку 🎉'
: 'Вы не смогли подписаться на рассылку. Попробуйте ещё раз через 100 лет 😢')
.then(message => {
statusMessage.textContent = message
})
.catch(() => {
statusMessage.textContent = 'Вы не смогли подписаться на рассылку. Попробуйте ещё раз через 100 лет 😢'
})
}
}

button.addEventListener('click', submitForm)
</script>
</body>
</html>
154 changes: 154 additions & 0 deletions a11y/role-form/demos/native-form-landmark/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<title>Обычная форма — form — Дока</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap">
<style>
*, *::before, *::after {
margin: 0;
padding: 0;
box-sizing: border-box;
}

html {
color-scheme: dark;
}

body {
min-height: 100vh;
padding: 50px;
display: flex;
align-items: center;
justify-content: center;
background-color: #18191C;
color: #FFFFFF;
font-family: "Roboto", sans-serif;
}

.container {
display: flex;
flex-direction: column;
gap: 20px;
}

.input-container {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
}

.label {
margin-right: 55px;
font-size: 24px;
font-weight: 500;
line-height: 1;
}

.input {
width: 300px;
border: 1px solid #FFFFFF;
border-radius: 6px;
padding: 10px 15px;
background-color: transparent;
color: #FFFFFF;
font-size: 18px;
font-weight: 300;
font-family: inherit;
-webkit-appearance: none;
appearance: none;
}

.input:focus {
border-color: #10F3AF;
outline: none;
}

.button {
display: flex;
justify-content: center;
display: flex;
align-self: end;
min-width: 210px;
border: 2px solid transparent;
border-radius: 6px;
padding: 9px 15px;
color: #000000;
font-size: 18px;
font-weight: 300;
font-family: inherit;
transition: background-color 0.2s linear;
}

.button-aqua {
background-color: #10F3AF;
}

.button:hover {
background-color: #FFFFFF;
cursor: pointer;
transition: background-color 0.2s linear;
}

.button:focus-visible {
border: 2px solid #FFFFFF;
outline: none;
}

.button:focus {
border: 2px solid #FFFFFF;
outline: none;
}

.form-message {
margin-top: 10px;
min-height: 30px;
text-align: center;
}

.input, .button {
width: 350px;
}

@media (max-width: 768px) {
body {
padding: 30px;
}

.input-container {
flex-direction: column;
}

.label {
margin-right: 0;
margin-bottom: 10px;
}

.input, .button {
width: 100%;
}
}
</style>
</head>
<body>
<form class="container" id="custom-form" aria-label="Подписка на рассылку">
<div class="input-container">
<label class="label" for="email">Электронная почта:</label>
<input class="input" type="text" id="email" name="email" autocomplete="email" spellcheck="false">
</div>
<button class="button button-aqua" id="subscribe-btn" type="submit">Подписаться</button>
<span class="form-message" id="status-message" aria-live="polite"></span>
</form>

<script>
document.getElementById('custom-form').addEventListener('submit', function(event) {
event.preventDefault()
document.getElementById('status-message').textContent = 'Вы не смогли подписаться на рассылку. Попробуйте ещё раз через 100 лет 😢'
})
</script>
</body>
</html>
Loading
Loading