From 513c5a85069f585fe4a1a626e0e9cf2a37ed0018 Mon Sep 17 00:00:00 2001 From: Michael Czechowski Date: Wed, 31 Dec 2025 01:45:52 +0100 Subject: [PATCH] feat(i18n): add support for Polish, Spanish, Arabic, and Ukrainian MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Create lesson directories and copy English lessons as templates - Add full UI translations for pl, es, ar, uk languages - Update lessons.js with module stores for all new languages - Implement language cycling (en → de → pl → es → ar → uk → en) - Fix playground mode detection (lesson.mode takes precedence) --- lessons/ar/00-basic-selectors.json | 550 ++++++++++++++++++++++ lessons/ar/00-welcome.json | 62 +++ lessons/ar/01-box-model.json | 180 +++++++ lessons/ar/05-units-variables.json | 116 +++++ lessons/ar/06-transitions-animations.json | 145 ++++++ lessons/ar/08-responsive.json | 126 +++++ lessons/ar/20-html-elements.json | 97 ++++ lessons/ar/21-html-forms-basic.json | 102 ++++ lessons/ar/22-html-forms-validation.json | 112 +++++ lessons/ar/23-html-details-summary.json | 97 ++++ lessons/ar/24-html-progress-meter.json | 102 ++++ lessons/ar/30-html-tables.json | 127 +++++ lessons/ar/31-html-marquee.json | 82 ++++ lessons/ar/32-html-svg.json | 102 ++++ lessons/ar/flexbox.json | 173 +++++++ lessons/es/00-basic-selectors.json | 550 ++++++++++++++++++++++ lessons/es/00-welcome.json | 62 +++ lessons/es/01-box-model.json | 180 +++++++ lessons/es/05-units-variables.json | 116 +++++ lessons/es/06-transitions-animations.json | 145 ++++++ lessons/es/08-responsive.json | 126 +++++ lessons/es/20-html-elements.json | 97 ++++ lessons/es/21-html-forms-basic.json | 102 ++++ lessons/es/22-html-forms-validation.json | 112 +++++ lessons/es/23-html-details-summary.json | 97 ++++ lessons/es/24-html-progress-meter.json | 102 ++++ lessons/es/30-html-tables.json | 127 +++++ lessons/es/31-html-marquee.json | 82 ++++ lessons/es/32-html-svg.json | 102 ++++ lessons/es/flexbox.json | 173 +++++++ lessons/pl/00-basic-selectors.json | 550 ++++++++++++++++++++++ lessons/pl/00-welcome.json | 62 +++ lessons/pl/01-box-model.json | 180 +++++++ lessons/pl/05-units-variables.json | 116 +++++ lessons/pl/06-transitions-animations.json | 145 ++++++ lessons/pl/08-responsive.json | 126 +++++ lessons/pl/20-html-elements.json | 97 ++++ lessons/pl/21-html-forms-basic.json | 102 ++++ lessons/pl/22-html-forms-validation.json | 112 +++++ lessons/pl/23-html-details-summary.json | 97 ++++ lessons/pl/24-html-progress-meter.json | 102 ++++ lessons/pl/30-html-tables.json | 127 +++++ lessons/pl/31-html-marquee.json | 82 ++++ lessons/pl/32-html-svg.json | 102 ++++ lessons/pl/flexbox.json | 173 +++++++ lessons/uk/00-basic-selectors.json | 550 ++++++++++++++++++++++ lessons/uk/00-welcome.json | 62 +++ lessons/uk/01-box-model.json | 180 +++++++ lessons/uk/05-units-variables.json | 116 +++++ lessons/uk/06-transitions-animations.json | 145 ++++++ lessons/uk/08-responsive.json | 126 +++++ lessons/uk/20-html-elements.json | 97 ++++ lessons/uk/21-html-forms-basic.json | 102 ++++ lessons/uk/22-html-forms-validation.json | 112 +++++ lessons/uk/23-html-details-summary.json | 97 ++++ lessons/uk/24-html-progress-meter.json | 102 ++++ lessons/uk/30-html-tables.json | 127 +++++ lessons/uk/31-html-marquee.json | 82 ++++ lessons/uk/32-html-svg.json | 102 ++++ lessons/uk/flexbox.json | 173 +++++++ src/app.js | 4 +- src/config/lessons.js | 160 ++++++- src/i18n.js | 427 ++++++++++++++++- 63 files changed, 9275 insertions(+), 8 deletions(-) create mode 100644 lessons/ar/00-basic-selectors.json create mode 100644 lessons/ar/00-welcome.json create mode 100644 lessons/ar/01-box-model.json create mode 100644 lessons/ar/05-units-variables.json create mode 100644 lessons/ar/06-transitions-animations.json create mode 100644 lessons/ar/08-responsive.json create mode 100644 lessons/ar/20-html-elements.json create mode 100644 lessons/ar/21-html-forms-basic.json create mode 100644 lessons/ar/22-html-forms-validation.json create mode 100644 lessons/ar/23-html-details-summary.json create mode 100644 lessons/ar/24-html-progress-meter.json create mode 100644 lessons/ar/30-html-tables.json create mode 100644 lessons/ar/31-html-marquee.json create mode 100644 lessons/ar/32-html-svg.json create mode 100644 lessons/ar/flexbox.json create mode 100644 lessons/es/00-basic-selectors.json create mode 100644 lessons/es/00-welcome.json create mode 100644 lessons/es/01-box-model.json create mode 100644 lessons/es/05-units-variables.json create mode 100644 lessons/es/06-transitions-animations.json create mode 100644 lessons/es/08-responsive.json create mode 100644 lessons/es/20-html-elements.json create mode 100644 lessons/es/21-html-forms-basic.json create mode 100644 lessons/es/22-html-forms-validation.json create mode 100644 lessons/es/23-html-details-summary.json create mode 100644 lessons/es/24-html-progress-meter.json create mode 100644 lessons/es/30-html-tables.json create mode 100644 lessons/es/31-html-marquee.json create mode 100644 lessons/es/32-html-svg.json create mode 100644 lessons/es/flexbox.json create mode 100644 lessons/pl/00-basic-selectors.json create mode 100644 lessons/pl/00-welcome.json create mode 100644 lessons/pl/01-box-model.json create mode 100644 lessons/pl/05-units-variables.json create mode 100644 lessons/pl/06-transitions-animations.json create mode 100644 lessons/pl/08-responsive.json create mode 100644 lessons/pl/20-html-elements.json create mode 100644 lessons/pl/21-html-forms-basic.json create mode 100644 lessons/pl/22-html-forms-validation.json create mode 100644 lessons/pl/23-html-details-summary.json create mode 100644 lessons/pl/24-html-progress-meter.json create mode 100644 lessons/pl/30-html-tables.json create mode 100644 lessons/pl/31-html-marquee.json create mode 100644 lessons/pl/32-html-svg.json create mode 100644 lessons/pl/flexbox.json create mode 100644 lessons/uk/00-basic-selectors.json create mode 100644 lessons/uk/00-welcome.json create mode 100644 lessons/uk/01-box-model.json create mode 100644 lessons/uk/05-units-variables.json create mode 100644 lessons/uk/06-transitions-animations.json create mode 100644 lessons/uk/08-responsive.json create mode 100644 lessons/uk/20-html-elements.json create mode 100644 lessons/uk/21-html-forms-basic.json create mode 100644 lessons/uk/22-html-forms-validation.json create mode 100644 lessons/uk/23-html-details-summary.json create mode 100644 lessons/uk/24-html-progress-meter.json create mode 100644 lessons/uk/30-html-tables.json create mode 100644 lessons/uk/31-html-marquee.json create mode 100644 lessons/uk/32-html-svg.json create mode 100644 lessons/uk/flexbox.json diff --git a/lessons/ar/00-basic-selectors.json b/lessons/ar/00-basic-selectors.json new file mode 100644 index 0000000..6e55337 --- /dev/null +++ b/lessons/ar/00-basic-selectors.json @@ -0,0 +1,550 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "css-basic-selectors", + "title": "CSS Selectors", + "description": "CSS selectors are the foundation of styling web pages, allowing you to target specific HTML elements for styling. This module introduces fundamental selector types including element type selectors, class selectors, ID selectors, and the universal selector.", + "difficulty": "beginner", + "lessons": [ + { + "id": "introduction-to-selectors", + "title": "What's a Selector?", + "description": "A CSS selector is the first part of a CSS rule that tells the browser which HTML elements should receive the styles defined in the declaration block. Selectors are essentially patterns that match against elements in your HTML document. Understanding selectors is fundamental because they determine which elements your CSS rules will affect. The element or elements targeted by a selector are referred to as the 'subject of the selector.' When writing a CSS rule, you first specify the selector, followed by curly braces that contain the style declarations.
For example, to change the text color of elements, you can use the color property within your declaration block.

/* Element selector */\np {\n  color: orangered;\n  /* │       └─── Indicates the value of the expression\n     │                                                     \n     └─────────── Indicates the property of the expression */\n}
", + "task": "Write a CSS rule using a type selector that targets all paragraph elements p in the document. Make the text blue by setting the color property to blue.", + "previewHTML": "

Introduction to CSS Selectors

\n

This paragraph should turn blue.

\n
This div element should remain unchanged.
\n

This second paragraph should also turn blue.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h1, p, div { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Write a type selector to target all paragraph elements */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "p { color: blue }", + "validations": [ + { + "type": "regex", + "value": "^p\\s*{", + "message": "Start your rule with p { … } to select all paragraph elements", + "options": { + "caseSensitive": false + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color: property in your CSS rule" + }, + { + "type": "contains", + "value": "blue", + "message": "Set the color value to blue" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "blue" + }, + "message": "Use color: blue to set the text color" + }, + { + "type": "regex", + "value": "p\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": false + } + } + ] + }, + { + "id": "type-selectors", + "title": "Type Selectors", + "description": "Type selectors (also called tag name selectors or element selectors) target HTML elements based on their tag name. For example, p selects all paragraph elements, h1 selects all level-one headings, and div selects all division elements. Type selectors are the most fundamental way to select elements, applying styles consistently to all instances of a particular HTML element throughout your document. You can define a variety of CSS properties with type selectors, such as color for text color, background-color for the background, and font-weight for text emphasis. They provide a broad approach for styling your page and are often the starting point for more specific styling using other selector types.", + "task": "Write three separate CSS rules using type selectors to target specific HTML elements: make h2 headings purple, give span elements a yellow background, and make strong elements red.", + "previewHTML": "

Type Selectors Example

\n

Regular paragraph text with a highlighted span that should have a yellow background.

\n

Another paragraph with strong important text that should be red.

\n

Another Heading

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p, span, strong { padding: 3px; }", + "codePrefix": "/* Write three separate type selectors below */\n\n", + "initialCode": "/* 1. Make h2 headings purple */\n\n\n/* 2. Give span elements a yellow background */\n\n\n/* 3. Make strong elements red */\n", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "/* 1. Make h2 headings purple */\nh2 {\n color: purple;\n}\n\n/* 2. Give span elements a yellow background */\nspan {\n background-color: yellow;\n}\n\n/* 3. Make strong elements red */\nstrong {\n color: red;\n}", + "validations": [ + { + "type": "regex", + "value": "^h2\\s*{", + "message": "Include an h2 { … } selector" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "purple" + }, + "message": "Set the color property to purple for h2 elements" + }, + { + "type": "regex", + "value": "h2\\s*{[^}]*}", + "message": "Make sure to close your h2 rule with a closing brace }" + }, + { + "type": "regex", + "value": "^span\\s*{", + "message": "Include a span { … } selector" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "yellow" + }, + "message": "Set a background-color: yellow for span elements" + }, + { + "type": "regex", + "value": "span\\s*{[^}]*}", + "message": "Make sure to close your span rule with a closing brace }" + }, + { + "type": "regex", + "value": "^strong\\s*{", + "message": "Include a strong { … } selector" + }, + { + "type": "regex", + "value": "strong\\s*{\\s*color:\\s*red;[^}]*}", + "message": "Set the color: red for strong elements" + } + ] + }, + { + "id": "class-selectors", + "title": "Class Selectors", + "description": "Class selectors target elements with a specific class attribute value. They begin with a dot (.) followed by the class name. Classes are powerful because they allow you to apply the same styles to multiple elements regardless of their type. An HTML element can have multiple classes (separated by spaces in the class attribute), and a class can be applied to any number of elements. When using class selectors, you can apply properties like background-color to set the background color of elements, and font-weight to control text thickness, making text bold or normal. This flexibility makes class selectors one of the most commonly used methods for applying styles in CSS, allowing for modular and reusable styling across your website.", + "task": "Create a CSS rule using a class selector that targets elements with the class highlight. Give these elements a yellow background and bold text.", + "previewHTML": "

Using Class Selectors

\n

This is a regular paragraph, but this span has the highlight class applied to it.

\n

This entire paragraph has the highlight class.

\n", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p, li { padding: 5px; margin-bottom: 10px; }", + "codePrefix": "/* Create a class selector for elements with the 'highlight' class */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^\\.highlight\\s*{", + "message": "Start your rule with .highlight { … } to create a class selector", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color: property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "yellow" + }, + "message": "Set the background color to yellow" + }, + { + "type": "contains", + "value": "font-weight:", + "message": "Include the font-weight: property" + }, + { + "type": "property_value", + "value": { + "property": "font-weight", + "expected": "bold" + }, + "message": "Set the font-weight to bold" + }, + { + "type": "regex", + "value": "\\.highlight\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "multiple-classes", + "title": "Multiple Classes", + "description": "HTML elements can have multiple classes applied simultaneously, allowing for composable and modular CSS designs. When an element has multiple classes, it will receive styles from all matching class selectors. This approach enables you to build a library of reusable CSS classes that can be combined in different ways. You can also target elements that have a specific combination of classes by chaining class selectors together without spaces (e.g., .class1.class2). When styling these elements, you might use properties like border-color to change the color of element borders, and background-color to set the background color of elements. This technique lets you create conditional styles that only apply when certain classes appear together.", + "task": "Complete the CSS rule that targets elements with both card and featured classes by chaining the selectors. Set the border-color to gold and the background-color to lemonchiffon to make featured cards stand out.", + "previewHTML": "

Multiple Class Combinations

\n
Regular Card
\n
Featured Card
\n
Just Featured (not a card)
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } .card { border: 2px solid gray; padding: 15px; margin-bottom: 10px; border-radius: 5px; }", + "sandboxCSS": "", + "codePrefix": "/* The .card class already has basic styling */\n/* Now target elements with BOTH classes: 'card' AND 'featured' */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": ".card.featured { border-color: gold; background-color: lemonchiffon }", + "validations": [ + { + "type": "regex", + "value": "^\\.card\\.featured\\s*{", + "message": "Chain the selectors as .card.featured (no space between them)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "border-color:", + "message": "Include the border-color property" + }, + { + "type": "property_value", + "value": { + "property": "border-color", + "expected": "gold" + }, + "message": "Set the border color to gold" + }, + { + "type": "regex", + "value": "\\.card\\.featured\\s*{[^}]*;", + "message": "Make sure to end your CSS rule with a semicolon ;" + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "lemonchiffon" + }, + "message": "Set the background color to lemonchiffon" + }, + { + "type": "regex", + "value": "\\.card\\.featured\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "class-with-type", + "title": "Combining Types", + "description": "You can combine type selectors with class selectors to target specific HTML elements that have a certain class. This creates a more specific selector that only matches when both conditions are true: the element is of the specified type AND it has the specified class. For example, p.note would select paragraph elements with the class note, but would not select divs or spans with that same class. You can style these combined selections using properties like background-color to set a colored background for your elements. This approach allows you to apply different styles to the same class when it appears on different element types.", + "task": "Create a CSS rule that specifically targets <span> elements with the class highlight. Make those elements have an orange background, while other elements with the highlight class remain untouched.", + "previewHTML": "

Type and Class Combinations

\n

This paragraph has a highlighted span that should have an orange background.

\n

This paragraph has the highlight class but should NOT have an orange background.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } .highlight { font-weight: bold; }", + "sandboxCSS": "h2, p, span { padding: 5px; }", + "codePrefix": "/* The .highlight class already sets font-weight to bold */\n/* Now target ONLY span elements with the highlight class */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^span\\.highlight\\s*{", + "message": "Use span.highlight selector (no space between element and class)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "orange" + }, + "message": "Set the background color to orange" + }, + { + "type": "regex", + "value": "span\\.highlight\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "id-selectors", + "title": "ID Selectors", + "description": "ID selectors target elements with a specific id attribute. They begin with a hash/pound sign (#) followed by the ID name. Unlike classes, IDs must be unique within a document—each ID value should be used only once per page. ID selectors have higher specificity than class or element selectors, meaning they override those selectors when conflicts arise. When styling with ID selectors, you can use properties like color to define text color, and text-decoration to control the appearance of text, such as adding underlines to elements. Because of their uniqueness requirement, IDs are best used for one-of-a-kind elements like page headers, main navigation, or specific unique components that appear only once on a page.", + "task": "Create a CSS rule with an ID selector that targets the element with the ID main-title. Set its color to purple and add an underline with text-decoration: underline.", + "previewHTML": "

Main Page Title

\n

Regular paragraph content.

\n

Secondary Heading

\n

Introduction paragraph (different ID).

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h1, h2, p { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Create an ID selector to target the element with id=\"main-title\" */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^#main-title\\s*{", + "message": "Start your rule with #main-title to create an ID selector", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color property" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "purple" + }, + "message": "Set the color to purple" + }, + { + "type": "contains", + "value": "text-decoration:", + "message": "Include the text-decoration property" + }, + { + "type": "property_value", + "value": { + "property": "text-decoration", + "expected": "underline" + }, + "message": "Set the text-decoration to underline" + }, + { + "type": "regex", + "value": "#main-title\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "id-with-type", + "title": "Type + ID", + "description": "Similar to how you can combine type and class selectors, you can also combine type selectors with ID selectors. For example, h1#title targets an h1 element with the ID 'title'. When using this combined approach, you can apply CSS properties like font-style to control the slant of the text, making it italic or normal. While this selector combination is more specific than using just the ID selector, it's often unnecessary since IDs should already be unique in a document. However, this technique can be useful for improving code readability or when you want to emphasize that a particular ID should only appear on a specific element type.", + "task": "Create a CSS rule that combines a type selector with an ID selector to target specifically a paragraph element with the ID special. Set its font style to italic.", + "previewHTML": "

Heading with ID \"special\" (should NOT be affected)

\n

Paragraph with ID \"special\" (should become italic)

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Create a combined type+ID selector for a paragraph with id=\"special\" */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^p#special\\s*{", + "message": "Use p#special to target paragraphs with ID special", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "font-style:", + "message": "Include the font-style property" + }, + { + "type": "property_value", + "value": { + "property": "font-style", + "expected": "italic" + }, + "message": "Set the font-style to italic" + }, + { + "type": "regex", + "value": "p#special\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "selector-lists", + "title": "Selector Lists", + "description": "When multiple elements need the same styling, you can group them together using a selector list (also known as grouping selectors). Selector lists are created by separating individual selectors with commas. This approach reduces repetition in your CSS, making it more maintainable and efficient. For example, h1, h2, h3 { color: blue; } applies the same blue color to all three heading levels. When styling multiple selectors at once, you can apply properties like background-color to set the background, border-left to create a left border with a specific thickness, style, and color, and padding-left to create space between the content and the left border. Whitespace around commas is optional, and each selector in the list can be any valid selector type-elements, classes, IDs, or even more complex selectors.", + "task": "Create a selector list that applies the same styles to three different elements: paragraphs with class note, list items with class important, and the element with ID summary. Give them a lightyellow background, a gold left border, and some left padding.", + "previewHTML": "

This is a note paragraph.

\n\n
Summary section
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "p, li, div { padding: 8px; margin-bottom: 8px; border: 1px dashed gray; }", + "codePrefix": "/* Create a selector list to apply the same styles to multiple different elements */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "p.note,\nli.important,\n#summary {\n background-color: lightyellow;\n border-left: 3px solid gold;\n padding-left: 10px\n}", + "validations": [ + { + "type": "contains", + "value": "p.note", + "message": "Include p.note in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "li.important", + "message": "Include li.important in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "#summary", + "message": "Include #summary in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "regex", + "value": "(p\\.note|li\\.important|#summary)\\s*,\\s*(p\\.note|li\\.important|#summary)\\s*,\\s*(p\\.note|li\\.important|#summary)", + "message": "Create a comma-separated list with all three selectors", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "lightyellow" + }, + "message": "Set the background color to lightyellow" + }, + { + "type": "contains", + "value": "border-left:", + "message": "Include the border-left property" + }, + { + "type": "property_value", + "value": { + "property": "border-left", + "expected": "3px solid gold" + }, + "message": "Use border-left: 3px solid gold to create a left border" + }, + { + "type": "contains", + "value": "padding-left:", + "message": "Include the padding-left property" + }, + { + "type": "property_value", + "value": { + "property": "padding-left", + "expected": "10px" + }, + "message": "Use padding-left: 10px to add left padding" + } + ] + }, + { + "id": "universal-selector", + "title": "Universal (*)", + "description": "The universal selector is denoted by an asterisk (*) and matches any element of any type. It selects everything in the document or, when combined with other selectors, everything within a specific context. For example, * { margin: 0; } removes margins from all elements, while article * selects all elements inside article elements. When using the universal selector in combination with other selectors, you can apply properties like margin to control the spacing around elements. The universal selector is powerful but should be used carefully due to its broad impact. It's commonly used in CSS resets, to override default browser styling, or to target all children of a particular element.", + "task": "Use the universal selector to remove margins from all elements inside the container div. Create a rule using div.container * as the selector and set margin: 0.", + "previewHTML": "
\n

Inside Container

\n

This paragraph is inside the container.

\n \n
\n

This paragraph is outside the container and should not be affected.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } div.container { border: 2px solid navy; padding: 15px; background-color: lavender; } h2, p, ul, li { margin: 15px 0; }", + "sandboxCSS": "", + "codePrefix": "/* Use the universal selector to target all elements inside the container */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^div\\.container\\s+\\*\\s*{", + "message": "Use div.container * selector (with a space between container and *)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "margin:", + "message": "Include the margin property" + }, + { + "type": "property_value", + "value": { + "property": "margin", + "expected": "0" + }, + "message": "Set margin to 0" + }, + { + "type": "regex", + "value": "div\\.container\\s+\\*\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "specificity-basics", + "title": "Specificity", + "description": "CSS specificity determines which styles take precedence when multiple conflicting rules target the same element. Specificity follows a hierarchical system: inline styles have the highest specificity, followed by ID selectors, then class/attribute/pseudo-class selectors, and finally element/pseudo-element selectors. This can be conceptualized as a four-part score (inline, ID, class, element). When creating multiple rules that may target the same elements, you can use the color property to set text colors, and specificity will determine which color is actually applied. Understanding specificity is crucial for predictable styling and debugging CSS conflicts. When two selectors have equal specificity, the one that comes last in the stylesheet wins.", + "task": "Examine the existing CSS rules and add a new rule with higher specificity to override the text color of the paragraph. Create a rule using '.content p' as the selector and set color: green.", + "previewHTML": "
\n

What color will this paragraph be? Look at the CSS rules and their specificity.

\n
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "p { border: 1px dashed gray; padding: 10px; }", + "codePrefix": "/* These CSS rules target the same paragraph but have different specificity */\n\n/* Rule 1: Element selector (lowest specificity) */\np {\n color: red;\n}\n\n/* Rule 2: Descendant selector (higher specificity than just 'p') */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^\\.content\\s+p\\s*{", + "message": "Use .content p as your selector (note the space between)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color property" + }, + { + "type": "contains", + "value": "green", + "message": "" + } + ] + } + ] +} diff --git a/lessons/ar/00-welcome.json b/lessons/ar/00-welcome.json new file mode 100644 index 0000000..ce364c4 --- /dev/null +++ b/lessons/ar/00-welcome.json @@ -0,0 +1,62 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "welcome", + "title": "Code Crispies", + "description": "Welcome to Code Crispies - your interactive web development learning platform", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "get-started", + "title": "Get Started", + "description": "Code Crispies is a free, open-source platform for learning web development through hands-on exercises. No account required!

What you'll learn:
HTML - Semantic elements, forms, tables, SVG (HTML Block & Inline, HTML Forms, HTML Tables)
CSS - Selectors, box model, flexbox, animations (CSS Selectors, CSS Box Model, CSS Flexbox)
Responsive Design - Media queries and mobile-first layouts

How it works:
1. Read the task in the left panel
2. Write code in the editor
3. See live results in the preview
4. Get instant feedback with hints

Keyboard shortcuts: Ctrl+Z to undo, Ctrl+Shift+Z to redo

More resources:
HTML over JS - Native HTML vs JavaScript solutions
Web Engineering Mandala - JavaScript technology roadmap", + "task": "Hello World", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 20px; text-align: center; } h1 { color: #6366f1; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Hello World

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "Hello", + "message": "Write 'Hello World'" + } + ] + }, + { + "id": "overview", + "title": "Overview", + "description": "You're ready! Open the menu (☰) to explore all modules.

Recommended learning path:
1. HTML Block & Inline - Understand container vs inline elements
2. HTML Forms - Build interactive forms with validation
3. CSS Selectors - Target elements precisely
4. CSS Box Model - Master padding, margin, borders
5. CSS Flexbox - Create flexible layouts
6. CSS Animations - Add motion and transitions

Tips:
• Use Show Expected to see the target result
• Your progress is saved automatically
• Try Emmet in HTML mode: ul>li*3 + Tab

Open Source:
Gitea (Source) · GitHub (Mirror)
• Made by LibreTECH · Michael Czechowski", + "task": "Click Next to continue", + "previewHTML": "

Hello World! 🌍

Hallo Welt!

Bonjour le monde!

¡Hola Mundo!

Ciao Mondo!

Olá Mundo!

こんにちは世界!

你好世界!

안녕 세상!

Привет мир!

שלום עולם!

مرحبا بالعالم!

", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 12px; } p { margin: 6px 0; padding: 6px 12px; border-radius: 6px; font-weight: 600; font-size: 0.95em; } p:nth-child(1) { background: #fef3c7; color: #92400e; font-size: 1.2em; } p:nth-child(2) { background: #dcfce7; color: #166534; } p:nth-child(3) { background: #dbeafe; color: #1e40af; } p:nth-child(4) { background: #fce7f3; color: #9d174d; } p:nth-child(5) { background: #e0e7ff; color: #4338ca; } p:nth-child(6) { background: #fef9c3; color: #854d0e; } p:nth-child(7) { background: #fee2e2; color: #991b1b; } p:nth-child(8) { background: #f3e8ff; color: #7c3aed; } p:nth-child(9) { background: #ccfbf1; color: #0f766e; } p:nth-child(10) { background: #fae8ff; color: #86198f; } p:nth-child(11) { background: #fef3c7; color: #b45309; } p:nth-child(12) { background: #d1fae5; color: #047857; }", + "sandboxCSS": "", + "initialCode": "

Hello World! 🌍

\n

Hallo Welt!

\n

Bonjour le monde!

\n

¡Hola Mundo!

\n

Ciao Mondo!

\n

Olá Mundo!

\n

こんにちは世界!

\n

你好世界!

\n

안녕 세상!

\n

Привет мир!

\n

שלום עולם!

\n

مرحبا بالعالم!

", + "solution": "

Hello World! 🌍

\n

Hallo Welt!

\n

Bonjour le monde!

\n

¡Hola Mundo!

\n

Ciao Mondo!

\n

Olá Mundo!

\n

こんにちは世界!

\n

你好世界!

\n

안녕 세상!

\n

Привет мир!

\n

שלום עולם!

\n

مرحبا بالعالم!

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "Hello", + "message": "Click Next to continue" + } + ] + }, + { + "id": "playground", + "title": "Playground", + "mode": "playground", + "description": "", + "task": "", + "previewHTML": "", + "previewBaseCSS": "", + "sandboxCSS": "", + "initialCode": "\n\n

Hello World

\n

Start coding!

", + "solution": "", + "previewContainer": "preview-area", + "validations": [] + } + ] +} diff --git a/lessons/ar/01-box-model.json b/lessons/ar/01-box-model.json new file mode 100644 index 0000000..a5b10a6 --- /dev/null +++ b/lessons/ar/01-box-model.json @@ -0,0 +1,180 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "box-model", + "title": "CSS Box Model", + "description": "Master the fundamental principles of space management in web design through the CSS box model. This module explores how content, padding, borders, and margins combine to create layout structures that are both visually appealing and structurally sound.", + "difficulty": "beginner", + "lessons": [ + { + "id": "box-model-1", + "title": "Box Model Components", + "description": "The CSS box model consists of four concentric layers: content area (innermost), padding, border, and margin (outermost). Understanding how these components interact is essential for precise layout control.", + "task": "Add padding: 1rem to .box to create space between its content and border.", + "previewHTML": "
Box Model Components
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background-color: lavender; border: 2px dashed slategray; }", + "sandboxCSS": "", + "codePrefix": ".box {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "padding: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "padding", "expected": "1rem" }, + "message": "Set padding: 1rem" + } + ] + }, + { + "id": "box-model-2", + "title": "Adding Borders", + "description": "Borders outline an element, creating visual separation from surrounding content. The border shorthand accepts three values: width, style, and color.", + "task": "Add border: 2px solid darkslategray to .box.", + "previewHTML": "
This box needs a border
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background-color: mintcream; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": ".box {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "border: 2px solid darkslategray;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "border:\\s*2px\\s+solid\\s+darkslategray", + "message": "Set border: 2px solid darkslategray", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "box-model-3", + "title": "Adding Margins", + "description": "Margins create space between elements, controlling how they relate to one another within a layout. Unlike padding (which affects internal spacing), margins exist outside the element's border.", + "task": "Add margin: 1rem to .outer to create space between it and the adjacent element.", + "previewHTML": "
This box needs margins
Adjacent element
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .container { background-color: whitesmoke; padding: 8px; } .outer { background-color: plum; padding: 1rem; border: 2px solid orchid; } .neighbor { background-color: lightblue; padding: 1rem; border: 2px solid steelblue; }", + "sandboxCSS": "", + "codePrefix": ".outer {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "margin", "expected": "1rem" }, + "message": "Set margin: 1rem" + } + ] + }, + { + "id": "box-model-4", + "title": "Box Sizing: Border-Box", + "description": "The box-sizing property determines how element dimensions are calculated. The default content-box excludes padding and border from width/height, while border-box includes them, making layout calculations more intuitive.", + "task": "Add box-sizing: border-box to .sized so padding and border are included in its width.", + "previewHTML": "
Content-box (default)
Border-box
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .sizing-demo { display: flex; gap: 1rem; } .box { width: 200px; padding: 1rem; border: 4px solid teal; background: lightcyan; } .default { box-sizing: content-box; }", + "sandboxCSS": "", + "codePrefix": ".sized {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "box-sizing: border-box;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "box-sizing", "expected": "border-box" }, + "message": "Set box-sizing: border-box" + } + ] + }, + { + "id": "box-model-5", + "title": "Margin Collapse", + "description": "When two vertical margins meet, they collapse to the larger value instead of adding up. Understanding this behavior is crucial for consistent vertical spacing.", + "task": "Add margin-bottom: 2rem to .first. Notice the space between paragraphs equals 2rem (not 3rem) due to margin collapse.", + "previewHTML": "

This paragraph has a bottom margin.

This paragraph has a top margin of 1rem.

", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .collapse-demo { border: 1px solid silver; padding: 8px; background: ghostwhite; } .second { margin-top: 1rem; background: linen; }", + "sandboxCSS": "", + "codePrefix": ".first {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin-bottom: 2rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "margin-bottom", "expected": "2rem" }, + "message": "Set margin-bottom: 2rem" + } + ] + }, + { + "id": "box-model-6", + "title": "Margin Shorthand Notation", + "description": "The margin shorthand can set all four sides at once. Two values set vertical (top/bottom) and horizontal (left/right) margins respectively.", + "task": "Add margin: 1rem 2rem to .spaced for 1rem top/bottom and 2rem left/right.", + "previewHTML": "
This box needs margins: 1rem top/bottom, 2rem left/right
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .container { background-color: whitesmoke; padding: 8px; } .spaced { background-color: honeydew; border: 2px solid mediumseagreen; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": ".spaced {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin: 1rem 2rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "margin:\\s*1rem\\s+2rem", + "message": "Set margin: 1rem 2rem", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "box-model-7", + "title": "Padding Shorthand Notation", + "description": "Like margin, padding shorthand allows setting all sides at once. A single value applies to all four sides equally.", + "task": "Add padding: 1.5rem to .padded to add equal padding on all sides.", + "previewHTML": "
This box needs equal padding on all sides
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .padded { background-color: papayawhip; border: 2px solid orange; }", + "sandboxCSS": "", + "codePrefix": ".padded {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "padding: 1.5rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "padding", "expected": "1.5rem" }, + "message": "Set padding: 1.5rem" + } + ] + }, + { + "id": "box-model-8", + "title": "Border on Specific Sides", + "description": "For granular control, you can target specific sides with border-top, border-right, border-bottom, or border-left.", + "task": "Add border-bottom: 4px solid dodgerblue to .line.", + "previewHTML": "
This element needs only a bottom border
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .line { padding: 1rem; background-color: aliceblue; }", + "sandboxCSS": "", + "codePrefix": ".line {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "border-bottom: 4px solid dodgerblue;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "border-bottom:\\s*4px\\s+solid\\s+dodgerblue", + "message": "Set border-bottom: 4px solid dodgerblue", + "options": { "caseSensitive": false } + } + ] + } + ] +} diff --git a/lessons/ar/05-units-variables.json b/lessons/ar/05-units-variables.json new file mode 100644 index 0000000..67a9272 --- /dev/null +++ b/lessons/ar/05-units-variables.json @@ -0,0 +1,116 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "units-variables", + "title": "CSS Units & Variables", + "description": "Understand the variety of CSS measurement units and how to define and use custom properties for maintainable styles.", + "difficulty": "beginner", + "lessons": [ + { + "id": "units-1", + "title": "Absolute vs. Relative Units", + "description": "Learn the difference between px, rem, em, %, and vw/vh for flexible, responsive layouts.", + "task": "Set the width of .box to 80% and max-width to 37.5rem.", + "previewHTML": "
Resize me!
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .box { background: #f5f5f5; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Set flexible sizing */\n.box {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: 80%;\n max-width: 37.5rem;", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "width", "message": "Use width property", "options": { "caseSensitive": false } }, + { "type": "property_value", "value": { "property": "width", "expected": "80%" }, "message": "Set width to 80%" }, + { "type": "contains", "value": "max-width", "message": "Use max-width property", "options": { "caseSensitive": false } }, + { + "type": "property_value", + "value": { "property": "max-width", "expected": "37.5rem" }, + "message": "Set max-width to 37.5rem" + } + ] + }, + { + "id": "units-2", + "title": "CSS Custom Properties", + "description": "Define and reuse variables (--custom properties) to centralize your theme values.", + "task": "Create a --main-color variable in :root with #6200ee and apply it as the border color on .themed.", + "previewHTML": "
Variable Box
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .themed { padding: 1rem; border: 0.125rem solid #ddd; }", + "sandboxCSS": "", + "codePrefix": "/* Define and use a CSS variable */\n:root {", + "initialCode": "", + "codeSuffix": "}\n.themed { }", + "solution": " --main-color: #6200ee;\n}\n.themed {\n border-color: var(--main-color);", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "--main-color", + "message": "Define --main-color in :root", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": "var(--main-color)", + "message": "Use var(--main-color)", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "border", "expected": "var(--main-color)" }, + "message": "Apply variable to border color", + "options": { "exact": false } + } + ] + }, + { + "id": "units-3", + "title": "Unit Calculations (calc)", + "description": "Use the calc() function to combine different units in one expression.", + "task": "Set the width of .sized to calc(100% - 2rem) and min-height to calc(10vh + 1rem).", + "previewHTML": "
Calc Demo
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .sized { background: #e8f5e9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Use calc for dynamic sizing */\n.sized {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: calc(100% - 2rem);\n min-height: calc(10vh + 1rem);", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "calc", "message": "Use calc() function", "options": { "caseSensitive": false } }, + { + "type": "regex", + "value": "width:\\s*calc\\(100% - 2rem\\)", + "message": "Width should be calc(100% - 2rem)", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "min-height:\\s*calc\\(10vh \\+ 1rem\\)", + "message": "Min-height should be calc(10vh + 1rem)", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "units-4", + "title": "Viewport & Responsive Units", + "description": "Control layouts relative to viewport size with vw, vh, and vmin/vmax units.", + "task": "Give .view a width of 50vw and height of 20vh.", + "previewHTML": "
Viewport Box
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .view { background: #ffe0b2; }", + "sandboxCSS": "", + "codePrefix": "/* Use viewport units */\n.view {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: 50vw;\n height: 20vh;", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "vw", "message": "Use vw unit", "options": { "caseSensitive": false } }, + { "type": "contains", "value": "vh", "message": "Use vh unit", "options": { "caseSensitive": false } }, + { "type": "property_value", "value": { "property": "width", "expected": "50vw" }, "message": "Set width to 50vw" }, + { "type": "property_value", "value": { "property": "height", "expected": "20vh" }, "message": "Set height to 20vh" } + ] + } + ] +} diff --git a/lessons/ar/06-transitions-animations.json b/lessons/ar/06-transitions-animations.json new file mode 100644 index 0000000..2697fd7 --- /dev/null +++ b/lessons/ar/06-transitions-animations.json @@ -0,0 +1,145 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "transitions-animations", + "title": "CSS Animations", + "description": "Bring interactivity to your UI by smoothly transitioning properties and creating keyframe-driven animations.", + "difficulty": "beginner", + "lessons": [ + { + "id": "transitions-1", + "title": "Transitions", + "description": "Learn how to apply transition to properties for smooth changes on state changes.", + "task": "Add transition: background-color 0.3s to .btn so the color fades smoothly on hover.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .btn { background: black; color: white; padding: 0.5rem 1rem; border: none; cursor: pointer; } .btn:hover { background: white; color: black; }", + "sandboxCSS": "", + "codePrefix": "/* Add transition */\n.btn {", + "initialCode": "", + "codeSuffix": "}", + "solution": " transition: background-color 0.3s;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "transition", + "message": "Use the transition property", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "transition:\\s*background-color\\s*0\\.3s", + "message": "Set transition: background-color 0.3s", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "transitions-2", + "title": "Timing Funcs", + "description": "Explore easing functions like ease, linear, ease-in, ease-out to control animation pacing.", + "task": "Set transition-timing-function to ease-in-out on .btn.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .btn { background: navy; color: gold; padding: 0.5rem 1rem; border: none; cursor: pointer; transition: all 0.5s; } .btn:hover { background: gold; color: navy; transform: scale(1.1); }", + "sandboxCSS": "", + "codePrefix": "/* Set timing function */\n.btn {", + "initialCode": "", + "codeSuffix": "}", + "solution": " transition-timing-function: ease-in-out;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "transition-timing-function", + "message": "Use transition-timing-function", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "transition-timing-function", "expected": "ease-in-out" }, + "message": "Set timing to ease-in-out" + } + ] + }, + { + "id": "transitions-3", + "title": "Keyframes", + "description": "Create named animations using @keyframes and apply them via the animation shorthand.", + "task": "Define a keyframe at 50% with transform: translateY(-20px) and apply animation: bounce 1s infinite to .ball.", + "previewHTML": "
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .ball { width: 50px; height: 50px; background: crimson; border-radius: 50%; margin: 2rem auto; }", + "sandboxCSS": "", + "codePrefix": "/* Define keyframes and apply animation */\n@keyframes bounce {", + "initialCode": "", + "codeSuffix": "}\n.ball { }", + "solution": " 50% { transform: translateY(-20px); }\n}\n.ball {\n animation: bounce 1s infinite;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "@keyframes bounce", + "message": "Define @keyframes bounce", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "50%.*transform: translateY\\(-20px\\)", + "message": "At 50%, use transform: translateY(-20px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": "animation", + "message": "Use animation property on .ball", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "animation:.*bounce.*1s.*infinite", + "message": "Apply animation: bounce 1s infinite", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "transitions-4", + "title": "Anim Properties", + "description": "Fine-tune animations with animation-delay, animation-iteration-count, animation-direction, and animation-fill-mode.", + "task": "Apply the pulse animation to .box with animation-name: pulse, animation-duration: 2s, animation-delay: 1s, animation-iteration-count: 2, and animation-fill-mode: forwards.", + "previewHTML": "
Pulse
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .box { width: 100px; height: 100px; background: black; color: white; display: flex; align-items: center; justify-content: center; margin: 2rem auto; } @keyframes pulse { 0% { background: black; color: white; transform: scale(1); } 50% { background: white; color: black; transform: scale(1.2); } 100% { background: limegreen; color: black; transform: scale(1); } }", + "sandboxCSS": "", + "codePrefix": "/* Apply animation properties */\n.box {", + "initialCode": "", + "codeSuffix": "}", + "solution": " animation-name: pulse;\n animation-duration: 2s;\n animation-delay: 1s;\n animation-iteration-count: 2;\n animation-fill-mode: forwards;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "animation-name", "expected": "pulse" }, + "message": "Set animation-name: pulse" + }, + { + "type": "property_value", + "value": { "property": "animation-duration", "expected": "2s" }, + "message": "Set animation-duration: 2s" + }, + { + "type": "property_value", + "value": { "property": "animation-delay", "expected": "1s" }, + "message": "Set animation-delay: 1s" + }, + { + "type": "property_value", + "value": { "property": "animation-iteration-count", "expected": "2" }, + "message": "Set animation-iteration-count: 2" + }, + { + "type": "property_value", + "value": { "property": "animation-fill-mode", "expected": "forwards" }, + "message": "Set animation-fill-mode: forwards" + } + ] + } + ] +} diff --git a/lessons/ar/08-responsive.json b/lessons/ar/08-responsive.json new file mode 100644 index 0000000..0db9b98 --- /dev/null +++ b/lessons/ar/08-responsive.json @@ -0,0 +1,126 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "responsive-design", + "title": "CSS Responsive Design", + "description": "Make your layouts adapt to different screen sizes using media queries and fluid design techniques.", + "difficulty": "intermediate", + "lessons": [ + { + "id": "responsive-1", + "title": "Media Queries", + "description": "Understand the syntax and use cases for CSS media queries to apply styles conditionally based on viewport characteristics.", + "task": "Write a media query with @media (max-width: 600px) that changes .panel background to lightcoral.", + "previewHTML": "
Resize the window
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .panel { padding: 1rem; background: lightblue; }", + "sandboxCSS": "", + "codePrefix": "/* Add your media query below */\n", + "initialCode": "", + "codeSuffix": "", + "solution": "@media (max-width: 600px) {\n .panel {\n background: lightcoral;\n }\n}", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "@media\\s*\\(max-width:\\s*600px\\)", + "message": "Use @media (max-width: 600px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": ".panel", + "message": "Target .panel inside the media query", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "background", "expected": "lightcoral" }, + "message": "Set background: lightcoral", + "options": { "exact": false } + } + ] + }, + { + "id": "responsive-2", + "title": "Fluid Type", + "description": "Use relative units like vw to make font sizes scale with the viewport width.", + "task": "Set font-size: 5vw on .text so it scales as the viewport changes.", + "previewHTML": "

Fluid Typography

", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Apply fluid font sizing */\n.text {", + "initialCode": "", + "codeSuffix": "}", + "solution": " font-size: 5vw;", + "previewContainer": "preview-area", + "validations": [ + { "type": "property_value", "value": { "property": "font-size", "expected": "5vw" }, "message": "Set font-size: 5vw" } + ] + }, + { + "id": "responsive-3", + "title": "Flex Grids", + "description": "Combine CSS Grid with auto-fit or auto-fill for responsive column layouts.", + "task": "Add display: grid, grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)), and gap: 1rem to .cards.", + "previewHTML": "
1
2
3
4
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .cards > div { background: #d1c4e9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Create a responsive grid */\n.cards {", + "initialCode": "", + "codeSuffix": "}", + "solution": " display: grid;\n grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));\n gap: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "display", "expected": "grid" }, + "message": "Set display: grid" + }, + { + "type": "regex", + "value": "repeat\\(auto-fit,\\s*minmax\\(200px,\\s*1fr\\)\\)", + "message": "Use repeat(auto-fit, minmax(200px, 1fr))", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "gap", "expected": "1rem" }, + "message": "Set gap: 1rem" + } + ] + }, + { + "id": "responsive-4", + "title": "Mobile-First", + "description": "Adopt a mobile-first approach by writing base styles for small screens and enhancing for larger viewports.", + "task": "Write a media query with @media (min-width: 768px) that sets .sidebar width to 250px.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .sidebar { background: #c8e6c9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Add mobile-first enhancement */\n", + "initialCode": "", + "codeSuffix": "", + "solution": "@media (min-width: 768px) {\n .sidebar {\n width: 250px;\n }\n}", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "@media\\s*\\(min-width:\\s*768px\\)", + "message": "Use @media (min-width: 768px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": ".sidebar", + "message": "Target .sidebar inside media query", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "width", "expected": "250px" }, + "message": "Set width: 250px", + "options": { "exact": false } + } + ] + } + ] +} diff --git a/lessons/ar/20-html-elements.json b/lessons/ar/20-html-elements.json new file mode 100644 index 0000000..93f9214 --- /dev/null +++ b/lessons/ar/20-html-elements.json @@ -0,0 +1,97 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-elements", + "title": "HTML Block & Inline", + "description": "Understanding the fundamental difference between container (block) and inline elements", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "block-vs-inline-intro", + "title": "Block vs Inline Elements", + "description": "HTML elements fall into two main categories:

Block elements (containers) start on a new line and take full width. Examples: <div>, <p>, <h1>, <section>

Inline elements flow within text and only take needed width. Examples: <span>, <a>, <strong>, <em>", + "task": "Wrap the word important with <strong> tags to make it bold. Notice how the paragraph (block) takes full width while strong (inline) flows with text.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 20px; } p { background: #e3f2fd; padding: 10px; } strong { background: #ffecb3; }", + "sandboxCSS": "", + "initialCode": "

This is a paragraph with an important word.

", + "solution": "

This is a paragraph with an important word.

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "p", + "message": "Add a <p> paragraph element" + }, + { + "type": "parent_child", + "value": { "parent": "p", "child": "strong" }, + "message": "Wrap the word important with <strong> tags" + } + ] + }, + { + "id": "semantic-containers", + "title": "Semantic Tags", + "description": "Modern HTML uses semantic containers that describe their content:

<header> - Page or section header
<nav> - Navigation links
<main> - Main content area
<section> - Thematic grouping
<article> - Self-contained content
<footer> - Page or section footer", + "task": "Create a basic page structure:
1. Add a <header> with an <h1> containing the text 'My Website'
2. Add a <main> element with a paragraph saying 'Welcome to my site!'
3. Add a <footer> with a paragraph saying 'Copyright 2025'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; margin: 0; } header { background: #1976d2; color: white; padding: 15px; } main { padding: 20px; min-height: 100px; } footer { background: #424242; color: white; padding: 10px; text-align: center; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "
\n

My Website

\n
\n
\n

Welcome to my site!

\n
\n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "header", + "message": "Add a <header> element" + }, + { + "type": "element_exists", + "value": "main", + "message": "Add a <main> element" + }, + { + "type": "element_exists", + "value": "footer", + "message": "Add a <footer> element" + }, + { + "type": "parent_child", + "value": { "parent": "header", "child": "h1" }, + "message": "Add an <h1> heading inside your header" + } + ] + }, + { + "id": "div-vs-span", + "title": "div & span", + "description": "When you need a container without semantic meaning:

<div> - Generic block container (for layout/grouping)
<span> - Generic inline container (for styling text portions)

Use semantic elements when possible, div/span when no semantic element fits.", + "task": "Wrap the word 'highlighted' in a <span> to style it differently. Wrap the whole quote in a <div>.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: Georgia, serif; padding: 20px; } div { background: #f5f5f5; padding: 15px; border-left: 4px solid #1976d2; } span { background: #fff59d; padding: 2px 4px; }", + "sandboxCSS": "", + "initialCode": "The most highlighted moment was unforgettable.", + "solution": "
The most highlighted moment was unforgettable.
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "div", + "message": "Wrap everything in a <div> element" + }, + { + "type": "element_exists", + "value": "span", + "message": "Add a <span> around the word highlighted" + }, + { + "type": "element_text", + "value": { "selector": "span", "text": "highlighted" }, + "message": "The <span> should contain the word highlighted" + } + ] + } + ] +} diff --git a/lessons/ar/21-html-forms-basic.json b/lessons/ar/21-html-forms-basic.json new file mode 100644 index 0000000..d971cbf --- /dev/null +++ b/lessons/ar/21-html-forms-basic.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-forms-basic", + "title": "HTML Forms", + "description": "Learn to create forms with various input types", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "form-structure", + "title": "Form Structure", + "description": "Every form needs a <form> wrapper. Inside, use <label> to describe inputs and <input> for user data entry.

The for attribute on labels should match the id on inputs for accessibility.", + "task": "Create a form with:
1. A <label> with the text 'Name:' and for=\"name\" attribute
2. A text <input> with id=\"name\" and name=\"name\" attributes", + "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": "Wrap everything in a <form> element" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for your input" + }, + { + "type": "element_exists", + "value": "input", + "message": "Add an <input> element" + }, + { + "type": "attribute_value", + "value": { "selector": "label", "attr": "for", "value": null }, + "message": "Add a for attribute to your label" + }, + { + "type": "attribute_value", + "value": { "selector": "input", "attr": "id", "value": null }, + "message": "Add an id attribute to your input" + } + ] + }, + { + "id": "input-types", + "title": "Input Types", + "description": "Different input types provide appropriate keyboards and validation:

type=\"text\" - General text
type=\"email\" - Email with @ validation
type=\"password\" - Hidden characters
type=\"number\" - Numeric keyboard
type=\"tel\" - Phone keyboard", + "task": "Create a login form with two fields:
1. An email field: <label for=\"email\">Email:</label> and <input type=\"email\" id=\"email\">
2. A password field: <label for=\"password\">Password:</label> and <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": "Add an input with type=\"email\"" + }, + { + "type": "element_exists", + "value": "input[type='password']", + "message": "Add an input with type=\"password\"" + }, + { + "type": "element_count", + "value": { "selector": "label", "min": 2 }, + "message": "Add labels for both inputs" + } + ] + }, + { + "id": "submit-button", + "title": "Submit Button", + "description": "Forms need a way to submit data. Use:

<button type=\"submit\"> - Preferred, flexible content
<input type=\"submit\"> - Simple text-only button

The button text should be action-oriented (e.g., 'Sign In', 'Register', 'Send').", + "task": "Add a submit button to the form with the text 'Sign In'.", + "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": "Add a submit button to your form" + }, + { + "type": "element_text", + "value": { "selector": "button", "text": "Sign In" }, + "message": "The button should say Sign In" + } + ] + } + ] +} diff --git a/lessons/ar/22-html-forms-validation.json b/lessons/ar/22-html-forms-validation.json new file mode 100644 index 0000000..72f4cd1 --- /dev/null +++ b/lessons/ar/22-html-forms-validation.json @@ -0,0 +1,112 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-forms-validation", + "title": "HTML Validation", + "description": "Learn HTML5 built-in form validation attributes", + "mode": "html", + "difficulty": "intermediate", + "lessons": [ + { + "id": "required-fields", + "title": "Required Fields", + "description": "The required attribute prevents form submission if the field is empty.

Add it to any input that must be filled:
<input type=\"text\" required>

The browser shows a validation message automatically.", + "task": "Make both the name and email fields required by adding the required attribute.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 350px; } label { display: block; margin-top: 15px; margin-bottom: 5px; } label:first-of-type { margin-top: 0; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } input:invalid { border-color: #d32f2f; } button { margin-top: 20px; padding: 10px 20px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; }", + "sandboxCSS": "", + "initialCode": "
\n \n \n \n \n \n \n \n
", + "solution": "
\n \n \n \n \n \n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "input[name='name']", "attr": "required", "value": true }, + "message": "Add the required attribute to the name input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[name='email']", "attr": "required", "value": true }, + "message": "Add the required attribute to the email input" + } + ] + }, + { + "id": "input-constraints", + "title": "Constraints", + "description": "Control what users can enter:

minlength / maxlength - Text length limits
min / max - Number range
pattern - Regex pattern matching
placeholder - Hint text (not a label!)", + "task": "Add validation to the password input:
1. Add minlength=\"8\" for minimum length
2. Add maxlength=\"20\" for maximum length
3. Add placeholder=\"Enter password\" as a hint", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 350px; } label { display: block; margin-bottom: 5px; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } input:invalid:not(:placeholder-shown) { border-color: #d32f2f; } small { display: block; font-size: 12px; color: #666; margin-top: 4px; } button { margin-top: 20px; padding: 10px 20px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; }", + "sandboxCSS": "", + "initialCode": "
\n \n \n Must be 8-20 characters\n \n \n
", + "solution": "
\n \n \n Must be 8-20 characters\n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "minlength", "value": "8" }, + "message": "Add minlength=\"8\" to the password input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "maxlength", "value": "20" }, + "message": "Add maxlength=\"20\" to the password input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "placeholder", "value": null }, + "message": "Add a placeholder to hint what to enter" + } + ] + }, + { + "id": "complete-registration", + "title": "Full Form", + "description": "Build a complete registration form with all validation concepts:

- Required fields marked with *
- Email validation (use type=\"email\")
- Password with length constraints
- Terms checkbox (required)
- Submit button", + "task": "Complete the registration form. Add required attributes, proper input types, and validation constraints.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 400px; background: #f5f5f5; padding: 25px; border-radius: 8px; } h2 { margin-top: 0; margin-bottom: 20px; } label { display: block; margin-top: 15px; margin-bottom: 5px; font-weight: 500; } input[type='text'], input[type='email'], input[type='password'] { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 14px; } input:focus { outline: 2px solid #1976d2; border-color: transparent; } input[type='checkbox'] { width: auto; margin-right: 8px; vertical-align: middle; } label:has(input[type='checkbox']) { display: flex; align-items: center; font-weight: normal; } button { width: 100%; margin-top: 20px; padding: 12px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; font-weight: 500; } button:hover { background: #1565c0; }", + "sandboxCSS": "", + "initialCode": "
\n

Create Account

\n \n \n \n \n \n \n \n \n \n \n \n \n \n
", + "solution": "
\n

Create Account

\n \n \n \n \n \n \n \n \n \n \n \n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "#fullname", "attr": "required", "value": true }, + "message": "Make the full name field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#email", "attr": "type", "value": "email" }, + "message": "Set the email input type=\"email\"" + }, + { + "type": "attribute_value", + "value": { "selector": "#email", "attr": "required", "value": true }, + "message": "Make the email field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "type", "value": "password" }, + "message": "Set the password input type=\"password\"" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "required", "value": true }, + "message": "Make the password field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "minlength", "value": "8" }, + "message": "Add minlength=\"8\" to password" + }, + { + "type": "attribute_value", + "value": { "selector": "#terms", "attr": "required", "value": true }, + "message": "Make the terms checkbox required" + } + ] + } + ] +} diff --git a/lessons/ar/23-html-details-summary.json b/lessons/ar/23-html-details-summary.json new file mode 100644 index 0000000..3c60ad0 --- /dev/null +++ b/lessons/ar/23-html-details-summary.json @@ -0,0 +1,97 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-details-summary", + "title": "HTML Details & Summary", + "description": "Create expandable content sections without JavaScript", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "details-summary-basic", + "title": "First Widget", + "description": "The <details> element creates a collapsible section. The <summary> provides the clickable label.

Click the summary to toggle the hidden content - no JavaScript needed!", + "task": "Create a <details> element with:
1. A <summary> saying 'Click to reveal'
2. A <p> with the text 'This content was hidden!'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } details { border: 1px solid #ddd; border-radius: 8px; padding: 15px; } summary { font-weight: 600; cursor: pointer; } summary:hover { color: #1976d2; } details p { margin-top: 15px; color: #666; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "
\n Click to reveal\n

This content was hidden!

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "details", + "message": "Add a <details> element" + }, + { + "type": "element_exists", + "value": "summary", + "message": "Add a <summary> inside the details" + }, + { + "type": "parent_child", + "value": { "parent": "details", "child": "summary" }, + "message": "The <summary> must be inside <details>" + }, + { + "type": "parent_child", + "value": { "parent": "details", "child": "p" }, + "message": "Add a <p> inside <details> for the hidden content" + } + ] + }, + { + "id": "details-open-attribute", + "title": "Pre-expanded Details", + "description": "By default, <details> is closed. Add the open attribute to show the content initially.

This is a boolean attribute - just add open without a value.", + "task": "Add the open attribute to the <details> element to show the content by default.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } details { border: 1px solid #ddd; border-radius: 8px; padding: 15px; background: #f9f9f9; } summary { font-weight: 600; cursor: pointer; } details p { margin-top: 15px; color: #666; }", + "sandboxCSS": "", + "initialCode": "
\n FAQ: What is HTML5?\n

HTML5 is the latest version of the HTML standard with new semantic elements and APIs.

\n
", + "solution": "
\n FAQ: What is HTML5?\n

HTML5 is the latest version of the HTML standard with new semantic elements and APIs.

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "details", "attr": "open", "value": true }, + "message": "Add the open attribute to <details>" + } + ] + }, + { + "id": "faq-accordion", + "title": "FAQ Accordion", + "description": "Multiple <details> elements create an accordion-style FAQ. Each question can be expanded independently.

Pro tip: Type details*3>summary+p and press Tab for Emmet expansion. *3 creates 3 elements, > nests inside, + adds siblings.", + "task": "Create an FAQ section with:
1. An <h1> saying 'Frequently Asked Questions'
2. Three <details> elements, each with a question in <summary> and an answer in <p>", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; min-height: 100vh; background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); display: flex; flex-direction: column; justify-content: center; padding: 40px; margin: 0; box-sizing: border-box; } h1 { font-size: 2.5rem; color: #4a4a4a; text-align: center; margin: 0 0 30px 0; } details { background: white; border-radius: 12px; margin-bottom: 15px; padding: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } summary { font-size: 1.3rem; font-weight: 600; color: #5c5c5c; cursor: pointer; list-style: none; } summary::before { content: '▸ '; color: #fcb69f; } details[open] summary::before { content: '▾ '; } details p { margin: 15px 0 0 0; color: #666; line-height: 1.6; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Frequently Asked Questions

\n\n
\n What is HTML5?\n

HTML5 is the latest version of HTML with new semantic elements and APIs.

\n
\n\n
\n Do I need JavaScript?\n

Many interactive features work with pure HTML5, no JavaScript required!

\n
\n\n
\n Is this accessible?\n

Yes! Native HTML elements have built-in keyboard and screen reader support.

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "h1", + "message": "Add an <h1> heading for the FAQ title" + }, + { + "type": "element_count", + "value": { "selector": "details", "min": 3 }, + "message": "Create at least 3 <details> elements for the FAQ" + }, + { + "type": "element_count", + "value": { "selector": "summary", "min": 3 }, + "message": "Each <details> needs a <summary> for the question" + }, + { + "type": "element_count", + "value": { "selector": "details p", "min": 3 }, + "message": "Each <details> needs a <p> for the answer" + } + ] + } + ] +} diff --git a/lessons/ar/24-html-progress-meter.json b/lessons/ar/24-html-progress-meter.json new file mode 100644 index 0000000..28b3bf3 --- /dev/null +++ b/lessons/ar/24-html-progress-meter.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-progress-meter", + "title": "HTML Progress & Meter", + "description": "Display completion status and scalar measurements natively", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "progress-basic", + "title": "Progress Bars", + "description": "The <progress> element shows task completion. Use value for current progress and max for the total.

Note: This is not a self-closing tag! Write <progress>...</progress> with fallback text inside for older browsers.", + "task": "Create a progress bar showing 70% completion:
1. Add a <label> saying 'Download:'
2. Add a <progress> with value=\"70\" and max=\"100\"", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } label { display: block; margin-bottom: 8px; font-weight: 500; } progress { width: 100%; height: 20px; border-radius: 10px; } progress::-webkit-progress-bar { background: #e0e0e0; border-radius: 10px; } progress::-webkit-progress-value { background: linear-gradient(90deg, #4caf50, #8bc34a); border-radius: 10px; } progress::-moz-progress-bar { background: linear-gradient(90deg, #4caf50, #8bc34a); border-radius: 10px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n70%", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "progress", + "message": "Add a <progress> element" + }, + { + "type": "attribute_value", + "value": { "selector": "progress", "attr": "value", "value": "70" }, + "message": "Set value=\"70\" on the progress element" + }, + { + "type": "attribute_value", + "value": { "selector": "progress", "attr": "max", "value": "100" }, + "message": "Set max=\"100\" on the progress element" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for the progress bar" + } + ] + }, + { + "id": "progress-indeterminate", + "title": "Indeterminate Progress", + "description": "When progress is unknown (like loading), omit the value attribute. This creates an animated indeterminate state.

Useful for network requests or processes with unknown duration.", + "task": "Create a loading indicator:
1. Add a <p> saying 'Loading...'
2. Add a <progress> without a value attribute", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } p { margin-bottom: 10px; color: #666; } progress { width: 100%; height: 8px; border-radius: 4px; } progress::-webkit-progress-bar { background: #e0e0e0; border-radius: 4px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Loading...

\n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "progress", + "message": "Add a <progress> element" + }, + { + "type": "element_exists", + "value": "p", + "message": "Add a <p> with loading text" + } + ] + }, + { + "id": "meter-gauge", + "title": "Meter Gauges", + "description": "The <meter> element displays a scalar value within a range. Use it for measurements like disk space, battery, or ratings.

Set low, high, and optimum to define good/bad ranges - the browser colors it accordingly!", + "task": "Create a battery level meter:
1. Add a <label> saying 'Battery:'
2. Add a <meter> with:
- value=\"0.8\"
- min=\"0\" and max=\"1\"
- low=\"0.2\" and high=\"0.8\"
- optimum=\"1\"", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } label { display: block; margin-bottom: 8px; font-weight: 500; } meter { width: 100%; height: 25px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n80%", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "meter", + "message": "Add a <meter> element" + }, + { + "type": "attribute_value", + "value": { "selector": "meter", "attr": "value", "value": "0.8" }, + "message": "Set value=\"0.8\" on the meter" + }, + { + "type": "attribute_value", + "value": { "selector": "meter", "attr": "low", "value": "0.2" }, + "message": "Set low=\"0.2\" to define the low threshold" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for the meter" + } + ] + } + ] +} diff --git a/lessons/ar/30-html-tables.json b/lessons/ar/30-html-tables.json new file mode 100644 index 0000000..1bdfaeb --- /dev/null +++ b/lessons/ar/30-html-tables.json @@ -0,0 +1,127 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-tables", + "title": "HTML Tables", + "description": "Create structured data tables with headers and captions", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "table-basic", + "title": "Basic Table Structure", + "description": "Tables use <table> with <tr> for rows. Inside rows, use <th> for headers and <td> for data cells.

The <caption> element provides an accessible title for the table.", + "task": "Create a simple table with:
1. A <caption> saying 'Fruit Prices'
2. A header row with 'Fruit' and 'Price' columns
3. At least 2 data rows", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #f5f5f5; } table { border-collapse: collapse; width: 100%; max-width: 400px; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } caption { padding: 15px; font-weight: 600; font-size: 1.2rem; color: #333; background: #f8f9fa; } th, td { padding: 12px 20px; text-align: left; border-bottom: 1px solid #eee; } th { background: #3498db; color: white; font-weight: 500; } tr:hover { background: #f8f9fa; } tr:last-child td { border-bottom: none; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n
Fruit Prices
FruitPrice
Apple$1.50
Banana$0.75
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> for the table title" + }, + { + "type": "element_count", + "value": { "selector": "th", "min": 2 }, + "message": "Add at least 2 header cells (th)" + }, + { + "type": "element_count", + "value": { "selector": "tr", "min": 3 }, + "message": "Add at least 3 rows (1 header + 2 data rows)" + } + ] + }, + { + "id": "table-thead-tbody", + "title": "Table Head & Body", + "description": "Use <thead> to group header rows and <tbody> to group data rows. This helps browsers and assistive technology understand the table structure.

You can also use <tfoot> for footer rows like totals.", + "task": "Create a structured table:
1. A <caption> with 'Monthly Sales'
2. A <thead> with Month and Revenue headers
3. A <tbody> with at least 2 data rows", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; margin: 0; box-sizing: border-box; } table { border-collapse: collapse; width: 100%; max-width: 450px; background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.2); } caption { padding: 20px; font-weight: 700; font-size: 1.3rem; color: white; background: transparent; text-shadow: 0 2px 4px rgba(0,0,0,0.2); caption-side: top; } thead { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); } th { padding: 15px 20px; text-align: left; color: white; font-weight: 500; } tbody tr { border-bottom: 1px solid #eee; } tbody tr:hover { background: #f8f9fa; } td { padding: 15px 20px; color: #333; } tbody tr:last-child { border-bottom: none; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Monthly Sales
MonthRevenue
January$12,500
February$14,200
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> element" + }, + { + "type": "element_exists", + "value": "thead", + "message": "Add a <thead> for the header section" + }, + { + "type": "element_exists", + "value": "tbody", + "message": "Add a <tbody> for the data rows" + }, + { + "type": "element_count", + "value": { "selector": "tbody tr", "min": 2 }, + "message": "Add at least 2 data rows in tbody" + } + ] + }, + { + "id": "table-complete", + "title": "Complete Table with Footer", + "description": "Add <tfoot> to create a footer section for totals or summary data. The footer stays at the bottom even if tbody has many rows.

Combine all sections for a fully structured, accessible table.", + "task": "Create a complete table:
1. A <caption> with 'Order Summary'
2. A <thead> with Item and Price headers
3. A <tbody> with 2 items
4. A <tfoot> with a Total row", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #fafafa; } table { border-collapse: collapse; width: 100%; max-width: 400px; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } caption { padding: 15px 20px; font-weight: 600; font-size: 1.1rem; color: #333; text-align: left; background: #f8f9fa; border-bottom: 2px solid #eee; } th, td { padding: 12px 20px; text-align: left; } thead th { background: #2c3e50; color: white; } tbody td { border-bottom: 1px solid #eee; } tbody tr:hover { background: #f8f9fa; } tfoot { background: #ecf0f1; font-weight: 600; } tfoot td { border-top: 2px solid #2c3e50; color: #2c3e50; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Order Summary
ItemPrice
Widget$25.00
Gadget$35.00
Total$60.00
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> element" + }, + { + "type": "element_exists", + "value": "thead", + "message": "Add a <thead> section" + }, + { + "type": "element_exists", + "value": "tbody", + "message": "Add a <tbody> section" + }, + { + "type": "element_exists", + "value": "tfoot", + "message": "Add a <tfoot> section for the total" + }, + { + "type": "element_count", + "value": { "selector": "tbody tr", "min": 2 }, + "message": "Add at least 2 item rows in tbody" + } + ] + } + ] +} diff --git a/lessons/ar/31-html-marquee.json b/lessons/ar/31-html-marquee.json new file mode 100644 index 0000000..7c2939a --- /dev/null +++ b/lessons/ar/31-html-marquee.json @@ -0,0 +1,82 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-marquee", + "title": "HTML Marquee", + "description": "Create scrolling text with the classic (deprecated but fun!) marquee element", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "marquee-basic", + "title": "Scrolling Text", + "description": "The <marquee> element creates scrolling text - a classic from the early web! While deprecated, it still works in most browsers.

Note: For production, use CSS animations instead. But for learning and fun, marquee is great!", + "task": "Create a simple marquee:
1. Add a <marquee> element
2. Put some text inside like 'Welcome to my website!'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%); min-height: 150px; display: flex; align-items: center; } marquee { font-size: 2rem; color: #00ff00; text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00; font-family: 'Courier New', monospace; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "Welcome to my website!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + } + ] + }, + { + "id": "marquee-direction", + "title": "Direction & Behavior", + "description": "Control the marquee with attributes:
direction: left, right, up, down
behavior: scroll (default), slide (stops at edge), alternate (bounces)
scrollamount: speed (default is 6)", + "task": "Create a bouncing marquee:
1. Add a <marquee> element
2. Set behavior=\"alternate\" to make it bounce
3. Add some fun text", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%); min-height: 150px; display: flex; align-items: center; } marquee { font-size: 2.5rem; color: white; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); font-weight: bold; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "Bounce! Bounce! Bounce!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "behavior", "value": "alternate" }, + "message": "Add behavior=\"alternate\" to make it bounce" + } + ] + }, + { + "id": "marquee-retro", + "title": "Retro News Ticker", + "description": "Combine multiple marquee attributes for a classic news ticker effect. You can even put multiple elements inside!

Remember: This is deprecated HTML. Modern sites use CSS animations, but marquee is great for understanding web history.", + "task": "Create a news ticker:
1. A <marquee> with direction=\"left\"
2. Set scrollamount=\"5\" for smooth scrolling
3. Add a breaking news headline inside", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 0; margin: 0; background: #1a1a2e; } marquee { background: linear-gradient(90deg, #c0392b 0%, #e74c3c 50%, #c0392b 100%); padding: 15px 0; font-size: 1.3rem; color: white; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; border-top: 3px solid #f1c40f; border-bottom: 3px solid #f1c40f; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "BREAKING NEWS: Marquee element still works in browsers!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "direction", "value": "left" }, + "message": "Add direction=\"left\" for horizontal scrolling" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "scrollamount", "value": "5" }, + "message": "Add scrollamount=\"5\" for smooth speed" + } + ] + } + ] +} diff --git a/lessons/ar/32-html-svg.json b/lessons/ar/32-html-svg.json new file mode 100644 index 0000000..59b9dbb --- /dev/null +++ b/lessons/ar/32-html-svg.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-svg", + "title": "HTML SVG", + "description": "Draw scalable vector graphics directly in HTML", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "svg-circle", + "title": "Drawing Circles", + "description": "SVG (Scalable Vector Graphics) lets you draw shapes directly in HTML. The <svg> element is the container, with width and height attributes.

Use <circle> with cx, cy (center) and r (radius) to draw circles.", + "task": "Create an SVG with a circle:
1. An <svg> with width=\"200\" and height=\"200\"
2. A <circle> centered at (100,100) with radius 50
3. Add a fill color", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #f5f5f5; display: flex; justify-content: center; } svg { background: white; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_exists", + "value": "circle", + "message": "Add a <circle> element inside the SVG" + }, + { + "type": "attribute_value", + "value": { "selector": "circle", "attr": "cx", "value": "100" }, + "message": "Set cx=\"100\" for the circle's horizontal center" + }, + { + "type": "attribute_value", + "value": { "selector": "circle", "attr": "cy", "value": "100" }, + "message": "Set cy=\"100\" for the circle's vertical center" + } + ] + }, + { + "id": "svg-rect-line", + "title": "Rectangles & Lines", + "description": "Draw rectangles with <rect> using x, y, width, height.

Draw lines with <line> using x1, y1 (start) and x2, y2 (end). Lines need a stroke color!", + "task": "Create an SVG with:
1. An <svg> (200x150)
2. A <rect> at position (20,20) with size 80x60
3. A <line> from (120,30) to (180,90) with a stroke color", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 200px; display: flex; justify-content: center; align-items: center; } svg { background: white; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_exists", + "value": "rect", + "message": "Add a <rect> element" + }, + { + "type": "element_exists", + "value": "line", + "message": "Add a <line> element" + } + ] + }, + { + "id": "svg-shapes", + "title": "Multiple Shapes", + "description": "Combine shapes to create simple graphics! Add stroke for outlines and stroke-width for thickness.

Use fill=\"none\" for hollow shapes. Shapes stack in order - later elements appear on top.", + "task": "Create a simple face:
1. An <svg> (200x200)
2. A large <circle> for the face
3. Two small <circle> elements for eyes
4. A <line> for the smile", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); min-height: 250px; display: flex; justify-content: center; align-items: center; } svg { background: white; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_count", + "value": { "selector": "circle", "min": 3 }, + "message": "Add at least 3 circles (1 face + 2 eyes)" + }, + { + "type": "element_exists", + "value": "line", + "message": "Add a <line> for the smile" + } + ] + } + ] +} diff --git a/lessons/ar/flexbox.json b/lessons/ar/flexbox.json new file mode 100644 index 0000000..7b34c96 --- /dev/null +++ b/lessons/ar/flexbox.json @@ -0,0 +1,173 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "flexbox", + "title": "CSS Flexbox", + "description": "Master the flexible box layout model for modern responsive designs", + "difficulty": "intermediate", + "lessons": [ + { + "id": "flexbox-1", + "title": "Container", + "description": "Learn how to create a flex container and understand the main and cross axes.", + "task": "Add display: flex to .wrap to create a flexbox layout.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "display: flex;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "display", + "expected": "flex" + }, + "message": "Set display: flex" + } + ] + }, + { + "id": "flexbox-2", + "title": "Direction & Wrap", + "description": "Control the direction and wrapping of flex items within a container.", + "task": "Add flex-direction: column and flex-wrap: wrap to .wrap.", + "previewHTML": "
1
2
3
4
5
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; height: 16rem; display: flex; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "flex-direction: column;\n flex-wrap: wrap;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "flex-direction", + "expected": "column" + }, + "message": "Set flex-direction: column", + "options": { + "exact": true + } + }, + { + "type": "property_value", + "value": { + "property": "flex-wrap", + "expected": "wrap" + }, + "message": "Set flex-wrap: wrap", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-3", + "title": "Justify Content", + "description": "Learn how to align flex items along the main axis of the flex container.", + "task": "Add justify-content: space-between to .wrap to distribute the boxes evenly.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "justify-content: space-between;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "justify-content", + "expected": "space-between" + }, + "message": "Set justify-content: space-between", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-4", + "title": "Align Items", + "description": "Control how flex items are aligned along the cross axis of the flex container.", + "task": "Add align-items: center to .wrap to vertically center the boxes.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; display: flex; justify-content: center; } .tall { height: 6rem; } .short { height: 3rem; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; height: 10rem; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "align-items: center;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "align-items", + "expected": "center" + }, + "message": "Set align-items: center", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-5", + "title": "Flex Grow", + "description": "The flex property controls how much an item grows relative to others.", + "task": "Add flex: 2 to .box2 to make it grow twice as wide.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; display: flex; align-items: center; justify-content: center; } .box1 { background: coral; flex: 1; } .box2 { background: mediumseagreen; } .box3 { background: gold; flex: 1; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; }", + "codePrefix": ".box2 {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "flex: 2;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "flex", + "expected": "2" + }, + "message": "Set flex: 2" + } + ] + }, + { + "id": "flexbox-6", + "title": "Align Self", + "description": "Use align-self to override alignment for a single flex item.", + "task": "Add align-self: flex-start to .middle to move it to the top.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; } .middle { background: mediumseagreen; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; height: 12rem; align-items: center; }", + "codePrefix": ".middle {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "align-self: flex-start;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "align-self", + "expected": "flex-start" + }, + "message": "Set align-self: flex-start" + } + ] + } + ] +} diff --git a/lessons/es/00-basic-selectors.json b/lessons/es/00-basic-selectors.json new file mode 100644 index 0000000..6e55337 --- /dev/null +++ b/lessons/es/00-basic-selectors.json @@ -0,0 +1,550 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "css-basic-selectors", + "title": "CSS Selectors", + "description": "CSS selectors are the foundation of styling web pages, allowing you to target specific HTML elements for styling. This module introduces fundamental selector types including element type selectors, class selectors, ID selectors, and the universal selector.", + "difficulty": "beginner", + "lessons": [ + { + "id": "introduction-to-selectors", + "title": "What's a Selector?", + "description": "A CSS selector is the first part of a CSS rule that tells the browser which HTML elements should receive the styles defined in the declaration block. Selectors are essentially patterns that match against elements in your HTML document. Understanding selectors is fundamental because they determine which elements your CSS rules will affect. The element or elements targeted by a selector are referred to as the 'subject of the selector.' When writing a CSS rule, you first specify the selector, followed by curly braces that contain the style declarations.
For example, to change the text color of elements, you can use the color property within your declaration block.

/* Element selector */\np {\n  color: orangered;\n  /* │       └─── Indicates the value of the expression\n     │                                                     \n     └─────────── Indicates the property of the expression */\n}
", + "task": "Write a CSS rule using a type selector that targets all paragraph elements p in the document. Make the text blue by setting the color property to blue.", + "previewHTML": "

Introduction to CSS Selectors

\n

This paragraph should turn blue.

\n
This div element should remain unchanged.
\n

This second paragraph should also turn blue.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h1, p, div { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Write a type selector to target all paragraph elements */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "p { color: blue }", + "validations": [ + { + "type": "regex", + "value": "^p\\s*{", + "message": "Start your rule with p { … } to select all paragraph elements", + "options": { + "caseSensitive": false + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color: property in your CSS rule" + }, + { + "type": "contains", + "value": "blue", + "message": "Set the color value to blue" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "blue" + }, + "message": "Use color: blue to set the text color" + }, + { + "type": "regex", + "value": "p\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": false + } + } + ] + }, + { + "id": "type-selectors", + "title": "Type Selectors", + "description": "Type selectors (also called tag name selectors or element selectors) target HTML elements based on their tag name. For example, p selects all paragraph elements, h1 selects all level-one headings, and div selects all division elements. Type selectors are the most fundamental way to select elements, applying styles consistently to all instances of a particular HTML element throughout your document. You can define a variety of CSS properties with type selectors, such as color for text color, background-color for the background, and font-weight for text emphasis. They provide a broad approach for styling your page and are often the starting point for more specific styling using other selector types.", + "task": "Write three separate CSS rules using type selectors to target specific HTML elements: make h2 headings purple, give span elements a yellow background, and make strong elements red.", + "previewHTML": "

Type Selectors Example

\n

Regular paragraph text with a highlighted span that should have a yellow background.

\n

Another paragraph with strong important text that should be red.

\n

Another Heading

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p, span, strong { padding: 3px; }", + "codePrefix": "/* Write three separate type selectors below */\n\n", + "initialCode": "/* 1. Make h2 headings purple */\n\n\n/* 2. Give span elements a yellow background */\n\n\n/* 3. Make strong elements red */\n", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "/* 1. Make h2 headings purple */\nh2 {\n color: purple;\n}\n\n/* 2. Give span elements a yellow background */\nspan {\n background-color: yellow;\n}\n\n/* 3. Make strong elements red */\nstrong {\n color: red;\n}", + "validations": [ + { + "type": "regex", + "value": "^h2\\s*{", + "message": "Include an h2 { … } selector" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "purple" + }, + "message": "Set the color property to purple for h2 elements" + }, + { + "type": "regex", + "value": "h2\\s*{[^}]*}", + "message": "Make sure to close your h2 rule with a closing brace }" + }, + { + "type": "regex", + "value": "^span\\s*{", + "message": "Include a span { … } selector" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "yellow" + }, + "message": "Set a background-color: yellow for span elements" + }, + { + "type": "regex", + "value": "span\\s*{[^}]*}", + "message": "Make sure to close your span rule with a closing brace }" + }, + { + "type": "regex", + "value": "^strong\\s*{", + "message": "Include a strong { … } selector" + }, + { + "type": "regex", + "value": "strong\\s*{\\s*color:\\s*red;[^}]*}", + "message": "Set the color: red for strong elements" + } + ] + }, + { + "id": "class-selectors", + "title": "Class Selectors", + "description": "Class selectors target elements with a specific class attribute value. They begin with a dot (.) followed by the class name. Classes are powerful because they allow you to apply the same styles to multiple elements regardless of their type. An HTML element can have multiple classes (separated by spaces in the class attribute), and a class can be applied to any number of elements. When using class selectors, you can apply properties like background-color to set the background color of elements, and font-weight to control text thickness, making text bold or normal. This flexibility makes class selectors one of the most commonly used methods for applying styles in CSS, allowing for modular and reusable styling across your website.", + "task": "Create a CSS rule using a class selector that targets elements with the class highlight. Give these elements a yellow background and bold text.", + "previewHTML": "

Using Class Selectors

\n

This is a regular paragraph, but this span has the highlight class applied to it.

\n

This entire paragraph has the highlight class.

\n", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p, li { padding: 5px; margin-bottom: 10px; }", + "codePrefix": "/* Create a class selector for elements with the 'highlight' class */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^\\.highlight\\s*{", + "message": "Start your rule with .highlight { … } to create a class selector", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color: property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "yellow" + }, + "message": "Set the background color to yellow" + }, + { + "type": "contains", + "value": "font-weight:", + "message": "Include the font-weight: property" + }, + { + "type": "property_value", + "value": { + "property": "font-weight", + "expected": "bold" + }, + "message": "Set the font-weight to bold" + }, + { + "type": "regex", + "value": "\\.highlight\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "multiple-classes", + "title": "Multiple Classes", + "description": "HTML elements can have multiple classes applied simultaneously, allowing for composable and modular CSS designs. When an element has multiple classes, it will receive styles from all matching class selectors. This approach enables you to build a library of reusable CSS classes that can be combined in different ways. You can also target elements that have a specific combination of classes by chaining class selectors together without spaces (e.g., .class1.class2). When styling these elements, you might use properties like border-color to change the color of element borders, and background-color to set the background color of elements. This technique lets you create conditional styles that only apply when certain classes appear together.", + "task": "Complete the CSS rule that targets elements with both card and featured classes by chaining the selectors. Set the border-color to gold and the background-color to lemonchiffon to make featured cards stand out.", + "previewHTML": "

Multiple Class Combinations

\n
Regular Card
\n
Featured Card
\n
Just Featured (not a card)
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } .card { border: 2px solid gray; padding: 15px; margin-bottom: 10px; border-radius: 5px; }", + "sandboxCSS": "", + "codePrefix": "/* The .card class already has basic styling */\n/* Now target elements with BOTH classes: 'card' AND 'featured' */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": ".card.featured { border-color: gold; background-color: lemonchiffon }", + "validations": [ + { + "type": "regex", + "value": "^\\.card\\.featured\\s*{", + "message": "Chain the selectors as .card.featured (no space between them)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "border-color:", + "message": "Include the border-color property" + }, + { + "type": "property_value", + "value": { + "property": "border-color", + "expected": "gold" + }, + "message": "Set the border color to gold" + }, + { + "type": "regex", + "value": "\\.card\\.featured\\s*{[^}]*;", + "message": "Make sure to end your CSS rule with a semicolon ;" + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "lemonchiffon" + }, + "message": "Set the background color to lemonchiffon" + }, + { + "type": "regex", + "value": "\\.card\\.featured\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "class-with-type", + "title": "Combining Types", + "description": "You can combine type selectors with class selectors to target specific HTML elements that have a certain class. This creates a more specific selector that only matches when both conditions are true: the element is of the specified type AND it has the specified class. For example, p.note would select paragraph elements with the class note, but would not select divs or spans with that same class. You can style these combined selections using properties like background-color to set a colored background for your elements. This approach allows you to apply different styles to the same class when it appears on different element types.", + "task": "Create a CSS rule that specifically targets <span> elements with the class highlight. Make those elements have an orange background, while other elements with the highlight class remain untouched.", + "previewHTML": "

Type and Class Combinations

\n

This paragraph has a highlighted span that should have an orange background.

\n

This paragraph has the highlight class but should NOT have an orange background.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } .highlight { font-weight: bold; }", + "sandboxCSS": "h2, p, span { padding: 5px; }", + "codePrefix": "/* The .highlight class already sets font-weight to bold */\n/* Now target ONLY span elements with the highlight class */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^span\\.highlight\\s*{", + "message": "Use span.highlight selector (no space between element and class)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "orange" + }, + "message": "Set the background color to orange" + }, + { + "type": "regex", + "value": "span\\.highlight\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "id-selectors", + "title": "ID Selectors", + "description": "ID selectors target elements with a specific id attribute. They begin with a hash/pound sign (#) followed by the ID name. Unlike classes, IDs must be unique within a document—each ID value should be used only once per page. ID selectors have higher specificity than class or element selectors, meaning they override those selectors when conflicts arise. When styling with ID selectors, you can use properties like color to define text color, and text-decoration to control the appearance of text, such as adding underlines to elements. Because of their uniqueness requirement, IDs are best used for one-of-a-kind elements like page headers, main navigation, or specific unique components that appear only once on a page.", + "task": "Create a CSS rule with an ID selector that targets the element with the ID main-title. Set its color to purple and add an underline with text-decoration: underline.", + "previewHTML": "

Main Page Title

\n

Regular paragraph content.

\n

Secondary Heading

\n

Introduction paragraph (different ID).

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h1, h2, p { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Create an ID selector to target the element with id=\"main-title\" */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^#main-title\\s*{", + "message": "Start your rule with #main-title to create an ID selector", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color property" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "purple" + }, + "message": "Set the color to purple" + }, + { + "type": "contains", + "value": "text-decoration:", + "message": "Include the text-decoration property" + }, + { + "type": "property_value", + "value": { + "property": "text-decoration", + "expected": "underline" + }, + "message": "Set the text-decoration to underline" + }, + { + "type": "regex", + "value": "#main-title\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "id-with-type", + "title": "Type + ID", + "description": "Similar to how you can combine type and class selectors, you can also combine type selectors with ID selectors. For example, h1#title targets an h1 element with the ID 'title'. When using this combined approach, you can apply CSS properties like font-style to control the slant of the text, making it italic or normal. While this selector combination is more specific than using just the ID selector, it's often unnecessary since IDs should already be unique in a document. However, this technique can be useful for improving code readability or when you want to emphasize that a particular ID should only appear on a specific element type.", + "task": "Create a CSS rule that combines a type selector with an ID selector to target specifically a paragraph element with the ID special. Set its font style to italic.", + "previewHTML": "

Heading with ID \"special\" (should NOT be affected)

\n

Paragraph with ID \"special\" (should become italic)

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Create a combined type+ID selector for a paragraph with id=\"special\" */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^p#special\\s*{", + "message": "Use p#special to target paragraphs with ID special", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "font-style:", + "message": "Include the font-style property" + }, + { + "type": "property_value", + "value": { + "property": "font-style", + "expected": "italic" + }, + "message": "Set the font-style to italic" + }, + { + "type": "regex", + "value": "p#special\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "selector-lists", + "title": "Selector Lists", + "description": "When multiple elements need the same styling, you can group them together using a selector list (also known as grouping selectors). Selector lists are created by separating individual selectors with commas. This approach reduces repetition in your CSS, making it more maintainable and efficient. For example, h1, h2, h3 { color: blue; } applies the same blue color to all three heading levels. When styling multiple selectors at once, you can apply properties like background-color to set the background, border-left to create a left border with a specific thickness, style, and color, and padding-left to create space between the content and the left border. Whitespace around commas is optional, and each selector in the list can be any valid selector type-elements, classes, IDs, or even more complex selectors.", + "task": "Create a selector list that applies the same styles to three different elements: paragraphs with class note, list items with class important, and the element with ID summary. Give them a lightyellow background, a gold left border, and some left padding.", + "previewHTML": "

This is a note paragraph.

\n\n
Summary section
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "p, li, div { padding: 8px; margin-bottom: 8px; border: 1px dashed gray; }", + "codePrefix": "/* Create a selector list to apply the same styles to multiple different elements */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "p.note,\nli.important,\n#summary {\n background-color: lightyellow;\n border-left: 3px solid gold;\n padding-left: 10px\n}", + "validations": [ + { + "type": "contains", + "value": "p.note", + "message": "Include p.note in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "li.important", + "message": "Include li.important in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "#summary", + "message": "Include #summary in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "regex", + "value": "(p\\.note|li\\.important|#summary)\\s*,\\s*(p\\.note|li\\.important|#summary)\\s*,\\s*(p\\.note|li\\.important|#summary)", + "message": "Create a comma-separated list with all three selectors", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "lightyellow" + }, + "message": "Set the background color to lightyellow" + }, + { + "type": "contains", + "value": "border-left:", + "message": "Include the border-left property" + }, + { + "type": "property_value", + "value": { + "property": "border-left", + "expected": "3px solid gold" + }, + "message": "Use border-left: 3px solid gold to create a left border" + }, + { + "type": "contains", + "value": "padding-left:", + "message": "Include the padding-left property" + }, + { + "type": "property_value", + "value": { + "property": "padding-left", + "expected": "10px" + }, + "message": "Use padding-left: 10px to add left padding" + } + ] + }, + { + "id": "universal-selector", + "title": "Universal (*)", + "description": "The universal selector is denoted by an asterisk (*) and matches any element of any type. It selects everything in the document or, when combined with other selectors, everything within a specific context. For example, * { margin: 0; } removes margins from all elements, while article * selects all elements inside article elements. When using the universal selector in combination with other selectors, you can apply properties like margin to control the spacing around elements. The universal selector is powerful but should be used carefully due to its broad impact. It's commonly used in CSS resets, to override default browser styling, or to target all children of a particular element.", + "task": "Use the universal selector to remove margins from all elements inside the container div. Create a rule using div.container * as the selector and set margin: 0.", + "previewHTML": "
\n

Inside Container

\n

This paragraph is inside the container.

\n \n
\n

This paragraph is outside the container and should not be affected.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } div.container { border: 2px solid navy; padding: 15px; background-color: lavender; } h2, p, ul, li { margin: 15px 0; }", + "sandboxCSS": "", + "codePrefix": "/* Use the universal selector to target all elements inside the container */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^div\\.container\\s+\\*\\s*{", + "message": "Use div.container * selector (with a space between container and *)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "margin:", + "message": "Include the margin property" + }, + { + "type": "property_value", + "value": { + "property": "margin", + "expected": "0" + }, + "message": "Set margin to 0" + }, + { + "type": "regex", + "value": "div\\.container\\s+\\*\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "specificity-basics", + "title": "Specificity", + "description": "CSS specificity determines which styles take precedence when multiple conflicting rules target the same element. Specificity follows a hierarchical system: inline styles have the highest specificity, followed by ID selectors, then class/attribute/pseudo-class selectors, and finally element/pseudo-element selectors. This can be conceptualized as a four-part score (inline, ID, class, element). When creating multiple rules that may target the same elements, you can use the color property to set text colors, and specificity will determine which color is actually applied. Understanding specificity is crucial for predictable styling and debugging CSS conflicts. When two selectors have equal specificity, the one that comes last in the stylesheet wins.", + "task": "Examine the existing CSS rules and add a new rule with higher specificity to override the text color of the paragraph. Create a rule using '.content p' as the selector and set color: green.", + "previewHTML": "
\n

What color will this paragraph be? Look at the CSS rules and their specificity.

\n
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "p { border: 1px dashed gray; padding: 10px; }", + "codePrefix": "/* These CSS rules target the same paragraph but have different specificity */\n\n/* Rule 1: Element selector (lowest specificity) */\np {\n color: red;\n}\n\n/* Rule 2: Descendant selector (higher specificity than just 'p') */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^\\.content\\s+p\\s*{", + "message": "Use .content p as your selector (note the space between)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color property" + }, + { + "type": "contains", + "value": "green", + "message": "" + } + ] + } + ] +} diff --git a/lessons/es/00-welcome.json b/lessons/es/00-welcome.json new file mode 100644 index 0000000..ce364c4 --- /dev/null +++ b/lessons/es/00-welcome.json @@ -0,0 +1,62 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "welcome", + "title": "Code Crispies", + "description": "Welcome to Code Crispies - your interactive web development learning platform", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "get-started", + "title": "Get Started", + "description": "Code Crispies is a free, open-source platform for learning web development through hands-on exercises. No account required!

What you'll learn:
HTML - Semantic elements, forms, tables, SVG (HTML Block & Inline, HTML Forms, HTML Tables)
CSS - Selectors, box model, flexbox, animations (CSS Selectors, CSS Box Model, CSS Flexbox)
Responsive Design - Media queries and mobile-first layouts

How it works:
1. Read the task in the left panel
2. Write code in the editor
3. See live results in the preview
4. Get instant feedback with hints

Keyboard shortcuts: Ctrl+Z to undo, Ctrl+Shift+Z to redo

More resources:
HTML over JS - Native HTML vs JavaScript solutions
Web Engineering Mandala - JavaScript technology roadmap", + "task": "Hello World", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 20px; text-align: center; } h1 { color: #6366f1; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Hello World

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "Hello", + "message": "Write 'Hello World'" + } + ] + }, + { + "id": "overview", + "title": "Overview", + "description": "You're ready! Open the menu (☰) to explore all modules.

Recommended learning path:
1. HTML Block & Inline - Understand container vs inline elements
2. HTML Forms - Build interactive forms with validation
3. CSS Selectors - Target elements precisely
4. CSS Box Model - Master padding, margin, borders
5. CSS Flexbox - Create flexible layouts
6. CSS Animations - Add motion and transitions

Tips:
• Use Show Expected to see the target result
• Your progress is saved automatically
• Try Emmet in HTML mode: ul>li*3 + Tab

Open Source:
Gitea (Source) · GitHub (Mirror)
• Made by LibreTECH · Michael Czechowski", + "task": "Click Next to continue", + "previewHTML": "

Hello World! 🌍

Hallo Welt!

Bonjour le monde!

¡Hola Mundo!

Ciao Mondo!

Olá Mundo!

こんにちは世界!

你好世界!

안녕 세상!

Привет мир!

שלום עולם!

مرحبا بالعالم!

", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 12px; } p { margin: 6px 0; padding: 6px 12px; border-radius: 6px; font-weight: 600; font-size: 0.95em; } p:nth-child(1) { background: #fef3c7; color: #92400e; font-size: 1.2em; } p:nth-child(2) { background: #dcfce7; color: #166534; } p:nth-child(3) { background: #dbeafe; color: #1e40af; } p:nth-child(4) { background: #fce7f3; color: #9d174d; } p:nth-child(5) { background: #e0e7ff; color: #4338ca; } p:nth-child(6) { background: #fef9c3; color: #854d0e; } p:nth-child(7) { background: #fee2e2; color: #991b1b; } p:nth-child(8) { background: #f3e8ff; color: #7c3aed; } p:nth-child(9) { background: #ccfbf1; color: #0f766e; } p:nth-child(10) { background: #fae8ff; color: #86198f; } p:nth-child(11) { background: #fef3c7; color: #b45309; } p:nth-child(12) { background: #d1fae5; color: #047857; }", + "sandboxCSS": "", + "initialCode": "

Hello World! 🌍

\n

Hallo Welt!

\n

Bonjour le monde!

\n

¡Hola Mundo!

\n

Ciao Mondo!

\n

Olá Mundo!

\n

こんにちは世界!

\n

你好世界!

\n

안녕 세상!

\n

Привет мир!

\n

שלום עולם!

\n

مرحبا بالعالم!

", + "solution": "

Hello World! 🌍

\n

Hallo Welt!

\n

Bonjour le monde!

\n

¡Hola Mundo!

\n

Ciao Mondo!

\n

Olá Mundo!

\n

こんにちは世界!

\n

你好世界!

\n

안녕 세상!

\n

Привет мир!

\n

שלום עולם!

\n

مرحبا بالعالم!

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "Hello", + "message": "Click Next to continue" + } + ] + }, + { + "id": "playground", + "title": "Playground", + "mode": "playground", + "description": "", + "task": "", + "previewHTML": "", + "previewBaseCSS": "", + "sandboxCSS": "", + "initialCode": "\n\n

Hello World

\n

Start coding!

", + "solution": "", + "previewContainer": "preview-area", + "validations": [] + } + ] +} diff --git a/lessons/es/01-box-model.json b/lessons/es/01-box-model.json new file mode 100644 index 0000000..a5b10a6 --- /dev/null +++ b/lessons/es/01-box-model.json @@ -0,0 +1,180 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "box-model", + "title": "CSS Box Model", + "description": "Master the fundamental principles of space management in web design through the CSS box model. This module explores how content, padding, borders, and margins combine to create layout structures that are both visually appealing and structurally sound.", + "difficulty": "beginner", + "lessons": [ + { + "id": "box-model-1", + "title": "Box Model Components", + "description": "The CSS box model consists of four concentric layers: content area (innermost), padding, border, and margin (outermost). Understanding how these components interact is essential for precise layout control.", + "task": "Add padding: 1rem to .box to create space between its content and border.", + "previewHTML": "
Box Model Components
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background-color: lavender; border: 2px dashed slategray; }", + "sandboxCSS": "", + "codePrefix": ".box {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "padding: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "padding", "expected": "1rem" }, + "message": "Set padding: 1rem" + } + ] + }, + { + "id": "box-model-2", + "title": "Adding Borders", + "description": "Borders outline an element, creating visual separation from surrounding content. The border shorthand accepts three values: width, style, and color.", + "task": "Add border: 2px solid darkslategray to .box.", + "previewHTML": "
This box needs a border
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background-color: mintcream; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": ".box {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "border: 2px solid darkslategray;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "border:\\s*2px\\s+solid\\s+darkslategray", + "message": "Set border: 2px solid darkslategray", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "box-model-3", + "title": "Adding Margins", + "description": "Margins create space between elements, controlling how they relate to one another within a layout. Unlike padding (which affects internal spacing), margins exist outside the element's border.", + "task": "Add margin: 1rem to .outer to create space between it and the adjacent element.", + "previewHTML": "
This box needs margins
Adjacent element
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .container { background-color: whitesmoke; padding: 8px; } .outer { background-color: plum; padding: 1rem; border: 2px solid orchid; } .neighbor { background-color: lightblue; padding: 1rem; border: 2px solid steelblue; }", + "sandboxCSS": "", + "codePrefix": ".outer {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "margin", "expected": "1rem" }, + "message": "Set margin: 1rem" + } + ] + }, + { + "id": "box-model-4", + "title": "Box Sizing: Border-Box", + "description": "The box-sizing property determines how element dimensions are calculated. The default content-box excludes padding and border from width/height, while border-box includes them, making layout calculations more intuitive.", + "task": "Add box-sizing: border-box to .sized so padding and border are included in its width.", + "previewHTML": "
Content-box (default)
Border-box
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .sizing-demo { display: flex; gap: 1rem; } .box { width: 200px; padding: 1rem; border: 4px solid teal; background: lightcyan; } .default { box-sizing: content-box; }", + "sandboxCSS": "", + "codePrefix": ".sized {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "box-sizing: border-box;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "box-sizing", "expected": "border-box" }, + "message": "Set box-sizing: border-box" + } + ] + }, + { + "id": "box-model-5", + "title": "Margin Collapse", + "description": "When two vertical margins meet, they collapse to the larger value instead of adding up. Understanding this behavior is crucial for consistent vertical spacing.", + "task": "Add margin-bottom: 2rem to .first. Notice the space between paragraphs equals 2rem (not 3rem) due to margin collapse.", + "previewHTML": "

This paragraph has a bottom margin.

This paragraph has a top margin of 1rem.

", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .collapse-demo { border: 1px solid silver; padding: 8px; background: ghostwhite; } .second { margin-top: 1rem; background: linen; }", + "sandboxCSS": "", + "codePrefix": ".first {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin-bottom: 2rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "margin-bottom", "expected": "2rem" }, + "message": "Set margin-bottom: 2rem" + } + ] + }, + { + "id": "box-model-6", + "title": "Margin Shorthand Notation", + "description": "The margin shorthand can set all four sides at once. Two values set vertical (top/bottom) and horizontal (left/right) margins respectively.", + "task": "Add margin: 1rem 2rem to .spaced for 1rem top/bottom and 2rem left/right.", + "previewHTML": "
This box needs margins: 1rem top/bottom, 2rem left/right
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .container { background-color: whitesmoke; padding: 8px; } .spaced { background-color: honeydew; border: 2px solid mediumseagreen; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": ".spaced {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin: 1rem 2rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "margin:\\s*1rem\\s+2rem", + "message": "Set margin: 1rem 2rem", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "box-model-7", + "title": "Padding Shorthand Notation", + "description": "Like margin, padding shorthand allows setting all sides at once. A single value applies to all four sides equally.", + "task": "Add padding: 1.5rem to .padded to add equal padding on all sides.", + "previewHTML": "
This box needs equal padding on all sides
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .padded { background-color: papayawhip; border: 2px solid orange; }", + "sandboxCSS": "", + "codePrefix": ".padded {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "padding: 1.5rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "padding", "expected": "1.5rem" }, + "message": "Set padding: 1.5rem" + } + ] + }, + { + "id": "box-model-8", + "title": "Border on Specific Sides", + "description": "For granular control, you can target specific sides with border-top, border-right, border-bottom, or border-left.", + "task": "Add border-bottom: 4px solid dodgerblue to .line.", + "previewHTML": "
This element needs only a bottom border
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .line { padding: 1rem; background-color: aliceblue; }", + "sandboxCSS": "", + "codePrefix": ".line {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "border-bottom: 4px solid dodgerblue;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "border-bottom:\\s*4px\\s+solid\\s+dodgerblue", + "message": "Set border-bottom: 4px solid dodgerblue", + "options": { "caseSensitive": false } + } + ] + } + ] +} diff --git a/lessons/es/05-units-variables.json b/lessons/es/05-units-variables.json new file mode 100644 index 0000000..67a9272 --- /dev/null +++ b/lessons/es/05-units-variables.json @@ -0,0 +1,116 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "units-variables", + "title": "CSS Units & Variables", + "description": "Understand the variety of CSS measurement units and how to define and use custom properties for maintainable styles.", + "difficulty": "beginner", + "lessons": [ + { + "id": "units-1", + "title": "Absolute vs. Relative Units", + "description": "Learn the difference between px, rem, em, %, and vw/vh for flexible, responsive layouts.", + "task": "Set the width of .box to 80% and max-width to 37.5rem.", + "previewHTML": "
Resize me!
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .box { background: #f5f5f5; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Set flexible sizing */\n.box {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: 80%;\n max-width: 37.5rem;", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "width", "message": "Use width property", "options": { "caseSensitive": false } }, + { "type": "property_value", "value": { "property": "width", "expected": "80%" }, "message": "Set width to 80%" }, + { "type": "contains", "value": "max-width", "message": "Use max-width property", "options": { "caseSensitive": false } }, + { + "type": "property_value", + "value": { "property": "max-width", "expected": "37.5rem" }, + "message": "Set max-width to 37.5rem" + } + ] + }, + { + "id": "units-2", + "title": "CSS Custom Properties", + "description": "Define and reuse variables (--custom properties) to centralize your theme values.", + "task": "Create a --main-color variable in :root with #6200ee and apply it as the border color on .themed.", + "previewHTML": "
Variable Box
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .themed { padding: 1rem; border: 0.125rem solid #ddd; }", + "sandboxCSS": "", + "codePrefix": "/* Define and use a CSS variable */\n:root {", + "initialCode": "", + "codeSuffix": "}\n.themed { }", + "solution": " --main-color: #6200ee;\n}\n.themed {\n border-color: var(--main-color);", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "--main-color", + "message": "Define --main-color in :root", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": "var(--main-color)", + "message": "Use var(--main-color)", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "border", "expected": "var(--main-color)" }, + "message": "Apply variable to border color", + "options": { "exact": false } + } + ] + }, + { + "id": "units-3", + "title": "Unit Calculations (calc)", + "description": "Use the calc() function to combine different units in one expression.", + "task": "Set the width of .sized to calc(100% - 2rem) and min-height to calc(10vh + 1rem).", + "previewHTML": "
Calc Demo
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .sized { background: #e8f5e9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Use calc for dynamic sizing */\n.sized {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: calc(100% - 2rem);\n min-height: calc(10vh + 1rem);", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "calc", "message": "Use calc() function", "options": { "caseSensitive": false } }, + { + "type": "regex", + "value": "width:\\s*calc\\(100% - 2rem\\)", + "message": "Width should be calc(100% - 2rem)", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "min-height:\\s*calc\\(10vh \\+ 1rem\\)", + "message": "Min-height should be calc(10vh + 1rem)", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "units-4", + "title": "Viewport & Responsive Units", + "description": "Control layouts relative to viewport size with vw, vh, and vmin/vmax units.", + "task": "Give .view a width of 50vw and height of 20vh.", + "previewHTML": "
Viewport Box
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .view { background: #ffe0b2; }", + "sandboxCSS": "", + "codePrefix": "/* Use viewport units */\n.view {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: 50vw;\n height: 20vh;", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "vw", "message": "Use vw unit", "options": { "caseSensitive": false } }, + { "type": "contains", "value": "vh", "message": "Use vh unit", "options": { "caseSensitive": false } }, + { "type": "property_value", "value": { "property": "width", "expected": "50vw" }, "message": "Set width to 50vw" }, + { "type": "property_value", "value": { "property": "height", "expected": "20vh" }, "message": "Set height to 20vh" } + ] + } + ] +} diff --git a/lessons/es/06-transitions-animations.json b/lessons/es/06-transitions-animations.json new file mode 100644 index 0000000..2697fd7 --- /dev/null +++ b/lessons/es/06-transitions-animations.json @@ -0,0 +1,145 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "transitions-animations", + "title": "CSS Animations", + "description": "Bring interactivity to your UI by smoothly transitioning properties and creating keyframe-driven animations.", + "difficulty": "beginner", + "lessons": [ + { + "id": "transitions-1", + "title": "Transitions", + "description": "Learn how to apply transition to properties for smooth changes on state changes.", + "task": "Add transition: background-color 0.3s to .btn so the color fades smoothly on hover.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .btn { background: black; color: white; padding: 0.5rem 1rem; border: none; cursor: pointer; } .btn:hover { background: white; color: black; }", + "sandboxCSS": "", + "codePrefix": "/* Add transition */\n.btn {", + "initialCode": "", + "codeSuffix": "}", + "solution": " transition: background-color 0.3s;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "transition", + "message": "Use the transition property", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "transition:\\s*background-color\\s*0\\.3s", + "message": "Set transition: background-color 0.3s", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "transitions-2", + "title": "Timing Funcs", + "description": "Explore easing functions like ease, linear, ease-in, ease-out to control animation pacing.", + "task": "Set transition-timing-function to ease-in-out on .btn.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .btn { background: navy; color: gold; padding: 0.5rem 1rem; border: none; cursor: pointer; transition: all 0.5s; } .btn:hover { background: gold; color: navy; transform: scale(1.1); }", + "sandboxCSS": "", + "codePrefix": "/* Set timing function */\n.btn {", + "initialCode": "", + "codeSuffix": "}", + "solution": " transition-timing-function: ease-in-out;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "transition-timing-function", + "message": "Use transition-timing-function", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "transition-timing-function", "expected": "ease-in-out" }, + "message": "Set timing to ease-in-out" + } + ] + }, + { + "id": "transitions-3", + "title": "Keyframes", + "description": "Create named animations using @keyframes and apply them via the animation shorthand.", + "task": "Define a keyframe at 50% with transform: translateY(-20px) and apply animation: bounce 1s infinite to .ball.", + "previewHTML": "
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .ball { width: 50px; height: 50px; background: crimson; border-radius: 50%; margin: 2rem auto; }", + "sandboxCSS": "", + "codePrefix": "/* Define keyframes and apply animation */\n@keyframes bounce {", + "initialCode": "", + "codeSuffix": "}\n.ball { }", + "solution": " 50% { transform: translateY(-20px); }\n}\n.ball {\n animation: bounce 1s infinite;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "@keyframes bounce", + "message": "Define @keyframes bounce", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "50%.*transform: translateY\\(-20px\\)", + "message": "At 50%, use transform: translateY(-20px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": "animation", + "message": "Use animation property on .ball", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "animation:.*bounce.*1s.*infinite", + "message": "Apply animation: bounce 1s infinite", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "transitions-4", + "title": "Anim Properties", + "description": "Fine-tune animations with animation-delay, animation-iteration-count, animation-direction, and animation-fill-mode.", + "task": "Apply the pulse animation to .box with animation-name: pulse, animation-duration: 2s, animation-delay: 1s, animation-iteration-count: 2, and animation-fill-mode: forwards.", + "previewHTML": "
Pulse
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .box { width: 100px; height: 100px; background: black; color: white; display: flex; align-items: center; justify-content: center; margin: 2rem auto; } @keyframes pulse { 0% { background: black; color: white; transform: scale(1); } 50% { background: white; color: black; transform: scale(1.2); } 100% { background: limegreen; color: black; transform: scale(1); } }", + "sandboxCSS": "", + "codePrefix": "/* Apply animation properties */\n.box {", + "initialCode": "", + "codeSuffix": "}", + "solution": " animation-name: pulse;\n animation-duration: 2s;\n animation-delay: 1s;\n animation-iteration-count: 2;\n animation-fill-mode: forwards;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "animation-name", "expected": "pulse" }, + "message": "Set animation-name: pulse" + }, + { + "type": "property_value", + "value": { "property": "animation-duration", "expected": "2s" }, + "message": "Set animation-duration: 2s" + }, + { + "type": "property_value", + "value": { "property": "animation-delay", "expected": "1s" }, + "message": "Set animation-delay: 1s" + }, + { + "type": "property_value", + "value": { "property": "animation-iteration-count", "expected": "2" }, + "message": "Set animation-iteration-count: 2" + }, + { + "type": "property_value", + "value": { "property": "animation-fill-mode", "expected": "forwards" }, + "message": "Set animation-fill-mode: forwards" + } + ] + } + ] +} diff --git a/lessons/es/08-responsive.json b/lessons/es/08-responsive.json new file mode 100644 index 0000000..0db9b98 --- /dev/null +++ b/lessons/es/08-responsive.json @@ -0,0 +1,126 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "responsive-design", + "title": "CSS Responsive Design", + "description": "Make your layouts adapt to different screen sizes using media queries and fluid design techniques.", + "difficulty": "intermediate", + "lessons": [ + { + "id": "responsive-1", + "title": "Media Queries", + "description": "Understand the syntax and use cases for CSS media queries to apply styles conditionally based on viewport characteristics.", + "task": "Write a media query with @media (max-width: 600px) that changes .panel background to lightcoral.", + "previewHTML": "
Resize the window
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .panel { padding: 1rem; background: lightblue; }", + "sandboxCSS": "", + "codePrefix": "/* Add your media query below */\n", + "initialCode": "", + "codeSuffix": "", + "solution": "@media (max-width: 600px) {\n .panel {\n background: lightcoral;\n }\n}", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "@media\\s*\\(max-width:\\s*600px\\)", + "message": "Use @media (max-width: 600px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": ".panel", + "message": "Target .panel inside the media query", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "background", "expected": "lightcoral" }, + "message": "Set background: lightcoral", + "options": { "exact": false } + } + ] + }, + { + "id": "responsive-2", + "title": "Fluid Type", + "description": "Use relative units like vw to make font sizes scale with the viewport width.", + "task": "Set font-size: 5vw on .text so it scales as the viewport changes.", + "previewHTML": "

Fluid Typography

", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Apply fluid font sizing */\n.text {", + "initialCode": "", + "codeSuffix": "}", + "solution": " font-size: 5vw;", + "previewContainer": "preview-area", + "validations": [ + { "type": "property_value", "value": { "property": "font-size", "expected": "5vw" }, "message": "Set font-size: 5vw" } + ] + }, + { + "id": "responsive-3", + "title": "Flex Grids", + "description": "Combine CSS Grid with auto-fit or auto-fill for responsive column layouts.", + "task": "Add display: grid, grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)), and gap: 1rem to .cards.", + "previewHTML": "
1
2
3
4
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .cards > div { background: #d1c4e9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Create a responsive grid */\n.cards {", + "initialCode": "", + "codeSuffix": "}", + "solution": " display: grid;\n grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));\n gap: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "display", "expected": "grid" }, + "message": "Set display: grid" + }, + { + "type": "regex", + "value": "repeat\\(auto-fit,\\s*minmax\\(200px,\\s*1fr\\)\\)", + "message": "Use repeat(auto-fit, minmax(200px, 1fr))", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "gap", "expected": "1rem" }, + "message": "Set gap: 1rem" + } + ] + }, + { + "id": "responsive-4", + "title": "Mobile-First", + "description": "Adopt a mobile-first approach by writing base styles for small screens and enhancing for larger viewports.", + "task": "Write a media query with @media (min-width: 768px) that sets .sidebar width to 250px.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .sidebar { background: #c8e6c9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Add mobile-first enhancement */\n", + "initialCode": "", + "codeSuffix": "", + "solution": "@media (min-width: 768px) {\n .sidebar {\n width: 250px;\n }\n}", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "@media\\s*\\(min-width:\\s*768px\\)", + "message": "Use @media (min-width: 768px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": ".sidebar", + "message": "Target .sidebar inside media query", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "width", "expected": "250px" }, + "message": "Set width: 250px", + "options": { "exact": false } + } + ] + } + ] +} diff --git a/lessons/es/20-html-elements.json b/lessons/es/20-html-elements.json new file mode 100644 index 0000000..93f9214 --- /dev/null +++ b/lessons/es/20-html-elements.json @@ -0,0 +1,97 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-elements", + "title": "HTML Block & Inline", + "description": "Understanding the fundamental difference between container (block) and inline elements", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "block-vs-inline-intro", + "title": "Block vs Inline Elements", + "description": "HTML elements fall into two main categories:

Block elements (containers) start on a new line and take full width. Examples: <div>, <p>, <h1>, <section>

Inline elements flow within text and only take needed width. Examples: <span>, <a>, <strong>, <em>", + "task": "Wrap the word important with <strong> tags to make it bold. Notice how the paragraph (block) takes full width while strong (inline) flows with text.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 20px; } p { background: #e3f2fd; padding: 10px; } strong { background: #ffecb3; }", + "sandboxCSS": "", + "initialCode": "

This is a paragraph with an important word.

", + "solution": "

This is a paragraph with an important word.

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "p", + "message": "Add a <p> paragraph element" + }, + { + "type": "parent_child", + "value": { "parent": "p", "child": "strong" }, + "message": "Wrap the word important with <strong> tags" + } + ] + }, + { + "id": "semantic-containers", + "title": "Semantic Tags", + "description": "Modern HTML uses semantic containers that describe their content:

<header> - Page or section header
<nav> - Navigation links
<main> - Main content area
<section> - Thematic grouping
<article> - Self-contained content
<footer> - Page or section footer", + "task": "Create a basic page structure:
1. Add a <header> with an <h1> containing the text 'My Website'
2. Add a <main> element with a paragraph saying 'Welcome to my site!'
3. Add a <footer> with a paragraph saying 'Copyright 2025'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; margin: 0; } header { background: #1976d2; color: white; padding: 15px; } main { padding: 20px; min-height: 100px; } footer { background: #424242; color: white; padding: 10px; text-align: center; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "
\n

My Website

\n
\n
\n

Welcome to my site!

\n
\n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "header", + "message": "Add a <header> element" + }, + { + "type": "element_exists", + "value": "main", + "message": "Add a <main> element" + }, + { + "type": "element_exists", + "value": "footer", + "message": "Add a <footer> element" + }, + { + "type": "parent_child", + "value": { "parent": "header", "child": "h1" }, + "message": "Add an <h1> heading inside your header" + } + ] + }, + { + "id": "div-vs-span", + "title": "div & span", + "description": "When you need a container without semantic meaning:

<div> - Generic block container (for layout/grouping)
<span> - Generic inline container (for styling text portions)

Use semantic elements when possible, div/span when no semantic element fits.", + "task": "Wrap the word 'highlighted' in a <span> to style it differently. Wrap the whole quote in a <div>.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: Georgia, serif; padding: 20px; } div { background: #f5f5f5; padding: 15px; border-left: 4px solid #1976d2; } span { background: #fff59d; padding: 2px 4px; }", + "sandboxCSS": "", + "initialCode": "The most highlighted moment was unforgettable.", + "solution": "
The most highlighted moment was unforgettable.
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "div", + "message": "Wrap everything in a <div> element" + }, + { + "type": "element_exists", + "value": "span", + "message": "Add a <span> around the word highlighted" + }, + { + "type": "element_text", + "value": { "selector": "span", "text": "highlighted" }, + "message": "The <span> should contain the word highlighted" + } + ] + } + ] +} diff --git a/lessons/es/21-html-forms-basic.json b/lessons/es/21-html-forms-basic.json new file mode 100644 index 0000000..d971cbf --- /dev/null +++ b/lessons/es/21-html-forms-basic.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-forms-basic", + "title": "HTML Forms", + "description": "Learn to create forms with various input types", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "form-structure", + "title": "Form Structure", + "description": "Every form needs a <form> wrapper. Inside, use <label> to describe inputs and <input> for user data entry.

The for attribute on labels should match the id on inputs for accessibility.", + "task": "Create a form with:
1. A <label> with the text 'Name:' and for=\"name\" attribute
2. A text <input> with id=\"name\" and name=\"name\" attributes", + "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": "Wrap everything in a <form> element" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for your input" + }, + { + "type": "element_exists", + "value": "input", + "message": "Add an <input> element" + }, + { + "type": "attribute_value", + "value": { "selector": "label", "attr": "for", "value": null }, + "message": "Add a for attribute to your label" + }, + { + "type": "attribute_value", + "value": { "selector": "input", "attr": "id", "value": null }, + "message": "Add an id attribute to your input" + } + ] + }, + { + "id": "input-types", + "title": "Input Types", + "description": "Different input types provide appropriate keyboards and validation:

type=\"text\" - General text
type=\"email\" - Email with @ validation
type=\"password\" - Hidden characters
type=\"number\" - Numeric keyboard
type=\"tel\" - Phone keyboard", + "task": "Create a login form with two fields:
1. An email field: <label for=\"email\">Email:</label> and <input type=\"email\" id=\"email\">
2. A password field: <label for=\"password\">Password:</label> and <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": "Add an input with type=\"email\"" + }, + { + "type": "element_exists", + "value": "input[type='password']", + "message": "Add an input with type=\"password\"" + }, + { + "type": "element_count", + "value": { "selector": "label", "min": 2 }, + "message": "Add labels for both inputs" + } + ] + }, + { + "id": "submit-button", + "title": "Submit Button", + "description": "Forms need a way to submit data. Use:

<button type=\"submit\"> - Preferred, flexible content
<input type=\"submit\"> - Simple text-only button

The button text should be action-oriented (e.g., 'Sign In', 'Register', 'Send').", + "task": "Add a submit button to the form with the text 'Sign In'.", + "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": "Add a submit button to your form" + }, + { + "type": "element_text", + "value": { "selector": "button", "text": "Sign In" }, + "message": "The button should say Sign In" + } + ] + } + ] +} diff --git a/lessons/es/22-html-forms-validation.json b/lessons/es/22-html-forms-validation.json new file mode 100644 index 0000000..72f4cd1 --- /dev/null +++ b/lessons/es/22-html-forms-validation.json @@ -0,0 +1,112 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-forms-validation", + "title": "HTML Validation", + "description": "Learn HTML5 built-in form validation attributes", + "mode": "html", + "difficulty": "intermediate", + "lessons": [ + { + "id": "required-fields", + "title": "Required Fields", + "description": "The required attribute prevents form submission if the field is empty.

Add it to any input that must be filled:
<input type=\"text\" required>

The browser shows a validation message automatically.", + "task": "Make both the name and email fields required by adding the required attribute.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 350px; } label { display: block; margin-top: 15px; margin-bottom: 5px; } label:first-of-type { margin-top: 0; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } input:invalid { border-color: #d32f2f; } button { margin-top: 20px; padding: 10px 20px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; }", + "sandboxCSS": "", + "initialCode": "
\n \n \n \n \n \n \n \n
", + "solution": "
\n \n \n \n \n \n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "input[name='name']", "attr": "required", "value": true }, + "message": "Add the required attribute to the name input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[name='email']", "attr": "required", "value": true }, + "message": "Add the required attribute to the email input" + } + ] + }, + { + "id": "input-constraints", + "title": "Constraints", + "description": "Control what users can enter:

minlength / maxlength - Text length limits
min / max - Number range
pattern - Regex pattern matching
placeholder - Hint text (not a label!)", + "task": "Add validation to the password input:
1. Add minlength=\"8\" for minimum length
2. Add maxlength=\"20\" for maximum length
3. Add placeholder=\"Enter password\" as a hint", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 350px; } label { display: block; margin-bottom: 5px; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } input:invalid:not(:placeholder-shown) { border-color: #d32f2f; } small { display: block; font-size: 12px; color: #666; margin-top: 4px; } button { margin-top: 20px; padding: 10px 20px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; }", + "sandboxCSS": "", + "initialCode": "
\n \n \n Must be 8-20 characters\n \n \n
", + "solution": "
\n \n \n Must be 8-20 characters\n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "minlength", "value": "8" }, + "message": "Add minlength=\"8\" to the password input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "maxlength", "value": "20" }, + "message": "Add maxlength=\"20\" to the password input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "placeholder", "value": null }, + "message": "Add a placeholder to hint what to enter" + } + ] + }, + { + "id": "complete-registration", + "title": "Full Form", + "description": "Build a complete registration form with all validation concepts:

- Required fields marked with *
- Email validation (use type=\"email\")
- Password with length constraints
- Terms checkbox (required)
- Submit button", + "task": "Complete the registration form. Add required attributes, proper input types, and validation constraints.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 400px; background: #f5f5f5; padding: 25px; border-radius: 8px; } h2 { margin-top: 0; margin-bottom: 20px; } label { display: block; margin-top: 15px; margin-bottom: 5px; font-weight: 500; } input[type='text'], input[type='email'], input[type='password'] { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 14px; } input:focus { outline: 2px solid #1976d2; border-color: transparent; } input[type='checkbox'] { width: auto; margin-right: 8px; vertical-align: middle; } label:has(input[type='checkbox']) { display: flex; align-items: center; font-weight: normal; } button { width: 100%; margin-top: 20px; padding: 12px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; font-weight: 500; } button:hover { background: #1565c0; }", + "sandboxCSS": "", + "initialCode": "
\n

Create Account

\n \n \n \n \n \n \n \n \n \n \n \n \n \n
", + "solution": "
\n

Create Account

\n \n \n \n \n \n \n \n \n \n \n \n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "#fullname", "attr": "required", "value": true }, + "message": "Make the full name field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#email", "attr": "type", "value": "email" }, + "message": "Set the email input type=\"email\"" + }, + { + "type": "attribute_value", + "value": { "selector": "#email", "attr": "required", "value": true }, + "message": "Make the email field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "type", "value": "password" }, + "message": "Set the password input type=\"password\"" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "required", "value": true }, + "message": "Make the password field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "minlength", "value": "8" }, + "message": "Add minlength=\"8\" to password" + }, + { + "type": "attribute_value", + "value": { "selector": "#terms", "attr": "required", "value": true }, + "message": "Make the terms checkbox required" + } + ] + } + ] +} diff --git a/lessons/es/23-html-details-summary.json b/lessons/es/23-html-details-summary.json new file mode 100644 index 0000000..3c60ad0 --- /dev/null +++ b/lessons/es/23-html-details-summary.json @@ -0,0 +1,97 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-details-summary", + "title": "HTML Details & Summary", + "description": "Create expandable content sections without JavaScript", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "details-summary-basic", + "title": "First Widget", + "description": "The <details> element creates a collapsible section. The <summary> provides the clickable label.

Click the summary to toggle the hidden content - no JavaScript needed!", + "task": "Create a <details> element with:
1. A <summary> saying 'Click to reveal'
2. A <p> with the text 'This content was hidden!'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } details { border: 1px solid #ddd; border-radius: 8px; padding: 15px; } summary { font-weight: 600; cursor: pointer; } summary:hover { color: #1976d2; } details p { margin-top: 15px; color: #666; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "
\n Click to reveal\n

This content was hidden!

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "details", + "message": "Add a <details> element" + }, + { + "type": "element_exists", + "value": "summary", + "message": "Add a <summary> inside the details" + }, + { + "type": "parent_child", + "value": { "parent": "details", "child": "summary" }, + "message": "The <summary> must be inside <details>" + }, + { + "type": "parent_child", + "value": { "parent": "details", "child": "p" }, + "message": "Add a <p> inside <details> for the hidden content" + } + ] + }, + { + "id": "details-open-attribute", + "title": "Pre-expanded Details", + "description": "By default, <details> is closed. Add the open attribute to show the content initially.

This is a boolean attribute - just add open without a value.", + "task": "Add the open attribute to the <details> element to show the content by default.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } details { border: 1px solid #ddd; border-radius: 8px; padding: 15px; background: #f9f9f9; } summary { font-weight: 600; cursor: pointer; } details p { margin-top: 15px; color: #666; }", + "sandboxCSS": "", + "initialCode": "
\n FAQ: What is HTML5?\n

HTML5 is the latest version of the HTML standard with new semantic elements and APIs.

\n
", + "solution": "
\n FAQ: What is HTML5?\n

HTML5 is the latest version of the HTML standard with new semantic elements and APIs.

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "details", "attr": "open", "value": true }, + "message": "Add the open attribute to <details>" + } + ] + }, + { + "id": "faq-accordion", + "title": "FAQ Accordion", + "description": "Multiple <details> elements create an accordion-style FAQ. Each question can be expanded independently.

Pro tip: Type details*3>summary+p and press Tab for Emmet expansion. *3 creates 3 elements, > nests inside, + adds siblings.", + "task": "Create an FAQ section with:
1. An <h1> saying 'Frequently Asked Questions'
2. Three <details> elements, each with a question in <summary> and an answer in <p>", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; min-height: 100vh; background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); display: flex; flex-direction: column; justify-content: center; padding: 40px; margin: 0; box-sizing: border-box; } h1 { font-size: 2.5rem; color: #4a4a4a; text-align: center; margin: 0 0 30px 0; } details { background: white; border-radius: 12px; margin-bottom: 15px; padding: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } summary { font-size: 1.3rem; font-weight: 600; color: #5c5c5c; cursor: pointer; list-style: none; } summary::before { content: '▸ '; color: #fcb69f; } details[open] summary::before { content: '▾ '; } details p { margin: 15px 0 0 0; color: #666; line-height: 1.6; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Frequently Asked Questions

\n\n
\n What is HTML5?\n

HTML5 is the latest version of HTML with new semantic elements and APIs.

\n
\n\n
\n Do I need JavaScript?\n

Many interactive features work with pure HTML5, no JavaScript required!

\n
\n\n
\n Is this accessible?\n

Yes! Native HTML elements have built-in keyboard and screen reader support.

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "h1", + "message": "Add an <h1> heading for the FAQ title" + }, + { + "type": "element_count", + "value": { "selector": "details", "min": 3 }, + "message": "Create at least 3 <details> elements for the FAQ" + }, + { + "type": "element_count", + "value": { "selector": "summary", "min": 3 }, + "message": "Each <details> needs a <summary> for the question" + }, + { + "type": "element_count", + "value": { "selector": "details p", "min": 3 }, + "message": "Each <details> needs a <p> for the answer" + } + ] + } + ] +} diff --git a/lessons/es/24-html-progress-meter.json b/lessons/es/24-html-progress-meter.json new file mode 100644 index 0000000..28b3bf3 --- /dev/null +++ b/lessons/es/24-html-progress-meter.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-progress-meter", + "title": "HTML Progress & Meter", + "description": "Display completion status and scalar measurements natively", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "progress-basic", + "title": "Progress Bars", + "description": "The <progress> element shows task completion. Use value for current progress and max for the total.

Note: This is not a self-closing tag! Write <progress>...</progress> with fallback text inside for older browsers.", + "task": "Create a progress bar showing 70% completion:
1. Add a <label> saying 'Download:'
2. Add a <progress> with value=\"70\" and max=\"100\"", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } label { display: block; margin-bottom: 8px; font-weight: 500; } progress { width: 100%; height: 20px; border-radius: 10px; } progress::-webkit-progress-bar { background: #e0e0e0; border-radius: 10px; } progress::-webkit-progress-value { background: linear-gradient(90deg, #4caf50, #8bc34a); border-radius: 10px; } progress::-moz-progress-bar { background: linear-gradient(90deg, #4caf50, #8bc34a); border-radius: 10px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n70%", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "progress", + "message": "Add a <progress> element" + }, + { + "type": "attribute_value", + "value": { "selector": "progress", "attr": "value", "value": "70" }, + "message": "Set value=\"70\" on the progress element" + }, + { + "type": "attribute_value", + "value": { "selector": "progress", "attr": "max", "value": "100" }, + "message": "Set max=\"100\" on the progress element" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for the progress bar" + } + ] + }, + { + "id": "progress-indeterminate", + "title": "Indeterminate Progress", + "description": "When progress is unknown (like loading), omit the value attribute. This creates an animated indeterminate state.

Useful for network requests or processes with unknown duration.", + "task": "Create a loading indicator:
1. Add a <p> saying 'Loading...'
2. Add a <progress> without a value attribute", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } p { margin-bottom: 10px; color: #666; } progress { width: 100%; height: 8px; border-radius: 4px; } progress::-webkit-progress-bar { background: #e0e0e0; border-radius: 4px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Loading...

\n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "progress", + "message": "Add a <progress> element" + }, + { + "type": "element_exists", + "value": "p", + "message": "Add a <p> with loading text" + } + ] + }, + { + "id": "meter-gauge", + "title": "Meter Gauges", + "description": "The <meter> element displays a scalar value within a range. Use it for measurements like disk space, battery, or ratings.

Set low, high, and optimum to define good/bad ranges - the browser colors it accordingly!", + "task": "Create a battery level meter:
1. Add a <label> saying 'Battery:'
2. Add a <meter> with:
- value=\"0.8\"
- min=\"0\" and max=\"1\"
- low=\"0.2\" and high=\"0.8\"
- optimum=\"1\"", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } label { display: block; margin-bottom: 8px; font-weight: 500; } meter { width: 100%; height: 25px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n80%", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "meter", + "message": "Add a <meter> element" + }, + { + "type": "attribute_value", + "value": { "selector": "meter", "attr": "value", "value": "0.8" }, + "message": "Set value=\"0.8\" on the meter" + }, + { + "type": "attribute_value", + "value": { "selector": "meter", "attr": "low", "value": "0.2" }, + "message": "Set low=\"0.2\" to define the low threshold" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for the meter" + } + ] + } + ] +} diff --git a/lessons/es/30-html-tables.json b/lessons/es/30-html-tables.json new file mode 100644 index 0000000..1bdfaeb --- /dev/null +++ b/lessons/es/30-html-tables.json @@ -0,0 +1,127 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-tables", + "title": "HTML Tables", + "description": "Create structured data tables with headers and captions", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "table-basic", + "title": "Basic Table Structure", + "description": "Tables use <table> with <tr> for rows. Inside rows, use <th> for headers and <td> for data cells.

The <caption> element provides an accessible title for the table.", + "task": "Create a simple table with:
1. A <caption> saying 'Fruit Prices'
2. A header row with 'Fruit' and 'Price' columns
3. At least 2 data rows", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #f5f5f5; } table { border-collapse: collapse; width: 100%; max-width: 400px; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } caption { padding: 15px; font-weight: 600; font-size: 1.2rem; color: #333; background: #f8f9fa; } th, td { padding: 12px 20px; text-align: left; border-bottom: 1px solid #eee; } th { background: #3498db; color: white; font-weight: 500; } tr:hover { background: #f8f9fa; } tr:last-child td { border-bottom: none; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n
Fruit Prices
FruitPrice
Apple$1.50
Banana$0.75
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> for the table title" + }, + { + "type": "element_count", + "value": { "selector": "th", "min": 2 }, + "message": "Add at least 2 header cells (th)" + }, + { + "type": "element_count", + "value": { "selector": "tr", "min": 3 }, + "message": "Add at least 3 rows (1 header + 2 data rows)" + } + ] + }, + { + "id": "table-thead-tbody", + "title": "Table Head & Body", + "description": "Use <thead> to group header rows and <tbody> to group data rows. This helps browsers and assistive technology understand the table structure.

You can also use <tfoot> for footer rows like totals.", + "task": "Create a structured table:
1. A <caption> with 'Monthly Sales'
2. A <thead> with Month and Revenue headers
3. A <tbody> with at least 2 data rows", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; margin: 0; box-sizing: border-box; } table { border-collapse: collapse; width: 100%; max-width: 450px; background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.2); } caption { padding: 20px; font-weight: 700; font-size: 1.3rem; color: white; background: transparent; text-shadow: 0 2px 4px rgba(0,0,0,0.2); caption-side: top; } thead { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); } th { padding: 15px 20px; text-align: left; color: white; font-weight: 500; } tbody tr { border-bottom: 1px solid #eee; } tbody tr:hover { background: #f8f9fa; } td { padding: 15px 20px; color: #333; } tbody tr:last-child { border-bottom: none; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Monthly Sales
MonthRevenue
January$12,500
February$14,200
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> element" + }, + { + "type": "element_exists", + "value": "thead", + "message": "Add a <thead> for the header section" + }, + { + "type": "element_exists", + "value": "tbody", + "message": "Add a <tbody> for the data rows" + }, + { + "type": "element_count", + "value": { "selector": "tbody tr", "min": 2 }, + "message": "Add at least 2 data rows in tbody" + } + ] + }, + { + "id": "table-complete", + "title": "Complete Table with Footer", + "description": "Add <tfoot> to create a footer section for totals or summary data. The footer stays at the bottom even if tbody has many rows.

Combine all sections for a fully structured, accessible table.", + "task": "Create a complete table:
1. A <caption> with 'Order Summary'
2. A <thead> with Item and Price headers
3. A <tbody> with 2 items
4. A <tfoot> with a Total row", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #fafafa; } table { border-collapse: collapse; width: 100%; max-width: 400px; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } caption { padding: 15px 20px; font-weight: 600; font-size: 1.1rem; color: #333; text-align: left; background: #f8f9fa; border-bottom: 2px solid #eee; } th, td { padding: 12px 20px; text-align: left; } thead th { background: #2c3e50; color: white; } tbody td { border-bottom: 1px solid #eee; } tbody tr:hover { background: #f8f9fa; } tfoot { background: #ecf0f1; font-weight: 600; } tfoot td { border-top: 2px solid #2c3e50; color: #2c3e50; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Order Summary
ItemPrice
Widget$25.00
Gadget$35.00
Total$60.00
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> element" + }, + { + "type": "element_exists", + "value": "thead", + "message": "Add a <thead> section" + }, + { + "type": "element_exists", + "value": "tbody", + "message": "Add a <tbody> section" + }, + { + "type": "element_exists", + "value": "tfoot", + "message": "Add a <tfoot> section for the total" + }, + { + "type": "element_count", + "value": { "selector": "tbody tr", "min": 2 }, + "message": "Add at least 2 item rows in tbody" + } + ] + } + ] +} diff --git a/lessons/es/31-html-marquee.json b/lessons/es/31-html-marquee.json new file mode 100644 index 0000000..7c2939a --- /dev/null +++ b/lessons/es/31-html-marquee.json @@ -0,0 +1,82 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-marquee", + "title": "HTML Marquee", + "description": "Create scrolling text with the classic (deprecated but fun!) marquee element", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "marquee-basic", + "title": "Scrolling Text", + "description": "The <marquee> element creates scrolling text - a classic from the early web! While deprecated, it still works in most browsers.

Note: For production, use CSS animations instead. But for learning and fun, marquee is great!", + "task": "Create a simple marquee:
1. Add a <marquee> element
2. Put some text inside like 'Welcome to my website!'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%); min-height: 150px; display: flex; align-items: center; } marquee { font-size: 2rem; color: #00ff00; text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00; font-family: 'Courier New', monospace; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "Welcome to my website!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + } + ] + }, + { + "id": "marquee-direction", + "title": "Direction & Behavior", + "description": "Control the marquee with attributes:
direction: left, right, up, down
behavior: scroll (default), slide (stops at edge), alternate (bounces)
scrollamount: speed (default is 6)", + "task": "Create a bouncing marquee:
1. Add a <marquee> element
2. Set behavior=\"alternate\" to make it bounce
3. Add some fun text", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%); min-height: 150px; display: flex; align-items: center; } marquee { font-size: 2.5rem; color: white; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); font-weight: bold; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "Bounce! Bounce! Bounce!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "behavior", "value": "alternate" }, + "message": "Add behavior=\"alternate\" to make it bounce" + } + ] + }, + { + "id": "marquee-retro", + "title": "Retro News Ticker", + "description": "Combine multiple marquee attributes for a classic news ticker effect. You can even put multiple elements inside!

Remember: This is deprecated HTML. Modern sites use CSS animations, but marquee is great for understanding web history.", + "task": "Create a news ticker:
1. A <marquee> with direction=\"left\"
2. Set scrollamount=\"5\" for smooth scrolling
3. Add a breaking news headline inside", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 0; margin: 0; background: #1a1a2e; } marquee { background: linear-gradient(90deg, #c0392b 0%, #e74c3c 50%, #c0392b 100%); padding: 15px 0; font-size: 1.3rem; color: white; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; border-top: 3px solid #f1c40f; border-bottom: 3px solid #f1c40f; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "BREAKING NEWS: Marquee element still works in browsers!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "direction", "value": "left" }, + "message": "Add direction=\"left\" for horizontal scrolling" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "scrollamount", "value": "5" }, + "message": "Add scrollamount=\"5\" for smooth speed" + } + ] + } + ] +} diff --git a/lessons/es/32-html-svg.json b/lessons/es/32-html-svg.json new file mode 100644 index 0000000..59b9dbb --- /dev/null +++ b/lessons/es/32-html-svg.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-svg", + "title": "HTML SVG", + "description": "Draw scalable vector graphics directly in HTML", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "svg-circle", + "title": "Drawing Circles", + "description": "SVG (Scalable Vector Graphics) lets you draw shapes directly in HTML. The <svg> element is the container, with width and height attributes.

Use <circle> with cx, cy (center) and r (radius) to draw circles.", + "task": "Create an SVG with a circle:
1. An <svg> with width=\"200\" and height=\"200\"
2. A <circle> centered at (100,100) with radius 50
3. Add a fill color", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #f5f5f5; display: flex; justify-content: center; } svg { background: white; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_exists", + "value": "circle", + "message": "Add a <circle> element inside the SVG" + }, + { + "type": "attribute_value", + "value": { "selector": "circle", "attr": "cx", "value": "100" }, + "message": "Set cx=\"100\" for the circle's horizontal center" + }, + { + "type": "attribute_value", + "value": { "selector": "circle", "attr": "cy", "value": "100" }, + "message": "Set cy=\"100\" for the circle's vertical center" + } + ] + }, + { + "id": "svg-rect-line", + "title": "Rectangles & Lines", + "description": "Draw rectangles with <rect> using x, y, width, height.

Draw lines with <line> using x1, y1 (start) and x2, y2 (end). Lines need a stroke color!", + "task": "Create an SVG with:
1. An <svg> (200x150)
2. A <rect> at position (20,20) with size 80x60
3. A <line> from (120,30) to (180,90) with a stroke color", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 200px; display: flex; justify-content: center; align-items: center; } svg { background: white; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_exists", + "value": "rect", + "message": "Add a <rect> element" + }, + { + "type": "element_exists", + "value": "line", + "message": "Add a <line> element" + } + ] + }, + { + "id": "svg-shapes", + "title": "Multiple Shapes", + "description": "Combine shapes to create simple graphics! Add stroke for outlines and stroke-width for thickness.

Use fill=\"none\" for hollow shapes. Shapes stack in order - later elements appear on top.", + "task": "Create a simple face:
1. An <svg> (200x200)
2. A large <circle> for the face
3. Two small <circle> elements for eyes
4. A <line> for the smile", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); min-height: 250px; display: flex; justify-content: center; align-items: center; } svg { background: white; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_count", + "value": { "selector": "circle", "min": 3 }, + "message": "Add at least 3 circles (1 face + 2 eyes)" + }, + { + "type": "element_exists", + "value": "line", + "message": "Add a <line> for the smile" + } + ] + } + ] +} diff --git a/lessons/es/flexbox.json b/lessons/es/flexbox.json new file mode 100644 index 0000000..7b34c96 --- /dev/null +++ b/lessons/es/flexbox.json @@ -0,0 +1,173 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "flexbox", + "title": "CSS Flexbox", + "description": "Master the flexible box layout model for modern responsive designs", + "difficulty": "intermediate", + "lessons": [ + { + "id": "flexbox-1", + "title": "Container", + "description": "Learn how to create a flex container and understand the main and cross axes.", + "task": "Add display: flex to .wrap to create a flexbox layout.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "display: flex;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "display", + "expected": "flex" + }, + "message": "Set display: flex" + } + ] + }, + { + "id": "flexbox-2", + "title": "Direction & Wrap", + "description": "Control the direction and wrapping of flex items within a container.", + "task": "Add flex-direction: column and flex-wrap: wrap to .wrap.", + "previewHTML": "
1
2
3
4
5
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; height: 16rem; display: flex; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "flex-direction: column;\n flex-wrap: wrap;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "flex-direction", + "expected": "column" + }, + "message": "Set flex-direction: column", + "options": { + "exact": true + } + }, + { + "type": "property_value", + "value": { + "property": "flex-wrap", + "expected": "wrap" + }, + "message": "Set flex-wrap: wrap", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-3", + "title": "Justify Content", + "description": "Learn how to align flex items along the main axis of the flex container.", + "task": "Add justify-content: space-between to .wrap to distribute the boxes evenly.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "justify-content: space-between;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "justify-content", + "expected": "space-between" + }, + "message": "Set justify-content: space-between", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-4", + "title": "Align Items", + "description": "Control how flex items are aligned along the cross axis of the flex container.", + "task": "Add align-items: center to .wrap to vertically center the boxes.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; display: flex; justify-content: center; } .tall { height: 6rem; } .short { height: 3rem; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; height: 10rem; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "align-items: center;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "align-items", + "expected": "center" + }, + "message": "Set align-items: center", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-5", + "title": "Flex Grow", + "description": "The flex property controls how much an item grows relative to others.", + "task": "Add flex: 2 to .box2 to make it grow twice as wide.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; display: flex; align-items: center; justify-content: center; } .box1 { background: coral; flex: 1; } .box2 { background: mediumseagreen; } .box3 { background: gold; flex: 1; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; }", + "codePrefix": ".box2 {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "flex: 2;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "flex", + "expected": "2" + }, + "message": "Set flex: 2" + } + ] + }, + { + "id": "flexbox-6", + "title": "Align Self", + "description": "Use align-self to override alignment for a single flex item.", + "task": "Add align-self: flex-start to .middle to move it to the top.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; } .middle { background: mediumseagreen; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; height: 12rem; align-items: center; }", + "codePrefix": ".middle {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "align-self: flex-start;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "align-self", + "expected": "flex-start" + }, + "message": "Set align-self: flex-start" + } + ] + } + ] +} diff --git a/lessons/pl/00-basic-selectors.json b/lessons/pl/00-basic-selectors.json new file mode 100644 index 0000000..6e55337 --- /dev/null +++ b/lessons/pl/00-basic-selectors.json @@ -0,0 +1,550 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "css-basic-selectors", + "title": "CSS Selectors", + "description": "CSS selectors are the foundation of styling web pages, allowing you to target specific HTML elements for styling. This module introduces fundamental selector types including element type selectors, class selectors, ID selectors, and the universal selector.", + "difficulty": "beginner", + "lessons": [ + { + "id": "introduction-to-selectors", + "title": "What's a Selector?", + "description": "A CSS selector is the first part of a CSS rule that tells the browser which HTML elements should receive the styles defined in the declaration block. Selectors are essentially patterns that match against elements in your HTML document. Understanding selectors is fundamental because they determine which elements your CSS rules will affect. The element or elements targeted by a selector are referred to as the 'subject of the selector.' When writing a CSS rule, you first specify the selector, followed by curly braces that contain the style declarations.
For example, to change the text color of elements, you can use the color property within your declaration block.

/* Element selector */\np {\n  color: orangered;\n  /* │       └─── Indicates the value of the expression\n     │                                                     \n     └─────────── Indicates the property of the expression */\n}
", + "task": "Write a CSS rule using a type selector that targets all paragraph elements p in the document. Make the text blue by setting the color property to blue.", + "previewHTML": "

Introduction to CSS Selectors

\n

This paragraph should turn blue.

\n
This div element should remain unchanged.
\n

This second paragraph should also turn blue.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h1, p, div { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Write a type selector to target all paragraph elements */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "p { color: blue }", + "validations": [ + { + "type": "regex", + "value": "^p\\s*{", + "message": "Start your rule with p { … } to select all paragraph elements", + "options": { + "caseSensitive": false + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color: property in your CSS rule" + }, + { + "type": "contains", + "value": "blue", + "message": "Set the color value to blue" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "blue" + }, + "message": "Use color: blue to set the text color" + }, + { + "type": "regex", + "value": "p\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": false + } + } + ] + }, + { + "id": "type-selectors", + "title": "Type Selectors", + "description": "Type selectors (also called tag name selectors or element selectors) target HTML elements based on their tag name. For example, p selects all paragraph elements, h1 selects all level-one headings, and div selects all division elements. Type selectors are the most fundamental way to select elements, applying styles consistently to all instances of a particular HTML element throughout your document. You can define a variety of CSS properties with type selectors, such as color for text color, background-color for the background, and font-weight for text emphasis. They provide a broad approach for styling your page and are often the starting point for more specific styling using other selector types.", + "task": "Write three separate CSS rules using type selectors to target specific HTML elements: make h2 headings purple, give span elements a yellow background, and make strong elements red.", + "previewHTML": "

Type Selectors Example

\n

Regular paragraph text with a highlighted span that should have a yellow background.

\n

Another paragraph with strong important text that should be red.

\n

Another Heading

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p, span, strong { padding: 3px; }", + "codePrefix": "/* Write three separate type selectors below */\n\n", + "initialCode": "/* 1. Make h2 headings purple */\n\n\n/* 2. Give span elements a yellow background */\n\n\n/* 3. Make strong elements red */\n", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "/* 1. Make h2 headings purple */\nh2 {\n color: purple;\n}\n\n/* 2. Give span elements a yellow background */\nspan {\n background-color: yellow;\n}\n\n/* 3. Make strong elements red */\nstrong {\n color: red;\n}", + "validations": [ + { + "type": "regex", + "value": "^h2\\s*{", + "message": "Include an h2 { … } selector" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "purple" + }, + "message": "Set the color property to purple for h2 elements" + }, + { + "type": "regex", + "value": "h2\\s*{[^}]*}", + "message": "Make sure to close your h2 rule with a closing brace }" + }, + { + "type": "regex", + "value": "^span\\s*{", + "message": "Include a span { … } selector" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "yellow" + }, + "message": "Set a background-color: yellow for span elements" + }, + { + "type": "regex", + "value": "span\\s*{[^}]*}", + "message": "Make sure to close your span rule with a closing brace }" + }, + { + "type": "regex", + "value": "^strong\\s*{", + "message": "Include a strong { … } selector" + }, + { + "type": "regex", + "value": "strong\\s*{\\s*color:\\s*red;[^}]*}", + "message": "Set the color: red for strong elements" + } + ] + }, + { + "id": "class-selectors", + "title": "Class Selectors", + "description": "Class selectors target elements with a specific class attribute value. They begin with a dot (.) followed by the class name. Classes are powerful because they allow you to apply the same styles to multiple elements regardless of their type. An HTML element can have multiple classes (separated by spaces in the class attribute), and a class can be applied to any number of elements. When using class selectors, you can apply properties like background-color to set the background color of elements, and font-weight to control text thickness, making text bold or normal. This flexibility makes class selectors one of the most commonly used methods for applying styles in CSS, allowing for modular and reusable styling across your website.", + "task": "Create a CSS rule using a class selector that targets elements with the class highlight. Give these elements a yellow background and bold text.", + "previewHTML": "

Using Class Selectors

\n

This is a regular paragraph, but this span has the highlight class applied to it.

\n

This entire paragraph has the highlight class.

\n", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p, li { padding: 5px; margin-bottom: 10px; }", + "codePrefix": "/* Create a class selector for elements with the 'highlight' class */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^\\.highlight\\s*{", + "message": "Start your rule with .highlight { … } to create a class selector", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color: property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "yellow" + }, + "message": "Set the background color to yellow" + }, + { + "type": "contains", + "value": "font-weight:", + "message": "Include the font-weight: property" + }, + { + "type": "property_value", + "value": { + "property": "font-weight", + "expected": "bold" + }, + "message": "Set the font-weight to bold" + }, + { + "type": "regex", + "value": "\\.highlight\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "multiple-classes", + "title": "Multiple Classes", + "description": "HTML elements can have multiple classes applied simultaneously, allowing for composable and modular CSS designs. When an element has multiple classes, it will receive styles from all matching class selectors. This approach enables you to build a library of reusable CSS classes that can be combined in different ways. You can also target elements that have a specific combination of classes by chaining class selectors together without spaces (e.g., .class1.class2). When styling these elements, you might use properties like border-color to change the color of element borders, and background-color to set the background color of elements. This technique lets you create conditional styles that only apply when certain classes appear together.", + "task": "Complete the CSS rule that targets elements with both card and featured classes by chaining the selectors. Set the border-color to gold and the background-color to lemonchiffon to make featured cards stand out.", + "previewHTML": "

Multiple Class Combinations

\n
Regular Card
\n
Featured Card
\n
Just Featured (not a card)
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } .card { border: 2px solid gray; padding: 15px; margin-bottom: 10px; border-radius: 5px; }", + "sandboxCSS": "", + "codePrefix": "/* The .card class already has basic styling */\n/* Now target elements with BOTH classes: 'card' AND 'featured' */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": ".card.featured { border-color: gold; background-color: lemonchiffon }", + "validations": [ + { + "type": "regex", + "value": "^\\.card\\.featured\\s*{", + "message": "Chain the selectors as .card.featured (no space between them)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "border-color:", + "message": "Include the border-color property" + }, + { + "type": "property_value", + "value": { + "property": "border-color", + "expected": "gold" + }, + "message": "Set the border color to gold" + }, + { + "type": "regex", + "value": "\\.card\\.featured\\s*{[^}]*;", + "message": "Make sure to end your CSS rule with a semicolon ;" + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "lemonchiffon" + }, + "message": "Set the background color to lemonchiffon" + }, + { + "type": "regex", + "value": "\\.card\\.featured\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "class-with-type", + "title": "Combining Types", + "description": "You can combine type selectors with class selectors to target specific HTML elements that have a certain class. This creates a more specific selector that only matches when both conditions are true: the element is of the specified type AND it has the specified class. For example, p.note would select paragraph elements with the class note, but would not select divs or spans with that same class. You can style these combined selections using properties like background-color to set a colored background for your elements. This approach allows you to apply different styles to the same class when it appears on different element types.", + "task": "Create a CSS rule that specifically targets <span> elements with the class highlight. Make those elements have an orange background, while other elements with the highlight class remain untouched.", + "previewHTML": "

Type and Class Combinations

\n

This paragraph has a highlighted span that should have an orange background.

\n

This paragraph has the highlight class but should NOT have an orange background.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } .highlight { font-weight: bold; }", + "sandboxCSS": "h2, p, span { padding: 5px; }", + "codePrefix": "/* The .highlight class already sets font-weight to bold */\n/* Now target ONLY span elements with the highlight class */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^span\\.highlight\\s*{", + "message": "Use span.highlight selector (no space between element and class)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "orange" + }, + "message": "Set the background color to orange" + }, + { + "type": "regex", + "value": "span\\.highlight\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "id-selectors", + "title": "ID Selectors", + "description": "ID selectors target elements with a specific id attribute. They begin with a hash/pound sign (#) followed by the ID name. Unlike classes, IDs must be unique within a document—each ID value should be used only once per page. ID selectors have higher specificity than class or element selectors, meaning they override those selectors when conflicts arise. When styling with ID selectors, you can use properties like color to define text color, and text-decoration to control the appearance of text, such as adding underlines to elements. Because of their uniqueness requirement, IDs are best used for one-of-a-kind elements like page headers, main navigation, or specific unique components that appear only once on a page.", + "task": "Create a CSS rule with an ID selector that targets the element with the ID main-title. Set its color to purple and add an underline with text-decoration: underline.", + "previewHTML": "

Main Page Title

\n

Regular paragraph content.

\n

Secondary Heading

\n

Introduction paragraph (different ID).

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h1, h2, p { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Create an ID selector to target the element with id=\"main-title\" */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^#main-title\\s*{", + "message": "Start your rule with #main-title to create an ID selector", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color property" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "purple" + }, + "message": "Set the color to purple" + }, + { + "type": "contains", + "value": "text-decoration:", + "message": "Include the text-decoration property" + }, + { + "type": "property_value", + "value": { + "property": "text-decoration", + "expected": "underline" + }, + "message": "Set the text-decoration to underline" + }, + { + "type": "regex", + "value": "#main-title\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "id-with-type", + "title": "Type + ID", + "description": "Similar to how you can combine type and class selectors, you can also combine type selectors with ID selectors. For example, h1#title targets an h1 element with the ID 'title'. When using this combined approach, you can apply CSS properties like font-style to control the slant of the text, making it italic or normal. While this selector combination is more specific than using just the ID selector, it's often unnecessary since IDs should already be unique in a document. However, this technique can be useful for improving code readability or when you want to emphasize that a particular ID should only appear on a specific element type.", + "task": "Create a CSS rule that combines a type selector with an ID selector to target specifically a paragraph element with the ID special. Set its font style to italic.", + "previewHTML": "

Heading with ID \"special\" (should NOT be affected)

\n

Paragraph with ID \"special\" (should become italic)

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Create a combined type+ID selector for a paragraph with id=\"special\" */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^p#special\\s*{", + "message": "Use p#special to target paragraphs with ID special", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "font-style:", + "message": "Include the font-style property" + }, + { + "type": "property_value", + "value": { + "property": "font-style", + "expected": "italic" + }, + "message": "Set the font-style to italic" + }, + { + "type": "regex", + "value": "p#special\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "selector-lists", + "title": "Selector Lists", + "description": "When multiple elements need the same styling, you can group them together using a selector list (also known as grouping selectors). Selector lists are created by separating individual selectors with commas. This approach reduces repetition in your CSS, making it more maintainable and efficient. For example, h1, h2, h3 { color: blue; } applies the same blue color to all three heading levels. When styling multiple selectors at once, you can apply properties like background-color to set the background, border-left to create a left border with a specific thickness, style, and color, and padding-left to create space between the content and the left border. Whitespace around commas is optional, and each selector in the list can be any valid selector type-elements, classes, IDs, or even more complex selectors.", + "task": "Create a selector list that applies the same styles to three different elements: paragraphs with class note, list items with class important, and the element with ID summary. Give them a lightyellow background, a gold left border, and some left padding.", + "previewHTML": "

This is a note paragraph.

\n\n
Summary section
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "p, li, div { padding: 8px; margin-bottom: 8px; border: 1px dashed gray; }", + "codePrefix": "/* Create a selector list to apply the same styles to multiple different elements */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "p.note,\nli.important,\n#summary {\n background-color: lightyellow;\n border-left: 3px solid gold;\n padding-left: 10px\n}", + "validations": [ + { + "type": "contains", + "value": "p.note", + "message": "Include p.note in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "li.important", + "message": "Include li.important in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "#summary", + "message": "Include #summary in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "regex", + "value": "(p\\.note|li\\.important|#summary)\\s*,\\s*(p\\.note|li\\.important|#summary)\\s*,\\s*(p\\.note|li\\.important|#summary)", + "message": "Create a comma-separated list with all three selectors", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "lightyellow" + }, + "message": "Set the background color to lightyellow" + }, + { + "type": "contains", + "value": "border-left:", + "message": "Include the border-left property" + }, + { + "type": "property_value", + "value": { + "property": "border-left", + "expected": "3px solid gold" + }, + "message": "Use border-left: 3px solid gold to create a left border" + }, + { + "type": "contains", + "value": "padding-left:", + "message": "Include the padding-left property" + }, + { + "type": "property_value", + "value": { + "property": "padding-left", + "expected": "10px" + }, + "message": "Use padding-left: 10px to add left padding" + } + ] + }, + { + "id": "universal-selector", + "title": "Universal (*)", + "description": "The universal selector is denoted by an asterisk (*) and matches any element of any type. It selects everything in the document or, when combined with other selectors, everything within a specific context. For example, * { margin: 0; } removes margins from all elements, while article * selects all elements inside article elements. When using the universal selector in combination with other selectors, you can apply properties like margin to control the spacing around elements. The universal selector is powerful but should be used carefully due to its broad impact. It's commonly used in CSS resets, to override default browser styling, or to target all children of a particular element.", + "task": "Use the universal selector to remove margins from all elements inside the container div. Create a rule using div.container * as the selector and set margin: 0.", + "previewHTML": "
\n

Inside Container

\n

This paragraph is inside the container.

\n \n
\n

This paragraph is outside the container and should not be affected.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } div.container { border: 2px solid navy; padding: 15px; background-color: lavender; } h2, p, ul, li { margin: 15px 0; }", + "sandboxCSS": "", + "codePrefix": "/* Use the universal selector to target all elements inside the container */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^div\\.container\\s+\\*\\s*{", + "message": "Use div.container * selector (with a space between container and *)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "margin:", + "message": "Include the margin property" + }, + { + "type": "property_value", + "value": { + "property": "margin", + "expected": "0" + }, + "message": "Set margin to 0" + }, + { + "type": "regex", + "value": "div\\.container\\s+\\*\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "specificity-basics", + "title": "Specificity", + "description": "CSS specificity determines which styles take precedence when multiple conflicting rules target the same element. Specificity follows a hierarchical system: inline styles have the highest specificity, followed by ID selectors, then class/attribute/pseudo-class selectors, and finally element/pseudo-element selectors. This can be conceptualized as a four-part score (inline, ID, class, element). When creating multiple rules that may target the same elements, you can use the color property to set text colors, and specificity will determine which color is actually applied. Understanding specificity is crucial for predictable styling and debugging CSS conflicts. When two selectors have equal specificity, the one that comes last in the stylesheet wins.", + "task": "Examine the existing CSS rules and add a new rule with higher specificity to override the text color of the paragraph. Create a rule using '.content p' as the selector and set color: green.", + "previewHTML": "
\n

What color will this paragraph be? Look at the CSS rules and their specificity.

\n
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "p { border: 1px dashed gray; padding: 10px; }", + "codePrefix": "/* These CSS rules target the same paragraph but have different specificity */\n\n/* Rule 1: Element selector (lowest specificity) */\np {\n color: red;\n}\n\n/* Rule 2: Descendant selector (higher specificity than just 'p') */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^\\.content\\s+p\\s*{", + "message": "Use .content p as your selector (note the space between)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color property" + }, + { + "type": "contains", + "value": "green", + "message": "" + } + ] + } + ] +} diff --git a/lessons/pl/00-welcome.json b/lessons/pl/00-welcome.json new file mode 100644 index 0000000..ce364c4 --- /dev/null +++ b/lessons/pl/00-welcome.json @@ -0,0 +1,62 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "welcome", + "title": "Code Crispies", + "description": "Welcome to Code Crispies - your interactive web development learning platform", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "get-started", + "title": "Get Started", + "description": "Code Crispies is a free, open-source platform for learning web development through hands-on exercises. No account required!

What you'll learn:
HTML - Semantic elements, forms, tables, SVG (HTML Block & Inline, HTML Forms, HTML Tables)
CSS - Selectors, box model, flexbox, animations (CSS Selectors, CSS Box Model, CSS Flexbox)
Responsive Design - Media queries and mobile-first layouts

How it works:
1. Read the task in the left panel
2. Write code in the editor
3. See live results in the preview
4. Get instant feedback with hints

Keyboard shortcuts: Ctrl+Z to undo, Ctrl+Shift+Z to redo

More resources:
HTML over JS - Native HTML vs JavaScript solutions
Web Engineering Mandala - JavaScript technology roadmap", + "task": "Hello World", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 20px; text-align: center; } h1 { color: #6366f1; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Hello World

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "Hello", + "message": "Write 'Hello World'" + } + ] + }, + { + "id": "overview", + "title": "Overview", + "description": "You're ready! Open the menu (☰) to explore all modules.

Recommended learning path:
1. HTML Block & Inline - Understand container vs inline elements
2. HTML Forms - Build interactive forms with validation
3. CSS Selectors - Target elements precisely
4. CSS Box Model - Master padding, margin, borders
5. CSS Flexbox - Create flexible layouts
6. CSS Animations - Add motion and transitions

Tips:
• Use Show Expected to see the target result
• Your progress is saved automatically
• Try Emmet in HTML mode: ul>li*3 + Tab

Open Source:
Gitea (Source) · GitHub (Mirror)
• Made by LibreTECH · Michael Czechowski", + "task": "Click Next to continue", + "previewHTML": "

Hello World! 🌍

Hallo Welt!

Bonjour le monde!

¡Hola Mundo!

Ciao Mondo!

Olá Mundo!

こんにちは世界!

你好世界!

안녕 세상!

Привет мир!

שלום עולם!

مرحبا بالعالم!

", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 12px; } p { margin: 6px 0; padding: 6px 12px; border-radius: 6px; font-weight: 600; font-size: 0.95em; } p:nth-child(1) { background: #fef3c7; color: #92400e; font-size: 1.2em; } p:nth-child(2) { background: #dcfce7; color: #166534; } p:nth-child(3) { background: #dbeafe; color: #1e40af; } p:nth-child(4) { background: #fce7f3; color: #9d174d; } p:nth-child(5) { background: #e0e7ff; color: #4338ca; } p:nth-child(6) { background: #fef9c3; color: #854d0e; } p:nth-child(7) { background: #fee2e2; color: #991b1b; } p:nth-child(8) { background: #f3e8ff; color: #7c3aed; } p:nth-child(9) { background: #ccfbf1; color: #0f766e; } p:nth-child(10) { background: #fae8ff; color: #86198f; } p:nth-child(11) { background: #fef3c7; color: #b45309; } p:nth-child(12) { background: #d1fae5; color: #047857; }", + "sandboxCSS": "", + "initialCode": "

Hello World! 🌍

\n

Hallo Welt!

\n

Bonjour le monde!

\n

¡Hola Mundo!

\n

Ciao Mondo!

\n

Olá Mundo!

\n

こんにちは世界!

\n

你好世界!

\n

안녕 세상!

\n

Привет мир!

\n

שלום עולם!

\n

مرحبا بالعالم!

", + "solution": "

Hello World! 🌍

\n

Hallo Welt!

\n

Bonjour le monde!

\n

¡Hola Mundo!

\n

Ciao Mondo!

\n

Olá Mundo!

\n

こんにちは世界!

\n

你好世界!

\n

안녕 세상!

\n

Привет мир!

\n

שלום עולם!

\n

مرحبا بالعالم!

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "Hello", + "message": "Click Next to continue" + } + ] + }, + { + "id": "playground", + "title": "Playground", + "mode": "playground", + "description": "", + "task": "", + "previewHTML": "", + "previewBaseCSS": "", + "sandboxCSS": "", + "initialCode": "\n\n

Hello World

\n

Start coding!

", + "solution": "", + "previewContainer": "preview-area", + "validations": [] + } + ] +} diff --git a/lessons/pl/01-box-model.json b/lessons/pl/01-box-model.json new file mode 100644 index 0000000..a5b10a6 --- /dev/null +++ b/lessons/pl/01-box-model.json @@ -0,0 +1,180 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "box-model", + "title": "CSS Box Model", + "description": "Master the fundamental principles of space management in web design through the CSS box model. This module explores how content, padding, borders, and margins combine to create layout structures that are both visually appealing and structurally sound.", + "difficulty": "beginner", + "lessons": [ + { + "id": "box-model-1", + "title": "Box Model Components", + "description": "The CSS box model consists of four concentric layers: content area (innermost), padding, border, and margin (outermost). Understanding how these components interact is essential for precise layout control.", + "task": "Add padding: 1rem to .box to create space between its content and border.", + "previewHTML": "
Box Model Components
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background-color: lavender; border: 2px dashed slategray; }", + "sandboxCSS": "", + "codePrefix": ".box {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "padding: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "padding", "expected": "1rem" }, + "message": "Set padding: 1rem" + } + ] + }, + { + "id": "box-model-2", + "title": "Adding Borders", + "description": "Borders outline an element, creating visual separation from surrounding content. The border shorthand accepts three values: width, style, and color.", + "task": "Add border: 2px solid darkslategray to .box.", + "previewHTML": "
This box needs a border
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background-color: mintcream; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": ".box {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "border: 2px solid darkslategray;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "border:\\s*2px\\s+solid\\s+darkslategray", + "message": "Set border: 2px solid darkslategray", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "box-model-3", + "title": "Adding Margins", + "description": "Margins create space between elements, controlling how they relate to one another within a layout. Unlike padding (which affects internal spacing), margins exist outside the element's border.", + "task": "Add margin: 1rem to .outer to create space between it and the adjacent element.", + "previewHTML": "
This box needs margins
Adjacent element
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .container { background-color: whitesmoke; padding: 8px; } .outer { background-color: plum; padding: 1rem; border: 2px solid orchid; } .neighbor { background-color: lightblue; padding: 1rem; border: 2px solid steelblue; }", + "sandboxCSS": "", + "codePrefix": ".outer {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "margin", "expected": "1rem" }, + "message": "Set margin: 1rem" + } + ] + }, + { + "id": "box-model-4", + "title": "Box Sizing: Border-Box", + "description": "The box-sizing property determines how element dimensions are calculated. The default content-box excludes padding and border from width/height, while border-box includes them, making layout calculations more intuitive.", + "task": "Add box-sizing: border-box to .sized so padding and border are included in its width.", + "previewHTML": "
Content-box (default)
Border-box
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .sizing-demo { display: flex; gap: 1rem; } .box { width: 200px; padding: 1rem; border: 4px solid teal; background: lightcyan; } .default { box-sizing: content-box; }", + "sandboxCSS": "", + "codePrefix": ".sized {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "box-sizing: border-box;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "box-sizing", "expected": "border-box" }, + "message": "Set box-sizing: border-box" + } + ] + }, + { + "id": "box-model-5", + "title": "Margin Collapse", + "description": "When two vertical margins meet, they collapse to the larger value instead of adding up. Understanding this behavior is crucial for consistent vertical spacing.", + "task": "Add margin-bottom: 2rem to .first. Notice the space between paragraphs equals 2rem (not 3rem) due to margin collapse.", + "previewHTML": "

This paragraph has a bottom margin.

This paragraph has a top margin of 1rem.

", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .collapse-demo { border: 1px solid silver; padding: 8px; background: ghostwhite; } .second { margin-top: 1rem; background: linen; }", + "sandboxCSS": "", + "codePrefix": ".first {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin-bottom: 2rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "margin-bottom", "expected": "2rem" }, + "message": "Set margin-bottom: 2rem" + } + ] + }, + { + "id": "box-model-6", + "title": "Margin Shorthand Notation", + "description": "The margin shorthand can set all four sides at once. Two values set vertical (top/bottom) and horizontal (left/right) margins respectively.", + "task": "Add margin: 1rem 2rem to .spaced for 1rem top/bottom and 2rem left/right.", + "previewHTML": "
This box needs margins: 1rem top/bottom, 2rem left/right
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .container { background-color: whitesmoke; padding: 8px; } .spaced { background-color: honeydew; border: 2px solid mediumseagreen; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": ".spaced {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin: 1rem 2rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "margin:\\s*1rem\\s+2rem", + "message": "Set margin: 1rem 2rem", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "box-model-7", + "title": "Padding Shorthand Notation", + "description": "Like margin, padding shorthand allows setting all sides at once. A single value applies to all four sides equally.", + "task": "Add padding: 1.5rem to .padded to add equal padding on all sides.", + "previewHTML": "
This box needs equal padding on all sides
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .padded { background-color: papayawhip; border: 2px solid orange; }", + "sandboxCSS": "", + "codePrefix": ".padded {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "padding: 1.5rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "padding", "expected": "1.5rem" }, + "message": "Set padding: 1.5rem" + } + ] + }, + { + "id": "box-model-8", + "title": "Border on Specific Sides", + "description": "For granular control, you can target specific sides with border-top, border-right, border-bottom, or border-left.", + "task": "Add border-bottom: 4px solid dodgerblue to .line.", + "previewHTML": "
This element needs only a bottom border
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .line { padding: 1rem; background-color: aliceblue; }", + "sandboxCSS": "", + "codePrefix": ".line {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "border-bottom: 4px solid dodgerblue;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "border-bottom:\\s*4px\\s+solid\\s+dodgerblue", + "message": "Set border-bottom: 4px solid dodgerblue", + "options": { "caseSensitive": false } + } + ] + } + ] +} diff --git a/lessons/pl/05-units-variables.json b/lessons/pl/05-units-variables.json new file mode 100644 index 0000000..67a9272 --- /dev/null +++ b/lessons/pl/05-units-variables.json @@ -0,0 +1,116 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "units-variables", + "title": "CSS Units & Variables", + "description": "Understand the variety of CSS measurement units and how to define and use custom properties for maintainable styles.", + "difficulty": "beginner", + "lessons": [ + { + "id": "units-1", + "title": "Absolute vs. Relative Units", + "description": "Learn the difference between px, rem, em, %, and vw/vh for flexible, responsive layouts.", + "task": "Set the width of .box to 80% and max-width to 37.5rem.", + "previewHTML": "
Resize me!
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .box { background: #f5f5f5; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Set flexible sizing */\n.box {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: 80%;\n max-width: 37.5rem;", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "width", "message": "Use width property", "options": { "caseSensitive": false } }, + { "type": "property_value", "value": { "property": "width", "expected": "80%" }, "message": "Set width to 80%" }, + { "type": "contains", "value": "max-width", "message": "Use max-width property", "options": { "caseSensitive": false } }, + { + "type": "property_value", + "value": { "property": "max-width", "expected": "37.5rem" }, + "message": "Set max-width to 37.5rem" + } + ] + }, + { + "id": "units-2", + "title": "CSS Custom Properties", + "description": "Define and reuse variables (--custom properties) to centralize your theme values.", + "task": "Create a --main-color variable in :root with #6200ee and apply it as the border color on .themed.", + "previewHTML": "
Variable Box
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .themed { padding: 1rem; border: 0.125rem solid #ddd; }", + "sandboxCSS": "", + "codePrefix": "/* Define and use a CSS variable */\n:root {", + "initialCode": "", + "codeSuffix": "}\n.themed { }", + "solution": " --main-color: #6200ee;\n}\n.themed {\n border-color: var(--main-color);", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "--main-color", + "message": "Define --main-color in :root", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": "var(--main-color)", + "message": "Use var(--main-color)", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "border", "expected": "var(--main-color)" }, + "message": "Apply variable to border color", + "options": { "exact": false } + } + ] + }, + { + "id": "units-3", + "title": "Unit Calculations (calc)", + "description": "Use the calc() function to combine different units in one expression.", + "task": "Set the width of .sized to calc(100% - 2rem) and min-height to calc(10vh + 1rem).", + "previewHTML": "
Calc Demo
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .sized { background: #e8f5e9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Use calc for dynamic sizing */\n.sized {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: calc(100% - 2rem);\n min-height: calc(10vh + 1rem);", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "calc", "message": "Use calc() function", "options": { "caseSensitive": false } }, + { + "type": "regex", + "value": "width:\\s*calc\\(100% - 2rem\\)", + "message": "Width should be calc(100% - 2rem)", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "min-height:\\s*calc\\(10vh \\+ 1rem\\)", + "message": "Min-height should be calc(10vh + 1rem)", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "units-4", + "title": "Viewport & Responsive Units", + "description": "Control layouts relative to viewport size with vw, vh, and vmin/vmax units.", + "task": "Give .view a width of 50vw and height of 20vh.", + "previewHTML": "
Viewport Box
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .view { background: #ffe0b2; }", + "sandboxCSS": "", + "codePrefix": "/* Use viewport units */\n.view {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: 50vw;\n height: 20vh;", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "vw", "message": "Use vw unit", "options": { "caseSensitive": false } }, + { "type": "contains", "value": "vh", "message": "Use vh unit", "options": { "caseSensitive": false } }, + { "type": "property_value", "value": { "property": "width", "expected": "50vw" }, "message": "Set width to 50vw" }, + { "type": "property_value", "value": { "property": "height", "expected": "20vh" }, "message": "Set height to 20vh" } + ] + } + ] +} diff --git a/lessons/pl/06-transitions-animations.json b/lessons/pl/06-transitions-animations.json new file mode 100644 index 0000000..2697fd7 --- /dev/null +++ b/lessons/pl/06-transitions-animations.json @@ -0,0 +1,145 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "transitions-animations", + "title": "CSS Animations", + "description": "Bring interactivity to your UI by smoothly transitioning properties and creating keyframe-driven animations.", + "difficulty": "beginner", + "lessons": [ + { + "id": "transitions-1", + "title": "Transitions", + "description": "Learn how to apply transition to properties for smooth changes on state changes.", + "task": "Add transition: background-color 0.3s to .btn so the color fades smoothly on hover.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .btn { background: black; color: white; padding: 0.5rem 1rem; border: none; cursor: pointer; } .btn:hover { background: white; color: black; }", + "sandboxCSS": "", + "codePrefix": "/* Add transition */\n.btn {", + "initialCode": "", + "codeSuffix": "}", + "solution": " transition: background-color 0.3s;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "transition", + "message": "Use the transition property", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "transition:\\s*background-color\\s*0\\.3s", + "message": "Set transition: background-color 0.3s", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "transitions-2", + "title": "Timing Funcs", + "description": "Explore easing functions like ease, linear, ease-in, ease-out to control animation pacing.", + "task": "Set transition-timing-function to ease-in-out on .btn.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .btn { background: navy; color: gold; padding: 0.5rem 1rem; border: none; cursor: pointer; transition: all 0.5s; } .btn:hover { background: gold; color: navy; transform: scale(1.1); }", + "sandboxCSS": "", + "codePrefix": "/* Set timing function */\n.btn {", + "initialCode": "", + "codeSuffix": "}", + "solution": " transition-timing-function: ease-in-out;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "transition-timing-function", + "message": "Use transition-timing-function", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "transition-timing-function", "expected": "ease-in-out" }, + "message": "Set timing to ease-in-out" + } + ] + }, + { + "id": "transitions-3", + "title": "Keyframes", + "description": "Create named animations using @keyframes and apply them via the animation shorthand.", + "task": "Define a keyframe at 50% with transform: translateY(-20px) and apply animation: bounce 1s infinite to .ball.", + "previewHTML": "
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .ball { width: 50px; height: 50px; background: crimson; border-radius: 50%; margin: 2rem auto; }", + "sandboxCSS": "", + "codePrefix": "/* Define keyframes and apply animation */\n@keyframes bounce {", + "initialCode": "", + "codeSuffix": "}\n.ball { }", + "solution": " 50% { transform: translateY(-20px); }\n}\n.ball {\n animation: bounce 1s infinite;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "@keyframes bounce", + "message": "Define @keyframes bounce", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "50%.*transform: translateY\\(-20px\\)", + "message": "At 50%, use transform: translateY(-20px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": "animation", + "message": "Use animation property on .ball", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "animation:.*bounce.*1s.*infinite", + "message": "Apply animation: bounce 1s infinite", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "transitions-4", + "title": "Anim Properties", + "description": "Fine-tune animations with animation-delay, animation-iteration-count, animation-direction, and animation-fill-mode.", + "task": "Apply the pulse animation to .box with animation-name: pulse, animation-duration: 2s, animation-delay: 1s, animation-iteration-count: 2, and animation-fill-mode: forwards.", + "previewHTML": "
Pulse
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .box { width: 100px; height: 100px; background: black; color: white; display: flex; align-items: center; justify-content: center; margin: 2rem auto; } @keyframes pulse { 0% { background: black; color: white; transform: scale(1); } 50% { background: white; color: black; transform: scale(1.2); } 100% { background: limegreen; color: black; transform: scale(1); } }", + "sandboxCSS": "", + "codePrefix": "/* Apply animation properties */\n.box {", + "initialCode": "", + "codeSuffix": "}", + "solution": " animation-name: pulse;\n animation-duration: 2s;\n animation-delay: 1s;\n animation-iteration-count: 2;\n animation-fill-mode: forwards;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "animation-name", "expected": "pulse" }, + "message": "Set animation-name: pulse" + }, + { + "type": "property_value", + "value": { "property": "animation-duration", "expected": "2s" }, + "message": "Set animation-duration: 2s" + }, + { + "type": "property_value", + "value": { "property": "animation-delay", "expected": "1s" }, + "message": "Set animation-delay: 1s" + }, + { + "type": "property_value", + "value": { "property": "animation-iteration-count", "expected": "2" }, + "message": "Set animation-iteration-count: 2" + }, + { + "type": "property_value", + "value": { "property": "animation-fill-mode", "expected": "forwards" }, + "message": "Set animation-fill-mode: forwards" + } + ] + } + ] +} diff --git a/lessons/pl/08-responsive.json b/lessons/pl/08-responsive.json new file mode 100644 index 0000000..0db9b98 --- /dev/null +++ b/lessons/pl/08-responsive.json @@ -0,0 +1,126 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "responsive-design", + "title": "CSS Responsive Design", + "description": "Make your layouts adapt to different screen sizes using media queries and fluid design techniques.", + "difficulty": "intermediate", + "lessons": [ + { + "id": "responsive-1", + "title": "Media Queries", + "description": "Understand the syntax and use cases for CSS media queries to apply styles conditionally based on viewport characteristics.", + "task": "Write a media query with @media (max-width: 600px) that changes .panel background to lightcoral.", + "previewHTML": "
Resize the window
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .panel { padding: 1rem; background: lightblue; }", + "sandboxCSS": "", + "codePrefix": "/* Add your media query below */\n", + "initialCode": "", + "codeSuffix": "", + "solution": "@media (max-width: 600px) {\n .panel {\n background: lightcoral;\n }\n}", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "@media\\s*\\(max-width:\\s*600px\\)", + "message": "Use @media (max-width: 600px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": ".panel", + "message": "Target .panel inside the media query", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "background", "expected": "lightcoral" }, + "message": "Set background: lightcoral", + "options": { "exact": false } + } + ] + }, + { + "id": "responsive-2", + "title": "Fluid Type", + "description": "Use relative units like vw to make font sizes scale with the viewport width.", + "task": "Set font-size: 5vw on .text so it scales as the viewport changes.", + "previewHTML": "

Fluid Typography

", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Apply fluid font sizing */\n.text {", + "initialCode": "", + "codeSuffix": "}", + "solution": " font-size: 5vw;", + "previewContainer": "preview-area", + "validations": [ + { "type": "property_value", "value": { "property": "font-size", "expected": "5vw" }, "message": "Set font-size: 5vw" } + ] + }, + { + "id": "responsive-3", + "title": "Flex Grids", + "description": "Combine CSS Grid with auto-fit or auto-fill for responsive column layouts.", + "task": "Add display: grid, grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)), and gap: 1rem to .cards.", + "previewHTML": "
1
2
3
4
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .cards > div { background: #d1c4e9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Create a responsive grid */\n.cards {", + "initialCode": "", + "codeSuffix": "}", + "solution": " display: grid;\n grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));\n gap: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "display", "expected": "grid" }, + "message": "Set display: grid" + }, + { + "type": "regex", + "value": "repeat\\(auto-fit,\\s*minmax\\(200px,\\s*1fr\\)\\)", + "message": "Use repeat(auto-fit, minmax(200px, 1fr))", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "gap", "expected": "1rem" }, + "message": "Set gap: 1rem" + } + ] + }, + { + "id": "responsive-4", + "title": "Mobile-First", + "description": "Adopt a mobile-first approach by writing base styles for small screens and enhancing for larger viewports.", + "task": "Write a media query with @media (min-width: 768px) that sets .sidebar width to 250px.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .sidebar { background: #c8e6c9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Add mobile-first enhancement */\n", + "initialCode": "", + "codeSuffix": "", + "solution": "@media (min-width: 768px) {\n .sidebar {\n width: 250px;\n }\n}", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "@media\\s*\\(min-width:\\s*768px\\)", + "message": "Use @media (min-width: 768px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": ".sidebar", + "message": "Target .sidebar inside media query", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "width", "expected": "250px" }, + "message": "Set width: 250px", + "options": { "exact": false } + } + ] + } + ] +} diff --git a/lessons/pl/20-html-elements.json b/lessons/pl/20-html-elements.json new file mode 100644 index 0000000..93f9214 --- /dev/null +++ b/lessons/pl/20-html-elements.json @@ -0,0 +1,97 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-elements", + "title": "HTML Block & Inline", + "description": "Understanding the fundamental difference between container (block) and inline elements", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "block-vs-inline-intro", + "title": "Block vs Inline Elements", + "description": "HTML elements fall into two main categories:

Block elements (containers) start on a new line and take full width. Examples: <div>, <p>, <h1>, <section>

Inline elements flow within text and only take needed width. Examples: <span>, <a>, <strong>, <em>", + "task": "Wrap the word important with <strong> tags to make it bold. Notice how the paragraph (block) takes full width while strong (inline) flows with text.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 20px; } p { background: #e3f2fd; padding: 10px; } strong { background: #ffecb3; }", + "sandboxCSS": "", + "initialCode": "

This is a paragraph with an important word.

", + "solution": "

This is a paragraph with an important word.

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "p", + "message": "Add a <p> paragraph element" + }, + { + "type": "parent_child", + "value": { "parent": "p", "child": "strong" }, + "message": "Wrap the word important with <strong> tags" + } + ] + }, + { + "id": "semantic-containers", + "title": "Semantic Tags", + "description": "Modern HTML uses semantic containers that describe their content:

<header> - Page or section header
<nav> - Navigation links
<main> - Main content area
<section> - Thematic grouping
<article> - Self-contained content
<footer> - Page or section footer", + "task": "Create a basic page structure:
1. Add a <header> with an <h1> containing the text 'My Website'
2. Add a <main> element with a paragraph saying 'Welcome to my site!'
3. Add a <footer> with a paragraph saying 'Copyright 2025'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; margin: 0; } header { background: #1976d2; color: white; padding: 15px; } main { padding: 20px; min-height: 100px; } footer { background: #424242; color: white; padding: 10px; text-align: center; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "
\n

My Website

\n
\n
\n

Welcome to my site!

\n
\n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "header", + "message": "Add a <header> element" + }, + { + "type": "element_exists", + "value": "main", + "message": "Add a <main> element" + }, + { + "type": "element_exists", + "value": "footer", + "message": "Add a <footer> element" + }, + { + "type": "parent_child", + "value": { "parent": "header", "child": "h1" }, + "message": "Add an <h1> heading inside your header" + } + ] + }, + { + "id": "div-vs-span", + "title": "div & span", + "description": "When you need a container without semantic meaning:

<div> - Generic block container (for layout/grouping)
<span> - Generic inline container (for styling text portions)

Use semantic elements when possible, div/span when no semantic element fits.", + "task": "Wrap the word 'highlighted' in a <span> to style it differently. Wrap the whole quote in a <div>.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: Georgia, serif; padding: 20px; } div { background: #f5f5f5; padding: 15px; border-left: 4px solid #1976d2; } span { background: #fff59d; padding: 2px 4px; }", + "sandboxCSS": "", + "initialCode": "The most highlighted moment was unforgettable.", + "solution": "
The most highlighted moment was unforgettable.
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "div", + "message": "Wrap everything in a <div> element" + }, + { + "type": "element_exists", + "value": "span", + "message": "Add a <span> around the word highlighted" + }, + { + "type": "element_text", + "value": { "selector": "span", "text": "highlighted" }, + "message": "The <span> should contain the word highlighted" + } + ] + } + ] +} diff --git a/lessons/pl/21-html-forms-basic.json b/lessons/pl/21-html-forms-basic.json new file mode 100644 index 0000000..d971cbf --- /dev/null +++ b/lessons/pl/21-html-forms-basic.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-forms-basic", + "title": "HTML Forms", + "description": "Learn to create forms with various input types", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "form-structure", + "title": "Form Structure", + "description": "Every form needs a <form> wrapper. Inside, use <label> to describe inputs and <input> for user data entry.

The for attribute on labels should match the id on inputs for accessibility.", + "task": "Create a form with:
1. A <label> with the text 'Name:' and for=\"name\" attribute
2. A text <input> with id=\"name\" and name=\"name\" attributes", + "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": "Wrap everything in a <form> element" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for your input" + }, + { + "type": "element_exists", + "value": "input", + "message": "Add an <input> element" + }, + { + "type": "attribute_value", + "value": { "selector": "label", "attr": "for", "value": null }, + "message": "Add a for attribute to your label" + }, + { + "type": "attribute_value", + "value": { "selector": "input", "attr": "id", "value": null }, + "message": "Add an id attribute to your input" + } + ] + }, + { + "id": "input-types", + "title": "Input Types", + "description": "Different input types provide appropriate keyboards and validation:

type=\"text\" - General text
type=\"email\" - Email with @ validation
type=\"password\" - Hidden characters
type=\"number\" - Numeric keyboard
type=\"tel\" - Phone keyboard", + "task": "Create a login form with two fields:
1. An email field: <label for=\"email\">Email:</label> and <input type=\"email\" id=\"email\">
2. A password field: <label for=\"password\">Password:</label> and <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": "Add an input with type=\"email\"" + }, + { + "type": "element_exists", + "value": "input[type='password']", + "message": "Add an input with type=\"password\"" + }, + { + "type": "element_count", + "value": { "selector": "label", "min": 2 }, + "message": "Add labels for both inputs" + } + ] + }, + { + "id": "submit-button", + "title": "Submit Button", + "description": "Forms need a way to submit data. Use:

<button type=\"submit\"> - Preferred, flexible content
<input type=\"submit\"> - Simple text-only button

The button text should be action-oriented (e.g., 'Sign In', 'Register', 'Send').", + "task": "Add a submit button to the form with the text 'Sign In'.", + "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": "Add a submit button to your form" + }, + { + "type": "element_text", + "value": { "selector": "button", "text": "Sign In" }, + "message": "The button should say Sign In" + } + ] + } + ] +} diff --git a/lessons/pl/22-html-forms-validation.json b/lessons/pl/22-html-forms-validation.json new file mode 100644 index 0000000..72f4cd1 --- /dev/null +++ b/lessons/pl/22-html-forms-validation.json @@ -0,0 +1,112 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-forms-validation", + "title": "HTML Validation", + "description": "Learn HTML5 built-in form validation attributes", + "mode": "html", + "difficulty": "intermediate", + "lessons": [ + { + "id": "required-fields", + "title": "Required Fields", + "description": "The required attribute prevents form submission if the field is empty.

Add it to any input that must be filled:
<input type=\"text\" required>

The browser shows a validation message automatically.", + "task": "Make both the name and email fields required by adding the required attribute.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 350px; } label { display: block; margin-top: 15px; margin-bottom: 5px; } label:first-of-type { margin-top: 0; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } input:invalid { border-color: #d32f2f; } button { margin-top: 20px; padding: 10px 20px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; }", + "sandboxCSS": "", + "initialCode": "
\n \n \n \n \n \n \n \n
", + "solution": "
\n \n \n \n \n \n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "input[name='name']", "attr": "required", "value": true }, + "message": "Add the required attribute to the name input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[name='email']", "attr": "required", "value": true }, + "message": "Add the required attribute to the email input" + } + ] + }, + { + "id": "input-constraints", + "title": "Constraints", + "description": "Control what users can enter:

minlength / maxlength - Text length limits
min / max - Number range
pattern - Regex pattern matching
placeholder - Hint text (not a label!)", + "task": "Add validation to the password input:
1. Add minlength=\"8\" for minimum length
2. Add maxlength=\"20\" for maximum length
3. Add placeholder=\"Enter password\" as a hint", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 350px; } label { display: block; margin-bottom: 5px; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } input:invalid:not(:placeholder-shown) { border-color: #d32f2f; } small { display: block; font-size: 12px; color: #666; margin-top: 4px; } button { margin-top: 20px; padding: 10px 20px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; }", + "sandboxCSS": "", + "initialCode": "
\n \n \n Must be 8-20 characters\n \n \n
", + "solution": "
\n \n \n Must be 8-20 characters\n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "minlength", "value": "8" }, + "message": "Add minlength=\"8\" to the password input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "maxlength", "value": "20" }, + "message": "Add maxlength=\"20\" to the password input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "placeholder", "value": null }, + "message": "Add a placeholder to hint what to enter" + } + ] + }, + { + "id": "complete-registration", + "title": "Full Form", + "description": "Build a complete registration form with all validation concepts:

- Required fields marked with *
- Email validation (use type=\"email\")
- Password with length constraints
- Terms checkbox (required)
- Submit button", + "task": "Complete the registration form. Add required attributes, proper input types, and validation constraints.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 400px; background: #f5f5f5; padding: 25px; border-radius: 8px; } h2 { margin-top: 0; margin-bottom: 20px; } label { display: block; margin-top: 15px; margin-bottom: 5px; font-weight: 500; } input[type='text'], input[type='email'], input[type='password'] { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 14px; } input:focus { outline: 2px solid #1976d2; border-color: transparent; } input[type='checkbox'] { width: auto; margin-right: 8px; vertical-align: middle; } label:has(input[type='checkbox']) { display: flex; align-items: center; font-weight: normal; } button { width: 100%; margin-top: 20px; padding: 12px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; font-weight: 500; } button:hover { background: #1565c0; }", + "sandboxCSS": "", + "initialCode": "
\n

Create Account

\n \n \n \n \n \n \n \n \n \n \n \n \n \n
", + "solution": "
\n

Create Account

\n \n \n \n \n \n \n \n \n \n \n \n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "#fullname", "attr": "required", "value": true }, + "message": "Make the full name field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#email", "attr": "type", "value": "email" }, + "message": "Set the email input type=\"email\"" + }, + { + "type": "attribute_value", + "value": { "selector": "#email", "attr": "required", "value": true }, + "message": "Make the email field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "type", "value": "password" }, + "message": "Set the password input type=\"password\"" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "required", "value": true }, + "message": "Make the password field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "minlength", "value": "8" }, + "message": "Add minlength=\"8\" to password" + }, + { + "type": "attribute_value", + "value": { "selector": "#terms", "attr": "required", "value": true }, + "message": "Make the terms checkbox required" + } + ] + } + ] +} diff --git a/lessons/pl/23-html-details-summary.json b/lessons/pl/23-html-details-summary.json new file mode 100644 index 0000000..3c60ad0 --- /dev/null +++ b/lessons/pl/23-html-details-summary.json @@ -0,0 +1,97 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-details-summary", + "title": "HTML Details & Summary", + "description": "Create expandable content sections without JavaScript", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "details-summary-basic", + "title": "First Widget", + "description": "The <details> element creates a collapsible section. The <summary> provides the clickable label.

Click the summary to toggle the hidden content - no JavaScript needed!", + "task": "Create a <details> element with:
1. A <summary> saying 'Click to reveal'
2. A <p> with the text 'This content was hidden!'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } details { border: 1px solid #ddd; border-radius: 8px; padding: 15px; } summary { font-weight: 600; cursor: pointer; } summary:hover { color: #1976d2; } details p { margin-top: 15px; color: #666; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "
\n Click to reveal\n

This content was hidden!

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "details", + "message": "Add a <details> element" + }, + { + "type": "element_exists", + "value": "summary", + "message": "Add a <summary> inside the details" + }, + { + "type": "parent_child", + "value": { "parent": "details", "child": "summary" }, + "message": "The <summary> must be inside <details>" + }, + { + "type": "parent_child", + "value": { "parent": "details", "child": "p" }, + "message": "Add a <p> inside <details> for the hidden content" + } + ] + }, + { + "id": "details-open-attribute", + "title": "Pre-expanded Details", + "description": "By default, <details> is closed. Add the open attribute to show the content initially.

This is a boolean attribute - just add open without a value.", + "task": "Add the open attribute to the <details> element to show the content by default.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } details { border: 1px solid #ddd; border-radius: 8px; padding: 15px; background: #f9f9f9; } summary { font-weight: 600; cursor: pointer; } details p { margin-top: 15px; color: #666; }", + "sandboxCSS": "", + "initialCode": "
\n FAQ: What is HTML5?\n

HTML5 is the latest version of the HTML standard with new semantic elements and APIs.

\n
", + "solution": "
\n FAQ: What is HTML5?\n

HTML5 is the latest version of the HTML standard with new semantic elements and APIs.

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "details", "attr": "open", "value": true }, + "message": "Add the open attribute to <details>" + } + ] + }, + { + "id": "faq-accordion", + "title": "FAQ Accordion", + "description": "Multiple <details> elements create an accordion-style FAQ. Each question can be expanded independently.

Pro tip: Type details*3>summary+p and press Tab for Emmet expansion. *3 creates 3 elements, > nests inside, + adds siblings.", + "task": "Create an FAQ section with:
1. An <h1> saying 'Frequently Asked Questions'
2. Three <details> elements, each with a question in <summary> and an answer in <p>", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; min-height: 100vh; background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); display: flex; flex-direction: column; justify-content: center; padding: 40px; margin: 0; box-sizing: border-box; } h1 { font-size: 2.5rem; color: #4a4a4a; text-align: center; margin: 0 0 30px 0; } details { background: white; border-radius: 12px; margin-bottom: 15px; padding: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } summary { font-size: 1.3rem; font-weight: 600; color: #5c5c5c; cursor: pointer; list-style: none; } summary::before { content: '▸ '; color: #fcb69f; } details[open] summary::before { content: '▾ '; } details p { margin: 15px 0 0 0; color: #666; line-height: 1.6; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Frequently Asked Questions

\n\n
\n What is HTML5?\n

HTML5 is the latest version of HTML with new semantic elements and APIs.

\n
\n\n
\n Do I need JavaScript?\n

Many interactive features work with pure HTML5, no JavaScript required!

\n
\n\n
\n Is this accessible?\n

Yes! Native HTML elements have built-in keyboard and screen reader support.

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "h1", + "message": "Add an <h1> heading for the FAQ title" + }, + { + "type": "element_count", + "value": { "selector": "details", "min": 3 }, + "message": "Create at least 3 <details> elements for the FAQ" + }, + { + "type": "element_count", + "value": { "selector": "summary", "min": 3 }, + "message": "Each <details> needs a <summary> for the question" + }, + { + "type": "element_count", + "value": { "selector": "details p", "min": 3 }, + "message": "Each <details> needs a <p> for the answer" + } + ] + } + ] +} diff --git a/lessons/pl/24-html-progress-meter.json b/lessons/pl/24-html-progress-meter.json new file mode 100644 index 0000000..28b3bf3 --- /dev/null +++ b/lessons/pl/24-html-progress-meter.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-progress-meter", + "title": "HTML Progress & Meter", + "description": "Display completion status and scalar measurements natively", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "progress-basic", + "title": "Progress Bars", + "description": "The <progress> element shows task completion. Use value for current progress and max for the total.

Note: This is not a self-closing tag! Write <progress>...</progress> with fallback text inside for older browsers.", + "task": "Create a progress bar showing 70% completion:
1. Add a <label> saying 'Download:'
2. Add a <progress> with value=\"70\" and max=\"100\"", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } label { display: block; margin-bottom: 8px; font-weight: 500; } progress { width: 100%; height: 20px; border-radius: 10px; } progress::-webkit-progress-bar { background: #e0e0e0; border-radius: 10px; } progress::-webkit-progress-value { background: linear-gradient(90deg, #4caf50, #8bc34a); border-radius: 10px; } progress::-moz-progress-bar { background: linear-gradient(90deg, #4caf50, #8bc34a); border-radius: 10px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n70%", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "progress", + "message": "Add a <progress> element" + }, + { + "type": "attribute_value", + "value": { "selector": "progress", "attr": "value", "value": "70" }, + "message": "Set value=\"70\" on the progress element" + }, + { + "type": "attribute_value", + "value": { "selector": "progress", "attr": "max", "value": "100" }, + "message": "Set max=\"100\" on the progress element" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for the progress bar" + } + ] + }, + { + "id": "progress-indeterminate", + "title": "Indeterminate Progress", + "description": "When progress is unknown (like loading), omit the value attribute. This creates an animated indeterminate state.

Useful for network requests or processes with unknown duration.", + "task": "Create a loading indicator:
1. Add a <p> saying 'Loading...'
2. Add a <progress> without a value attribute", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } p { margin-bottom: 10px; color: #666; } progress { width: 100%; height: 8px; border-radius: 4px; } progress::-webkit-progress-bar { background: #e0e0e0; border-radius: 4px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Loading...

\n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "progress", + "message": "Add a <progress> element" + }, + { + "type": "element_exists", + "value": "p", + "message": "Add a <p> with loading text" + } + ] + }, + { + "id": "meter-gauge", + "title": "Meter Gauges", + "description": "The <meter> element displays a scalar value within a range. Use it for measurements like disk space, battery, or ratings.

Set low, high, and optimum to define good/bad ranges - the browser colors it accordingly!", + "task": "Create a battery level meter:
1. Add a <label> saying 'Battery:'
2. Add a <meter> with:
- value=\"0.8\"
- min=\"0\" and max=\"1\"
- low=\"0.2\" and high=\"0.8\"
- optimum=\"1\"", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } label { display: block; margin-bottom: 8px; font-weight: 500; } meter { width: 100%; height: 25px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n80%", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "meter", + "message": "Add a <meter> element" + }, + { + "type": "attribute_value", + "value": { "selector": "meter", "attr": "value", "value": "0.8" }, + "message": "Set value=\"0.8\" on the meter" + }, + { + "type": "attribute_value", + "value": { "selector": "meter", "attr": "low", "value": "0.2" }, + "message": "Set low=\"0.2\" to define the low threshold" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for the meter" + } + ] + } + ] +} diff --git a/lessons/pl/30-html-tables.json b/lessons/pl/30-html-tables.json new file mode 100644 index 0000000..1bdfaeb --- /dev/null +++ b/lessons/pl/30-html-tables.json @@ -0,0 +1,127 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-tables", + "title": "HTML Tables", + "description": "Create structured data tables with headers and captions", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "table-basic", + "title": "Basic Table Structure", + "description": "Tables use <table> with <tr> for rows. Inside rows, use <th> for headers and <td> for data cells.

The <caption> element provides an accessible title for the table.", + "task": "Create a simple table with:
1. A <caption> saying 'Fruit Prices'
2. A header row with 'Fruit' and 'Price' columns
3. At least 2 data rows", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #f5f5f5; } table { border-collapse: collapse; width: 100%; max-width: 400px; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } caption { padding: 15px; font-weight: 600; font-size: 1.2rem; color: #333; background: #f8f9fa; } th, td { padding: 12px 20px; text-align: left; border-bottom: 1px solid #eee; } th { background: #3498db; color: white; font-weight: 500; } tr:hover { background: #f8f9fa; } tr:last-child td { border-bottom: none; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n
Fruit Prices
FruitPrice
Apple$1.50
Banana$0.75
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> for the table title" + }, + { + "type": "element_count", + "value": { "selector": "th", "min": 2 }, + "message": "Add at least 2 header cells (th)" + }, + { + "type": "element_count", + "value": { "selector": "tr", "min": 3 }, + "message": "Add at least 3 rows (1 header + 2 data rows)" + } + ] + }, + { + "id": "table-thead-tbody", + "title": "Table Head & Body", + "description": "Use <thead> to group header rows and <tbody> to group data rows. This helps browsers and assistive technology understand the table structure.

You can also use <tfoot> for footer rows like totals.", + "task": "Create a structured table:
1. A <caption> with 'Monthly Sales'
2. A <thead> with Month and Revenue headers
3. A <tbody> with at least 2 data rows", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; margin: 0; box-sizing: border-box; } table { border-collapse: collapse; width: 100%; max-width: 450px; background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.2); } caption { padding: 20px; font-weight: 700; font-size: 1.3rem; color: white; background: transparent; text-shadow: 0 2px 4px rgba(0,0,0,0.2); caption-side: top; } thead { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); } th { padding: 15px 20px; text-align: left; color: white; font-weight: 500; } tbody tr { border-bottom: 1px solid #eee; } tbody tr:hover { background: #f8f9fa; } td { padding: 15px 20px; color: #333; } tbody tr:last-child { border-bottom: none; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Monthly Sales
MonthRevenue
January$12,500
February$14,200
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> element" + }, + { + "type": "element_exists", + "value": "thead", + "message": "Add a <thead> for the header section" + }, + { + "type": "element_exists", + "value": "tbody", + "message": "Add a <tbody> for the data rows" + }, + { + "type": "element_count", + "value": { "selector": "tbody tr", "min": 2 }, + "message": "Add at least 2 data rows in tbody" + } + ] + }, + { + "id": "table-complete", + "title": "Complete Table with Footer", + "description": "Add <tfoot> to create a footer section for totals or summary data. The footer stays at the bottom even if tbody has many rows.

Combine all sections for a fully structured, accessible table.", + "task": "Create a complete table:
1. A <caption> with 'Order Summary'
2. A <thead> with Item and Price headers
3. A <tbody> with 2 items
4. A <tfoot> with a Total row", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #fafafa; } table { border-collapse: collapse; width: 100%; max-width: 400px; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } caption { padding: 15px 20px; font-weight: 600; font-size: 1.1rem; color: #333; text-align: left; background: #f8f9fa; border-bottom: 2px solid #eee; } th, td { padding: 12px 20px; text-align: left; } thead th { background: #2c3e50; color: white; } tbody td { border-bottom: 1px solid #eee; } tbody tr:hover { background: #f8f9fa; } tfoot { background: #ecf0f1; font-weight: 600; } tfoot td { border-top: 2px solid #2c3e50; color: #2c3e50; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Order Summary
ItemPrice
Widget$25.00
Gadget$35.00
Total$60.00
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> element" + }, + { + "type": "element_exists", + "value": "thead", + "message": "Add a <thead> section" + }, + { + "type": "element_exists", + "value": "tbody", + "message": "Add a <tbody> section" + }, + { + "type": "element_exists", + "value": "tfoot", + "message": "Add a <tfoot> section for the total" + }, + { + "type": "element_count", + "value": { "selector": "tbody tr", "min": 2 }, + "message": "Add at least 2 item rows in tbody" + } + ] + } + ] +} diff --git a/lessons/pl/31-html-marquee.json b/lessons/pl/31-html-marquee.json new file mode 100644 index 0000000..7c2939a --- /dev/null +++ b/lessons/pl/31-html-marquee.json @@ -0,0 +1,82 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-marquee", + "title": "HTML Marquee", + "description": "Create scrolling text with the classic (deprecated but fun!) marquee element", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "marquee-basic", + "title": "Scrolling Text", + "description": "The <marquee> element creates scrolling text - a classic from the early web! While deprecated, it still works in most browsers.

Note: For production, use CSS animations instead. But for learning and fun, marquee is great!", + "task": "Create a simple marquee:
1. Add a <marquee> element
2. Put some text inside like 'Welcome to my website!'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%); min-height: 150px; display: flex; align-items: center; } marquee { font-size: 2rem; color: #00ff00; text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00; font-family: 'Courier New', monospace; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "Welcome to my website!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + } + ] + }, + { + "id": "marquee-direction", + "title": "Direction & Behavior", + "description": "Control the marquee with attributes:
direction: left, right, up, down
behavior: scroll (default), slide (stops at edge), alternate (bounces)
scrollamount: speed (default is 6)", + "task": "Create a bouncing marquee:
1. Add a <marquee> element
2. Set behavior=\"alternate\" to make it bounce
3. Add some fun text", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%); min-height: 150px; display: flex; align-items: center; } marquee { font-size: 2.5rem; color: white; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); font-weight: bold; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "Bounce! Bounce! Bounce!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "behavior", "value": "alternate" }, + "message": "Add behavior=\"alternate\" to make it bounce" + } + ] + }, + { + "id": "marquee-retro", + "title": "Retro News Ticker", + "description": "Combine multiple marquee attributes for a classic news ticker effect. You can even put multiple elements inside!

Remember: This is deprecated HTML. Modern sites use CSS animations, but marquee is great for understanding web history.", + "task": "Create a news ticker:
1. A <marquee> with direction=\"left\"
2. Set scrollamount=\"5\" for smooth scrolling
3. Add a breaking news headline inside", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 0; margin: 0; background: #1a1a2e; } marquee { background: linear-gradient(90deg, #c0392b 0%, #e74c3c 50%, #c0392b 100%); padding: 15px 0; font-size: 1.3rem; color: white; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; border-top: 3px solid #f1c40f; border-bottom: 3px solid #f1c40f; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "BREAKING NEWS: Marquee element still works in browsers!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "direction", "value": "left" }, + "message": "Add direction=\"left\" for horizontal scrolling" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "scrollamount", "value": "5" }, + "message": "Add scrollamount=\"5\" for smooth speed" + } + ] + } + ] +} diff --git a/lessons/pl/32-html-svg.json b/lessons/pl/32-html-svg.json new file mode 100644 index 0000000..59b9dbb --- /dev/null +++ b/lessons/pl/32-html-svg.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-svg", + "title": "HTML SVG", + "description": "Draw scalable vector graphics directly in HTML", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "svg-circle", + "title": "Drawing Circles", + "description": "SVG (Scalable Vector Graphics) lets you draw shapes directly in HTML. The <svg> element is the container, with width and height attributes.

Use <circle> with cx, cy (center) and r (radius) to draw circles.", + "task": "Create an SVG with a circle:
1. An <svg> with width=\"200\" and height=\"200\"
2. A <circle> centered at (100,100) with radius 50
3. Add a fill color", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #f5f5f5; display: flex; justify-content: center; } svg { background: white; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_exists", + "value": "circle", + "message": "Add a <circle> element inside the SVG" + }, + { + "type": "attribute_value", + "value": { "selector": "circle", "attr": "cx", "value": "100" }, + "message": "Set cx=\"100\" for the circle's horizontal center" + }, + { + "type": "attribute_value", + "value": { "selector": "circle", "attr": "cy", "value": "100" }, + "message": "Set cy=\"100\" for the circle's vertical center" + } + ] + }, + { + "id": "svg-rect-line", + "title": "Rectangles & Lines", + "description": "Draw rectangles with <rect> using x, y, width, height.

Draw lines with <line> using x1, y1 (start) and x2, y2 (end). Lines need a stroke color!", + "task": "Create an SVG with:
1. An <svg> (200x150)
2. A <rect> at position (20,20) with size 80x60
3. A <line> from (120,30) to (180,90) with a stroke color", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 200px; display: flex; justify-content: center; align-items: center; } svg { background: white; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_exists", + "value": "rect", + "message": "Add a <rect> element" + }, + { + "type": "element_exists", + "value": "line", + "message": "Add a <line> element" + } + ] + }, + { + "id": "svg-shapes", + "title": "Multiple Shapes", + "description": "Combine shapes to create simple graphics! Add stroke for outlines and stroke-width for thickness.

Use fill=\"none\" for hollow shapes. Shapes stack in order - later elements appear on top.", + "task": "Create a simple face:
1. An <svg> (200x200)
2. A large <circle> for the face
3. Two small <circle> elements for eyes
4. A <line> for the smile", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); min-height: 250px; display: flex; justify-content: center; align-items: center; } svg { background: white; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_count", + "value": { "selector": "circle", "min": 3 }, + "message": "Add at least 3 circles (1 face + 2 eyes)" + }, + { + "type": "element_exists", + "value": "line", + "message": "Add a <line> for the smile" + } + ] + } + ] +} diff --git a/lessons/pl/flexbox.json b/lessons/pl/flexbox.json new file mode 100644 index 0000000..7b34c96 --- /dev/null +++ b/lessons/pl/flexbox.json @@ -0,0 +1,173 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "flexbox", + "title": "CSS Flexbox", + "description": "Master the flexible box layout model for modern responsive designs", + "difficulty": "intermediate", + "lessons": [ + { + "id": "flexbox-1", + "title": "Container", + "description": "Learn how to create a flex container and understand the main and cross axes.", + "task": "Add display: flex to .wrap to create a flexbox layout.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "display: flex;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "display", + "expected": "flex" + }, + "message": "Set display: flex" + } + ] + }, + { + "id": "flexbox-2", + "title": "Direction & Wrap", + "description": "Control the direction and wrapping of flex items within a container.", + "task": "Add flex-direction: column and flex-wrap: wrap to .wrap.", + "previewHTML": "
1
2
3
4
5
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; height: 16rem; display: flex; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "flex-direction: column;\n flex-wrap: wrap;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "flex-direction", + "expected": "column" + }, + "message": "Set flex-direction: column", + "options": { + "exact": true + } + }, + { + "type": "property_value", + "value": { + "property": "flex-wrap", + "expected": "wrap" + }, + "message": "Set flex-wrap: wrap", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-3", + "title": "Justify Content", + "description": "Learn how to align flex items along the main axis of the flex container.", + "task": "Add justify-content: space-between to .wrap to distribute the boxes evenly.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "justify-content: space-between;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "justify-content", + "expected": "space-between" + }, + "message": "Set justify-content: space-between", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-4", + "title": "Align Items", + "description": "Control how flex items are aligned along the cross axis of the flex container.", + "task": "Add align-items: center to .wrap to vertically center the boxes.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; display: flex; justify-content: center; } .tall { height: 6rem; } .short { height: 3rem; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; height: 10rem; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "align-items: center;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "align-items", + "expected": "center" + }, + "message": "Set align-items: center", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-5", + "title": "Flex Grow", + "description": "The flex property controls how much an item grows relative to others.", + "task": "Add flex: 2 to .box2 to make it grow twice as wide.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; display: flex; align-items: center; justify-content: center; } .box1 { background: coral; flex: 1; } .box2 { background: mediumseagreen; } .box3 { background: gold; flex: 1; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; }", + "codePrefix": ".box2 {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "flex: 2;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "flex", + "expected": "2" + }, + "message": "Set flex: 2" + } + ] + }, + { + "id": "flexbox-6", + "title": "Align Self", + "description": "Use align-self to override alignment for a single flex item.", + "task": "Add align-self: flex-start to .middle to move it to the top.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; } .middle { background: mediumseagreen; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; height: 12rem; align-items: center; }", + "codePrefix": ".middle {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "align-self: flex-start;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "align-self", + "expected": "flex-start" + }, + "message": "Set align-self: flex-start" + } + ] + } + ] +} diff --git a/lessons/uk/00-basic-selectors.json b/lessons/uk/00-basic-selectors.json new file mode 100644 index 0000000..6e55337 --- /dev/null +++ b/lessons/uk/00-basic-selectors.json @@ -0,0 +1,550 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "css-basic-selectors", + "title": "CSS Selectors", + "description": "CSS selectors are the foundation of styling web pages, allowing you to target specific HTML elements for styling. This module introduces fundamental selector types including element type selectors, class selectors, ID selectors, and the universal selector.", + "difficulty": "beginner", + "lessons": [ + { + "id": "introduction-to-selectors", + "title": "What's a Selector?", + "description": "A CSS selector is the first part of a CSS rule that tells the browser which HTML elements should receive the styles defined in the declaration block. Selectors are essentially patterns that match against elements in your HTML document. Understanding selectors is fundamental because they determine which elements your CSS rules will affect. The element or elements targeted by a selector are referred to as the 'subject of the selector.' When writing a CSS rule, you first specify the selector, followed by curly braces that contain the style declarations.
For example, to change the text color of elements, you can use the color property within your declaration block.

/* Element selector */\np {\n  color: orangered;\n  /* │       └─── Indicates the value of the expression\n     │                                                     \n     └─────────── Indicates the property of the expression */\n}
", + "task": "Write a CSS rule using a type selector that targets all paragraph elements p in the document. Make the text blue by setting the color property to blue.", + "previewHTML": "

Introduction to CSS Selectors

\n

This paragraph should turn blue.

\n
This div element should remain unchanged.
\n

This second paragraph should also turn blue.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h1, p, div { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Write a type selector to target all paragraph elements */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "p { color: blue }", + "validations": [ + { + "type": "regex", + "value": "^p\\s*{", + "message": "Start your rule with p { … } to select all paragraph elements", + "options": { + "caseSensitive": false + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color: property in your CSS rule" + }, + { + "type": "contains", + "value": "blue", + "message": "Set the color value to blue" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "blue" + }, + "message": "Use color: blue to set the text color" + }, + { + "type": "regex", + "value": "p\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": false + } + } + ] + }, + { + "id": "type-selectors", + "title": "Type Selectors", + "description": "Type selectors (also called tag name selectors or element selectors) target HTML elements based on their tag name. For example, p selects all paragraph elements, h1 selects all level-one headings, and div selects all division elements. Type selectors are the most fundamental way to select elements, applying styles consistently to all instances of a particular HTML element throughout your document. You can define a variety of CSS properties with type selectors, such as color for text color, background-color for the background, and font-weight for text emphasis. They provide a broad approach for styling your page and are often the starting point for more specific styling using other selector types.", + "task": "Write three separate CSS rules using type selectors to target specific HTML elements: make h2 headings purple, give span elements a yellow background, and make strong elements red.", + "previewHTML": "

Type Selectors Example

\n

Regular paragraph text with a highlighted span that should have a yellow background.

\n

Another paragraph with strong important text that should be red.

\n

Another Heading

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p, span, strong { padding: 3px; }", + "codePrefix": "/* Write three separate type selectors below */\n\n", + "initialCode": "/* 1. Make h2 headings purple */\n\n\n/* 2. Give span elements a yellow background */\n\n\n/* 3. Make strong elements red */\n", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "/* 1. Make h2 headings purple */\nh2 {\n color: purple;\n}\n\n/* 2. Give span elements a yellow background */\nspan {\n background-color: yellow;\n}\n\n/* 3. Make strong elements red */\nstrong {\n color: red;\n}", + "validations": [ + { + "type": "regex", + "value": "^h2\\s*{", + "message": "Include an h2 { … } selector" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "purple" + }, + "message": "Set the color property to purple for h2 elements" + }, + { + "type": "regex", + "value": "h2\\s*{[^}]*}", + "message": "Make sure to close your h2 rule with a closing brace }" + }, + { + "type": "regex", + "value": "^span\\s*{", + "message": "Include a span { … } selector" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "yellow" + }, + "message": "Set a background-color: yellow for span elements" + }, + { + "type": "regex", + "value": "span\\s*{[^}]*}", + "message": "Make sure to close your span rule with a closing brace }" + }, + { + "type": "regex", + "value": "^strong\\s*{", + "message": "Include a strong { … } selector" + }, + { + "type": "regex", + "value": "strong\\s*{\\s*color:\\s*red;[^}]*}", + "message": "Set the color: red for strong elements" + } + ] + }, + { + "id": "class-selectors", + "title": "Class Selectors", + "description": "Class selectors target elements with a specific class attribute value. They begin with a dot (.) followed by the class name. Classes are powerful because they allow you to apply the same styles to multiple elements regardless of their type. An HTML element can have multiple classes (separated by spaces in the class attribute), and a class can be applied to any number of elements. When using class selectors, you can apply properties like background-color to set the background color of elements, and font-weight to control text thickness, making text bold or normal. This flexibility makes class selectors one of the most commonly used methods for applying styles in CSS, allowing for modular and reusable styling across your website.", + "task": "Create a CSS rule using a class selector that targets elements with the class highlight. Give these elements a yellow background and bold text.", + "previewHTML": "

Using Class Selectors

\n

This is a regular paragraph, but this span has the highlight class applied to it.

\n

This entire paragraph has the highlight class.

\n", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p, li { padding: 5px; margin-bottom: 10px; }", + "codePrefix": "/* Create a class selector for elements with the 'highlight' class */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^\\.highlight\\s*{", + "message": "Start your rule with .highlight { … } to create a class selector", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color: property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "yellow" + }, + "message": "Set the background color to yellow" + }, + { + "type": "contains", + "value": "font-weight:", + "message": "Include the font-weight: property" + }, + { + "type": "property_value", + "value": { + "property": "font-weight", + "expected": "bold" + }, + "message": "Set the font-weight to bold" + }, + { + "type": "regex", + "value": "\\.highlight\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "multiple-classes", + "title": "Multiple Classes", + "description": "HTML elements can have multiple classes applied simultaneously, allowing for composable and modular CSS designs. When an element has multiple classes, it will receive styles from all matching class selectors. This approach enables you to build a library of reusable CSS classes that can be combined in different ways. You can also target elements that have a specific combination of classes by chaining class selectors together without spaces (e.g., .class1.class2). When styling these elements, you might use properties like border-color to change the color of element borders, and background-color to set the background color of elements. This technique lets you create conditional styles that only apply when certain classes appear together.", + "task": "Complete the CSS rule that targets elements with both card and featured classes by chaining the selectors. Set the border-color to gold and the background-color to lemonchiffon to make featured cards stand out.", + "previewHTML": "

Multiple Class Combinations

\n
Regular Card
\n
Featured Card
\n
Just Featured (not a card)
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } .card { border: 2px solid gray; padding: 15px; margin-bottom: 10px; border-radius: 5px; }", + "sandboxCSS": "", + "codePrefix": "/* The .card class already has basic styling */\n/* Now target elements with BOTH classes: 'card' AND 'featured' */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": ".card.featured { border-color: gold; background-color: lemonchiffon }", + "validations": [ + { + "type": "regex", + "value": "^\\.card\\.featured\\s*{", + "message": "Chain the selectors as .card.featured (no space between them)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "border-color:", + "message": "Include the border-color property" + }, + { + "type": "property_value", + "value": { + "property": "border-color", + "expected": "gold" + }, + "message": "Set the border color to gold" + }, + { + "type": "regex", + "value": "\\.card\\.featured\\s*{[^}]*;", + "message": "Make sure to end your CSS rule with a semicolon ;" + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "lemonchiffon" + }, + "message": "Set the background color to lemonchiffon" + }, + { + "type": "regex", + "value": "\\.card\\.featured\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "class-with-type", + "title": "Combining Types", + "description": "You can combine type selectors with class selectors to target specific HTML elements that have a certain class. This creates a more specific selector that only matches when both conditions are true: the element is of the specified type AND it has the specified class. For example, p.note would select paragraph elements with the class note, but would not select divs or spans with that same class. You can style these combined selections using properties like background-color to set a colored background for your elements. This approach allows you to apply different styles to the same class when it appears on different element types.", + "task": "Create a CSS rule that specifically targets <span> elements with the class highlight. Make those elements have an orange background, while other elements with the highlight class remain untouched.", + "previewHTML": "

Type and Class Combinations

\n

This paragraph has a highlighted span that should have an orange background.

\n

This paragraph has the highlight class but should NOT have an orange background.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } .highlight { font-weight: bold; }", + "sandboxCSS": "h2, p, span { padding: 5px; }", + "codePrefix": "/* The .highlight class already sets font-weight to bold */\n/* Now target ONLY span elements with the highlight class */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^span\\.highlight\\s*{", + "message": "Use span.highlight selector (no space between element and class)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "orange" + }, + "message": "Set the background color to orange" + }, + { + "type": "regex", + "value": "span\\.highlight\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "id-selectors", + "title": "ID Selectors", + "description": "ID selectors target elements with a specific id attribute. They begin with a hash/pound sign (#) followed by the ID name. Unlike classes, IDs must be unique within a document—each ID value should be used only once per page. ID selectors have higher specificity than class or element selectors, meaning they override those selectors when conflicts arise. When styling with ID selectors, you can use properties like color to define text color, and text-decoration to control the appearance of text, such as adding underlines to elements. Because of their uniqueness requirement, IDs are best used for one-of-a-kind elements like page headers, main navigation, or specific unique components that appear only once on a page.", + "task": "Create a CSS rule with an ID selector that targets the element with the ID main-title. Set its color to purple and add an underline with text-decoration: underline.", + "previewHTML": "

Main Page Title

\n

Regular paragraph content.

\n

Secondary Heading

\n

Introduction paragraph (different ID).

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h1, h2, p { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Create an ID selector to target the element with id=\"main-title\" */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^#main-title\\s*{", + "message": "Start your rule with #main-title to create an ID selector", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color property" + }, + { + "type": "property_value", + "value": { + "property": "color", + "expected": "purple" + }, + "message": "Set the color to purple" + }, + { + "type": "contains", + "value": "text-decoration:", + "message": "Include the text-decoration property" + }, + { + "type": "property_value", + "value": { + "property": "text-decoration", + "expected": "underline" + }, + "message": "Set the text-decoration to underline" + }, + { + "type": "regex", + "value": "#main-title\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "id-with-type", + "title": "Type + ID", + "description": "Similar to how you can combine type and class selectors, you can also combine type selectors with ID selectors. For example, h1#title targets an h1 element with the ID 'title'. When using this combined approach, you can apply CSS properties like font-style to control the slant of the text, making it italic or normal. While this selector combination is more specific than using just the ID selector, it's often unnecessary since IDs should already be unique in a document. However, this technique can be useful for improving code readability or when you want to emphasize that a particular ID should only appear on a specific element type.", + "task": "Create a CSS rule that combines a type selector with an ID selector to target specifically a paragraph element with the ID special. Set its font style to italic.", + "previewHTML": "

Heading with ID \"special\" (should NOT be affected)

\n

Paragraph with ID \"special\" (should become italic)

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "h2, p { padding: 8px; margin-bottom: 10px; border: 1px dashed #ccc; }", + "codePrefix": "/* Create a combined type+ID selector for a paragraph with id=\"special\" */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^p#special\\s*{", + "message": "Use p#special to target paragraphs with ID special", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "font-style:", + "message": "Include the font-style property" + }, + { + "type": "property_value", + "value": { + "property": "font-style", + "expected": "italic" + }, + "message": "Set the font-style to italic" + }, + { + "type": "regex", + "value": "p#special\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "selector-lists", + "title": "Selector Lists", + "description": "When multiple elements need the same styling, you can group them together using a selector list (also known as grouping selectors). Selector lists are created by separating individual selectors with commas. This approach reduces repetition in your CSS, making it more maintainable and efficient. For example, h1, h2, h3 { color: blue; } applies the same blue color to all three heading levels. When styling multiple selectors at once, you can apply properties like background-color to set the background, border-left to create a left border with a specific thickness, style, and color, and padding-left to create space between the content and the left border. Whitespace around commas is optional, and each selector in the list can be any valid selector type-elements, classes, IDs, or even more complex selectors.", + "task": "Create a selector list that applies the same styles to three different elements: paragraphs with class note, list items with class important, and the element with ID summary. Give them a lightyellow background, a gold left border, and some left padding.", + "previewHTML": "

This is a note paragraph.

\n\n
Summary section
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "p, li, div { padding: 8px; margin-bottom: 8px; border: 1px dashed gray; }", + "codePrefix": "/* Create a selector list to apply the same styles to multiple different elements */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "solution": "p.note,\nli.important,\n#summary {\n background-color: lightyellow;\n border-left: 3px solid gold;\n padding-left: 10px\n}", + "validations": [ + { + "type": "contains", + "value": "p.note", + "message": "Include p.note in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "li.important", + "message": "Include li.important in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "#summary", + "message": "Include #summary in your selector list", + "options": { + "caseSensitive": true + } + }, + { + "type": "regex", + "value": "(p\\.note|li\\.important|#summary)\\s*,\\s*(p\\.note|li\\.important|#summary)\\s*,\\s*(p\\.note|li\\.important|#summary)", + "message": "Create a comma-separated list with all three selectors", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "background-color:", + "message": "Include the background-color property" + }, + { + "type": "property_value", + "value": { + "property": "background-color", + "expected": "lightyellow" + }, + "message": "Set the background color to lightyellow" + }, + { + "type": "contains", + "value": "border-left:", + "message": "Include the border-left property" + }, + { + "type": "property_value", + "value": { + "property": "border-left", + "expected": "3px solid gold" + }, + "message": "Use border-left: 3px solid gold to create a left border" + }, + { + "type": "contains", + "value": "padding-left:", + "message": "Include the padding-left property" + }, + { + "type": "property_value", + "value": { + "property": "padding-left", + "expected": "10px" + }, + "message": "Use padding-left: 10px to add left padding" + } + ] + }, + { + "id": "universal-selector", + "title": "Universal (*)", + "description": "The universal selector is denoted by an asterisk (*) and matches any element of any type. It selects everything in the document or, when combined with other selectors, everything within a specific context. For example, * { margin: 0; } removes margins from all elements, while article * selects all elements inside article elements. When using the universal selector in combination with other selectors, you can apply properties like margin to control the spacing around elements. The universal selector is powerful but should be used carefully due to its broad impact. It's commonly used in CSS resets, to override default browser styling, or to target all children of a particular element.", + "task": "Use the universal selector to remove margins from all elements inside the container div. Create a rule using div.container * as the selector and set margin: 0.", + "previewHTML": "
\n

Inside Container

\n

This paragraph is inside the container.

\n \n
\n

This paragraph is outside the container and should not be affected.

", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; } div.container { border: 2px solid navy; padding: 15px; background-color: lavender; } h2, p, ul, li { margin: 15px 0; }", + "sandboxCSS": "", + "codePrefix": "/* Use the universal selector to target all elements inside the container */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^div\\.container\\s+\\*\\s*{", + "message": "Use div.container * selector (with a space between container and *)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "margin:", + "message": "Include the margin property" + }, + { + "type": "property_value", + "value": { + "property": "margin", + "expected": "0" + }, + "message": "Set margin to 0" + }, + { + "type": "regex", + "value": "div\\.container\\s+\\*\\s*{[^}]*}", + "message": "Make sure to close your CSS rule with a closing brace }", + "options": { + "caseSensitive": true + } + } + ] + }, + { + "id": "specificity-basics", + "title": "Specificity", + "description": "CSS specificity determines which styles take precedence when multiple conflicting rules target the same element. Specificity follows a hierarchical system: inline styles have the highest specificity, followed by ID selectors, then class/attribute/pseudo-class selectors, and finally element/pseudo-element selectors. This can be conceptualized as a four-part score (inline, ID, class, element). When creating multiple rules that may target the same elements, you can use the color property to set text colors, and specificity will determine which color is actually applied. Understanding specificity is crucial for predictable styling and debugging CSS conflicts. When two selectors have equal specificity, the one that comes last in the stylesheet wins.", + "task": "Examine the existing CSS rules and add a new rule with higher specificity to override the text color of the paragraph. Create a rule using '.content p' as the selector and set color: green.", + "previewHTML": "
\n

What color will this paragraph be? Look at the CSS rules and their specificity.

\n
", + "previewBaseCSS": "body { font-family: sans-serif; line-height: 1.5; padding: 20px; }", + "sandboxCSS": "p { border: 1px dashed gray; padding: 10px; }", + "codePrefix": "/* These CSS rules target the same paragraph but have different specificity */\n\n/* Rule 1: Element selector (lowest specificity) */\np {\n color: red;\n}\n\n/* Rule 2: Descendant selector (higher specificity than just 'p') */\n", + "initialCode": "", + "codeSuffix": "", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "^\\.content\\s+p\\s*{", + "message": "Use .content p as your selector (note the space between)", + "options": { + "caseSensitive": true + } + }, + { + "type": "contains", + "value": "color:", + "message": "Include the color property" + }, + { + "type": "contains", + "value": "green", + "message": "" + } + ] + } + ] +} diff --git a/lessons/uk/00-welcome.json b/lessons/uk/00-welcome.json new file mode 100644 index 0000000..ce364c4 --- /dev/null +++ b/lessons/uk/00-welcome.json @@ -0,0 +1,62 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "welcome", + "title": "Code Crispies", + "description": "Welcome to Code Crispies - your interactive web development learning platform", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "get-started", + "title": "Get Started", + "description": "Code Crispies is a free, open-source platform for learning web development through hands-on exercises. No account required!

What you'll learn:
HTML - Semantic elements, forms, tables, SVG (HTML Block & Inline, HTML Forms, HTML Tables)
CSS - Selectors, box model, flexbox, animations (CSS Selectors, CSS Box Model, CSS Flexbox)
Responsive Design - Media queries and mobile-first layouts

How it works:
1. Read the task in the left panel
2. Write code in the editor
3. See live results in the preview
4. Get instant feedback with hints

Keyboard shortcuts: Ctrl+Z to undo, Ctrl+Shift+Z to redo

More resources:
HTML over JS - Native HTML vs JavaScript solutions
Web Engineering Mandala - JavaScript technology roadmap", + "task": "Hello World", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 20px; text-align: center; } h1 { color: #6366f1; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Hello World

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "Hello", + "message": "Write 'Hello World'" + } + ] + }, + { + "id": "overview", + "title": "Overview", + "description": "You're ready! Open the menu (☰) to explore all modules.

Recommended learning path:
1. HTML Block & Inline - Understand container vs inline elements
2. HTML Forms - Build interactive forms with validation
3. CSS Selectors - Target elements precisely
4. CSS Box Model - Master padding, margin, borders
5. CSS Flexbox - Create flexible layouts
6. CSS Animations - Add motion and transitions

Tips:
• Use Show Expected to see the target result
• Your progress is saved automatically
• Try Emmet in HTML mode: ul>li*3 + Tab

Open Source:
Gitea (Source) · GitHub (Mirror)
• Made by LibreTECH · Michael Czechowski", + "task": "Click Next to continue", + "previewHTML": "

Hello World! 🌍

Hallo Welt!

Bonjour le monde!

¡Hola Mundo!

Ciao Mondo!

Olá Mundo!

こんにちは世界!

你好世界!

안녕 세상!

Привет мир!

שלום עולם!

مرحبا بالعالم!

", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 12px; } p { margin: 6px 0; padding: 6px 12px; border-radius: 6px; font-weight: 600; font-size: 0.95em; } p:nth-child(1) { background: #fef3c7; color: #92400e; font-size: 1.2em; } p:nth-child(2) { background: #dcfce7; color: #166534; } p:nth-child(3) { background: #dbeafe; color: #1e40af; } p:nth-child(4) { background: #fce7f3; color: #9d174d; } p:nth-child(5) { background: #e0e7ff; color: #4338ca; } p:nth-child(6) { background: #fef9c3; color: #854d0e; } p:nth-child(7) { background: #fee2e2; color: #991b1b; } p:nth-child(8) { background: #f3e8ff; color: #7c3aed; } p:nth-child(9) { background: #ccfbf1; color: #0f766e; } p:nth-child(10) { background: #fae8ff; color: #86198f; } p:nth-child(11) { background: #fef3c7; color: #b45309; } p:nth-child(12) { background: #d1fae5; color: #047857; }", + "sandboxCSS": "", + "initialCode": "

Hello World! 🌍

\n

Hallo Welt!

\n

Bonjour le monde!

\n

¡Hola Mundo!

\n

Ciao Mondo!

\n

Olá Mundo!

\n

こんにちは世界!

\n

你好世界!

\n

안녕 세상!

\n

Привет мир!

\n

שלום עולם!

\n

مرحبا بالعالم!

", + "solution": "

Hello World! 🌍

\n

Hallo Welt!

\n

Bonjour le monde!

\n

¡Hola Mundo!

\n

Ciao Mondo!

\n

Olá Mundo!

\n

こんにちは世界!

\n

你好世界!

\n

안녕 세상!

\n

Привет мир!

\n

שלום עולם!

\n

مرحبا بالعالم!

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "Hello", + "message": "Click Next to continue" + } + ] + }, + { + "id": "playground", + "title": "Playground", + "mode": "playground", + "description": "", + "task": "", + "previewHTML": "", + "previewBaseCSS": "", + "sandboxCSS": "", + "initialCode": "\n\n

Hello World

\n

Start coding!

", + "solution": "", + "previewContainer": "preview-area", + "validations": [] + } + ] +} diff --git a/lessons/uk/01-box-model.json b/lessons/uk/01-box-model.json new file mode 100644 index 0000000..a5b10a6 --- /dev/null +++ b/lessons/uk/01-box-model.json @@ -0,0 +1,180 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "box-model", + "title": "CSS Box Model", + "description": "Master the fundamental principles of space management in web design through the CSS box model. This module explores how content, padding, borders, and margins combine to create layout structures that are both visually appealing and structurally sound.", + "difficulty": "beginner", + "lessons": [ + { + "id": "box-model-1", + "title": "Box Model Components", + "description": "The CSS box model consists of four concentric layers: content area (innermost), padding, border, and margin (outermost). Understanding how these components interact is essential for precise layout control.", + "task": "Add padding: 1rem to .box to create space between its content and border.", + "previewHTML": "
Box Model Components
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background-color: lavender; border: 2px dashed slategray; }", + "sandboxCSS": "", + "codePrefix": ".box {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "padding: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "padding", "expected": "1rem" }, + "message": "Set padding: 1rem" + } + ] + }, + { + "id": "box-model-2", + "title": "Adding Borders", + "description": "Borders outline an element, creating visual separation from surrounding content. The border shorthand accepts three values: width, style, and color.", + "task": "Add border: 2px solid darkslategray to .box.", + "previewHTML": "
This box needs a border
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background-color: mintcream; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": ".box {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "border: 2px solid darkslategray;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "border:\\s*2px\\s+solid\\s+darkslategray", + "message": "Set border: 2px solid darkslategray", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "box-model-3", + "title": "Adding Margins", + "description": "Margins create space between elements, controlling how they relate to one another within a layout. Unlike padding (which affects internal spacing), margins exist outside the element's border.", + "task": "Add margin: 1rem to .outer to create space between it and the adjacent element.", + "previewHTML": "
This box needs margins
Adjacent element
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .container { background-color: whitesmoke; padding: 8px; } .outer { background-color: plum; padding: 1rem; border: 2px solid orchid; } .neighbor { background-color: lightblue; padding: 1rem; border: 2px solid steelblue; }", + "sandboxCSS": "", + "codePrefix": ".outer {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "margin", "expected": "1rem" }, + "message": "Set margin: 1rem" + } + ] + }, + { + "id": "box-model-4", + "title": "Box Sizing: Border-Box", + "description": "The box-sizing property determines how element dimensions are calculated. The default content-box excludes padding and border from width/height, while border-box includes them, making layout calculations more intuitive.", + "task": "Add box-sizing: border-box to .sized so padding and border are included in its width.", + "previewHTML": "
Content-box (default)
Border-box
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .sizing-demo { display: flex; gap: 1rem; } .box { width: 200px; padding: 1rem; border: 4px solid teal; background: lightcyan; } .default { box-sizing: content-box; }", + "sandboxCSS": "", + "codePrefix": ".sized {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "box-sizing: border-box;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "box-sizing", "expected": "border-box" }, + "message": "Set box-sizing: border-box" + } + ] + }, + { + "id": "box-model-5", + "title": "Margin Collapse", + "description": "When two vertical margins meet, they collapse to the larger value instead of adding up. Understanding this behavior is crucial for consistent vertical spacing.", + "task": "Add margin-bottom: 2rem to .first. Notice the space between paragraphs equals 2rem (not 3rem) due to margin collapse.", + "previewHTML": "

This paragraph has a bottom margin.

This paragraph has a top margin of 1rem.

", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .collapse-demo { border: 1px solid silver; padding: 8px; background: ghostwhite; } .second { margin-top: 1rem; background: linen; }", + "sandboxCSS": "", + "codePrefix": ".first {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin-bottom: 2rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "margin-bottom", "expected": "2rem" }, + "message": "Set margin-bottom: 2rem" + } + ] + }, + { + "id": "box-model-6", + "title": "Margin Shorthand Notation", + "description": "The margin shorthand can set all four sides at once. Two values set vertical (top/bottom) and horizontal (left/right) margins respectively.", + "task": "Add margin: 1rem 2rem to .spaced for 1rem top/bottom and 2rem left/right.", + "previewHTML": "
This box needs margins: 1rem top/bottom, 2rem left/right
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .container { background-color: whitesmoke; padding: 8px; } .spaced { background-color: honeydew; border: 2px solid mediumseagreen; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": ".spaced {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "margin: 1rem 2rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "margin:\\s*1rem\\s+2rem", + "message": "Set margin: 1rem 2rem", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "box-model-7", + "title": "Padding Shorthand Notation", + "description": "Like margin, padding shorthand allows setting all sides at once. A single value applies to all four sides equally.", + "task": "Add padding: 1.5rem to .padded to add equal padding on all sides.", + "previewHTML": "
This box needs equal padding on all sides
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .padded { background-color: papayawhip; border: 2px solid orange; }", + "sandboxCSS": "", + "codePrefix": ".padded {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "padding: 1.5rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "padding", "expected": "1.5rem" }, + "message": "Set padding: 1.5rem" + } + ] + }, + { + "id": "box-model-8", + "title": "Border on Specific Sides", + "description": "For granular control, you can target specific sides with border-top, border-right, border-bottom, or border-left.", + "task": "Add border-bottom: 4px solid dodgerblue to .line.", + "previewHTML": "
This element needs only a bottom border
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .line { padding: 1rem; background-color: aliceblue; }", + "sandboxCSS": "", + "codePrefix": ".line {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "border-bottom: 4px solid dodgerblue;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "border-bottom:\\s*4px\\s+solid\\s+dodgerblue", + "message": "Set border-bottom: 4px solid dodgerblue", + "options": { "caseSensitive": false } + } + ] + } + ] +} diff --git a/lessons/uk/05-units-variables.json b/lessons/uk/05-units-variables.json new file mode 100644 index 0000000..67a9272 --- /dev/null +++ b/lessons/uk/05-units-variables.json @@ -0,0 +1,116 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "units-variables", + "title": "CSS Units & Variables", + "description": "Understand the variety of CSS measurement units and how to define and use custom properties for maintainable styles.", + "difficulty": "beginner", + "lessons": [ + { + "id": "units-1", + "title": "Absolute vs. Relative Units", + "description": "Learn the difference between px, rem, em, %, and vw/vh for flexible, responsive layouts.", + "task": "Set the width of .box to 80% and max-width to 37.5rem.", + "previewHTML": "
Resize me!
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .box { background: #f5f5f5; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Set flexible sizing */\n.box {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: 80%;\n max-width: 37.5rem;", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "width", "message": "Use width property", "options": { "caseSensitive": false } }, + { "type": "property_value", "value": { "property": "width", "expected": "80%" }, "message": "Set width to 80%" }, + { "type": "contains", "value": "max-width", "message": "Use max-width property", "options": { "caseSensitive": false } }, + { + "type": "property_value", + "value": { "property": "max-width", "expected": "37.5rem" }, + "message": "Set max-width to 37.5rem" + } + ] + }, + { + "id": "units-2", + "title": "CSS Custom Properties", + "description": "Define and reuse variables (--custom properties) to centralize your theme values.", + "task": "Create a --main-color variable in :root with #6200ee and apply it as the border color on .themed.", + "previewHTML": "
Variable Box
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .themed { padding: 1rem; border: 0.125rem solid #ddd; }", + "sandboxCSS": "", + "codePrefix": "/* Define and use a CSS variable */\n:root {", + "initialCode": "", + "codeSuffix": "}\n.themed { }", + "solution": " --main-color: #6200ee;\n}\n.themed {\n border-color: var(--main-color);", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "--main-color", + "message": "Define --main-color in :root", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": "var(--main-color)", + "message": "Use var(--main-color)", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "border", "expected": "var(--main-color)" }, + "message": "Apply variable to border color", + "options": { "exact": false } + } + ] + }, + { + "id": "units-3", + "title": "Unit Calculations (calc)", + "description": "Use the calc() function to combine different units in one expression.", + "task": "Set the width of .sized to calc(100% - 2rem) and min-height to calc(10vh + 1rem).", + "previewHTML": "
Calc Demo
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .sized { background: #e8f5e9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Use calc for dynamic sizing */\n.sized {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: calc(100% - 2rem);\n min-height: calc(10vh + 1rem);", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "calc", "message": "Use calc() function", "options": { "caseSensitive": false } }, + { + "type": "regex", + "value": "width:\\s*calc\\(100% - 2rem\\)", + "message": "Width should be calc(100% - 2rem)", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "min-height:\\s*calc\\(10vh \\+ 1rem\\)", + "message": "Min-height should be calc(10vh + 1rem)", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "units-4", + "title": "Viewport & Responsive Units", + "description": "Control layouts relative to viewport size with vw, vh, and vmin/vmax units.", + "task": "Give .view a width of 50vw and height of 20vh.", + "previewHTML": "
Viewport Box
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .view { background: #ffe0b2; }", + "sandboxCSS": "", + "codePrefix": "/* Use viewport units */\n.view {", + "initialCode": "", + "codeSuffix": "}", + "solution": " width: 50vw;\n height: 20vh;", + "previewContainer": "preview-area", + "validations": [ + { "type": "contains", "value": "vw", "message": "Use vw unit", "options": { "caseSensitive": false } }, + { "type": "contains", "value": "vh", "message": "Use vh unit", "options": { "caseSensitive": false } }, + { "type": "property_value", "value": { "property": "width", "expected": "50vw" }, "message": "Set width to 50vw" }, + { "type": "property_value", "value": { "property": "height", "expected": "20vh" }, "message": "Set height to 20vh" } + ] + } + ] +} diff --git a/lessons/uk/06-transitions-animations.json b/lessons/uk/06-transitions-animations.json new file mode 100644 index 0000000..2697fd7 --- /dev/null +++ b/lessons/uk/06-transitions-animations.json @@ -0,0 +1,145 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "transitions-animations", + "title": "CSS Animations", + "description": "Bring interactivity to your UI by smoothly transitioning properties and creating keyframe-driven animations.", + "difficulty": "beginner", + "lessons": [ + { + "id": "transitions-1", + "title": "Transitions", + "description": "Learn how to apply transition to properties for smooth changes on state changes.", + "task": "Add transition: background-color 0.3s to .btn so the color fades smoothly on hover.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .btn { background: black; color: white; padding: 0.5rem 1rem; border: none; cursor: pointer; } .btn:hover { background: white; color: black; }", + "sandboxCSS": "", + "codePrefix": "/* Add transition */\n.btn {", + "initialCode": "", + "codeSuffix": "}", + "solution": " transition: background-color 0.3s;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "transition", + "message": "Use the transition property", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "transition:\\s*background-color\\s*0\\.3s", + "message": "Set transition: background-color 0.3s", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "transitions-2", + "title": "Timing Funcs", + "description": "Explore easing functions like ease, linear, ease-in, ease-out to control animation pacing.", + "task": "Set transition-timing-function to ease-in-out on .btn.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .btn { background: navy; color: gold; padding: 0.5rem 1rem; border: none; cursor: pointer; transition: all 0.5s; } .btn:hover { background: gold; color: navy; transform: scale(1.1); }", + "sandboxCSS": "", + "codePrefix": "/* Set timing function */\n.btn {", + "initialCode": "", + "codeSuffix": "}", + "solution": " transition-timing-function: ease-in-out;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "transition-timing-function", + "message": "Use transition-timing-function", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "transition-timing-function", "expected": "ease-in-out" }, + "message": "Set timing to ease-in-out" + } + ] + }, + { + "id": "transitions-3", + "title": "Keyframes", + "description": "Create named animations using @keyframes and apply them via the animation shorthand.", + "task": "Define a keyframe at 50% with transform: translateY(-20px) and apply animation: bounce 1s infinite to .ball.", + "previewHTML": "
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .ball { width: 50px; height: 50px; background: crimson; border-radius: 50%; margin: 2rem auto; }", + "sandboxCSS": "", + "codePrefix": "/* Define keyframes and apply animation */\n@keyframes bounce {", + "initialCode": "", + "codeSuffix": "}\n.ball { }", + "solution": " 50% { transform: translateY(-20px); }\n}\n.ball {\n animation: bounce 1s infinite;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "contains", + "value": "@keyframes bounce", + "message": "Define @keyframes bounce", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "50%.*transform: translateY\\(-20px\\)", + "message": "At 50%, use transform: translateY(-20px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": "animation", + "message": "Use animation property on .ball", + "options": { "caseSensitive": false } + }, + { + "type": "regex", + "value": "animation:.*bounce.*1s.*infinite", + "message": "Apply animation: bounce 1s infinite", + "options": { "caseSensitive": false } + } + ] + }, + { + "id": "transitions-4", + "title": "Anim Properties", + "description": "Fine-tune animations with animation-delay, animation-iteration-count, animation-direction, and animation-fill-mode.", + "task": "Apply the pulse animation to .box with animation-name: pulse, animation-duration: 2s, animation-delay: 1s, animation-iteration-count: 2, and animation-fill-mode: forwards.", + "previewHTML": "
Pulse
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .box { width: 100px; height: 100px; background: black; color: white; display: flex; align-items: center; justify-content: center; margin: 2rem auto; } @keyframes pulse { 0% { background: black; color: white; transform: scale(1); } 50% { background: white; color: black; transform: scale(1.2); } 100% { background: limegreen; color: black; transform: scale(1); } }", + "sandboxCSS": "", + "codePrefix": "/* Apply animation properties */\n.box {", + "initialCode": "", + "codeSuffix": "}", + "solution": " animation-name: pulse;\n animation-duration: 2s;\n animation-delay: 1s;\n animation-iteration-count: 2;\n animation-fill-mode: forwards;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "animation-name", "expected": "pulse" }, + "message": "Set animation-name: pulse" + }, + { + "type": "property_value", + "value": { "property": "animation-duration", "expected": "2s" }, + "message": "Set animation-duration: 2s" + }, + { + "type": "property_value", + "value": { "property": "animation-delay", "expected": "1s" }, + "message": "Set animation-delay: 1s" + }, + { + "type": "property_value", + "value": { "property": "animation-iteration-count", "expected": "2" }, + "message": "Set animation-iteration-count: 2" + }, + { + "type": "property_value", + "value": { "property": "animation-fill-mode", "expected": "forwards" }, + "message": "Set animation-fill-mode: forwards" + } + ] + } + ] +} diff --git a/lessons/uk/08-responsive.json b/lessons/uk/08-responsive.json new file mode 100644 index 0000000..0db9b98 --- /dev/null +++ b/lessons/uk/08-responsive.json @@ -0,0 +1,126 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "responsive-design", + "title": "CSS Responsive Design", + "description": "Make your layouts adapt to different screen sizes using media queries and fluid design techniques.", + "difficulty": "intermediate", + "lessons": [ + { + "id": "responsive-1", + "title": "Media Queries", + "description": "Understand the syntax and use cases for CSS media queries to apply styles conditionally based on viewport characteristics.", + "task": "Write a media query with @media (max-width: 600px) that changes .panel background to lightcoral.", + "previewHTML": "
Resize the window
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .panel { padding: 1rem; background: lightblue; }", + "sandboxCSS": "", + "codePrefix": "/* Add your media query below */\n", + "initialCode": "", + "codeSuffix": "", + "solution": "@media (max-width: 600px) {\n .panel {\n background: lightcoral;\n }\n}", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "@media\\s*\\(max-width:\\s*600px\\)", + "message": "Use @media (max-width: 600px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": ".panel", + "message": "Target .panel inside the media query", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "background", "expected": "lightcoral" }, + "message": "Set background: lightcoral", + "options": { "exact": false } + } + ] + }, + { + "id": "responsive-2", + "title": "Fluid Type", + "description": "Use relative units like vw to make font sizes scale with the viewport width.", + "task": "Set font-size: 5vw on .text so it scales as the viewport changes.", + "previewHTML": "

Fluid Typography

", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Apply fluid font sizing */\n.text {", + "initialCode": "", + "codeSuffix": "}", + "solution": " font-size: 5vw;", + "previewContainer": "preview-area", + "validations": [ + { "type": "property_value", "value": { "property": "font-size", "expected": "5vw" }, "message": "Set font-size: 5vw" } + ] + }, + { + "id": "responsive-3", + "title": "Flex Grids", + "description": "Combine CSS Grid with auto-fit or auto-fill for responsive column layouts.", + "task": "Add display: grid, grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)), and gap: 1rem to .cards.", + "previewHTML": "
1
2
3
4
", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .cards > div { background: #d1c4e9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Create a responsive grid */\n.cards {", + "initialCode": "", + "codeSuffix": "}", + "solution": " display: grid;\n grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));\n gap: 1rem;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { "property": "display", "expected": "grid" }, + "message": "Set display: grid" + }, + { + "type": "regex", + "value": "repeat\\(auto-fit,\\s*minmax\\(200px,\\s*1fr\\)\\)", + "message": "Use repeat(auto-fit, minmax(200px, 1fr))", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "gap", "expected": "1rem" }, + "message": "Set gap: 1rem" + } + ] + }, + { + "id": "responsive-4", + "title": "Mobile-First", + "description": "Adopt a mobile-first approach by writing base styles for small screens and enhancing for larger viewports.", + "task": "Write a media query with @media (min-width: 768px) that sets .sidebar width to 250px.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: sans-serif; padding: 1rem; } .sidebar { background: #c8e6c9; padding: 1rem; }", + "sandboxCSS": "", + "codePrefix": "/* Add mobile-first enhancement */\n", + "initialCode": "", + "codeSuffix": "", + "solution": "@media (min-width: 768px) {\n .sidebar {\n width: 250px;\n }\n}", + "previewContainer": "preview-area", + "validations": [ + { + "type": "regex", + "value": "@media\\s*\\(min-width:\\s*768px\\)", + "message": "Use @media (min-width: 768px)", + "options": { "caseSensitive": false } + }, + { + "type": "contains", + "value": ".sidebar", + "message": "Target .sidebar inside media query", + "options": { "caseSensitive": false } + }, + { + "type": "property_value", + "value": { "property": "width", "expected": "250px" }, + "message": "Set width: 250px", + "options": { "exact": false } + } + ] + } + ] +} diff --git a/lessons/uk/20-html-elements.json b/lessons/uk/20-html-elements.json new file mode 100644 index 0000000..93f9214 --- /dev/null +++ b/lessons/uk/20-html-elements.json @@ -0,0 +1,97 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-elements", + "title": "HTML Block & Inline", + "description": "Understanding the fundamental difference between container (block) and inline elements", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "block-vs-inline-intro", + "title": "Block vs Inline Elements", + "description": "HTML elements fall into two main categories:

Block elements (containers) start on a new line and take full width. Examples: <div>, <p>, <h1>, <section>

Inline elements flow within text and only take needed width. Examples: <span>, <a>, <strong>, <em>", + "task": "Wrap the word important with <strong> tags to make it bold. Notice how the paragraph (block) takes full width while strong (inline) flows with text.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 20px; } p { background: #e3f2fd; padding: 10px; } strong { background: #ffecb3; }", + "sandboxCSS": "", + "initialCode": "

This is a paragraph with an important word.

", + "solution": "

This is a paragraph with an important word.

", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "p", + "message": "Add a <p> paragraph element" + }, + { + "type": "parent_child", + "value": { "parent": "p", "child": "strong" }, + "message": "Wrap the word important with <strong> tags" + } + ] + }, + { + "id": "semantic-containers", + "title": "Semantic Tags", + "description": "Modern HTML uses semantic containers that describe their content:

<header> - Page or section header
<nav> - Navigation links
<main> - Main content area
<section> - Thematic grouping
<article> - Self-contained content
<footer> - Page or section footer", + "task": "Create a basic page structure:
1. Add a <header> with an <h1> containing the text 'My Website'
2. Add a <main> element with a paragraph saying 'Welcome to my site!'
3. Add a <footer> with a paragraph saying 'Copyright 2025'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; margin: 0; } header { background: #1976d2; color: white; padding: 15px; } main { padding: 20px; min-height: 100px; } footer { background: #424242; color: white; padding: 10px; text-align: center; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "
\n

My Website

\n
\n
\n

Welcome to my site!

\n
\n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "header", + "message": "Add a <header> element" + }, + { + "type": "element_exists", + "value": "main", + "message": "Add a <main> element" + }, + { + "type": "element_exists", + "value": "footer", + "message": "Add a <footer> element" + }, + { + "type": "parent_child", + "value": { "parent": "header", "child": "h1" }, + "message": "Add an <h1> heading inside your header" + } + ] + }, + { + "id": "div-vs-span", + "title": "div & span", + "description": "When you need a container without semantic meaning:

<div> - Generic block container (for layout/grouping)
<span> - Generic inline container (for styling text portions)

Use semantic elements when possible, div/span when no semantic element fits.", + "task": "Wrap the word 'highlighted' in a <span> to style it differently. Wrap the whole quote in a <div>.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: Georgia, serif; padding: 20px; } div { background: #f5f5f5; padding: 15px; border-left: 4px solid #1976d2; } span { background: #fff59d; padding: 2px 4px; }", + "sandboxCSS": "", + "initialCode": "The most highlighted moment was unforgettable.", + "solution": "
The most highlighted moment was unforgettable.
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "div", + "message": "Wrap everything in a <div> element" + }, + { + "type": "element_exists", + "value": "span", + "message": "Add a <span> around the word highlighted" + }, + { + "type": "element_text", + "value": { "selector": "span", "text": "highlighted" }, + "message": "The <span> should contain the word highlighted" + } + ] + } + ] +} diff --git a/lessons/uk/21-html-forms-basic.json b/lessons/uk/21-html-forms-basic.json new file mode 100644 index 0000000..d971cbf --- /dev/null +++ b/lessons/uk/21-html-forms-basic.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-forms-basic", + "title": "HTML Forms", + "description": "Learn to create forms with various input types", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "form-structure", + "title": "Form Structure", + "description": "Every form needs a <form> wrapper. Inside, use <label> to describe inputs and <input> for user data entry.

The for attribute on labels should match the id on inputs for accessibility.", + "task": "Create a form with:
1. A <label> with the text 'Name:' and for=\"name\" attribute
2. A text <input> with id=\"name\" and name=\"name\" attributes", + "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": "Wrap everything in a <form> element" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for your input" + }, + { + "type": "element_exists", + "value": "input", + "message": "Add an <input> element" + }, + { + "type": "attribute_value", + "value": { "selector": "label", "attr": "for", "value": null }, + "message": "Add a for attribute to your label" + }, + { + "type": "attribute_value", + "value": { "selector": "input", "attr": "id", "value": null }, + "message": "Add an id attribute to your input" + } + ] + }, + { + "id": "input-types", + "title": "Input Types", + "description": "Different input types provide appropriate keyboards and validation:

type=\"text\" - General text
type=\"email\" - Email with @ validation
type=\"password\" - Hidden characters
type=\"number\" - Numeric keyboard
type=\"tel\" - Phone keyboard", + "task": "Create a login form with two fields:
1. An email field: <label for=\"email\">Email:</label> and <input type=\"email\" id=\"email\">
2. A password field: <label for=\"password\">Password:</label> and <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": "Add an input with type=\"email\"" + }, + { + "type": "element_exists", + "value": "input[type='password']", + "message": "Add an input with type=\"password\"" + }, + { + "type": "element_count", + "value": { "selector": "label", "min": 2 }, + "message": "Add labels for both inputs" + } + ] + }, + { + "id": "submit-button", + "title": "Submit Button", + "description": "Forms need a way to submit data. Use:

<button type=\"submit\"> - Preferred, flexible content
<input type=\"submit\"> - Simple text-only button

The button text should be action-oriented (e.g., 'Sign In', 'Register', 'Send').", + "task": "Add a submit button to the form with the text 'Sign In'.", + "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": "Add a submit button to your form" + }, + { + "type": "element_text", + "value": { "selector": "button", "text": "Sign In" }, + "message": "The button should say Sign In" + } + ] + } + ] +} diff --git a/lessons/uk/22-html-forms-validation.json b/lessons/uk/22-html-forms-validation.json new file mode 100644 index 0000000..72f4cd1 --- /dev/null +++ b/lessons/uk/22-html-forms-validation.json @@ -0,0 +1,112 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-forms-validation", + "title": "HTML Validation", + "description": "Learn HTML5 built-in form validation attributes", + "mode": "html", + "difficulty": "intermediate", + "lessons": [ + { + "id": "required-fields", + "title": "Required Fields", + "description": "The required attribute prevents form submission if the field is empty.

Add it to any input that must be filled:
<input type=\"text\" required>

The browser shows a validation message automatically.", + "task": "Make both the name and email fields required by adding the required attribute.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 350px; } label { display: block; margin-top: 15px; margin-bottom: 5px; } label:first-of-type { margin-top: 0; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } input:invalid { border-color: #d32f2f; } button { margin-top: 20px; padding: 10px 20px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; }", + "sandboxCSS": "", + "initialCode": "
\n \n \n \n \n \n \n \n
", + "solution": "
\n \n \n \n \n \n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "input[name='name']", "attr": "required", "value": true }, + "message": "Add the required attribute to the name input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[name='email']", "attr": "required", "value": true }, + "message": "Add the required attribute to the email input" + } + ] + }, + { + "id": "input-constraints", + "title": "Constraints", + "description": "Control what users can enter:

minlength / maxlength - Text length limits
min / max - Number range
pattern - Regex pattern matching
placeholder - Hint text (not a label!)", + "task": "Add validation to the password input:
1. Add minlength=\"8\" for minimum length
2. Add maxlength=\"20\" for maximum length
3. Add placeholder=\"Enter password\" as a hint", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 350px; } label { display: block; margin-bottom: 5px; } input { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; } input:invalid:not(:placeholder-shown) { border-color: #d32f2f; } small { display: block; font-size: 12px; color: #666; margin-top: 4px; } button { margin-top: 20px; padding: 10px 20px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; }", + "sandboxCSS": "", + "initialCode": "
\n \n \n Must be 8-20 characters\n \n \n
", + "solution": "
\n \n \n Must be 8-20 characters\n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "minlength", "value": "8" }, + "message": "Add minlength=\"8\" to the password input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "maxlength", "value": "20" }, + "message": "Add maxlength=\"20\" to the password input" + }, + { + "type": "attribute_value", + "value": { "selector": "input[type='password']", "attr": "placeholder", "value": null }, + "message": "Add a placeholder to hint what to enter" + } + ] + }, + { + "id": "complete-registration", + "title": "Full Form", + "description": "Build a complete registration form with all validation concepts:

- Required fields marked with *
- Email validation (use type=\"email\")
- Password with length constraints
- Terms checkbox (required)
- Submit button", + "task": "Complete the registration form. Add required attributes, proper input types, and validation constraints.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } form { max-width: 400px; background: #f5f5f5; padding: 25px; border-radius: 8px; } h2 { margin-top: 0; margin-bottom: 20px; } label { display: block; margin-top: 15px; margin-bottom: 5px; font-weight: 500; } input[type='text'], input[type='email'], input[type='password'] { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 14px; } input:focus { outline: 2px solid #1976d2; border-color: transparent; } input[type='checkbox'] { width: auto; margin-right: 8px; vertical-align: middle; } label:has(input[type='checkbox']) { display: flex; align-items: center; font-weight: normal; } button { width: 100%; margin-top: 20px; padding: 12px; background: #1976d2; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; font-weight: 500; } button:hover { background: #1565c0; }", + "sandboxCSS": "", + "initialCode": "
\n

Create Account

\n \n \n \n \n \n \n \n \n \n \n \n \n \n
", + "solution": "
\n

Create Account

\n \n \n \n \n \n \n \n \n \n \n \n \n \n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "#fullname", "attr": "required", "value": true }, + "message": "Make the full name field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#email", "attr": "type", "value": "email" }, + "message": "Set the email input type=\"email\"" + }, + { + "type": "attribute_value", + "value": { "selector": "#email", "attr": "required", "value": true }, + "message": "Make the email field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "type", "value": "password" }, + "message": "Set the password input type=\"password\"" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "required", "value": true }, + "message": "Make the password field required" + }, + { + "type": "attribute_value", + "value": { "selector": "#password", "attr": "minlength", "value": "8" }, + "message": "Add minlength=\"8\" to password" + }, + { + "type": "attribute_value", + "value": { "selector": "#terms", "attr": "required", "value": true }, + "message": "Make the terms checkbox required" + } + ] + } + ] +} diff --git a/lessons/uk/23-html-details-summary.json b/lessons/uk/23-html-details-summary.json new file mode 100644 index 0000000..3c60ad0 --- /dev/null +++ b/lessons/uk/23-html-details-summary.json @@ -0,0 +1,97 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-details-summary", + "title": "HTML Details & Summary", + "description": "Create expandable content sections without JavaScript", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "details-summary-basic", + "title": "First Widget", + "description": "The <details> element creates a collapsible section. The <summary> provides the clickable label.

Click the summary to toggle the hidden content - no JavaScript needed!", + "task": "Create a <details> element with:
1. A <summary> saying 'Click to reveal'
2. A <p> with the text 'This content was hidden!'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } details { border: 1px solid #ddd; border-radius: 8px; padding: 15px; } summary { font-weight: 600; cursor: pointer; } summary:hover { color: #1976d2; } details p { margin-top: 15px; color: #666; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "
\n Click to reveal\n

This content was hidden!

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "details", + "message": "Add a <details> element" + }, + { + "type": "element_exists", + "value": "summary", + "message": "Add a <summary> inside the details" + }, + { + "type": "parent_child", + "value": { "parent": "details", "child": "summary" }, + "message": "The <summary> must be inside <details>" + }, + { + "type": "parent_child", + "value": { "parent": "details", "child": "p" }, + "message": "Add a <p> inside <details> for the hidden content" + } + ] + }, + { + "id": "details-open-attribute", + "title": "Pre-expanded Details", + "description": "By default, <details> is closed. Add the open attribute to show the content initially.

This is a boolean attribute - just add open without a value.", + "task": "Add the open attribute to the <details> element to show the content by default.", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } details { border: 1px solid #ddd; border-radius: 8px; padding: 15px; background: #f9f9f9; } summary { font-weight: 600; cursor: pointer; } details p { margin-top: 15px; color: #666; }", + "sandboxCSS": "", + "initialCode": "
\n FAQ: What is HTML5?\n

HTML5 is the latest version of the HTML standard with new semantic elements and APIs.

\n
", + "solution": "
\n FAQ: What is HTML5?\n

HTML5 is the latest version of the HTML standard with new semantic elements and APIs.

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "attribute_value", + "value": { "selector": "details", "attr": "open", "value": true }, + "message": "Add the open attribute to <details>" + } + ] + }, + { + "id": "faq-accordion", + "title": "FAQ Accordion", + "description": "Multiple <details> elements create an accordion-style FAQ. Each question can be expanded independently.

Pro tip: Type details*3>summary+p and press Tab for Emmet expansion. *3 creates 3 elements, > nests inside, + adds siblings.", + "task": "Create an FAQ section with:
1. An <h1> saying 'Frequently Asked Questions'
2. Three <details> elements, each with a question in <summary> and an answer in <p>", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; min-height: 100vh; background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); display: flex; flex-direction: column; justify-content: center; padding: 40px; margin: 0; box-sizing: border-box; } h1 { font-size: 2.5rem; color: #4a4a4a; text-align: center; margin: 0 0 30px 0; } details { background: white; border-radius: 12px; margin-bottom: 15px; padding: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } summary { font-size: 1.3rem; font-weight: 600; color: #5c5c5c; cursor: pointer; list-style: none; } summary::before { content: '▸ '; color: #fcb69f; } details[open] summary::before { content: '▾ '; } details p { margin: 15px 0 0 0; color: #666; line-height: 1.6; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Frequently Asked Questions

\n\n
\n What is HTML5?\n

HTML5 is the latest version of HTML with new semantic elements and APIs.

\n
\n\n
\n Do I need JavaScript?\n

Many interactive features work with pure HTML5, no JavaScript required!

\n
\n\n
\n Is this accessible?\n

Yes! Native HTML elements have built-in keyboard and screen reader support.

\n
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "h1", + "message": "Add an <h1> heading for the FAQ title" + }, + { + "type": "element_count", + "value": { "selector": "details", "min": 3 }, + "message": "Create at least 3 <details> elements for the FAQ" + }, + { + "type": "element_count", + "value": { "selector": "summary", "min": 3 }, + "message": "Each <details> needs a <summary> for the question" + }, + { + "type": "element_count", + "value": { "selector": "details p", "min": 3 }, + "message": "Each <details> needs a <p> for the answer" + } + ] + } + ] +} diff --git a/lessons/uk/24-html-progress-meter.json b/lessons/uk/24-html-progress-meter.json new file mode 100644 index 0000000..28b3bf3 --- /dev/null +++ b/lessons/uk/24-html-progress-meter.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-progress-meter", + "title": "HTML Progress & Meter", + "description": "Display completion status and scalar measurements natively", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "progress-basic", + "title": "Progress Bars", + "description": "The <progress> element shows task completion. Use value for current progress and max for the total.

Note: This is not a self-closing tag! Write <progress>...</progress> with fallback text inside for older browsers.", + "task": "Create a progress bar showing 70% completion:
1. Add a <label> saying 'Download:'
2. Add a <progress> with value=\"70\" and max=\"100\"", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } label { display: block; margin-bottom: 8px; font-weight: 500; } progress { width: 100%; height: 20px; border-radius: 10px; } progress::-webkit-progress-bar { background: #e0e0e0; border-radius: 10px; } progress::-webkit-progress-value { background: linear-gradient(90deg, #4caf50, #8bc34a); border-radius: 10px; } progress::-moz-progress-bar { background: linear-gradient(90deg, #4caf50, #8bc34a); border-radius: 10px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n70%", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "progress", + "message": "Add a <progress> element" + }, + { + "type": "attribute_value", + "value": { "selector": "progress", "attr": "value", "value": "70" }, + "message": "Set value=\"70\" on the progress element" + }, + { + "type": "attribute_value", + "value": { "selector": "progress", "attr": "max", "value": "100" }, + "message": "Set max=\"100\" on the progress element" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for the progress bar" + } + ] + }, + { + "id": "progress-indeterminate", + "title": "Indeterminate Progress", + "description": "When progress is unknown (like loading), omit the value attribute. This creates an animated indeterminate state.

Useful for network requests or processes with unknown duration.", + "task": "Create a loading indicator:
1. Add a <p> saying 'Loading...'
2. Add a <progress> without a value attribute", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } p { margin-bottom: 10px; color: #666; } progress { width: 100%; height: 8px; border-radius: 4px; } progress::-webkit-progress-bar { background: #e0e0e0; border-radius: 4px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "

Loading...

\n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "progress", + "message": "Add a <progress> element" + }, + { + "type": "element_exists", + "value": "p", + "message": "Add a <p> with loading text" + } + ] + }, + { + "id": "meter-gauge", + "title": "Meter Gauges", + "description": "The <meter> element displays a scalar value within a range. Use it for measurements like disk space, battery, or ratings.

Set low, high, and optimum to define good/bad ranges - the browser colors it accordingly!", + "task": "Create a battery level meter:
1. Add a <label> saying 'Battery:'
2. Add a <meter> with:
- value=\"0.8\"
- min=\"0\" and max=\"1\"
- low=\"0.2\" and high=\"0.8\"
- optimum=\"1\"", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; } label { display: block; margin-bottom: 8px; font-weight: 500; } meter { width: 100%; height: 25px; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n80%", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "meter", + "message": "Add a <meter> element" + }, + { + "type": "attribute_value", + "value": { "selector": "meter", "attr": "value", "value": "0.8" }, + "message": "Set value=\"0.8\" on the meter" + }, + { + "type": "attribute_value", + "value": { "selector": "meter", "attr": "low", "value": "0.2" }, + "message": "Set low=\"0.2\" to define the low threshold" + }, + { + "type": "element_exists", + "value": "label", + "message": "Add a <label> for the meter" + } + ] + } + ] +} diff --git a/lessons/uk/30-html-tables.json b/lessons/uk/30-html-tables.json new file mode 100644 index 0000000..1bdfaeb --- /dev/null +++ b/lessons/uk/30-html-tables.json @@ -0,0 +1,127 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-tables", + "title": "HTML Tables", + "description": "Create structured data tables with headers and captions", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "table-basic", + "title": "Basic Table Structure", + "description": "Tables use <table> with <tr> for rows. Inside rows, use <th> for headers and <td> for data cells.

The <caption> element provides an accessible title for the table.", + "task": "Create a simple table with:
1. A <caption> saying 'Fruit Prices'
2. A header row with 'Fruit' and 'Price' columns
3. At least 2 data rows", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #f5f5f5; } table { border-collapse: collapse; width: 100%; max-width: 400px; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } caption { padding: 15px; font-weight: 600; font-size: 1.2rem; color: #333; background: #f8f9fa; } th, td { padding: 12px 20px; text-align: left; border-bottom: 1px solid #eee; } th { background: #3498db; color: white; font-weight: 500; } tr:hover { background: #f8f9fa; } tr:last-child td { border-bottom: none; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n
Fruit Prices
FruitPrice
Apple$1.50
Banana$0.75
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> for the table title" + }, + { + "type": "element_count", + "value": { "selector": "th", "min": 2 }, + "message": "Add at least 2 header cells (th)" + }, + { + "type": "element_count", + "value": { "selector": "tr", "min": 3 }, + "message": "Add at least 3 rows (1 header + 2 data rows)" + } + ] + }, + { + "id": "table-thead-tbody", + "title": "Table Head & Body", + "description": "Use <thead> to group header rows and <tbody> to group data rows. This helps browsers and assistive technology understand the table structure.

You can also use <tfoot> for footer rows like totals.", + "task": "Create a structured table:
1. A <caption> with 'Monthly Sales'
2. A <thead> with Month and Revenue headers
3. A <tbody> with at least 2 data rows", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; margin: 0; box-sizing: border-box; } table { border-collapse: collapse; width: 100%; max-width: 450px; background: white; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,0.2); } caption { padding: 20px; font-weight: 700; font-size: 1.3rem; color: white; background: transparent; text-shadow: 0 2px 4px rgba(0,0,0,0.2); caption-side: top; } thead { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); } th { padding: 15px 20px; text-align: left; color: white; font-weight: 500; } tbody tr { border-bottom: 1px solid #eee; } tbody tr:hover { background: #f8f9fa; } td { padding: 15px 20px; color: #333; } tbody tr:last-child { border-bottom: none; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Monthly Sales
MonthRevenue
January$12,500
February$14,200
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> element" + }, + { + "type": "element_exists", + "value": "thead", + "message": "Add a <thead> for the header section" + }, + { + "type": "element_exists", + "value": "tbody", + "message": "Add a <tbody> for the data rows" + }, + { + "type": "element_count", + "value": { "selector": "tbody tr", "min": 2 }, + "message": "Add at least 2 data rows in tbody" + } + ] + }, + { + "id": "table-complete", + "title": "Complete Table with Footer", + "description": "Add <tfoot> to create a footer section for totals or summary data. The footer stays at the bottom even if tbody has many rows.

Combine all sections for a fully structured, accessible table.", + "task": "Create a complete table:
1. A <caption> with 'Order Summary'
2. A <thead> with Item and Price headers
3. A <tbody> with 2 items
4. A <tfoot> with a Total row", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #fafafa; } table { border-collapse: collapse; width: 100%; max-width: 400px; background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 15px rgba(0,0,0,0.1); } caption { padding: 15px 20px; font-weight: 600; font-size: 1.1rem; color: #333; text-align: left; background: #f8f9fa; border-bottom: 2px solid #eee; } th, td { padding: 12px 20px; text-align: left; } thead th { background: #2c3e50; color: white; } tbody td { border-bottom: 1px solid #eee; } tbody tr:hover { background: #f8f9fa; } tfoot { background: #ecf0f1; font-weight: 600; } tfoot td { border-top: 2px solid #2c3e50; color: #2c3e50; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
Order Summary
ItemPrice
Widget$25.00
Gadget$35.00
Total$60.00
", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "table", + "message": "Add a <table> element" + }, + { + "type": "element_exists", + "value": "caption", + "message": "Add a <caption> element" + }, + { + "type": "element_exists", + "value": "thead", + "message": "Add a <thead> section" + }, + { + "type": "element_exists", + "value": "tbody", + "message": "Add a <tbody> section" + }, + { + "type": "element_exists", + "value": "tfoot", + "message": "Add a <tfoot> section for the total" + }, + { + "type": "element_count", + "value": { "selector": "tbody tr", "min": 2 }, + "message": "Add at least 2 item rows in tbody" + } + ] + } + ] +} diff --git a/lessons/uk/31-html-marquee.json b/lessons/uk/31-html-marquee.json new file mode 100644 index 0000000..7c2939a --- /dev/null +++ b/lessons/uk/31-html-marquee.json @@ -0,0 +1,82 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-marquee", + "title": "HTML Marquee", + "description": "Create scrolling text with the classic (deprecated but fun!) marquee element", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "marquee-basic", + "title": "Scrolling Text", + "description": "The <marquee> element creates scrolling text - a classic from the early web! While deprecated, it still works in most browsers.

Note: For production, use CSS animations instead. But for learning and fun, marquee is great!", + "task": "Create a simple marquee:
1. Add a <marquee> element
2. Put some text inside like 'Welcome to my website!'", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #0f0c29 0%, #302b63 50%, #24243e 100%); min-height: 150px; display: flex; align-items: center; } marquee { font-size: 2rem; color: #00ff00; text-shadow: 0 0 10px #00ff00, 0 0 20px #00ff00; font-family: 'Courier New', monospace; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "Welcome to my website!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + } + ] + }, + { + "id": "marquee-direction", + "title": "Direction & Behavior", + "description": "Control the marquee with attributes:
direction: left, right, up, down
behavior: scroll (default), slide (stops at edge), alternate (bounces)
scrollamount: speed (default is 6)", + "task": "Create a bouncing marquee:
1. Add a <marquee> element
2. Set behavior=\"alternate\" to make it bounce
3. Add some fun text", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #ff6b6b 0%, #feca57 100%); min-height: 150px; display: flex; align-items: center; } marquee { font-size: 2.5rem; color: white; text-shadow: 2px 2px 4px rgba(0,0,0,0.3); font-weight: bold; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "Bounce! Bounce! Bounce!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "behavior", "value": "alternate" }, + "message": "Add behavior=\"alternate\" to make it bounce" + } + ] + }, + { + "id": "marquee-retro", + "title": "Retro News Ticker", + "description": "Combine multiple marquee attributes for a classic news ticker effect. You can even put multiple elements inside!

Remember: This is deprecated HTML. Modern sites use CSS animations, but marquee is great for understanding web history.", + "task": "Create a news ticker:
1. A <marquee> with direction=\"left\"
2. Set scrollamount=\"5\" for smooth scrolling
3. Add a breaking news headline inside", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 0; margin: 0; background: #1a1a2e; } marquee { background: linear-gradient(90deg, #c0392b 0%, #e74c3c 50%, #c0392b 100%); padding: 15px 0; font-size: 1.3rem; color: white; font-weight: 500; text-transform: uppercase; letter-spacing: 1px; border-top: 3px solid #f1c40f; border-bottom: 3px solid #f1c40f; }", + "sandboxCSS": "", + "initialCode": "", + "solution": "BREAKING NEWS: Marquee element still works in browsers!", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "marquee", + "message": "Add a <marquee> element" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "direction", "value": "left" }, + "message": "Add direction=\"left\" for horizontal scrolling" + }, + { + "type": "attribute_value", + "value": { "selector": "marquee", "attr": "scrollamount", "value": "5" }, + "message": "Add scrollamount=\"5\" for smooth speed" + } + ] + } + ] +} diff --git a/lessons/uk/32-html-svg.json b/lessons/uk/32-html-svg.json new file mode 100644 index 0000000..59b9dbb --- /dev/null +++ b/lessons/uk/32-html-svg.json @@ -0,0 +1,102 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "html-svg", + "title": "HTML SVG", + "description": "Draw scalable vector graphics directly in HTML", + "mode": "html", + "difficulty": "beginner", + "lessons": [ + { + "id": "svg-circle", + "title": "Drawing Circles", + "description": "SVG (Scalable Vector Graphics) lets you draw shapes directly in HTML. The <svg> element is the container, with width and height attributes.

Use <circle> with cx, cy (center) and r (radius) to draw circles.", + "task": "Create an SVG with a circle:
1. An <svg> with width=\"200\" and height=\"200\"
2. A <circle> centered at (100,100) with radius 50
3. Add a fill color", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: #f5f5f5; display: flex; justify-content: center; } svg { background: white; border-radius: 10px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_exists", + "value": "circle", + "message": "Add a <circle> element inside the SVG" + }, + { + "type": "attribute_value", + "value": { "selector": "circle", "attr": "cx", "value": "100" }, + "message": "Set cx=\"100\" for the circle's horizontal center" + }, + { + "type": "attribute_value", + "value": { "selector": "circle", "attr": "cy", "value": "100" }, + "message": "Set cy=\"100\" for the circle's vertical center" + } + ] + }, + { + "id": "svg-rect-line", + "title": "Rectangles & Lines", + "description": "Draw rectangles with <rect> using x, y, width, height.

Draw lines with <line> using x1, y1 (start) and x2, y2 (end). Lines need a stroke color!", + "task": "Create an SVG with:
1. An <svg> (200x150)
2. A <rect> at position (20,20) with size 80x60
3. A <line> from (120,30) to (180,90) with a stroke color", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 200px; display: flex; justify-content: center; align-items: center; } svg { background: white; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_exists", + "value": "rect", + "message": "Add a <rect> element" + }, + { + "type": "element_exists", + "value": "line", + "message": "Add a <line> element" + } + ] + }, + { + "id": "svg-shapes", + "title": "Multiple Shapes", + "description": "Combine shapes to create simple graphics! Add stroke for outlines and stroke-width for thickness.

Use fill=\"none\" for hollow shapes. Shapes stack in order - later elements appear on top.", + "task": "Create a simple face:
1. An <svg> (200x200)
2. A large <circle> for the face
3. Two small <circle> elements for eyes
4. A <line> for the smile", + "previewHTML": "", + "previewBaseCSS": "body { font-family: system-ui; padding: 20px; background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%); min-height: 250px; display: flex; justify-content: center; align-items: center; } svg { background: white; border-radius: 15px; box-shadow: 0 10px 30px rgba(0,0,0,0.15); }", + "sandboxCSS": "", + "initialCode": "", + "solution": "\n \n \n \n \n", + "previewContainer": "preview-area", + "validations": [ + { + "type": "element_exists", + "value": "svg", + "message": "Add an <svg> element" + }, + { + "type": "element_count", + "value": { "selector": "circle", "min": 3 }, + "message": "Add at least 3 circles (1 face + 2 eyes)" + }, + { + "type": "element_exists", + "value": "line", + "message": "Add a <line> for the smile" + } + ] + } + ] +} diff --git a/lessons/uk/flexbox.json b/lessons/uk/flexbox.json new file mode 100644 index 0000000..7b34c96 --- /dev/null +++ b/lessons/uk/flexbox.json @@ -0,0 +1,173 @@ +{ + "$schema": "../../schemas/code-crispies-module-schema.json", + "id": "flexbox", + "title": "CSS Flexbox", + "description": "Master the flexible box layout model for modern responsive designs", + "difficulty": "intermediate", + "lessons": [ + { + "id": "flexbox-1", + "title": "Container", + "description": "Learn how to create a flex container and understand the main and cross axes.", + "task": "Add display: flex to .wrap to create a flexbox layout.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "display: flex;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "display", + "expected": "flex" + }, + "message": "Set display: flex" + } + ] + }, + { + "id": "flexbox-2", + "title": "Direction & Wrap", + "description": "Control the direction and wrapping of flex items within a container.", + "task": "Add flex-direction: column and flex-wrap: wrap to .wrap.", + "previewHTML": "
1
2
3
4
5
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; height: 16rem; display: flex; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "flex-direction: column;\n flex-wrap: wrap;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "flex-direction", + "expected": "column" + }, + "message": "Set flex-direction: column", + "options": { + "exact": true + } + }, + { + "type": "property_value", + "value": { + "property": "flex-wrap", + "expected": "wrap" + }, + "message": "Set flex-wrap: wrap", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-3", + "title": "Justify Content", + "description": "Learn how to align flex items along the main axis of the flex container.", + "task": "Add justify-content: space-between to .wrap to distribute the boxes evenly.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "justify-content: space-between;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "justify-content", + "expected": "space-between" + }, + "message": "Set justify-content: space-between", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-4", + "title": "Align Items", + "description": "Control how flex items are aligned along the cross axis of the flex container.", + "task": "Add align-items: center to .wrap to vertically center the boxes.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; display: flex; justify-content: center; } .tall { height: 6rem; } .short { height: 3rem; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; height: 10rem; }", + "codePrefix": ".wrap {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "align-items: center;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "align-items", + "expected": "center" + }, + "message": "Set align-items: center", + "options": { + "exact": true + } + } + ] + }, + { + "id": "flexbox-5", + "title": "Flex Grow", + "description": "The flex property controls how much an item grows relative to others.", + "task": "Add flex: 2 to .box2 to make it grow twice as wide.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; display: flex; align-items: center; justify-content: center; } .box1 { background: coral; flex: 1; } .box2 { background: mediumseagreen; } .box3 { background: gold; flex: 1; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; }", + "codePrefix": ".box2 {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "flex: 2;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "flex", + "expected": "2" + }, + "message": "Set flex: 2" + } + ] + }, + { + "id": "flexbox-6", + "title": "Align Self", + "description": "Use align-self to override alignment for a single flex item.", + "task": "Add align-self: flex-start to .middle to move it to the top.", + "previewHTML": "
1
2
3
", + "previewBaseCSS": "body { font-family: system-ui, sans-serif; padding: 1rem; } .box { background: steelblue; color: white; padding: 1rem; margin: 8px; text-align: center; font-weight: bold; width: 3rem; height: 3rem; display: flex; align-items: center; justify-content: center; } .middle { background: mediumseagreen; }", + "sandboxCSS": ".wrap { border: 2px dashed #aaa; padding: 1rem; display: flex; height: 12rem; align-items: center; }", + "codePrefix": ".middle {\n ", + "initialCode": "", + "codeSuffix": "\n}", + "solution": "align-self: flex-start;", + "previewContainer": "preview-area", + "validations": [ + { + "type": "property_value", + "value": { + "property": "align-self", + "expected": "flex-start" + }, + "message": "Set align-self: flex-start" + } + ] + } + ] +} diff --git a/src/app.js b/src/app.js index efac14a..8c1d77b 100644 --- a/src/app.js +++ b/src/app.js @@ -2,7 +2,7 @@ import { LessonEngine } from "./impl/LessonEngine.js"; import { CodeEditor } from "./impl/CodeEditor.js"; import { renderLesson, renderModuleList, renderLevelIndicator, updateActiveLessonInSidebar } from "./helpers/renderer.js"; import { loadModules } from "./config/lessons.js"; -import { initI18n, t, getLanguage, setLanguage, applyTranslations } from "./i18n.js"; +import { initI18n, t, getLanguage, setLanguage, getNextLanguage, applyTranslations } from "./i18n.js"; // Simplified state - LessonEngine now manages lesson state and progress const state = { @@ -119,7 +119,7 @@ function toggleExpectedResult() { function toggleLanguage() { const currentLang = getLanguage(); - const newLang = currentLang === "en" ? "de" : "en"; + const newLang = getNextLanguage(currentLang); // Add transition class before any updates elements.editorSection?.classList.add("transitioning"); diff --git a/src/config/lessons.js b/src/config/lessons.js index f019d7e..7bc3f87 100644 --- a/src/config/lessons.js +++ b/src/config/lessons.js @@ -37,6 +37,74 @@ import htmlMarqueeDE from "../../lessons/de/31-html-marquee.json"; import htmlSvgDE from "../../lessons/de/32-html-svg.json"; import flexboxDE from "../../lessons/de/flexbox.json"; +// Polish lesson imports +import welcomePL from "../../lessons/pl/00-welcome.json"; +import basicSelectorsPL from "../../lessons/pl/00-basic-selectors.json"; +import boxModelPL from "../../lessons/pl/01-box-model.json"; +import unitsVariablesPL from "../../lessons/pl/05-units-variables.json"; +import transitionsAnimationsPL from "../../lessons/pl/06-transitions-animations.json"; +import responsivePL from "../../lessons/pl/08-responsive.json"; +import htmlElementsPL from "../../lessons/pl/20-html-elements.json"; +import htmlFormsBasicPL from "../../lessons/pl/21-html-forms-basic.json"; +import htmlFormsValidationPL from "../../lessons/pl/22-html-forms-validation.json"; +import htmlDetailsSummaryPL from "../../lessons/pl/23-html-details-summary.json"; +import htmlProgressMeterPL from "../../lessons/pl/24-html-progress-meter.json"; +import htmlTablesPL from "../../lessons/pl/30-html-tables.json"; +import htmlMarqueePL from "../../lessons/pl/31-html-marquee.json"; +import htmlSvgPL from "../../lessons/pl/32-html-svg.json"; +import flexboxPL from "../../lessons/pl/flexbox.json"; + +// Spanish lesson imports +import welcomeES from "../../lessons/es/00-welcome.json"; +import basicSelectorsES from "../../lessons/es/00-basic-selectors.json"; +import boxModelES from "../../lessons/es/01-box-model.json"; +import unitsVariablesES from "../../lessons/es/05-units-variables.json"; +import transitionsAnimationsES from "../../lessons/es/06-transitions-animations.json"; +import responsiveES from "../../lessons/es/08-responsive.json"; +import htmlElementsES from "../../lessons/es/20-html-elements.json"; +import htmlFormsBasicES from "../../lessons/es/21-html-forms-basic.json"; +import htmlFormsValidationES from "../../lessons/es/22-html-forms-validation.json"; +import htmlDetailsSummaryES from "../../lessons/es/23-html-details-summary.json"; +import htmlProgressMeterES from "../../lessons/es/24-html-progress-meter.json"; +import htmlTablesES from "../../lessons/es/30-html-tables.json"; +import htmlMarqueeES from "../../lessons/es/31-html-marquee.json"; +import htmlSvgES from "../../lessons/es/32-html-svg.json"; +import flexboxES from "../../lessons/es/flexbox.json"; + +// Arabic lesson imports +import welcomeAR from "../../lessons/ar/00-welcome.json"; +import basicSelectorsAR from "../../lessons/ar/00-basic-selectors.json"; +import boxModelAR from "../../lessons/ar/01-box-model.json"; +import unitsVariablesAR from "../../lessons/ar/05-units-variables.json"; +import transitionsAnimationsAR from "../../lessons/ar/06-transitions-animations.json"; +import responsiveAR from "../../lessons/ar/08-responsive.json"; +import htmlElementsAR from "../../lessons/ar/20-html-elements.json"; +import htmlFormsBasicAR from "../../lessons/ar/21-html-forms-basic.json"; +import htmlFormsValidationAR from "../../lessons/ar/22-html-forms-validation.json"; +import htmlDetailsSummaryAR from "../../lessons/ar/23-html-details-summary.json"; +import htmlProgressMeterAR from "../../lessons/ar/24-html-progress-meter.json"; +import htmlTablesAR from "../../lessons/ar/30-html-tables.json"; +import htmlMarqueeAR from "../../lessons/ar/31-html-marquee.json"; +import htmlSvgAR from "../../lessons/ar/32-html-svg.json"; +import flexboxAR from "../../lessons/ar/flexbox.json"; + +// Ukrainian lesson imports +import welcomeUK from "../../lessons/uk/00-welcome.json"; +import basicSelectorsUK from "../../lessons/uk/00-basic-selectors.json"; +import boxModelUK from "../../lessons/uk/01-box-model.json"; +import unitsVariablesUK from "../../lessons/uk/05-units-variables.json"; +import transitionsAnimationsUK from "../../lessons/uk/06-transitions-animations.json"; +import responsiveUK from "../../lessons/uk/08-responsive.json"; +import htmlElementsUK from "../../lessons/uk/20-html-elements.json"; +import htmlFormsBasicUK from "../../lessons/uk/21-html-forms-basic.json"; +import htmlFormsValidationUK from "../../lessons/uk/22-html-forms-validation.json"; +import htmlDetailsSummaryUK from "../../lessons/uk/23-html-details-summary.json"; +import htmlProgressMeterUK from "../../lessons/uk/24-html-progress-meter.json"; +import htmlTablesUK from "../../lessons/uk/30-html-tables.json"; +import htmlMarqueeUK from "../../lessons/uk/31-html-marquee.json"; +import htmlSvgUK from "../../lessons/uk/32-html-svg.json"; +import flexboxUK from "../../lessons/uk/flexbox.json"; + // English module store - ordered by learning path const moduleStoreEN = [ // Welcome @@ -89,18 +157,104 @@ const moduleStoreDE = [ transitionsAnimationsDE ]; +// Polish module store - ordered by learning path +const moduleStorePL = [ + welcomePL, + htmlElementsPL, + htmlFormsBasicPL, + htmlFormsValidationPL, + htmlDetailsSummaryPL, + htmlProgressMeterPL, + htmlTablesPL, + htmlSvgPL, + htmlMarqueePL, + basicSelectorsPL, + boxModelPL, + unitsVariablesPL, + flexboxPL, + responsivePL, + transitionsAnimationsPL +]; + +// Spanish module store - ordered by learning path +const moduleStoreES = [ + welcomeES, + htmlElementsES, + htmlFormsBasicES, + htmlFormsValidationES, + htmlDetailsSummaryES, + htmlProgressMeterES, + htmlTablesES, + htmlSvgES, + htmlMarqueeES, + basicSelectorsES, + boxModelES, + unitsVariablesES, + flexboxES, + responsiveES, + transitionsAnimationsES +]; + +// Arabic module store - ordered by learning path +const moduleStoreAR = [ + welcomeAR, + htmlElementsAR, + htmlFormsBasicAR, + htmlFormsValidationAR, + htmlDetailsSummaryAR, + htmlProgressMeterAR, + htmlTablesAR, + htmlSvgAR, + htmlMarqueeAR, + basicSelectorsAR, + boxModelAR, + unitsVariablesAR, + flexboxAR, + responsiveAR, + transitionsAnimationsAR +]; + +// Ukrainian module store - ordered by learning path +const moduleStoreUK = [ + welcomeUK, + htmlElementsUK, + htmlFormsBasicUK, + htmlFormsValidationUK, + htmlDetailsSummaryUK, + htmlProgressMeterUK, + htmlTablesUK, + htmlSvgUK, + htmlMarqueeUK, + basicSelectorsUK, + boxModelUK, + unitsVariablesUK, + flexboxUK, + responsiveUK, + transitionsAnimationsUK +]; + +// Map of language codes to module stores +const moduleStores = { + en: moduleStoreEN, + de: moduleStoreDE, + pl: moduleStorePL, + es: moduleStoreES, + ar: moduleStoreAR, + uk: moduleStoreUK +}; + /** * Load all available modules for a given language - * @param {string} language - Language code ('en' or 'de') + * @param {string} language - Language code ('en', 'de', 'pl', 'es', 'ar', 'uk') * @returns {Array} Array of modules */ export function loadModules(language = "en") { - const store = language === "de" ? moduleStoreDE : moduleStoreEN; + const store = moduleStores[language] || moduleStoreEN; return store.map((module) => ({ ...module, lessons: module.lessons.map((lesson) => ({ ...lesson, - mode: module.mode || "css" + mode: lesson.mode || module.mode || "css" })) })); } diff --git a/src/i18n.js b/src/i18n.js index b3c70e1..93105db 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -11,7 +11,7 @@ const translations = { // Header menuOpen: "Open menu", langSwitch: "DE", - langSwitchLabel: "Sprache wechseln: Deutsch", + langSwitchLabel: "Switch language: Deutsch", help: "Help", // Instructions @@ -109,8 +109,8 @@ const translations = { // Header menuOpen: "Menü öffnen", - langSwitch: "EN", - langSwitchLabel: "Switch language: English", + langSwitch: "PL", + langSwitchLabel: "Zmień język: Polski", help: "Hilfe", // Instructions @@ -199,11 +199,432 @@ const translations = { tailwindPlaceholder: "Tailwind-Klassen eingeben (z.B. bg-blue-500 text-white p-4)", lessonFallback: "Lektion {index}", untitledLesson: "Unbenannte Lektion" + }, + + // Polish + pl: { + // Page + pageTitle: "Code Crispies - Nauka HTML i CSS interaktywnie", + skipLink: "Przejdź do głównej treści", + + // Header + menuOpen: "Otwórz menu", + langSwitch: "ES", + langSwitchLabel: "Cambiar idioma: Español", + help: "Pomoc", + + // Instructions + loading: "Ładowanie...", + selectLesson: "Wybierz lekcję, aby rozpocząć.", + editorLabel: "Edytor CSS", + undoTitle: "Cofnij (Ctrl+Z)", + redoTitle: "Ponów (Ctrl+Shift+Z)", + resetCodeTitle: "Przywróć kod początkowy", + run: "Uruchom", + rerun: "Uruchom ponownie", + + // Preview + yourOutput: "Twój wynik", + showExpected: "Pokaż oczekiwane", + hideExpected: "Ukryj oczekiwane", + previous: "Poprzednia", + next: "Następna", + levelIndicator: "Lekcja {current} z {total}", + lessonLabel: "Lekcja", + + // Sidebar + menu: "Menu", + closeMenu: "Zamknij menu", + progress: "Postęp", + progressText: "{percent}% ukończone ({completed}/{total})", + lessons: "Lekcje", + settings: "Ustawienia", + showHints: "Pokaż podpowiedzi", + resetAllProgress: "Resetuj cały postęp", + openSource: "Open Source:", + by: "przez", + + // Help dialog + helpTitle: "Pomoc", + aboutTitle: "O Code Crispies", + aboutText: "Code Crispies to darmowa platforma open-source do nauki tworzenia stron internetowych poprzez praktyczne ćwiczenia. Nie wymaga konta - po prostu zacznij kodować!", + learningModesTitle: "Tryby nauki", + modeCss: "CSS - Pisz reguły CSS do stylizowania elementów", + modeTailwind: "Tailwind - Stosuj klasy utility bezpośrednio w HTML", + modeHtml: "HTML - Ćwicz semantyczne znaczniki i natywne elementy", + gettingStartedTitle: "Pierwsze kroki", + gettingStartedText: "Otwórz menu (☰), aby przeglądać moduły lekcji. Każdy moduł obejmuje konkretny temat z progresywnymi ćwiczeniami.", + completingLessonsTitle: "Ukończanie lekcji", + completingStep1: "Przeczytaj instrukcje zadania po lewej stronie", + completingStep2: "Napisz swój kod w edytorze", + completingStep3: "Obserwuj podgląd na żywo podczas pisania", + completingStep4: "Postępuj zgodnie z podpowiedziami, aby naprawić problemy", + completingStep5: "Kliknij Następna po ukończeniu", + editorToolsTitle: "Narzędzia edytora", + editorToolUndo: "↶ Cofnij / ↷ Ponów - Nawiguj historię edycji", + editorToolReset: "⟲ Resetuj - Przywróć początkowy kod", + editorToolExpected: "Pokaż oczekiwane - Przełącz nakładkę wyniku docelowego", + keyboardShortcutsTitle: "Skróty klawiszowe", + shortcutRun: "Ctrl+Enter - Natychmiastowa walidacja", + shortcutUndo: "Ctrl+Z - Cofnij", + shortcutRedo: "Ctrl+Shift+Z - Ponów", + emmetTitle: "Skróty Emmet (tryb HTML)", + emmetText: "Wpisz skróty i naciśnij Tab, aby rozwinąć:", + emmetClass: "div.box → div z klasą", + emmetChildren: "ul>li*3 → ul z 3 elementami li", + emmetNested: "form>input+button → zagnieżdżona struktura", + emmetContent: "p{Cześć} → p z tekstem", + + // More Projects + moreProjectsTitle: "Więcej projektów", + htmlOverJsDesc: " - Naucz się wykorzystywać natywne elementy HTML zamiast niestandardowych rozwiązań JavaScript", + mandalaDesc: " - Interaktywna wizualizacja technologii JavaScript uporządkowanych według złożoności", + + // Contact + contactTitle: "Kontakt i linki", + contactText: "Code Crispies jest rozwijany przez LibreTECH", + + // Reset dialog + resetDialogTitle: "Resetuj postęp", + resetDialogText: "Czy na pewno chcesz zresetować cały postęp? Tej operacji nie można cofnąć.", + cancel: "Anuluj", + resetAll: "Resetuj wszystko", + + // Dynamic content + loadingFallbackText: "Nie można załadować lekcji. Wybierz jedną z menu lub sprawdź pomoc.", + completed: "Ukończono", + successMessage: "CRISPY! ٩(◕‿◕)۶ Twój kod działa poprawnie.", + keepTrying: "Próbuj dalej!", + failedToLoad: "Nie udało się załadować modułów. Odśwież stronę.", + tailwindPlaceholder: "Wprowadź klasy Tailwind (np. bg-blue-500 text-white p-4)", + lessonFallback: "Lekcja {index}", + untitledLesson: "Lekcja bez tytułu" + }, + + // Spanish + es: { + // Page + pageTitle: "Code Crispies - Aprende HTML y CSS de forma interactiva", + skipLink: "Saltar al contenido principal", + + // Header + menuOpen: "Abrir menú", + langSwitch: "AR", + langSwitchLabel: "تغيير اللغة: العربية", + help: "Ayuda", + + // Instructions + loading: "Cargando...", + selectLesson: "Selecciona una lección para comenzar.", + editorLabel: "Editor CSS", + undoTitle: "Deshacer (Ctrl+Z)", + redoTitle: "Rehacer (Ctrl+Shift+Z)", + resetCodeTitle: "Restaurar código inicial", + run: "Ejecutar", + rerun: "Volver a ejecutar", + + // Preview + yourOutput: "Tu resultado", + showExpected: "Mostrar esperado", + hideExpected: "Ocultar esperado", + previous: "Anterior", + next: "Siguiente", + levelIndicator: "Lección {current} de {total}", + lessonLabel: "Lección", + + // Sidebar + menu: "Menú", + closeMenu: "Cerrar menú", + progress: "Progreso", + progressText: "{percent}% completado ({completed}/{total})", + lessons: "Lecciones", + settings: "Configuración", + showHints: "Mostrar pistas", + resetAllProgress: "Reiniciar todo el progreso", + openSource: "Código abierto:", + by: "por", + + // Help dialog + helpTitle: "Ayuda", + aboutTitle: "Acerca de Code Crispies", + aboutText: "Code Crispies es una plataforma gratuita de código abierto para aprender desarrollo web a través de ejercicios prácticos. No se requiere cuenta, ¡solo empieza a programar!", + learningModesTitle: "Modos de aprendizaje", + modeCss: "CSS - Escribe reglas CSS para estilizar elementos", + modeTailwind: "Tailwind - Aplica clases de utilidad directamente en HTML", + modeHtml: "HTML - Practica marcado semántico y elementos nativos", + gettingStartedTitle: "Primeros pasos", + gettingStartedText: "Abre el menú (☰) para explorar los módulos de lecciones. Cada módulo cubre un tema específico con ejercicios progresivos.", + completingLessonsTitle: "Completar lecciones", + completingStep1: "Lee las instrucciones de la tarea a la izquierda", + completingStep2: "Escribe tu código en el editor", + completingStep3: "Observa la vista previa en vivo mientras escribes", + completingStep4: "Sigue las pistas para corregir problemas", + completingStep5: "Haz clic en Siguiente cuando termines", + editorToolsTitle: "Herramientas del editor", + editorToolUndo: "↶ Deshacer / ↷ Rehacer - Navegar historial de edición", + editorToolReset: "⟲ Reiniciar - Restaurar código inicial", + editorToolExpected: "Mostrar esperado - Alternar superposición del resultado objetivo", + keyboardShortcutsTitle: "Atajos de teclado", + shortcutRun: "Ctrl+Enter - Validar inmediatamente", + shortcutUndo: "Ctrl+Z - Deshacer", + shortcutRedo: "Ctrl+Shift+Z - Rehacer", + emmetTitle: "Atajos Emmet (modo HTML)", + emmetText: "Escribe abreviaturas y presiona Tab para expandir:", + emmetClass: "div.box → div con clase", + emmetChildren: "ul>li*3 → ul con 3 hijos li", + emmetNested: "form>input+button → estructura anidada", + emmetContent: "p{Hola} → p con contenido de texto", + + // More Projects + moreProjectsTitle: "Más proyectos", + htmlOverJsDesc: " - Aprende a aprovechar elementos HTML nativos en lugar de soluciones JavaScript personalizadas", + mandalaDesc: " - Visualización interactiva de tecnologías JavaScript organizadas por complejidad", + + // Contact + contactTitle: "Contacto y enlaces", + contactText: "Code Crispies es desarrollado por LibreTECH", + + // Reset dialog + resetDialogTitle: "Reiniciar progreso", + resetDialogText: "¿Estás seguro de que quieres reiniciar todo tu progreso? Esta acción no se puede deshacer.", + cancel: "Cancelar", + resetAll: "Reiniciar todo", + + // Dynamic content + loadingFallbackText: "No se pudo cargar la lección. Selecciona una del menú o consulta la ayuda.", + completed: "Completado", + successMessage: "¡CRISPY! ٩(◕‿◕)۶ Tu código funciona correctamente.", + keepTrying: "¡Sigue intentando!", + failedToLoad: "No se pudieron cargar los módulos. Actualiza la página.", + tailwindPlaceholder: "Ingresa clases de Tailwind (ej. bg-blue-500 text-white p-4)", + lessonFallback: "Lección {index}", + untitledLesson: "Lección sin título" + }, + + // Arabic + ar: { + // Page + pageTitle: "Code Crispies - تعلم HTML و CSS بشكل تفاعلي", + skipLink: "انتقل إلى المحتوى الرئيسي", + + // Header + menuOpen: "افتح القائمة", + langSwitch: "UK", + langSwitchLabel: "Змінити мову: Українська", + help: "مساعدة", + + // Instructions + loading: "جاري التحميل...", + selectLesson: "اختر درسًا للبدء.", + editorLabel: "محرر CSS", + undoTitle: "تراجع (Ctrl+Z)", + redoTitle: "إعادة (Ctrl+Shift+Z)", + resetCodeTitle: "استعادة الكود الأولي", + run: "تشغيل", + rerun: "إعادة التشغيل", + + // Preview + yourOutput: "نتيجتك", + showExpected: "إظهار المتوقع", + hideExpected: "إخفاء المتوقع", + previous: "السابق", + next: "التالي", + levelIndicator: "الدرس {current} من {total}", + lessonLabel: "درس", + + // Sidebar + menu: "القائمة", + closeMenu: "إغلاق القائمة", + progress: "التقدم", + progressText: "{percent}% مكتمل ({completed}/{total})", + lessons: "الدروس", + settings: "الإعدادات", + showHints: "إظهار التلميحات", + resetAllProgress: "إعادة تعيين كل التقدم", + openSource: "مفتوح المصدر:", + by: "بواسطة", + + // Help dialog + helpTitle: "مساعدة", + aboutTitle: "عن Code Crispies", + aboutText: "Code Crispies هي منصة مجانية مفتوحة المصدر لتعلم تطوير الويب من خلال تمارين عملية. لا يلزم حساب - فقط ابدأ البرمجة!", + learningModesTitle: "أوضاع التعلم", + modeCss: "CSS - اكتب قواعد CSS لتنسيق العناصر", + modeTailwind: "Tailwind - طبق فئات الأدوات مباشرة في HTML", + modeHtml: "HTML - تدرب على الترميز الدلالي والعناصر الأصلية", + gettingStartedTitle: "البداية", + gettingStartedText: "افتح القائمة (☰) لتصفح وحدات الدروس. كل وحدة تغطي موضوعًا محددًا مع تمارين تدريجية.", + completingLessonsTitle: "إكمال الدروس", + completingStep1: "اقرأ تعليمات المهمة على اليسار", + completingStep2: "اكتب الكود في المحرر", + completingStep3: "شاهد المعاينة المباشرة أثناء الكتابة", + completingStep4: "اتبع التلميحات لإصلاح أي مشاكل", + completingStep5: "انقر على التالي عند الانتهاء", + editorToolsTitle: "أدوات المحرر", + editorToolUndo: "↶ تراجع / ↷ إعادة - التنقل في سجل التحرير", + editorToolReset: "⟲ إعادة تعيين - استعادة الكود الأولي", + editorToolExpected: "إظهار المتوقع - تبديل طبقة النتيجة المستهدفة", + keyboardShortcutsTitle: "اختصارات لوحة المفاتيح", + shortcutRun: "Ctrl+Enter - التحقق فورًا", + shortcutUndo: "Ctrl+Z - تراجع", + shortcutRedo: "Ctrl+Shift+Z - إعادة", + emmetTitle: "اختصارات Emmet (وضع HTML)", + emmetText: "اكتب الاختصارات واضغط Tab للتوسيع:", + emmetClass: "div.box ← div مع فئة", + emmetChildren: "ul>li*3 ← ul مع 3 عناصر li", + emmetNested: "form>input+button ← هيكل متداخل", + emmetContent: "p{مرحبا} ← p مع محتوى نصي", + + // More Projects + moreProjectsTitle: "مشاريع أخرى", + htmlOverJsDesc: " - تعلم استخدام عناصر HTML الأصلية بدلاً من حلول JavaScript المخصصة", + mandalaDesc: " - تصور تفاعلي لتقنيات JavaScript مرتبة حسب التعقيد", + + // Contact + contactTitle: "التواصل والروابط", + contactText: "Code Crispies تم تطويره بواسطة LibreTECH", + + // Reset dialog + resetDialogTitle: "إعادة تعيين التقدم", + resetDialogText: "هل أنت متأكد أنك تريد إعادة تعيين كل تقدمك؟ لا يمكن التراجع عن هذا الإجراء.", + cancel: "إلغاء", + resetAll: "إعادة تعيين الكل", + + // Dynamic content + loadingFallbackText: "تعذر تحميل الدرس. اختر واحدًا من القائمة أو تحقق من المساعدة.", + completed: "مكتمل", + successMessage: "CRISPY! ٩(◕‿◕)۶ الكود يعمل بشكل صحيح.", + keepTrying: "استمر في المحاولة!", + failedToLoad: "فشل تحميل الوحدات. قم بتحديث الصفحة.", + tailwindPlaceholder: "أدخل فئات Tailwind (مثل bg-blue-500 text-white p-4)", + lessonFallback: "درس {index}", + untitledLesson: "درس بدون عنوان" + }, + + // Ukrainian + uk: { + // Page + pageTitle: "Code Crispies - Вивчай HTML та CSS інтерактивно", + skipLink: "Перейти до основного вмісту", + + // Header + menuOpen: "Відкрити меню", + langSwitch: "EN", + langSwitchLabel: "Switch language: English", + help: "Допомога", + + // Instructions + loading: "Завантаження...", + selectLesson: "Оберіть урок, щоб почати.", + editorLabel: "Редактор CSS", + undoTitle: "Скасувати (Ctrl+Z)", + redoTitle: "Повторити (Ctrl+Shift+Z)", + resetCodeTitle: "Відновити початковий код", + run: "Запустити", + rerun: "Запустити знову", + + // Preview + yourOutput: "Ваш результат", + showExpected: "Показати очікуване", + hideExpected: "Сховати очікуване", + previous: "Попередній", + next: "Наступний", + levelIndicator: "Урок {current} з {total}", + lessonLabel: "Урок", + + // Sidebar + menu: "Меню", + closeMenu: "Закрити меню", + progress: "Прогрес", + progressText: "{percent}% завершено ({completed}/{total})", + lessons: "Уроки", + settings: "Налаштування", + showHints: "Показувати підказки", + resetAllProgress: "Скинути весь прогрес", + openSource: "Відкритий код:", + by: "від", + + // Help dialog + helpTitle: "Допомога", + aboutTitle: "Про Code Crispies", + aboutText: "Code Crispies — це безкоштовна платформа з відкритим кодом для вивчення веб-розробки через практичні вправи. Обліковий запис не потрібен — просто починайте кодувати!", + learningModesTitle: "Режими навчання", + modeCss: "CSS - Пишіть правила CSS для стилізації елементів", + modeTailwind: "Tailwind - Застосовуйте утилітарні класи безпосередньо в HTML", + modeHtml: "HTML - Практикуйте семантичну розмітку та нативні елементи", + gettingStartedTitle: "Початок роботи", + gettingStartedText: "Відкрийте меню (☰), щоб переглянути модулі уроків. Кожен модуль охоплює конкретну тему з прогресивними вправами.", + completingLessonsTitle: "Завершення уроків", + completingStep1: "Прочитайте інструкції завдання зліва", + completingStep2: "Напишіть свій код у редакторі", + completingStep3: "Спостерігайте за попереднім переглядом під час введення", + completingStep4: "Слідуйте підказкам, щоб виправити проблеми", + completingStep5: "Натисніть Наступний після завершення", + editorToolsTitle: "Інструменти редактора", + editorToolUndo: "↶ Скасувати / ↷ Повторити - Навігація історією редагування", + editorToolReset: "⟲ Скинути - Відновити початковий код", + editorToolExpected: "Показати очікуване - Перемкнути накладення цільового результату", + keyboardShortcutsTitle: "Гарячі клавіші", + shortcutRun: "Ctrl+Enter - Негайна перевірка", + shortcutUndo: "Ctrl+Z - Скасувати", + shortcutRedo: "Ctrl+Shift+Z - Повторити", + emmetTitle: "Скорочення Emmet (режим HTML)", + emmetText: "Введіть скорочення та натисніть Tab для розгортання:", + emmetClass: "div.box → div з класом", + emmetChildren: "ul>li*3 → ul з 3 дочірніми li", + emmetNested: "form>input+button → вкладена структура", + emmetContent: "p{Привіт} → p з текстовим вмістом", + + // More Projects + moreProjectsTitle: "Більше проектів", + htmlOverJsDesc: " - Навчіться використовувати нативні HTML-елементи замість власних JavaScript-рішень", + mandalaDesc: " - Інтерактивна візуалізація JavaScript-технологій, впорядкованих за складністю", + + // Contact + contactTitle: "Контакти та посилання", + contactText: "Code Crispies розроблено LibreTECH", + + // Reset dialog + resetDialogTitle: "Скинути прогрес", + resetDialogText: "Ви впевнені, що хочете скинути весь свій прогрес? Цю дію неможливо скасувати.", + cancel: "Скасувати", + resetAll: "Скинути все", + + // Dynamic content + loadingFallbackText: "Не вдалося завантажити урок. Виберіть один з меню або перевірте допомогу.", + completed: "Завершено", + successMessage: "CRISPY! ٩(◕‿◕)۶ Ваш код працює правильно.", + keepTrying: "Продовжуйте спроби!", + failedToLoad: "Не вдалося завантажити модулі. Оновіть сторінку.", + tailwindPlaceholder: "Введіть класи Tailwind (напр. bg-blue-500 text-white p-4)", + lessonFallback: "Урок {index}", + untitledLesson: "Урок без назви" } }; let currentLang = "en"; +// Available languages in cycle order +const availableLanguages = ["en", "de", "pl", "es", "ar", "uk"]; + +/** + * Get array of available language codes + */ +export function getAvailableLanguages() { + return availableLanguages; +} + +/** + * Get the next language in the cycle + * @param {string} currentLang - Current language code + * @returns {string} Next language code + */ +export function getNextLanguage(current = currentLang) { + const currentIndex = availableLanguages.indexOf(current); + const nextIndex = (currentIndex + 1) % availableLanguages.length; + return availableLanguages[nextIndex]; +} + /** * Detect initial language from localStorage or browser */