{ "$schema": "../../schemas/code-crispies-module-schema.json", "id": "html-forms-basic", "title": "Formularze HTML", "description": "Naucz się tworzyć formularze z różnymi typami pól", "mode": "html", "difficulty": "beginner", "lessons": [ { "id": "form-structure", "title": "Struktura formularza", "description": "Każdy formularz potrzebuje wrappera <form>. Wewnątrz używaj <label> do opisywania pól i <input> do wprowadzania danych.

Atrybut for w labelach powinien odpowiadać id pól dla dostępności.", "task": "Stwórz formularz z:
1. <label> z tekstem Imię: i atrybutem for=\"name\"
2. Tekstowym <input> z atrybutami id=\"name\" i 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": "Otocz wszystko elementem <form>" }, { "type": "element_exists", "value": "label", "message": "Dodaj <label> dla swojego pola" }, { "type": "element_exists", "value": "input", "message": "Dodaj element <input>" }, { "type": "attribute_value", "value": { "selector": "label", "attr": "for", "value": null }, "message": "Dodaj atrybut for do swojego labela" }, { "type": "attribute_value", "value": { "selector": "input", "attr": "id", "value": null }, "message": "Dodaj atrybut id do swojego pola" } ] }, { "id": "input-types", "title": "Typy pól", "description": "Różne typy pól zapewniają odpowiednie klawiatury i walidację:

type=\"text\" - Ogólny tekst
type=\"email\" - Email z walidacją @
type=\"password\" - Ukryte znaki
type=\"number\" - Klawiatura numeryczna
type=\"tel\" - Klawiatura telefoniczna", "task": "Stwórz formularz logowania z dwoma polami:
1. Pole email: <label for=\"email\">Email:</label> i <input type=\"email\" id=\"email\">
2. Pole hasła: <label for=\"password\">Hasło:</label> i <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": "Dodaj pole z type=\"email\"" }, { "type": "element_exists", "value": "input[type='password']", "message": "Dodaj pole z type=\"password\"" }, { "type": "element_count", "value": { "selector": "label", "min": 2 }, "message": "Dodaj labele dla obu pól" } ] }, { "id": "submit-button", "title": "Przycisk wysyłania", "description": "Formularze potrzebują sposobu na wysłanie danych. Użyj:

<button type=\"submit\"> - Preferowany, elastyczna zawartość
<input type=\"submit\"> - Prosty przycisk tekstowy

Tekst przycisku powinien być zorientowany na akcję (np. Zaloguj, 'Zarejestruj', 'Wyślij').", "task": "Dodaj przycisk wysyłania do formularza z tekstem Zaloguj.", "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": "Dodaj przycisk wysyłania do formularza" }, { "type": "element_text", "value": { "selector": "button", "text": "Zaloguj" }, "message": "Przycisk powinien wyświetlać Zaloguj" } ] } ] }