{ "$schema": "../../schemas/code-crispies-module-schema.json", "id": "html-forms-basic", "title": "HTML Форми", "description": "Навчіться створювати форми з різними типами полів", "mode": "html", "difficulty": "beginner", "lessons": [ { "id": "form-structure", "title": "Структура форми", "description": "Кожна форма потребує обгортки <form>. Всередині використовуйте <label> для опису полів та <input> для введення даних.

Атрибут for у label має відповідати id полів для доступності.", "task": "Створіть форму з:
1. <label> з текстом Ім'я: та атрибутом for=\"name\"
2. Текстовим <input> з атрибутами id=\"name\" та name=\"name\"", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 300px; } label { display: block; margin-bottom: 5px; font-weight: 500; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }", "sandboxCSS": "", "initialCode": "", "solution": "
\n \n \n
", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "form", "message": "Оберніть все елементом <form>" }, { "type": "element_exists", "value": "label", "message": "Додайте <label> для вашого поля" }, { "type": "element_exists", "value": "input", "message": "Додайте елемент <input>" }, { "type": "attribute_value", "value": { "selector": "label", "attr": "for", "value": null }, "message": "Додайте атрибут for до вашого label" }, { "type": "attribute_value", "value": { "selector": "input", "attr": "id", "value": null }, "message": "Додайте атрибут id до вашого поля" } ] }, { "id": "input-types", "title": "Типи полів", "description": "Різні типи полів надають відповідні клавіатури та валідацію:

type=\"text\" - Загальний текст
type=\"email\" - Email з валідацією @
type=\"password\" - Приховані символи
type=\"number\" - Цифрова клавіатура
type=\"tel\" - Телефонна клавіатура", "task": "Створіть форму входу з двома полями:
1. Поле email: <label for=\"email\">Email:</label> та <input type=\"email\" id=\"email\">
2. Поле пароля: <label for=\"password\">Пароль:</label> та <input type=\"password\" id=\"password\">", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 300px; } label { display: block; margin-top: 15px; margin-bottom: 5px; } label:first-child { margin-top: 0; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; }", "sandboxCSS": "", "initialCode": "
\n \n
", "solution": "
\n \n \n \n \n \n
", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "input[type='email']", "message": "Додайте поле з type=\"email\"" }, { "type": "element_exists", "value": "input[type='password']", "message": "Додайте поле з type=\"password\"" }, { "type": "element_count", "value": { "selector": "label", "min": 2 }, "message": "Додайте label для обох полів" } ] }, { "id": "submit-button", "title": "Кнопка відправки", "description": "Форми потребують способу відправки даних. Використовуйте:

<button type=\"submit\"> - Переважно, гнучкий вміст
<input type=\"submit\"> - Простий текстовий кнопка

Текст кнопки має бути орієнтованим на дію (напр. Увійти, 'Зареєструватись', 'Надіслати').", "task": "Додайте кнопку відправки до форми з текстом Увійти.", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 300px; } label { display: block; margin-top: 15px; margin-bottom: 5px; } label:first-child { margin-top: 0; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } button { width: 100%; margin-top: 20px; padding: 10px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; } button:hover { background: #1565c0; }", "sandboxCSS": "", "initialCode": "
\n \n \n \n \n \n \n
", "solution": "
\n \n \n \n \n \n \n \n
", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "button[type='submit'], input[type='submit']", "message": "Додайте кнопку відправки до форми" }, { "type": "element_text", "value": { "selector": "button", "text": "Увійти" }, "message": "Кнопка має відображати Увійти" } ] } ] }