{ "$schema": "../../schemas/code-crispies-module-schema.json", "id": "html-dialog", "title": "Natives Dialog-Element", "description": "Erstelle modale Dialoge ohne JavaScript-Bibliotheken", "mode": "html", "difficulty": "beginner", "lessons": [ { "id": "dialog-basic", "title": "Dialog öffnen", "description": "Das <dialog>-Element erstellt ein natives Modal. Füge das open-Attribut hinzu, um es anzuzeigen.

Verwende <form method=\"dialog\"> darin, um es beim Absenden des Formulars zu schließen - kein JavaScript nötig!", "task": "Erstelle einen Dialog mit:
1. Dem open-Attribut, um ihn anzuzeigen
2. Einem <h2> mit 'Willkommen!'
3. Einem <p> mit einer Begrüßungsnachricht
4. Einem <form method=\"dialog\"> mit einem Schließen-Button", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; min-height: 200px; background: #f5f5f5; } dialog { border: none; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); padding: 25px; max-width: 400px; } dialog::backdrop { background: rgba(0,0,0,0.5); } dialog h2 { margin: 0 0 15px 0; color: #1976d2; } dialog p { color: #666; margin: 0 0 20px 0; } dialog button { background: #1976d2; color: white; border: none; padding: 10px 25px; border-radius: 6px; cursor: pointer; font-size: 16px; } dialog button:hover { background: #1565c0; }", "sandboxCSS": "", "initialCode": "", "solution": "\n

Willkommen!

\n

Dies ist ein natives HTML-Dialog-Element.

\n
\n \n
\n
", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "dialog", "message": "Füge ein -Element hinzu" }, { "type": "attribute_value", "value": { "selector": "dialog", "attr": "open", "value": true }, "message": "Füge das 'open'-Attribut hinzu, um den Dialog anzuzeigen" }, { "type": "element_exists", "value": "dialog h2", "message": "Füge eine

-Überschrift im Dialog hinzu" }, { "type": "element_exists", "value": "form[method='dialog']", "message": "Füge ein
zum Schließen hinzu" }, { "type": "element_exists", "value": "dialog button", "message": "Füge einen Schließen-Button im Formular hinzu" } ] }, { "id": "dialog-form", "title": "Dialog mit Formular", "description": "Dialoge können vollständige Formulare enthalten. Das method=\"dialog\" lässt das Formular den Dialog beim Absenden schließen, anstatt Daten zu senden.

Dieses Muster ist perfekt für Bestätigungsdialoge, schnelle Eingaben oder Einstellungspanels.", "task": "Erstelle einen Bestätigungsdialog:
1. Füge open hinzu, um ihn anzuzeigen
2. Ein <h2> mit 'Löschen bestätigen'
3. Ein <p> mit 'Bist du sicher?'
4. Ein <form method=\"dialog\"> mit Abbrechen- und Löschen-Buttons", "previewHTML": "", "previewBaseCSS": "body { font-family: system-ui; padding: 20px; min-height: 200px; background: linear-gradient(135deg, #fce4ec 0%, #f8bbd9 100%); } dialog { border: none; border-radius: 12px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); padding: 25px; max-width: 350px; text-align: center; } dialog h2 { margin: 0 0 10px 0; color: #c62828; } dialog p { color: #666; margin: 0 0 20px 0; } dialog form { display: flex; gap: 10px; justify-content: center; } dialog button { padding: 10px 20px; border-radius: 6px; cursor: pointer; font-size: 14px; border: none; } dialog button:first-child { background: #e0e0e0; color: #333; } dialog button:last-child { background: #c62828; color: white; } dialog button:hover { opacity: 0.9; }", "sandboxCSS": "", "initialCode": "", "solution": "\n

Löschen bestätigen

\n

Bist du sicher, dass du dieses Element löschen möchtest?

\n \n \n \n \n
", "previewContainer": "preview-area", "validations": [ { "type": "element_exists", "value": "dialog[open]", "message": "Füge ein mit dem open-Attribut hinzu" }, { "type": "element_exists", "value": "dialog h2", "message": "Füge eine Überschrift zum Dialog hinzu" }, { "type": "element_exists", "value": "form[method='dialog']", "message": "Füge ein
für die Buttons hinzu" }, { "type": "element_count", "value": { "selector": "dialog button", "min": 2 }, "message": "Füge mindestens 2 Buttons hinzu (Abbrechen und Bestätigen)" } ] } ] }