auto-claude: 3.1 - Add 'concept' objects to all 6 Flexbox lessons. Explicitly explain container vs item distinction. Include simple ASCII diagrams showing axis direction.

This commit is contained in:
2026-01-11 04:43:59 +01:00
parent 9e7781ada6
commit 0cf25b61b1

View File

@@ -18,6 +18,11 @@
"codeSuffix": "\n}",
"solution": "display: flex;",
"previewContainer": "preview-area",
"concept": {
"explanation": "Setting display: flex creates a flex container, which establishes a new flex formatting context for its direct children. By default, this creates a horizontal main axis (left to right) and a vertical cross axis (top to bottom). All direct children automatically become flex items that can be controlled by flex properties.",
"diagram": "┌─────────────────────────────────┐\n│ FLEX CONTAINER (.wrap) │\n│ │\n│ Main Axis (horizontal) → │\n│ ┌───┐ ┌───┐ ┌───┐ │\n│ │ 1 │ │ 2 │ │ 3 │ ← Items │\n│ └───┘ └───┘ └───┘ │\n│ ↑ │\n│ Cross Axis (vertical) │\n└─────────────────────────────────┘",
"containerVsItem": "display: flex is a CONTAINER property applied to the parent element. It affects how the container lays out its children, but doesn't change the children themselves."
},
"validations": [
{
"type": "property_value",
@@ -42,6 +47,11 @@
"codeSuffix": "\n}",
"solution": "flex-direction: column;\n flex-wrap: wrap;",
"previewContainer": "preview-area",
"concept": {
"explanation": "flex-direction changes which axis is the main axis: row (default) flows horizontally, while column flows vertically. This swaps how justify-content and align-items work. flex-wrap allows items to wrap onto new lines when they don't fit, instead of shrinking or overflowing.",
"diagram": "flex-direction: column\n\n┌──────────────┐\n│ Container │\n│ │\n│ ┌──┐ ┌──┐ │ Main Axis\n│ │1 │ │4 │ │ ↓\n│ └──┘ └──┘ │ (vertical)\n│ ┌──┐ ┌──┐ │\n│ │2 │ │5 │ │\n│ └──┘ └──┘ │ ← Cross Axis\n│ ┌──┐ │ (horizontal)\n│ │3 │ │\n│ └──┘ │\n└──────────────┘",
"containerVsItem": "Both flex-direction and flex-wrap are CONTAINER properties. They control how the container arranges its children, not the children themselves."
},
"validations": [
{
"type": "property_value",
@@ -80,6 +90,11 @@
"codeSuffix": "\n}",
"solution": "justify-content: space-between;",
"previewContainer": "preview-area",
"concept": {
"explanation": "justify-content controls how flex items are distributed along the main axis (horizontal by default). space-between places the first item at the start, the last at the end, and distributes remaining items with equal spacing between them. Other values include flex-start, center, flex-end, and space-around.",
"diagram": "justify-content: space-between\n\n┌─────────────────────────────┐\n│ ┌───┐ ┌───┐ ┌───┐ │\n│ │ 1 │ │ 2 │ │ 3 │ │\n│ └───┘ └───┘ └───┘ │\n│ ↑ ↑ ↑ │\n│ start equal gap end │\n│◄──────────────────────────► │\n│ Main Axis │\n└─────────────────────────────┘",
"containerVsItem": "justify-content is a CONTAINER property. The parent controls how its children are spaced, not the children themselves."
},
"validations": [
{
"type": "property_value",
@@ -107,6 +122,11 @@
"codeSuffix": "\n}",
"solution": "align-items: center;",
"previewContainer": "preview-area",
"concept": {
"explanation": "align-items controls how flex items are aligned along the cross axis (vertical by default). While justify-content handles spacing along the main axis, align-items handles alignment perpendicular to it. The center value aligns all items to the middle of the cross axis, regardless of their individual heights.",
"diagram": "align-items: center\n\n┌──────────────────────┐ ↑\n│ │ │\n│ ┌────┐ │ │ Cross\n│ │ 1 │ ┌──┐ │ │ Axis\n│ │ │ │2 │ ┌─┐ │ │\n│ ────┼────┼──┼──┼─┼─┼─│ center line\n│ │ │ └──┘ └─┘ │ │\n│ └────┘ 3 │ │\n│ │ ↓\n└──────────────────────┘",
"containerVsItem": "align-items is a CONTAINER property that sets the default cross-axis alignment for all child items. Individual items can override this with align-self."
},
"validations": [
{
"type": "property_value",
@@ -134,6 +154,11 @@
"codeSuffix": "\n}",
"solution": "flex: 2;",
"previewContainer": "preview-area",
"concept": {
"explanation": "The flex property controls how flex items grow to fill available space. It's shorthand for flex-grow, flex-shrink, and flex-basis. When you set flex: 2, the item gets 2 \"shares\" of leftover space, while flex: 1 items get 1 share each. This creates proportional sizing based on the numbers you provide.",
"diagram": "flex: 2 vs flex: 1\n\n┌────────────────────────────┐\n│ Available Space │\n├────────┬──────────┬────────┤\n│ Box 1 │ Box 2 │ Box 3 │\n│ flex:1 │ flex:2 │ flex:1 │\n│ 25% │ 50% │ 25% │\n│ (1/4) │ (2/4) │ (1/4) │\n└────────┴──────────┴────────┘\n 1 share 2 shares 1 share",
"containerVsItem": "flex is an ITEM property, unlike the container properties we've seen. It's applied to individual children to control how they grow, not to the parent."
},
"validations": [
{
"type": "property_value",
@@ -158,6 +183,11 @@
"codeSuffix": "\n}",
"solution": "align-self: flex-start;",
"previewContainer": "preview-area",
"concept": {
"explanation": "align-self allows a single flex item to override the container's align-items setting. While the container sets the default cross-axis alignment for all children, individual items can break free and align themselves differently. This is useful when one item needs special positioning without affecting the others.",
"diagram": "align-self: flex-start\n\n┌──────────────────────┐ ↑\n│ ┌─┐ │ │\n│ │2│ ← flex-start │ │\n│ └─┘ │ │ Cross\n│ ┌──┐ ┌──┐ │ │ Axis\n│ ──────│1 │────│3 │──│ ← center (default)\n│ └──┘ └──┘ │ │\n│ │ │\n│ │ ↓\n└──────────────────────┘",
"containerVsItem": "align-self is an ITEM property that overrides the container's align-items. This is the first property that gives individual children control over their own positioning."
},
"validations": [
{
"type": "property_value",