"
+ commit id: "Left Container (7 plants)"
+ commit id: "Right Container (7 plants)"
+ commit id: "Terrarium Structure"
+ checkout body
+ merge containers
+ checkout main
+ merge head
+ merge body
+ commit id: "Complete HTML Page"
+```
+
+### ๐ **Pedagogical Check-in**
+**HTML Structure Mastery**: Before moving forward, ensure you can:
+- โ
Explain the difference between HTML structure and visual appearance
+- โ
Identify semantic vs. non-semantic HTML elements
+- โ
Describe how proper markup benefits accessibility
+- โ
Recognize the complete document tree structure
+
+**Testing Your Understanding**: Try opening your HTML file in a browser with JavaScript disabled and CSS removed. This shows you the pure semantic structure you've created!
+
---
## GitHub Copilot Agent Challenge
@@ -346,6 +498,95 @@ HTML has been the foundation of the web for over 30 years, evolving from a simpl
- What new HTML features are being proposed for future versions?
- How does semantic HTML contribute to web accessibility and SEO?
+### โก **What You Can Do in the Next 5 Minutes**
+- [ ] Open DevTools (F12) and inspect the HTML structure of your favorite website
+- [ ] Create a simple HTML file with basic tags: `
` inside a `
` be?
+```css
+div { color: blue; }
+.special { color: green; }
+h1 { color: red; }
+```
+*Answer: Red (element selector directly targets h1)*
+
## Mastering CSS Selectors
CSS selectors are your way of targeting specific elements for styling. They work like giving precise directions - instead of saying "the house," you might say "the blue house with the red door on Maple Street."
@@ -285,6 +378,23 @@ Once you understand positioning, many layout challenges become manageable. Need
### The Five Position Values
+```mermaid
+quadrantChart
+ title CSS Positioning Strategy
+ x-axis Document Flow --> Removed from Flow
+ y-axis Static Position --> Precise Control
+ quadrant-1 Absolute
+ quadrant-2 Fixed
+ quadrant-3 Static
+ quadrant-4 Sticky
+
+ Static: [0.2, 0.2]
+ Relative: [0.3, 0.6]
+ Absolute: [0.8, 0.8]
+ Fixed: [0.9, 0.7]
+ Sticky: [0.5, 0.9]
+```
+
| Position Value | Behavior | Use Case |
|----------------|----------|----------|
| `static` | Default flow, ignores top/left/right/bottom | Normal document layout |
@@ -330,12 +440,46 @@ Our terrarium uses a strategic combination of positioning types to create the de
- How does the layout change if `.plant-holder` uses `absolute` instead of `relative`?
- What occurs when you switch `.plant` to `relative` positioning?
+### ๐ **Pedagogical Check-in**
+**CSS Positioning Mastery**: Pause to verify your understanding:
+- โ
Can you explain why plants need absolute positioning for drag-and-drop?
+- โ
Do you understand how relative containers create positioning context?
+- โ
Why do the side containers use absolute positioning?
+- โ
What would happen if you removed position declarations entirely?
+
+**Real-World Connection**: Think about how CSS positioning mirrors real-world layout:
+- **Static**: Books on a shelf (natural order)
+- **Relative**: Moving a book slightly but keeping its spot
+- **Absolute**: Placing a bookmark at an exact page number
+- **Fixed**: A sticky note that stays visible as you flip pages
+
## Building the Terrarium with CSS
Now we'll build a glass jar using only CSS - no images or graphics software required.
Creating realistic-looking glass, shadows, and depth effects using positioning and transparency demonstrates CSS's visual capabilities. This technique mirrors how architects in the Bauhaus movement used simple geometric forms to create complex, beautiful structures. Once you understand these principles, you'll recognize the CSS techniques behind many web designs.
+```mermaid
+flowchart LR
+ A[Jar Top] --> E[Complete Terrarium]
+ B[Jar Walls] --> E
+ C[Dirt Layer] --> E
+ D[Jar Bottom] --> E
+ F[Glass Effects] --> E
+
+ A1["50% width
5% height
Top position"] --> A
+ B1["60% width
80% height
Rounded corners
0.5 opacity"] --> B
+ C1["60% width
5% height
Dark brown
Bottom layer"] --> C
+ D1["50% width
1% height
Bottom position"] --> D
+ F1["Subtle shadows
Transparency
Z-index layering"] --> F
+
+ style E fill:#d1e1df,stroke:#3a241d
+ style A fill:#e8f5e8
+ style B fill:#e8f5e8
+ style C fill:#8B4513
+ style D fill:#e8f5e8
+```
+
### Creating the Glass Jar Components
Let's build the terrarium jar piece by piece. Each part uses absolute positioning and percentage-based sizing for responsive design:
@@ -416,6 +560,18 @@ We're using `rem` units for border-radius, which scale relative to the root font
- Adjust the dirt color from `#3a241d` to `#8B4513` โ what visual impact does this have?
- Modify the `z-index` of the dirt to 2 โ what happens to the layering?
+### ๐ **Pedagogical Check-in**
+**CSS Visual Design Understanding**: Confirm your grasp of visual CSS:
+- โ
How do percentage-based dimensions create responsive design?
+- โ
Why does opacity create the glass transparency effect?
+- โ
What role does z-index play in layering elements?
+- โ
How do border-radius values create the jar shape?
+
+**Design Principle**: Notice how we're building complex visuals from simple shapes:
+1. **Rectangles** โ **Rounded rectangles** โ **Jar components**
+2. **Flat colors** โ **Opacity** โ **Glass effect**
+3. **Individual elements** โ **Layered composition** โ **3D appearance**
+
---
## GitHub Copilot Agent Challenge ๐
@@ -468,6 +624,102 @@ Practice these concepts with these engaging, hands-on games:
For comprehensive CSS fundamentals, complete this Microsoft Learn module: [Style your HTML app with CSS](https://docs.microsoft.com/learn/modules/build-simple-website/4-css-basics/?WT.mc_id=academic-77807-sagibbon)
+### โก **What You Can Do in the Next 5 Minutes**
+- [ ] Open DevTools and inspect CSS styles on any website using the Elements panel
+- [ ] Create a simple CSS file and link it to an HTML page
+- [ ] Try changing colors using different methods: hex, RGB, and named colors
+- [ ] Practice the box model by adding padding and margin to a div
+
+### ๐ฏ **What You Can Accomplish This Hour**
+- [ ] Complete the post-lesson quiz and review CSS fundamentals
+- [ ] Style your HTML page with fonts, colors, and spacing
+- [ ] Create a simple layout using flexbox or grid
+- [ ] Experiment with CSS transitions for smooth effects
+- [ ] Practice responsive design with media queries
+
+### ๐
**Your Week-Long CSS Adventure**
+- [ ] Complete the terrarium styling assignment with creative flair
+- [ ] Master CSS Grid by building a photo gallery layout
+- [ ] Learn CSS animations to bring your designs to life
+- [ ] Explore CSS preprocessors like Sass or Less
+- [ ] Study design principles and apply them to your CSS
+- [ ] Analyze and recreate interesting designs you find online
+
+### ๐ **Your Month-Long Design Mastery**
+- [ ] Build a complete responsive website design system
+- [ ] Learn CSS-in-JS or utility-first frameworks like Tailwind
+- [ ] Contribute to open source projects with CSS improvements
+- [ ] Master advanced CSS concepts like CSS custom properties and containment
+- [ ] Create reusable component libraries with modular CSS
+- [ ] Mentor others learning CSS and share design knowledge
+
+## ๐ฏ Your CSS Mastery Timeline
+
+```mermaid
+timeline
+ title CSS Learning Progression
+
+ section Foundation (10 minutes)
+ File Connection: Link CSS to HTML
+ : Understand cascade rules
+ : Learn inheritance basics
+
+ section Selectors (15 minutes)
+ Targeting Elements: Element selectors
+ : Class patterns
+ : ID specificity
+ : Combinators
+
+ section Box Model (20 minutes)
+ Layout Fundamentals: Margin and padding
+ : Border properties
+ : Content sizing
+ : Box-sizing behavior
+
+ section Positioning (25 minutes)
+ Element Placement: Static vs relative
+ : Absolute positioning
+ : Z-index layering
+ : Responsive units
+
+ section Visual Design (30 minutes)
+ Styling Mastery: Colors and opacity
+ : Shadows and effects
+ : Transitions
+ : Transform properties
+
+ section Responsive Design (45 minutes)
+ Multi-Device Support: Media queries
+ : Flexible layouts
+ : Mobile-first approach
+ : Viewport optimization
+
+ section Advanced Techniques (1 week)
+ Modern CSS: Flexbox layouts
+ : CSS Grid systems
+ : Custom properties
+ : Animation keyframes
+
+ section Professional Skills (1 month)
+ CSS Architecture: Component patterns
+ : Maintainable code
+ : Performance optimization
+ : Cross-browser compatibility
+```
+
+### ๐ ๏ธ Your CSS Toolkit Summary
+
+After completing this lesson, you now have:
+- **Cascade Understanding**: How styles inherit and override each other
+- **Selector Mastery**: Precise targeting with elements, classes, and IDs
+- **Positioning Skills**: Strategic element placement and layering
+- **Visual Design**: Creating glass effects, shadows, and transparency
+- **Responsive Techniques**: Percentage-based layouts that adapt to any screen
+- **Code Organization**: Clean, maintainable CSS structure
+- **Modern Practices**: Using relative units and accessible design patterns
+
+**Next Steps**: Your terrarium now has both structure (HTML) and style (CSS). The final lesson will add interactivity with JavaScript!
+
## Assignment
[CSS Refactoring](assignment.md)
diff --git a/3-terrarium/3-intro-to-DOM-and-closures/README.md b/3-terrarium/3-intro-to-DOM-and-closures/README.md
index c92bcce3..a9be6ce0 100644
--- a/3-terrarium/3-intro-to-DOM-and-closures/README.md
+++ b/3-terrarium/3-intro-to-DOM-and-closures/README.md
@@ -1,5 +1,22 @@
# Terrarium Project Part 3: DOM Manipulation and JavaScript Closures
+```mermaid
+journey
+ title Your JavaScript DOM Journey
+ section Foundation
+ Understand DOM: 3: Student
+ Learn closures: 4: Student
+ Connect elements: 4: Student
+ section Interaction
+ Setup drag events: 4: Student
+ Track coordinates: 5: Student
+ Handle movement: 5: Student
+ section Polish
+ Add cleanup: 4: Student
+ Test functionality: 5: Student
+ Complete terrarium: 5: Student
+```
+

> Sketchnote by [Tomomi Imura](https://twitter.com/girlie_mac)
@@ -9,6 +26,36 @@ We'll also explore JavaScript closures, which might sound intimidating initially
Here's what we're building: a terrarium where users can drag and drop plants anywhere they want. You'll learn the DOM manipulation techniques that power everything from drag-and-drop file uploads to interactive games. Let's make your terrarium come alive.
+```mermaid
+mindmap
+ root((DOM & JavaScript))
+ DOM Tree
+ Element Selection
+ Property Access
+ Event Handling
+ Dynamic Updates
+ Events
+ Pointer Events
+ Mouse Events
+ Touch Events
+ Event Listeners
+ Closures
+ Private Variables
+ Function Scope
+ Memory Persistence
+ State Management
+ Drag & Drop
+ Position Tracking
+ Coordinate Math
+ Event Lifecycle
+ User Interaction
+ Modern Patterns
+ Event Delegation
+ Performance
+ Cross-Device
+ Accessibility
+```
+
## Pre-Lecture Quiz
[Pre-lecture quiz](https://ff-quizzes.netlify.app/web/quiz/19)
@@ -19,6 +66,36 @@ The Document Object Model (DOM) is how JavaScript communicates with your HTML el
DOM manipulation transforms static pages into interactive websites. Every time you see a button change color on hover, content update without page refresh, or elements you can drag around, that's DOM manipulation at work.
+```mermaid
+flowchart TD
+ A["Document"] --> B["HTML"]
+ B --> C["Head"]
+ B --> D["Body"]
+ C --> E["Title"]
+ C --> F["Meta Tags"]
+ D --> G["H1: My Terrarium"]
+ D --> H["Div: Page Container"]
+ H --> I["Div: Left Container"]
+ H --> J["Div: Right Container"]
+ H --> K["Div: Terrarium"]
+ I --> L["Plant Elements 1-7"]
+ J --> M["Plant Elements 8-14"]
+
+ L --> N["img#plant1"]
+ L --> O["img#plant2"]
+ M --> P["img#plant8"]
+ M --> Q["img#plant9"]
+
+ style A fill:#e1f5fe
+ style B fill:#f3e5f5
+ style D fill:#e8f5e8
+ style H fill:#fff3e0
+ style N fill:#ffebee
+ style O fill:#ffebee
+ style P fill:#ffebee
+ style Q fill:#ffebee
+```
+

> A representation of the DOM and the HTML markup that references it. From [Olfa Nasraoui](https://www.researchgate.net/publication/221417012_Profile-Based_Focused_Crawler_for_Social_Media-Sharing_Websites)
@@ -35,6 +112,33 @@ A [JavaScript closure](https://developer.mozilla.org/docs/Web/JavaScript/Closure
In our terrarium, closures help each plant remember its own position independently. This pattern appears throughout professional JavaScript development, making it a valuable concept to understand.
+```mermaid
+flowchart LR
+ A["dragElement(plant1)"] --> B["Creates Closure"]
+ A2["dragElement(plant2)"] --> B2["Creates Closure"]
+
+ B --> C["Private Variables"]
+ B2 --> C2["Private Variables"]
+
+ C --> D["pos1, pos2, pos3, pos4"]
+ C --> E["pointerDrag function"]
+ C --> F["elementDrag function"]
+ C --> G["stopElementDrag function"]
+
+ C2 --> D2["pos1, pos2, pos3, pos4"]
+ C2 --> E2["pointerDrag function"]
+ C2 --> F2["elementDrag function"]
+ C2 --> G2["stopElementDrag function"]
+
+ H["Plant 1 remembers its position"] --> B
+ H2["Plant 2 remembers its position"] --> B2
+
+ style B fill:#e8f5e8
+ style B2 fill:#e8f5e8
+ style C fill:#fff3e0
+ style C2 fill:#fff3e0
+```
+
> ๐ก **Understanding Closures**: Closures are a significant topic in JavaScript, and many developers use them for years before fully grasping all the theoretical aspects. Today, we're focusing on practical application - you'll see closures naturally emerge as we build our interactive features. Understanding will develop as you see how they solve real problems.

@@ -118,6 +222,16 @@ dragElement(document.getElementById('plant14'));
> ๐ก **Pro Tip**: Notice how we're calling `dragElement()` for each plant individually. This approach ensures that each plant gets its own independent dragging behavior, which is essential for smooth user interaction.
+### ๐ **Pedagogical Check-in**
+**DOM Connection Understanding**: Before moving to drag functionality, verify you can:
+- โ
Explain how `document.getElementById()` locates HTML elements
+- โ
Understand why we use unique IDs for each plant
+- โ
Describe the purpose of the `defer` attribute in script tags
+- โ
Recognize how JavaScript and HTML connect through the DOM
+
+**Quick Self-Test**: What would happen if two elements had the same ID? Why does `getElementById()` return only one element?
+*Answer: IDs should be unique; if duplicated, only the first element is returned*
+
---
## Building the Drag Element Closure
@@ -165,6 +279,34 @@ For our terrarium, each plant needs to remember its current position coordinates
> ๐ฏ **Learning Goal**: You don't need to master every aspect of closures right now. Focus on seeing how they help us organize code and maintain state for our dragging functionality.
+```mermaid
+stateDiagram-v2
+ [*] --> Ready: Page loads
+ Ready --> DragStart: User presses down (pointerdown)
+ DragStart --> Dragging: Mouse/finger moves (pointermove)
+ Dragging --> Dragging: Continue moving
+ Dragging --> DragEnd: User releases (pointerup)
+ DragEnd --> Ready: Reset for next drag
+
+ state DragStart {
+ [*] --> CapturePosition
+ CapturePosition --> SetupListeners
+ SetupListeners --> [*]
+ }
+
+ state Dragging {
+ [*] --> CalculateMovement
+ CalculateMovement --> UpdatePosition
+ UpdatePosition --> [*]
+ }
+
+ state DragEnd {
+ [*] --> RemoveListeners
+ RemoveListeners --> CleanupState
+ CleanupState --> [*]
+ }
+```
+
### Creating the dragElement Function
Now let's build the main function that will handle all the dragging logic. Add this function below your plant element declarations:
@@ -212,6 +354,19 @@ You might wonder why we use `onpointerdown` instead of the more familiar `onclic
> ๐ก **Future-Proofing**: Pointer events are the modern way to handle user interactions. Instead of writing separate code for mouse and touch, you get both for free. Pretty neat, right?
+### ๐ **Pedagogical Check-in**
+**Event Handling Understanding**: Pause to confirm your grasp of events:
+- โ
Why do we use pointer events instead of mouse events?
+- โ
How do closure variables persist between function calls?
+- โ
What role does `preventDefault()` play in smooth dragging?
+- โ
Why do we attach listeners to the document instead of individual elements?
+
+**Real-World Connection**: Think about drag-and-drop interfaces you use daily:
+- **File uploads**: Dragging files into a browser window
+- **Kanban boards**: Moving tasks between columns
+- **Image galleries**: Rearranging photo order
+- **Mobile interfaces**: Swiping and dragging on touchscreens
+
---
## The pointerDrag Function: Capturing the Start of a Drag
@@ -315,6 +470,30 @@ function elementDrag(e) {
- **`offsetTop` and `offsetLeft`**: Get the element's current position on the page
- **Subtraction logic**: Moves the element by the same amount the mouse moved
+```mermaid
+sequenceDiagram
+ participant User
+ participant Mouse
+ participant JavaScript
+ participant Plant
+
+ User->>Mouse: Start drag at (100, 50)
+ Mouse->>JavaScript: pointerdown event
+ JavaScript->>JavaScript: Store initial position (pos3=100, pos4=50)
+ JavaScript->>JavaScript: Setup move/up listeners
+
+ User->>Mouse: Move to (110, 60)
+ Mouse->>JavaScript: pointermove event
+ JavaScript->>JavaScript: Calculate: pos1=10, pos2=10
+ JavaScript->>Plant: Update: left += 10px, top += 10px
+ Plant->>Plant: Render at new position
+
+ User->>Mouse: Release at (120, 65)
+ Mouse->>JavaScript: pointerup event
+ JavaScript->>JavaScript: Remove listeners
+ JavaScript->>JavaScript: Reset for next drag
+```
+
**Here's the movement calculation breakdown:**
1. **Measures** the difference between old and new mouse positions
2. **Calculates** how much to move the element based on mouse movement
@@ -398,6 +577,19 @@ Now test your interactive terrarium! Open your `index.html` file in a web browse
๐ฅ **Achievement**: You've created a fully interactive web application using core concepts that professional developers use daily. That drag-and-drop functionality uses the same principles behind file uploads, kanban boards, and many other interactive interfaces.
+### ๐ **Pedagogical Check-in**
+**Complete System Understanding**: Verify your mastery of the full drag system:
+- โ
How do closures maintain independent state for each plant?
+- โ
Why is the coordinate calculation math necessary for smooth movement?
+- โ
What would happen if we forgot to clean up event listeners?
+- โ
How does this pattern scale to more complex interactions?
+
+**Code Quality Reflection**: Review your complete solution:
+- **Modular design**: Each plant gets its own closure instance
+- **Event efficiency**: Proper setup and cleanup of listeners
+- **Cross-device support**: Works on desktop and mobile
+- **Performance conscious**: No memory leaks or redundant calculations
+

---
@@ -471,6 +663,102 @@ We used pointer events for maximum flexibility, but web development offers multi
> ๐ฏ **Learning Strategy**: The best way to solidify these concepts is through practice. Try building variations of draggable interfaces โ each project will teach you something new about user interaction and DOM manipulation.
+### โก **What You Can Do in the Next 5 Minutes**
+- [ ] Open browser DevTools and type `document.querySelector('body')` in the console
+- [ ] Try changing a webpage's text using `innerHTML` or `textContent`
+- [ ] Add a click event listener to any button or link on a webpage
+- [ ] Inspect the DOM tree structure using the Elements panel
+
+### ๐ฏ **What You Can Accomplish This Hour**
+- [ ] Complete the post-lesson quiz and review DOM manipulation concepts
+- [ ] Create an interactive webpage that responds to user clicks
+- [ ] Practice event handling with different event types (click, mouseover, keypress)
+- [ ] Build a simple to-do list or counter using DOM manipulation
+- [ ] Explore the relationship between HTML elements and JavaScript objects
+
+### ๐
**Your Week-Long JavaScript Journey**
+- [ ] Complete the interactive terrarium project with drag-and-drop functionality
+- [ ] Master event delegation for efficient event handling
+- [ ] Learn about the event loop and asynchronous JavaScript
+- [ ] Practice closures by building modules with private state
+- [ ] Explore modern DOM APIs like Intersection Observer
+- [ ] Build interactive components without using frameworks
+
+### ๐ **Your Month-Long JavaScript Mastery**
+- [ ] Create a complex single-page application using vanilla JavaScript
+- [ ] Learn a modern framework (React, Vue, or Angular) and compare it to vanilla DOM
+- [ ] Contribute to open source JavaScript projects
+- [ ] Master advanced concepts like web components and custom elements
+- [ ] Build performant web applications with optimal DOM patterns
+- [ ] Teach others about DOM manipulation and JavaScript fundamentals
+
+## ๐ฏ Your JavaScript DOM Mastery Timeline
+
+```mermaid
+timeline
+ title DOM & JavaScript Learning Progression
+
+ section Foundation (15 minutes)
+ DOM Understanding: Element selection methods
+ : Tree structure navigation
+ : Property access patterns
+
+ section Event Handling (20 minutes)
+ User Interaction: Pointer event basics
+ : Event listener setup
+ : Cross-device compatibility
+ : Event prevention techniques
+
+ section Closures (25 minutes)
+ Scope Management: Private variable creation
+ : Function persistence
+ : State management patterns
+ : Memory efficiency
+
+ section Drag System (30 minutes)
+ Interactive Features: Coordinate tracking
+ : Position calculation
+ : Movement mathematics
+ : Cleanup procedures
+
+ section Advanced Patterns (45 minutes)
+ Professional Skills: Event delegation
+ : Performance optimization
+ : Error handling
+ : Accessibility considerations
+
+ section Framework Understanding (1 week)
+ Modern Development: Virtual DOM concepts
+ : State management libraries
+ : Component architectures
+ : Build tool integration
+
+ section Expert Level (1 month)
+ Advanced DOM APIs: Intersection Observer
+ : Mutation Observer
+ : Custom Elements
+ : Web Components
+```
+
+### ๐ ๏ธ Your JavaScript Toolkit Summary
+
+After completing this lesson, you now have:
+- **DOM Mastery**: Element selection, property manipulation, and tree navigation
+- **Event Expertise**: Cross-device interaction handling with pointer events
+- **Closure Understanding**: Private state management and function persistence
+- **Interactive Systems**: Complete drag-and-drop implementation from scratch
+- **Performance Awareness**: Proper event cleanup and memory management
+- **Modern Patterns**: Code organization techniques used in professional development
+- **User Experience**: Creating intuitive, responsive interfaces
+
+**Professional Skills Gained**: You've built features using the same techniques as:
+- **Trello/Kanban boards**: Card dragging between columns
+- **File upload systems**: Drag-and-drop file handling
+- **Image galleries**: Photo arrangement interfaces
+- **Mobile apps**: Touch-based interaction patterns
+
+**Next Level**: You're ready to explore modern frameworks like React, Vue, or Angular that build upon these fundamental DOM manipulation concepts!
+
## Assignment
[Work a bit more with the DOM](assignment.md)
diff --git a/4-typing-game/README.md b/4-typing-game/README.md
index 69392974..6d27fcf6 100644
--- a/4-typing-game/README.md
+++ b/4-typing-game/README.md
@@ -1,19 +1,132 @@
# Event-Driven Programming - Build a Typing Game
+```mermaid
+journey
+ title Your Typing Game Development Journey
+ section Foundation
+ Plan game structure: 3: Student
+ Design user interface: 4: Student
+ Setup HTML elements: 4: Student
+ section Functionality
+ Handle user input: 4: Student
+ Track timing: 5: Student
+ Calculate accuracy: 5: Student
+ section Features
+ Add visual feedback: 5: Student
+ Implement game logic: 5: Student
+ Polish experience: 5: Student
+```
+
## Introduction
Here's something every developer knows but rarely talks about: typing fast is a superpower! ๐ Think about it - the faster you can get your ideas from your brain to your code editor, the more your creativity can flow. It's like having a direct pipeline between your thoughts and the screen.
+```mermaid
+pie title Game Features
+ "Real-time Feedback" : 25
+ "Performance Tracking" : 20
+ "Interactive UI" : 20
+ "Timer System" : 15
+ "Quote Management" : 10
+ "Results Display" : 10
+```
+
Want to know one of the best ways to level up this skill? You guessed it - we're going to build a game!
+```mermaid
+flowchart LR
+ A[Player starts game] --> B[Random quote displayed]
+ B --> C[Player types characters]
+ C --> D{Character correct?}
+ D -->|Yes| E[Green highlight]
+ D -->|No| F[Red highlight]
+ E --> G[Update accuracy]
+ F --> G
+ G --> H{Quote complete?}
+ H -->|No| C
+ H -->|Yes| I[Calculate WPM]
+ I --> J[Display results]
+ J --> K[Play again?]
+ K -->|Yes| B
+ K -->|No| L[Game over]
+
+ style A fill:#e1f5fe
+ style D fill:#fff3e0
+ style E fill:#e8f5e8
+ style F fill:#ffebee
+ style I fill:#f3e5f5
+```
+
> Let's create an awesome typing game together!
Ready to put all those JavaScript, HTML, and CSS skills you've been learning to work? We're going to build a typing game that'll challenge you with random quotes from the legendary detective [Sherlock Holmes](https://en.wikipedia.org/wiki/Sherlock_Holmes). The game will track how fast and accurately you can type - and trust me, it's more addictive than you might think!
+```mermaid
+mindmap
+ root((Typing Game Development))
+ User Interface
+ Input Elements
+ Visual Feedback
+ Responsive Design
+ Accessibility
+ Game Logic
+ Quote Selection
+ Timer Management
+ Accuracy Tracking
+ Score Calculation
+ Event Handling
+ Keyboard Input
+ Button Clicks
+ Real-time Updates
+ Game State Changes
+ Performance Metrics
+ Words Per Minute
+ Character Accuracy
+ Error Tracking
+ Progress Display
+ User Experience
+ Immediate Feedback
+ Clear Instructions
+ Engaging Content
+ Achievement System
+```
+

## What You'll Need to Know
+```mermaid
+flowchart TD
+ A[User Action] --> B{Event Type?}
+ B -->|Key Press| C[Keyboard Event]
+ B -->|Button Click| D[Mouse Event]
+ B -->|Timer| E[Time Event]
+
+ C --> F[Check Character]
+ D --> G[Start/Reset Game]
+ E --> H[Update Timer]
+
+ F --> I{Correct?}
+ I -->|Yes| J[Highlight Green]
+ I -->|No| K[Highlight Red]
+
+ J --> L[Update Score]
+ K --> L
+ L --> M[Check Game State]
+
+ G --> N[Generate New Quote]
+ H --> O[Display Time]
+
+ M --> P{Game Complete?}
+ P -->|Yes| Q[Show Results]
+ P -->|No| R[Continue Game]
+
+ style A fill:#e1f5fe
+ style F fill:#e8f5e8
+ style I fill:#fff3e0
+ style Q fill:#f3e5f5
+```
+
Before we dive in, make sure you're comfortable with these concepts (don't worry if you need a quick refresher - we've all been there!):
- Creating text input and button controls
@@ -25,10 +138,144 @@ Before we dive in, make sure you're comfortable with these concepts (don't worry
If any of these feel a bit rusty, that's totally fine! Sometimes the best way to solidify your knowledge is by jumping into a project and figuring things out as you go.
+### ๐ **Pedagogical Check-in**
+**Foundation Assessment**: Before starting development, ensure you understand:
+- โ
How HTML forms and input elements work
+- โ
CSS classes and dynamic styling
+- โ
JavaScript event listeners and handlers
+- โ
Array manipulation and random selection
+- โ
Time measurement and calculations
+
+**Quick Self-Test**: Can you explain how these concepts work together in an interactive game?
+- **Events** trigger when users interact with elements
+- **Handlers** process those events and update game state
+- **CSS** provides visual feedback for user actions
+- **Timing** enables performance measurement and game progression
+
+```mermaid
+quadrantChart
+ title Typing Game Skills Development
+ x-axis Beginner --> Expert
+ y-axis Static --> Interactive
+ quadrant-1 Advanced Games
+ quadrant-2 Real-time Apps
+ quadrant-3 Basic Pages
+ quadrant-4 Interactive Sites
+
+ HTML Forms: [0.3, 0.2]
+ CSS Styling: [0.4, 0.3]
+ Event Handling: [0.7, 0.8]
+ Game Logic: [0.8, 0.9]
+ Performance Tracking: [0.9, 0.7]
+```
+
## Let's Build This Thing!
[Creating a typing game by using event driven programming](./typing-game/README.md)
+### โก **What You Can Do in the Next 5 Minutes**
+- [ ] Open your browser console and try listening for keyboard events with `addEventListener`
+- [ ] Create a simple HTML page with an input field and test typing detection
+- [ ] Practice string manipulation by comparing typed text with target text
+- [ ] Experiment with `setTimeout` to understand timing functions
+
+### ๐ฏ **What You Can Accomplish This Hour**
+- [ ] Complete the post-lesson quiz and understand event-driven programming
+- [ ] Build a basic version of the typing game with word validation
+- [ ] Add visual feedback for correct and incorrect typing
+- [ ] Implement a simple scoring system based on speed and accuracy
+- [ ] Style your game with CSS to make it visually appealing
+
+### ๐
**Your Week-Long Game Development**
+- [ ] Complete the full typing game with all features and polish
+- [ ] Add difficulty levels with varying word complexity
+- [ ] Implement user statistics tracking (WPM, accuracy over time)
+- [ ] Create sound effects and animations for better user experience
+- [ ] Make your game mobile-responsive for touch devices
+- [ ] Share your game online and gather feedback from users
+
+### ๐ **Your Month-Long Interactive Development**
+- [ ] Build multiple games exploring different interaction patterns
+- [ ] Learn about game loops, state management, and performance optimization
+- [ ] Contribute to open source game development projects
+- [ ] Master advanced timing concepts and smooth animations
+- [ ] Create a portfolio showcasing various interactive applications
+- [ ] Mentor others interested in game development and user interaction
+
+## ๐ฏ Your Typing Game Mastery Timeline
+
+```mermaid
+timeline
+ title Game Development Learning Progression
+
+ section Setup (10 minutes)
+ Project Structure: HTML foundation
+ : CSS styling setup
+ : JavaScript file creation
+
+ section User Interface (20 minutes)
+ Interactive Elements: Input fields
+ : Button controls
+ : Display areas
+ : Responsive layout
+
+ section Event Handling (25 minutes)
+ User Interaction: Keyboard events
+ : Mouse events
+ : Real-time feedback
+ : State management
+
+ section Game Logic (30 minutes)
+ Core Functionality: Quote generation
+ : Character comparison
+ : Accuracy calculation
+ : Timer implementation
+
+ section Performance Tracking (35 minutes)
+ Metrics & Analytics: WPM calculation
+ : Error tracking
+ : Progress visualization
+ : Results display
+
+ section Polish & Enhancement (45 minutes)
+ User Experience: Visual feedback
+ : Sound effects
+ : Animations
+ : Accessibility features
+
+ section Advanced Features (1 week)
+ Extended Functionality: Difficulty levels
+ : Leaderboards
+ : Custom quotes
+ : Multiplayer options
+
+ section Professional Skills (1 month)
+ Game Development: Performance optimization
+ : Code architecture
+ : Testing strategies
+ : Deployment patterns
+```
+
+### ๐ ๏ธ Your Game Development Toolkit Summary
+
+After completing this project, you'll have mastered:
+- **Event-Driven Programming**: Responsive user interfaces that react to input
+- **Real-Time Feedback**: Instant visual and performance updates
+- **Performance Measurement**: Accurate timing and scoring systems
+- **Game State Management**: Controlling application flow and user experience
+- **Interactive Design**: Creating engaging, addictive user experiences
+- **Modern Web APIs**: Utilizing browser capabilities for rich interactions
+- **Accessibility Patterns**: Inclusive design for all users
+
+**Real-World Applications**: These skills directly apply to:
+- **Web Applications**: Any interactive interface or dashboard
+- **Educational Software**: Learning platforms and skill assessment tools
+- **Productivity Tools**: Text editors, IDEs, and collaboration software
+- **Gaming Industry**: Browser games and interactive entertainment
+- **Mobile Development**: Touch-based interfaces and gesture handling
+
+**Next Level**: You're ready to explore advanced game frameworks, real-time multiplayer systems, or complex interactive applications!
+
## Credits
Written with โฅ๏ธ by [Christopher Harrison](http://www.twitter.com/geektrainer)
diff --git a/4-typing-game/typing-game/README.md b/4-typing-game/typing-game/README.md
index 1525a5e3..643408e7 100644
--- a/4-typing-game/typing-game/README.md
+++ b/4-typing-game/typing-game/README.md
@@ -532,6 +532,65 @@ Ready to take your typing game to the next level? Try implementing these advance
[Post-lecture quiz](https://ff-quizzes.netlify.app/web/quiz/22)
+---
+
+## ๐ Your Typing Game Mastery Timeline
+
+### โก **What You Can Do in the Next 5 Minutes**
+- [ ] Test your typing game with different quotes to ensure it works smoothly
+- [ ] Experiment with the CSS styling - try changing the highlight and error colors
+- [ ] Open your browser's DevTools (F12) and watch the Console while playing
+- [ ] Challenge yourself to complete a quote as fast as possible
+
+### โฐ **What You Can Accomplish This Hour**
+- [ ] Add more quotes to the array (maybe from your favorite books or movies)
+- [ ] Implement the localStorage high score system from the challenge section
+- [ ] Create a words-per-minute calculator that displays after each game
+- [ ] Add sound effects for correct typing, errors, and completion
+
+### ๐
**Your Week-Long Adventure**
+- [ ] Build a multiplayer version where friends can compete side-by-side
+- [ ] Create different difficulty levels with varying quote complexity
+- [ ] Add a progress bar showing how much of the quote is complete
+- [ ] Implement user accounts with personal statistics tracking
+- [ ] Design custom themes and let users choose their preferred styling
+
+### ๐๏ธ **Your Month-Long Transformation**
+- [ ] Create a typing course with lessons that progressively teach proper finger placement
+- [ ] Build analytics that show which letters or words cause the most errors
+- [ ] Add support for different languages and keyboard layouts
+- [ ] Integrate with educational APIs to pull quotes from literature databases
+- [ ] Publish your enhanced typing game for others to use and enjoy
+
+### ๐ฏ **Final Reflection Check-in**
+
+**Before you move on, take a moment to celebrate:**
+- What was the most satisfying moment while building this game?
+- How do you feel about event-driven programming now compared to when you started?
+- What's one feature you're excited to add to make this game uniquely yours?
+- How might you apply event handling concepts to other projects?
+
+```mermaid
+journey
+ title Your Event Programming Confidence Journey
+ section Today
+ Understanding Events: 3: You
+ Building UI: 4: You
+ Writing Event Listeners: 5: You
+ section This Week
+ Adding Features: 4: You
+ Debugging Issues: 5: You
+ Enhancing UX: 4: You
+ section Next Month
+ Building Complex Apps: 5: You
+ Teaching Others: 5: You
+ Creating Frameworks: 5: You
+```
+
+> ๐ **Remember**: You've just mastered one of the core concepts that powers every interactive website and application. Event-driven programming is what makes the web feel alive and responsive. Every time you see a dropdown menu, a form that validates as you type, or a game that responds to your clicks, you now understand the magic behind it. You're not just learning to code - you're learning to create experiences that feel intuitive and engaging! ๐
+
+---
+
## Review & Self Study
Read up on [all the events available](https://developer.mozilla.org/docs/Web/Events) to the developer via the web browser, and consider the scenarios in which you would use each one.
diff --git a/5-browser-extension/1-about-browsers/README.md b/5-browser-extension/1-about-browsers/README.md
index c977b032..7537d1fe 100644
--- a/5-browser-extension/1-about-browsers/README.md
+++ b/5-browser-extension/1-about-browsers/README.md
@@ -1,5 +1,22 @@
# Browser Extension Project Part 1: All about Browsers
+```mermaid
+journey
+ title Your Browser Extension Development Journey
+ section Foundation
+ Understand browsers: 3: Student
+ Learn extension types: 4: Student
+ Setup development: 4: Student
+ section Development
+ Build interface: 4: Student
+ Add functionality: 5: Student
+ Handle data: 5: Student
+ section Integration
+ Test in browser: 5: Student
+ Debug issues: 4: Student
+ Polish experience: 5: Student
+```
+

> Sketchnote by [Wassim Chegham](https://dev.to/wassimchegham/ever-wondered-what-happens-when-you-type-in-a-url-in-an-address-bar-in-a-browser-3dob)
@@ -15,6 +32,36 @@ Before we build your first extension, let's understand how browsers work. Just a
By the end of this lesson, you'll understand browser architecture and have started building your first extension.
+```mermaid
+mindmap
+ root((Browser Architecture))
+ Core Components
+ Rendering Engine
+ JavaScript Engine
+ Network Stack
+ Storage APIs
+ User Interface
+ Address Bar
+ Tab Management
+ Bookmarks
+ Extension Icons
+ Extension System
+ Manifest Files
+ Content Scripts
+ Background Pages
+ Popup Windows
+ Security Model
+ Same-Origin Policy
+ Permissions API
+ Content Security
+ Isolated Worlds
+ Development Tools
+ DevTools Integration
+ Debug Console
+ Performance Monitor
+ Extension Inspector
+```
+
## Understanding Web Browsers
A web browser is essentially a sophisticated document interpreter. When you type "google.com" into the address bar, the browser performs a complex series of operations - requesting content from servers worldwide, then parsing and rendering that code into the interactive web pages you see.
@@ -34,15 +81,21 @@ The process between entering a URL and seeing a webpage involves several coordin
sequenceDiagram
participant User
participant Browser
+ participant Extension
participant DNS
participant Server
User->>Browser: Types URL and presses Enter
+ Browser->>Extension: Trigger beforeRequest event
+ Extension->>Extension: Check if URL needs modification
Browser->>DNS: Looks up server IP address
DNS->>Browser: Returns IP address
Browser->>Server: Requests web page content
Server->>Browser: Sends HTML, CSS, and JavaScript
+ Browser->>Extension: Trigger beforeResponse event
+ Extension->>Extension: Modify content if needed
Browser->>User: Renders complete web page
+ Extension->>User: Show extension UI updates
```
**Here's what this process accomplishes:**
@@ -90,6 +143,26 @@ Browser extensions solve common web browsing challenges by adding functionality
This concept mirrors how early computer pioneers like Douglas Engelbart envisioned augmenting human capabilities with technology - extensions augment your browser's basic functionality.
+```mermaid
+quadrantChart
+ title Browser Extension Categories
+ x-axis Simple --> Complex
+ y-axis Personal Use --> Professional Tools
+ quadrant-1 Developer Tools
+ quadrant-2 Enterprise Solutions
+ quadrant-3 Personal Utilities
+ quadrant-4 Productivity Apps
+
+ Ad Blockers: [0.3, 0.2]
+ Password Managers: [0.7, 0.3]
+ Color Pickers: [0.4, 0.8]
+ Code Formatters: [0.8, 0.9]
+ Note Taking: [0.6, 0.5]
+ Video Downloaders: [0.5, 0.2]
+ Time Trackers: [0.7, 0.6]
+ Screenshot Tools: [0.4, 0.4]
+```
+
**Popular extension categories and their benefits:**
- **Productivity Tools**: Task managers, note-taking apps, and time trackers that help you stay organized
- **Security Enhancements**: Password managers, ad blockers, and privacy tools that protect your data
@@ -98,6 +171,20 @@ This concept mirrors how early computer pioneers like Douglas Engelbart envision
โ
**Reflection Question**: What are your favorite browser extensions? What specific tasks do they perform, and how do they improve your browsing experience?
+### ๐ **Pedagogical Check-in**
+**Browser Architecture Understanding**: Before moving to extension development, ensure you can:
+- โ
Explain how browsers process web requests and render content
+- โ
Identify the main components of browser architecture
+- โ
Understand how extensions integrate with browser functionality
+- โ
Recognize the security model that protects users
+
+**Quick Self-Test**: Can you trace the path from typing a URL to seeing a webpage?
+1. **DNS lookup** converts URL to IP address
+2. **HTTP request** fetches content from server
+3. **Parsing** processes HTML, CSS, and JavaScript
+4. **Rendering** displays the final webpage
+5. **Extensions** can modify content at multiple steps
+
## Installing and Managing Extensions
Understanding the extension installation process helps you anticipate the user experience when people install your extension. The installation process is standardized across modern browsers, with minor variations in interface design.
@@ -110,6 +197,26 @@ Understanding the extension installation process helps you anticipate the user e
When you're developing and testing your own extensions, follow this workflow:
+```mermaid
+flowchart TD
+ A[Write Code] --> B[Build Extension]
+ B --> C{First Install?}
+ C -->|Yes| D[Load Unpacked]
+ C -->|No| E[Reload Extension]
+ D --> F[Test Functionality]
+ E --> F
+ F --> G{Working Correctly?}
+ G -->|No| H[Debug Issues]
+ G -->|Yes| I[Ready for Users]
+ H --> A
+ I --> J[Publish to Store]
+
+ style A fill:#e1f5fe
+ style F fill:#e8f5e8
+ style I fill:#f3e5f5
+ style J fill:#fff3e0
+```
+
```bash
# Step 1: Build your extension
npm run build
@@ -164,6 +271,20 @@ Before beginning development, let's gather the required resources and dependenci
Understanding the project structure helps organize development work efficiently. Like how the Library of Alexandria was organized for easy knowledge retrieval, a well-structured codebase makes development more efficient:
+```mermaid
+fileStructure
+ project-root
+ dist
+ manifest.json
+ index.html
+ background.js
+ main.js
+ src
+ index.js
+ package.json
+ webpack.config.js
+```
+
```
project-root/
โโโ dist/ # Built extension files
@@ -286,6 +407,19 @@ At this point, you can test your extension:
- **Set up** a modern development workflow using industry-standard tools
- **Prepared** the foundation for adding interactive JavaScript functionality
+### ๐ **Pedagogical Check-in**
+**Extension Development Progress**: Verify your understanding before continuing:
+- โ
Can you explain the purpose of each file in the project structure?
+- โ
Do you understand how the build process transforms your source code?
+- โ
Why do we separate configuration and results into different UI sections?
+- โ
How does the form structure support both usability and accessibility?
+
+**Development Workflow Understanding**: You should now be able to:
+1. **Modify** HTML and CSS for your extension interface
+2. **Run** the build command to compile your changes
+3. **Reload** the extension in your browser to test updates
+4. **Debug** issues using browser developer tools
+
You've completed the first phase of browser extension development. Like how the Wright brothers first needed to understand aerodynamics before achieving flight, understanding these foundational concepts prepares you for building more complex interactive features in the next lesson.
## GitHub Copilot Agent Challenge ๐
@@ -316,6 +450,109 @@ In this lesson you learned a little about the history of the web browser; take t
[An interview with Tim Berners-Lee](https://www.theguardian.com/technology/2019/mar/12/tim-berners-lee-on-30-years-of-the-web-if-we-dream-a-little-we-can-get-the-web-we-want)
+### โก **What You Can Do in the Next 5 Minutes**
+- [ ] Open Chrome/Edge extensions page (chrome://extensions) and explore what you have installed
+- [ ] Look at your browser's DevTools Network tab while loading a webpage
+- [ ] Try viewing page source (Ctrl+U) to see HTML structure
+- [ ] Inspect any webpage element and modify its CSS in DevTools
+
+### ๐ฏ **What You Can Accomplish This Hour**
+- [ ] Complete the post-lesson quiz and understand browser fundamentals
+- [ ] Create a basic manifest.json file for a browser extension
+- [ ] Build a simple "Hello World" extension that shows a popup
+- [ ] Test loading your extension in developer mode
+- [ ] Explore the browser extension documentation for your target browser
+
+### ๐
**Your Week-Long Extension Journey**
+- [ ] Complete a functional browser extension with real utility
+- [ ] Learn about content scripts, background scripts, and popup interactions
+- [ ] Master browser APIs like storage, tabs, and messaging
+- [ ] Design user-friendly interfaces for your extension
+- [ ] Test your extension across different websites and scenarios
+- [ ] Publish your extension to the browser's extension store
+
+### ๐ **Your Month-Long Browser Development**
+- [ ] Build multiple extensions solving different user problems
+- [ ] Learn advanced browser APIs and security best practices
+- [ ] Contribute to open source browser extension projects
+- [ ] Master cross-browser compatibility and progressive enhancement
+- [ ] Create extension development tools and templates for others
+- [ ] Become a browser extension expert who helps other developers
+
+## ๐ฏ Your Browser Extension Mastery Timeline
+
+```mermaid
+timeline
+ title Browser Extension Development Progression
+
+ section Foundation (15 minutes)
+ Browser Understanding: Core architecture
+ : Rendering process
+ : Extension integration points
+
+ section Setup (20 minutes)
+ Development Environment: Project structure
+ : Build tools configuration
+ : Browser developer mode
+ : Extension loading process
+
+ section Interface Design (25 minutes)
+ User Experience: HTML structure
+ : CSS styling
+ : Form validation
+ : Responsive design
+
+ section Core Functionality (35 minutes)
+ JavaScript Integration: Event handling
+ : API interactions
+ : Data storage
+ : Error handling
+
+ section Browser APIs (45 minutes)
+ Platform Integration: Permissions system
+ : Storage APIs
+ : Tab management
+ : Context menus
+
+ section Advanced Features (1 week)
+ Professional Extensions: Background scripts
+ : Content scripts
+ : Cross-browser compatibility
+ : Performance optimization
+
+ section Publishing (2 weeks)
+ Distribution: Store submission
+ : Review process
+ : User feedback
+ : Update management
+
+ section Expert Level (1 month)
+ Extension Ecosystem: Advanced APIs
+ : Security best practices
+ : Enterprise features
+ : Framework integration
+```
+
+### ๐ ๏ธ Your Extension Development Toolkit Summary
+
+After completing this lesson, you now have:
+- **Browser Architecture Knowledge**: Understanding of rendering engines, security models, and extension integration
+- **Development Environment**: Modern toolchain with Webpack, NPM, and debugging capabilities
+- **UI/UX Foundation**: Semantic HTML structure with progressive disclosure patterns
+- **Security Awareness**: Understanding of browser permissions and safe development practices
+- **Cross-Browser Concepts**: Knowledge of compatibility considerations and testing approaches
+- **API Integration**: Foundation for working with external data sources
+- **Professional Workflow**: Industry-standard development and testing procedures
+
+**Real-World Applications**: These skills directly apply to:
+- **Web Development**: Single-page applications and progressive web apps
+- **Desktop Applications**: Electron and web-based desktop software
+- **Mobile Development**: Hybrid apps and web-based mobile solutions
+- **Enterprise Tools**: Internal productivity applications and workflow automation
+- **Open Source**: Contributing to browser extension projects and web standards
+
+**Next Level**: You're ready to add interactive functionality, work with browser APIs, and create extensions that solve real user problems!
+
## Assignment
[Restyle your extension](assignment.md)
diff --git a/5-browser-extension/2-forms-browsers-local-storage/README.md b/5-browser-extension/2-forms-browsers-local-storage/README.md
index 68378960..04ced7a8 100644
--- a/5-browser-extension/2-forms-browsers-local-storage/README.md
+++ b/5-browser-extension/2-forms-browsers-local-storage/README.md
@@ -1,5 +1,22 @@
# Browser Extension Project Part 2: Call an API, use Local Storage
+```mermaid
+journey
+ title Your API Integration & Storage Journey
+ section Foundation
+ Setup DOM references: 3: Student
+ Add event listeners: 4: Student
+ Handle form submission: 4: Student
+ section Data Management
+ Implement local storage: 4: Student
+ Build API calls: 5: Student
+ Handle async operations: 5: Student
+ section User Experience
+ Add error handling: 5: Student
+ Create loading states: 4: Student
+ Polish interactions: 5: Student
+```
+
## Pre-Lecture Quiz
[Pre-lecture quiz](https://ff-quizzes.netlify.app/web/quiz/25)
@@ -14,6 +31,36 @@ API integration might sound complex, but it's really just teaching your code how
By the end of this lesson, you'll have a browser extension that fetches real data, stores user preferences, and provides a smooth experience. Let's get started!
+```mermaid
+mindmap
+ root((Dynamic Extensions))
+ DOM Manipulation
+ Element Selection
+ Event Handling
+ State Management
+ UI Updates
+ Local Storage
+ Data Persistence
+ Key-Value Pairs
+ Session Management
+ User Preferences
+ API Integration
+ HTTP Requests
+ Authentication
+ Data Parsing
+ Error Handling
+ Async Programming
+ Promises
+ Async/Await
+ Error Catching
+ Non-blocking Code
+ User Experience
+ Loading States
+ Error Messages
+ Smooth Transitions
+ Data Validation
+```
+
โ
Follow the numbered segments in the appropriate files to know where to place your code
## Set up the elements to manipulate in the extension
@@ -22,6 +69,33 @@ Before your JavaScript can manipulate the interface, it needs references to spec
In your `index.js` file, we'll create `const` variables that capture references to each important form element. This is similar to how scientists label their equipment - instead of searching through the entire laboratory each time, they can directly access what they need.
+```mermaid
+flowchart LR
+ A[JavaScript Code] --> B[document.querySelector]
+ B --> C[CSS Selectors]
+ C --> D[HTML Elements]
+
+ D --> E[".form-data"]
+ D --> F[".region-name"]
+ D --> G[".api-key"]
+ D --> H[".loading"]
+ D --> I[".errors"]
+ D --> J[".result-container"]
+
+ E --> K[Form Element]
+ F --> L[Input Field]
+ G --> M[Input Field]
+ H --> N[UI Element]
+ I --> O[UI Element]
+ J --> P[UI Element]
+
+ style A fill:#e1f5fe
+ style D fill:#e8f5e8
+ style K fill:#fff3e0
+ style L fill:#fff3e0
+ style M fill:#fff3e0
+```
+
```javascript
// form fields
const form = document.querySelector('.form-data');
@@ -49,6 +123,29 @@ const clearBtn = document.querySelector('.clear-btn');
Now we'll make your extension respond to user actions. Event listeners are your code's way of monitoring user interactions. Think of them like the operators in early telephone exchanges - they listened for incoming calls and connected the right circuits when someone wanted to make a connection.
+```mermaid
+sequenceDiagram
+ participant User
+ participant Form
+ participant JavaScript
+ participant API
+ participant Storage
+
+ User->>Form: Fills out region/API key
+ User->>Form: Clicks submit
+ Form->>JavaScript: Triggers submit event
+ JavaScript->>JavaScript: handleSubmit(e)
+ JavaScript->>Storage: Save user preferences
+ JavaScript->>API: Fetch carbon data
+ API->>JavaScript: Returns data
+ JavaScript->>Form: Update UI with results
+
+ User->>Form: Clicks clear button
+ Form->>JavaScript: Triggers click event
+ JavaScript->>Storage: Clear saved data
+ JavaScript->>Form: Reset to initial state
+```
+
```javascript
form.addEventListener('submit', (e) => handleSubmit(e));
clearBtn.addEventListener('click', (e) => reset(e));
@@ -63,6 +160,16 @@ init();
โ
Notice the shorthand arrow function syntax used here. This modern JavaScript approach is cleaner than traditional function expressions, but both work equally well!
+### ๐ **Pedagogical Check-in**
+**Event Handling Understanding**: Before moving to initialization, ensure you can:
+- โ
Explain how `addEventListener` connects user actions to JavaScript functions
+- โ
Understand why we pass the event object `(e)` to handler functions
+- โ
Recognize the difference between `submit` and `click` events
+- โ
Describe when the `init()` function runs and why
+
+**Quick Self-Test**: What would happen if you forgot `e.preventDefault()` in a form submission?
+*Answer: The page would reload, losing all JavaScript state and interrupting the user experience*
+
## Build the initialization and reset functions
Let's create the initialization logic for your extension. The `init()` function is like a ship's navigation system checking its instruments - it determines the current state and adjusts the interface accordingly. It checks if someone has used your extension before and loads their previous settings.
@@ -128,6 +235,30 @@ function reset(e) {
You can view your stored data by opening browser Developer Tools (F12), navigating to the **Application** tab, and expanding the **Local Storage** section.
+```mermaid
+stateDiagram-v2
+ [*] --> CheckStorage: Extension starts
+ CheckStorage --> FirstTime: No stored data
+ CheckStorage --> Returning: Data found
+
+ FirstTime --> ShowForm: Display setup form
+ ShowForm --> UserInput: User enters data
+ UserInput --> SaveData: Store in localStorage
+ SaveData --> FetchAPI: Get carbon data
+
+ Returning --> LoadData: Read from localStorage
+ LoadData --> FetchAPI: Get carbon data
+
+ FetchAPI --> ShowResults: Display data
+ ShowResults --> UserAction: User interacts
+
+ UserAction --> Reset: Clear button clicked
+ UserAction --> ShowResults: View data
+
+ Reset --> ClearStorage: Remove saved data
+ ClearStorage --> FirstTime: Back to setup
+```
+

> โ ๏ธ **Security Consideration**: In production applications, storing API keys in LocalStorage poses security risks since JavaScript can access this data. For learning purposes, this approach works fine, but real applications should use secure server-side storage for sensitive credentials.
@@ -192,6 +323,36 @@ Now we'll connect your extension to external data sources through APIs. This tra
[APIs](https://www.webopedia.com/TERM/A/API.html) are how different applications communicate with each other. Think of them like the telegraph system that connected distant cities in the 19th century - operators would send requests to distant stations and receive responses with the requested information. Every time you check social media, ask a voice assistant a question, or use a delivery app, APIs are facilitating these data exchanges.
+```mermaid
+flowchart TD
+ A[Your Extension] --> B[HTTP Request]
+ B --> C[CO2 Signal API]
+ C --> D{Valid Request?}
+ D -->|Yes| E[Query Database]
+ D -->|No| F[Return Error]
+ E --> G[Carbon Data]
+ G --> H[JSON Response]
+ H --> I[Your Extension]
+ F --> I
+ I --> J[Update UI]
+
+ subgraph "API Request"
+ K[Headers: auth-token]
+ L[Parameters: countryCode]
+ M[Method: GET]
+ end
+
+ subgraph "API Response"
+ N[Carbon Intensity]
+ O[Fossil Fuel %]
+ P[Timestamp]
+ end
+
+ style C fill:#e8f5e8
+ style G fill:#fff3e0
+ style I fill:#e1f5fe
+```
+
**Key concepts about REST APIs:**
- **REST** stands for 'Representational State Transfer'
- **Uses** standard HTTP methods (GET, POST, PUT, DELETE) to interact with data
@@ -214,6 +375,33 @@ Here's a quick video about `async`:
> ๐ฅ Click the image above for a video about async/await.
+### ๐ **Pedagogical Check-in**
+**Async Programming Understanding**: Before diving into the API function, verify you understand:
+- โ
Why we use `async/await` instead of blocking the entire extension
+- โ
How `try/catch` blocks handle network errors gracefully
+- โ
The difference between synchronous and asynchronous operations
+- โ
Why API calls can fail and how to handle those failures
+
+**Real-World Connection**: Consider these everyday async examples:
+- **Ordering food**: You don't wait by the kitchen - you get a receipt and continue other activities
+- **Sending emails**: Your email app doesn't freeze while sending - you can compose more emails
+- **Loading web pages**: Images load progressively while you can already read the text
+
+**API Authentication Flow**:
+```mermaid
+sequenceDiagram
+ participant Ext as Extension
+ participant API as CO2 Signal API
+ participant DB as Database
+
+ Ext->>API: Request with auth-token
+ API->>API: Validate token
+ API->>DB: Query carbon data
+ DB->>API: Return data
+ API->>Ext: JSON response
+ Ext->>Ext: Update UI
+```
+
Create the function to fetch and display carbon usage data:
```javascript
@@ -283,6 +471,38 @@ async function displayCarbonUsage(apiKey, region) {
โ
This function demonstrates several important web development concepts - communicating with external servers, handling authentication, processing data, updating interfaces, and managing errors gracefully. These are fundamental skills that professional developers use regularly.
+```mermaid
+flowchart TD
+ A[Start API Call] --> B[Fetch Request]
+ B --> C{Network Success?}
+ C -->|No| D[Network Error]
+ C -->|Yes| E{Response OK?}
+ E -->|No| F[API Error]
+ E -->|Yes| G[Parse JSON]
+ G --> H{Valid Data?}
+ H -->|No| I[Data Error]
+ H -->|Yes| J[Update UI]
+
+ D --> K[Show Error Message]
+ F --> K
+ I --> K
+ J --> L[Hide Loading]
+ K --> L
+
+ style A fill:#e1f5fe
+ style J fill:#e8f5e8
+ style K fill:#ffebee
+ style L fill:#f3e5f5
+```
+
+### ๐ **Pedagogical Check-in**
+**Complete System Understanding**: Verify your mastery of the entire flow:
+- โ
How DOM references enable JavaScript to control the interface
+- โ
Why local storage creates persistence between browser sessions
+- โ
How async/await makes API calls without freezing the extension
+- โ
What happens when API calls fail and how errors are handled
+- โ
Why user experience includes loading states and error messages
+
๐ **What you've accomplished:** You've created a browser extension that:
- **Connects** to the internet and retrieves real environmental data
- **Persists** user settings between sessions
@@ -329,6 +549,109 @@ After your research, identify what characteristics make an API developer-friendl
You learned about LocalStorage and APIs in this lesson, both very useful for the professional web developer. Can you think about how these two things work together? Think about how you would architect a web site that would store items to be used by an API.
+### โก **What You Can Do in the Next 5 Minutes**
+- [ ] Open DevTools Application tab and explore localStorage on any website
+- [ ] Create a simple HTML form and test form validation in the browser
+- [ ] Try storing and retrieving data using localStorage in the browser console
+- [ ] Inspect form data being submitted using the Network tab
+
+### ๐ฏ **What You Can Accomplish This Hour**
+- [ ] Complete the post-lesson quiz and understand form handling concepts
+- [ ] Build a browser extension form that saves user preferences
+- [ ] Implement client-side form validation with helpful error messages
+- [ ] Practice using the chrome.storage API for extension data persistence
+- [ ] Create a user interface that responds to saved user settings
+
+### ๐
**Your Week-Long Extension Building**
+- [ ] Complete a full-featured browser extension with form functionality
+- [ ] Master different storage options: local, sync, and session storage
+- [ ] Implement advanced form features like autocomplete and validation
+- [ ] Add import/export functionality for user data
+- [ ] Test your extension thoroughly across different browsers
+- [ ] Polish your extension's user experience and error handling
+
+### ๐ **Your Month-Long Web API Mastery**
+- [ ] Build complex applications using various browser storage APIs
+- [ ] Learn about offline-first development patterns
+- [ ] Contribute to open source projects involving data persistence
+- [ ] Master privacy-focused development and GDPR compliance
+- [ ] Create reusable libraries for form handling and data management
+- [ ] Share knowledge about web APIs and extension development
+
+## ๐ฏ Your Extension Development Mastery Timeline
+
+```mermaid
+timeline
+ title API Integration & Storage Learning Progression
+
+ section DOM Fundamentals (15 minutes)
+ Element References: querySelector mastery
+ : Event listener setup
+ : State management basics
+
+ section Local Storage (20 minutes)
+ Data Persistence: Key-value storage
+ : Session management
+ : User preference handling
+ : Storage inspection tools
+
+ section Form Handling (25 minutes)
+ User Input: Form validation
+ : Event prevention
+ : Data extraction
+ : UI state transitions
+
+ section API Integration (35 minutes)
+ External Communication: HTTP requests
+ : Authentication patterns
+ : JSON data parsing
+ : Response handling
+
+ section Async Programming (40 minutes)
+ Modern JavaScript: Promise handling
+ : Async/await patterns
+ : Error management
+ : Non-blocking operations
+
+ section Error Handling (30 minutes)
+ Robust Applications: Try/catch blocks
+ : User-friendly messages
+ : Graceful degradation
+ : Debugging techniques
+
+ section Advanced Patterns (1 week)
+ Professional Development: Caching strategies
+ : Rate limiting
+ : Retry mechanisms
+ : Performance optimization
+
+ section Production Skills (1 month)
+ Enterprise Features: Security best practices
+ : API versioning
+ : Monitoring & logging
+ : Scalable architecture
+```
+
+### ๐ ๏ธ Your Full-Stack Development Toolkit Summary
+
+After completing this lesson, you now have:
+- **DOM Mastery**: Precise element targeting and manipulation
+- **Storage Expertise**: Persistent data management with localStorage
+- **API Integration**: Real-time data fetching and authentication
+- **Async Programming**: Non-blocking operations with modern JavaScript
+- **Error Handling**: Robust applications that gracefully handle failures
+- **User Experience**: Loading states, validation, and smooth interactions
+- **Modern Patterns**: fetch API, async/await, and ES6+ features
+
+**Professional Skills Gained**: You've implemented patterns used in:
+- **Web Applications**: Single-page apps with external data sources
+- **Mobile Development**: API-driven apps with offline capabilities
+- **Desktop Software**: Electron apps with persistent storage
+- **Enterprise Systems**: Authentication, caching, and error handling
+- **Modern Frameworks**: React/Vue/Angular data management patterns
+
+**Next Level**: You're ready to explore advanced topics like caching strategies, real-time WebSocket connections, or complex state management!
+
## Assignment
[Adopt an API](assignment.md)
diff --git a/5-browser-extension/3-background-tasks-and-performance/README.md b/5-browser-extension/3-background-tasks-and-performance/README.md
index 16819dd5..2b51df04 100644
--- a/5-browser-extension/3-background-tasks-and-performance/README.md
+++ b/5-browser-extension/3-background-tasks-and-performance/README.md
@@ -1,5 +1,22 @@
# Browser Extension Project Part 3: Learn about Background Tasks and Performance
+```mermaid
+journey
+ title Your Performance Optimization Journey
+ section Foundation
+ Learn browser tools: 3: Student
+ Understand profiling: 4: Student
+ Identify bottlenecks: 4: Student
+ section Extension Features
+ Build color system: 4: Student
+ Create background tasks: 5: Student
+ Update icons dynamically: 5: Student
+ section Optimization
+ Monitor performance: 5: Student
+ Debug issues: 4: Student
+ Polish experience: 5: Student
+```
+
Ever wonder what makes some browser extensions feel snappy and responsive while others seem sluggish? The secret lies in what's happening behind the scenes. While users click around your extension's interface, there's a whole world of background processes quietly managing data fetching, icon updates, and system resources.
This is our final lesson in the browser extension series, and we're going to make your carbon footprint tracker work smoothly. You'll add dynamic icon updates and learn how to spot performance issues before they become problems. It's like tuning a race car - small optimizations can make a huge difference in how everything runs.
@@ -16,6 +33,36 @@ In our previous lessons, you built a form, connected it to an API, and tackled a
Now we need to add the finishing touches - like making that extension icon change colors based on the carbon data. This reminds me of how NASA had to optimize every system on the Apollo spacecraft. They couldn't afford any wasted cycles or memory because lives depended on performance. While our browser extension isn't quite that critical, the same principles apply - efficient code creates better user experiences.
+```mermaid
+mindmap
+ root((Performance & Background Tasks))
+ Browser Performance
+ Rendering Pipeline
+ Asset Optimization
+ DOM Manipulation
+ JavaScript Execution
+ Profiling Tools
+ Developer Tools
+ Performance Tab
+ Timeline Analysis
+ Bottleneck Detection
+ Extension Architecture
+ Background Scripts
+ Content Scripts
+ Message Passing
+ Icon Management
+ Optimization Strategies
+ Code Splitting
+ Lazy Loading
+ Caching
+ Resource Compression
+ Visual Feedback
+ Dynamic Icons
+ Color Coding
+ Real-time Updates
+ User Experience
+```
+
## Web Performance Basics
When your code runs efficiently, people can actually *feel* the difference. You know that moment when a page loads instantly or an animation flows smoothly? That's good performance at work.
@@ -28,6 +75,38 @@ The topic of how to make your websites blazingly fast on all kinds of devices, f
The first step in optimizing your site is understanding what's actually happening under the hood. Fortunately, your browser comes with powerful detective tools built right in.
+```mermaid
+flowchart LR
+ A[HTML] --> B[Parse]
+ B --> C[DOM Tree]
+ D[CSS] --> E[Parse]
+ E --> F[CSSOM]
+ G[JavaScript] --> H[Execute]
+
+ C --> I[Render Tree]
+ F --> I
+ H --> I
+
+ I --> J[Layout]
+ J --> K[Paint]
+ K --> L[Composite]
+ L --> M[Display]
+
+ subgraph "Critical Rendering Path"
+ N["1. Parse HTML"]
+ O["2. Parse CSS"]
+ P["3. Execute JS"]
+ Q["4. Build Render Tree"]
+ R["5. Layout Elements"]
+ S["6. Paint Pixels"]
+ T["7. Composite Layers"]
+ end
+
+ style M fill:#e8f5e8
+ style I fill:#fff3e0
+ style H fill:#ffebee
+```
+
To open Developer Tools in Edge, click those three dots in the top right corner, then go to More Tools > Developer Tools. Or use the keyboard shortcut: `Ctrl` + `Shift` + `I` on Windows or `Option` + `Command` + `I` on Mac. Once you're there, click on the Performance tab - this is where you'll do your investigation.
**Here's your performance detective toolkit:**
@@ -56,6 +135,39 @@ Check the Event Log pane to see if any event took longer than 15 ms:
โ
Get to know your profiler! Open the developer tools on this site and see if there are any bottlenecks. What's the slowest-loading asset? The fastest?
+```mermaid
+flowchart TD
+ A[Open DevTools] --> B[Navigate to Performance Tab]
+ B --> C[Click Record Button]
+ C --> D[Perform Actions]
+ D --> E[Stop Recording]
+ E --> F{Analyze Results}
+
+ F --> G[Check Timeline]
+ F --> H[Review Network]
+ F --> I[Examine Scripts]
+ F --> J[Identify Paint Events]
+
+ G --> K{Long Tasks?}
+ H --> L{Large Assets?}
+ I --> M{Render Blocking?}
+ J --> N{Expensive Paints?}
+
+ K -->|Yes| O[Optimize JavaScript]
+ L -->|Yes| P[Compress Assets]
+ M -->|Yes| Q[Add Async/Defer]
+ N -->|Yes| R[Simplify Styles]
+
+ O --> S[Test Again]
+ P --> S
+ Q --> S
+ R --> S
+
+ style A fill:#e1f5fe
+ style F fill:#fff3e0
+ style S fill:#e8f5e8
+```
+
## What to Look For When Profiling
Running the profiler is just the beginning - the real skill is knowing what those colorful charts are actually telling you. Don't worry, you'll get the hang of reading them. Experienced developers have learned to spot the warning signs before they become full-blown problems.
@@ -90,6 +202,22 @@ Let's talk about the usual suspects - the performance troublemakers that tend to
โ
Try some sites on a [Site Speed Test website](https://www.webpagetest.org/) to learn more about the common checks that are done to determine site performance.
+### ๐ **Pedagogical Check-in**
+**Performance Understanding**: Before building extension features, ensure you can:
+- โ
Explain the critical rendering path from HTML to pixels
+- โ
Identify common performance bottlenecks in web applications
+- โ
Use browser developer tools to profile page performance
+- โ
Understand how asset size and DOM complexity affect speed
+
+**Quick Self-Test**: What happens when you have render-blocking JavaScript?
+*Answer: The browser must download and execute the script before it can continue parsing HTML and rendering the page*
+
+**Real-World Performance Impact**:
+- **100ms delay**: Users notice the slowdown
+- **1 second delay**: Users start losing focus
+- **3+ seconds**: 40% of users abandon the page
+- **Mobile networks**: Performance matters even more
+
Now that you have an idea of how the browser renders the assets you send to it, let's look at the last few things you need to do to complete your extension:
### Create a function to calculate color
@@ -98,6 +226,32 @@ Now we'll create a function that turns numerical data into meaningful colors. Th
This function will take the CO2 data from our API and determine what color best represents the environmental impact. It's similar to how scientists use color-coding in heat maps to visualize complex data patterns - from ocean temperatures to star formation. Let's add this to `/src/index.js`, right after those `const` variables we set up earlier:
+```mermaid
+flowchart LR
+ A[CO2 Value] --> B[Find Closest Scale Point]
+ B --> C[Get Scale Index]
+ C --> D[Map to Color]
+ D --> E[Send to Background]
+
+ subgraph "Color Scale"
+ F["0-150: Green (Clean)"]
+ G["150-600: Yellow (Moderate)"]
+ H["600-750: Orange (High)"]
+ I["750+: Brown (Very High)"]
+ end
+
+ subgraph "Message Passing"
+ J[Content Script]
+ K[chrome.runtime.sendMessage]
+ L[Background Script]
+ M[Icon Update]
+ end
+
+ style A fill:#e1f5fe
+ style D fill:#e8f5e8
+ style E fill:#fff3e0
+```
+
```javascript
function calculateColor(value) {
// Define CO2 intensity scale (grams per kWh)
@@ -144,6 +298,25 @@ The `chrome.runtime` [API](https://developer.chrome.com/extensions/runtime) is l
โ
If you're developing this browser extension for Edge, it might surprise you that you're using a chrome API. The newer Edge browser versions run on the Chromium browser engine, so you can leverage these tools.
+```mermaid
+architecture-beta
+ group browser(logos:chrome)[Browser]
+
+ service popup(logos:html5)[Popup UI] in browser
+ service content(logos:javascript)[Content Script] in browser
+ service background(database)[Background Script] in browser
+ service api(logos:api)[External API] in browser
+
+ popup:R -- L:content
+ content:R -- L:background
+ background:T -- B:api
+ content:T -- B:api
+
+ junction junctionCenter in browser
+ popup:R -- L:junctionCenter
+ junctionCenter:R -- L:background
+```
+
> **Pro Tip**: If you want to profile a browser extension, launch the dev tools from within the extension itself, as it is its own separate browser instance. This gives you access to extension-specific performance metrics.
### Set a default icon color
@@ -222,6 +395,36 @@ function drawIcon(value) {
โ
You'll learn more about the Canvas API in the [Space Game lessons](../../6-space-game/2-drawing-to-canvas/README.md).
+```mermaid
+sequenceDiagram
+ participant CS as Content Script
+ participant BG as Background Script
+ participant Canvas as OffscreenCanvas
+ participant Browser as Browser Icon
+
+ CS->>BG: sendMessage({action: 'updateIcon', color})
+ BG->>Canvas: new OffscreenCanvas(200, 200)
+ Canvas->>Canvas: getContext('2d')
+ Canvas->>Canvas: beginPath() + fillStyle + arc()
+ Canvas->>Canvas: fill() + getImageData()
+ Canvas->>BG: Return image data
+ BG->>Browser: chrome.action.setIcon(imageData)
+ Browser->>Browser: Update toolbar icon
+```
+
+### ๐ **Pedagogical Check-in**
+**Complete Extension Understanding**: Verify your mastery of the entire system:
+- โ
How does message passing work between different extension scripts?
+- โ
Why do we use OffscreenCanvas instead of regular Canvas for performance?
+- โ
What role does the Chrome Runtime API play in extension architecture?
+- โ
How does the color calculation algorithm map data to visual feedback?
+
+**Performance Considerations**: Your extension now demonstrates:
+- **Efficient messaging**: Clean communication between script contexts
+- **Optimized rendering**: OffscreenCanvas prevents UI blocking
+- **Real-time updates**: Dynamic icon changes based on live data
+- **Memory management**: Proper cleanup and resource handling
+
**Time to test your extension:**
- **Build** everything with `npm run build`
- **Reload** your extension in the browser (don't forget this step)
@@ -260,6 +463,126 @@ Consider signing up for a [performance newsletter](https://perf.email/)
Investigate some of the ways that browsers gauge web performance by looking through the performance tabs in their web tools. Do you find any major differences?
+### โก **What You Can Do in the Next 5 Minutes**
+- [ ] Open browser Task Manager (Shift+Esc in Chrome) to see extension resource usage
+- [ ] Use DevTools Performance tab to record and analyze webpage performance
+- [ ] Check the browser's Extensions page to see which extensions impact startup time
+- [ ] Try disabling extensions temporarily to see performance differences
+
+### ๐ฏ **What You Can Accomplish This Hour**
+- [ ] Complete the post-lesson quiz and understand performance concepts
+- [ ] Implement a background script for your browser extension
+- [ ] Learn to use browser.alarms for efficient background tasks
+- [ ] Practice message passing between content scripts and background scripts
+- [ ] Measure and optimize your extension's resource usage
+
+### ๐
**Your Week-Long Performance Journey**
+- [ ] Complete a high-performance browser extension with background functionality
+- [ ] Master service workers and modern extension architecture
+- [ ] Implement efficient data synchronization and caching strategies
+- [ ] Learn advanced debugging techniques for extension performance
+- [ ] Optimize your extension for both functionality and resource efficiency
+- [ ] Create comprehensive tests for extension performance scenarios
+
+### ๐ **Your Month-Long Optimization Mastery**
+- [ ] Build enterprise-grade browser extensions with optimal performance
+- [ ] Learn about Web Workers, Service Workers, and modern web performance
+- [ ] Contribute to open source projects focused on performance optimization
+- [ ] Master browser internals and advanced debugging techniques
+- [ ] Create performance monitoring tools and best practices guides
+- [ ] Become a performance expert who helps optimize web applications
+
+## ๐ฏ Your Browser Extension Mastery Timeline
+
+```mermaid
+timeline
+ title Complete Extension Development Progression
+
+ section Performance Fundamentals (20 minutes)
+ Browser Profiling: DevTools mastery
+ : Timeline analysis
+ : Bottleneck identification
+ : Critical rendering path
+
+ section Background Tasks (25 minutes)
+ Extension Architecture: Message passing
+ : Background scripts
+ : Runtime API usage
+ : Cross-context communication
+
+ section Visual Feedback (30 minutes)
+ Dynamic UI: Color calculation algorithms
+ : Canvas API integration
+ : Icon generation
+ : Real-time updates
+
+ section Performance Optimization (35 minutes)
+ Efficient Code: Async operations
+ : Memory management
+ : Resource cleanup
+ : Performance monitoring
+
+ section Production Ready (45 minutes)
+ Polish & Testing: Cross-browser compatibility
+ : Error handling
+ : User experience
+ : Performance validation
+
+ section Advanced Features (1 week)
+ Extension Ecosystem: Chrome Web Store
+ : User feedback
+ : Analytics integration
+ : Update management
+
+ section Professional Development (2 weeks)
+ Enterprise Extensions: Team collaboration
+ : Code reviews
+ : CI/CD pipelines
+ : Security audits
+
+ section Expert Mastery (1 month)
+ Platform Expertise: Advanced Chrome APIs
+ : Performance optimization
+ : Architecture patterns
+ : Open source contribution
+```
+
+### ๐ ๏ธ Your Complete Extension Development Toolkit
+
+After completing this trilogy, you now have mastered:
+- **Browser Architecture**: Deep understanding of how extensions integrate with browser systems
+- **Performance Profiling**: Ability to identify and fix bottlenecks using developer tools
+- **Async Programming**: Modern JavaScript patterns for responsive, non-blocking operations
+- **API Integration**: External data fetching with authentication and error handling
+- **Visual Design**: Dynamic UI updates and Canvas-based graphics generation
+- **Message Passing**: Inter-script communication in extension architectures
+- **User Experience**: Loading states, error handling, and intuitive interactions
+- **Production Skills**: Testing, debugging, and optimization for real-world deployment
+
+**Real-World Applications**: Your extension development skills apply directly to:
+- **Progressive Web Apps**: Similar architecture and performance patterns
+- **Electron Desktop Apps**: Cross-platform applications using web technologies
+- **Mobile Hybrid Apps**: Cordova/PhoneGap development using web APIs
+- **Enterprise Web Applications**: Complex dashboard and productivity tools
+- **Chrome DevTools Extensions**: Advanced developer tooling and debugging
+- **Web API Integration**: Any application that communicates with external services
+
+**Professional Impact**: You can now:
+- **Build** production-ready browser extensions from concept to deployment
+- **Optimize** web application performance using industry-standard profiling tools
+- **Architect** scalable systems with proper separation of concerns
+- **Debug** complex async operations and cross-context communication
+- **Contribute** to open source extension projects and browser standards
+
+**Next Level Opportunities**:
+- **Chrome Web Store Developer**: Publish extensions for millions of users
+- **Web Performance Engineer**: Specialize in optimization and user experience
+- **Browser Platform Developer**: Contribute to browser engine development
+- **Extension Framework Creator**: Build tools that help other developers
+- **Developer Relations**: Share knowledge through teaching and content creation
+
+๐ **Achievement Unlocked**: You've built a complete, functional browser extension that demonstrates professional development practices and modern web standards!
+
## Assignment
[Analyze a site for performance](assignment.md)
diff --git a/6-space-game/1-introduction/README.md b/6-space-game/1-introduction/README.md
index 863e3565..d580dce1 100644
--- a/6-space-game/1-introduction/README.md
+++ b/6-space-game/1-introduction/README.md
@@ -1,5 +1,22 @@
# Build a Space Game Part 1: Introduction
+```mermaid
+journey
+ title Your Game Development Journey
+ section Foundation
+ Learn game architecture: 3: Student
+ Understand inheritance: 4: Student
+ Explore composition: 4: Student
+ section Communication
+ Build pub/sub system: 4: Student
+ Design event flow: 5: Student
+ Connect components: 5: Student
+ section Application
+ Create game objects: 5: Student
+ Implement patterns: 5: Student
+ Plan game structure: 5: Student
+```
+

Just like NASA's mission control coordinates multiple systems during a space launch, we're going to build a space game that demonstrates how different parts of a program can work together seamlessly. While creating something you can actually play, you'll learn essential programming concepts that apply to any software project.
@@ -8,6 +25,36 @@ We'll explore two fundamental approaches to organizing code: inheritance and com
By the end of this series, you'll understand how to build applications that can scale and evolve โ whether you're developing games, web applications, or any other software system.
+```mermaid
+mindmap
+ root((Game Architecture))
+ Object Organization
+ Inheritance
+ Composition
+ Class Hierarchies
+ Behavior Mixing
+ Communication Patterns
+ Pub/Sub System
+ Event Emitters
+ Message Passing
+ Loose Coupling
+ Game Objects
+ Properties (x, y)
+ Behaviors (move, collide)
+ Lifecycle Management
+ State Management
+ Design Patterns
+ Factory Functions
+ Observer Pattern
+ Component System
+ Event-Driven Architecture
+ Scalability
+ Modular Design
+ Maintainable Code
+ Testing Strategies
+ Performance Optimization
+```
+
## Pre-Lecture Quiz
[Pre-lecture quiz](https://ff-quizzes.netlify.app/web/quiz/29)
@@ -31,6 +78,45 @@ Despite their visual differences, these objects often share fundamental behavior
โ
Think about a game like Pac-Man. Can you identify the four object types listed above in this game?
+```mermaid
+classDiagram
+ class GameObject {
+ +x: number
+ +y: number
+ +type: string
+ +exists_somewhere()
+ }
+
+ class MovableObject {
+ +moveTo(x, y)
+ +can_move_around()
+ }
+
+ class TemporaryObject {
+ +lifespan: number
+ +has_lifespan()
+ }
+
+ class InteractiveObject {
+ +onCollision()
+ +reacts_to_stuff()
+ }
+
+ GameObject <|-- MovableObject
+ GameObject <|-- TemporaryObject
+ GameObject <|-- InteractiveObject
+
+ MovableObject <|-- Hero
+ MovableObject <|-- Enemy
+ MovableObject <|-- Bullet
+
+ TemporaryObject <|-- PowerUp
+ TemporaryObject <|-- Explosion
+
+ InteractiveObject <|-- Collectible
+ InteractiveObject <|-- Obstacle
+```
+
### Expressing Behavior Through Code
Now that you understand the common behaviors game objects share, let's explore how to implement these behaviors in JavaScript. You can express object behavior through methods attached to either classes or individual objects, and there are several approaches to choose from.
@@ -182,6 +268,26 @@ const tree = createStatic(0, 0, 'Tree');
**Which Pattern Should You Choose?**
+**Which Pattern Should You Choose?**
+
+```mermaid
+quadrantChart
+ title Code Organization Patterns
+ x-axis Simple --> Complex
+ y-axis Rigid --> Flexible
+ quadrant-1 Advanced Composition
+ quadrant-2 Hybrid Approaches
+ quadrant-3 Basic Inheritance
+ quadrant-4 Modern Composition
+
+ Class Inheritance: [0.3, 0.2]
+ Interface Implementation: [0.6, 0.4]
+ Mixin Patterns: [0.7, 0.7]
+ Pure Composition: [0.8, 0.9]
+ Factory Functions: [0.5, 0.8]
+ Prototype Chain: [0.4, 0.3]
+```
+
> ๐ก **Pro Tip**: Both patterns have their place in modern JavaScript development. Classes work well for clearly defined hierarchies, while composition shines when you need maximum flexibility.
>
**Here's when to use each approach:**
@@ -190,6 +296,22 @@ const tree = createStatic(0, 0, 'Tree');
- **Consider** your team's preferences and project requirements
- **Remember** that you can mix both approaches in the same application
+### ๐ **Pedagogical Check-in**
+**Object Organization Understanding**: Before moving to communication patterns, ensure you can:
+- โ
Explain the difference between inheritance and composition
+- โ
Identify when to use classes vs factory functions
+- โ
Understand how the `super()` keyword works in inheritance
+- โ
Recognize the benefits of each approach for game development
+
+**Quick Self-Test**: How would you create a Flying Enemy that can both move and fly?
+- **Inheritance approach**: `class FlyingEnemy extends Movable`
+- **Composition approach**: `{ ...movable, ...flyable, ...gameObject }`
+
+**Real-World Connection**: These patterns appear everywhere:
+- **React Components**: Props (composition) vs class inheritance
+- **Game Engines**: Entity-component systems use composition
+- **Mobile Apps**: UI frameworks often use inheritance hierarchies
+
## Communication Patterns: The Pub/Sub System
As applications grow complex, managing communication between components becomes challenging. The publish-subscribe pattern (pub/sub) solves this problem using principles similar to radio broadcasting โ one transmitter can reach multiple receivers without knowing who's listening.
@@ -198,6 +320,30 @@ Consider what happens when a hero takes damage: the health bar updates, sound ef
โ
**Pub/Sub** stands for 'publish-subscribe'
+```mermaid
+flowchart TD
+ A[Hero Takes Damage] --> B[Publish: HERO_DAMAGED]
+ B --> C[Event System]
+
+ C --> D[Health Bar Subscriber]
+ C --> E[Sound System Subscriber]
+ C --> F[Visual Effects Subscriber]
+ C --> G[Achievement System Subscriber]
+
+ D --> H[Update Health Display]
+ E --> I[Play Damage Sound]
+ F --> J[Show Red Flash]
+ G --> K[Check Survival Achievements]
+
+ style A fill:#ffebee
+ style B fill:#e1f5fe
+ style C fill:#e8f5e8
+ style H fill:#fff3e0
+ style I fill:#fff3e0
+ style J fill:#fff3e0
+ style K fill:#fff3e0
+```
+
### Understanding the Pub/Sub Architecture
The pub/sub pattern keeps different parts of your application loosely coupled, meaning they can work together without being directly dependent on each other. This separation makes your code more maintainable, testable, and flexible to changes.
@@ -306,6 +452,26 @@ window.addEventListener('keydown', (event) => {
- **Allows** multiple systems to respond to the same keyboard events
- **Makes** it easy to change key bindings or add new input methods
+```mermaid
+sequenceDiagram
+ participant User
+ participant Keyboard
+ participant EventEmitter
+ participant Hero
+ participant SoundSystem
+ participant Camera
+
+ User->>Keyboard: Presses ArrowLeft
+ Keyboard->>EventEmitter: emit('HERO_MOVE_LEFT')
+ EventEmitter->>Hero: Move left 5 pixels
+ EventEmitter->>SoundSystem: Play footstep sound
+ EventEmitter->>Camera: Follow hero
+
+ Hero->>Hero: Update position
+ SoundSystem->>SoundSystem: Play audio
+ Camera->>Camera: Adjust viewport
+```
+
> ๐ก **Pro Tip**: The beauty of this pattern is flexibility! You can easily add sound effects, screen shake, or particle effects by simply adding more event listeners โ no need to modify the existing keyboard or movement code.
>
**Here's why you'll love this approach:**
@@ -326,6 +492,24 @@ The pub/sub pattern maintains simplicity as applications grow in complexity. Whe
- **Keeps** message payloads simple and focused
- **Documents** your message types for team collaboration
+### ๐ **Pedagogical Check-in**
+**Event-Driven Architecture Understanding**: Verify your grasp of the complete system:
+- โ
How does the pub/sub pattern prevent tight coupling between components?
+- โ
Why is it easier to add new features with event-driven architecture?
+- โ
What role does the EventEmitter play in the communication flow?
+- โ
How do message constants prevent bugs and improve maintainability?
+
+**Design Challenge**: How would you handle these game scenarios with pub/sub?
+1. **Enemy dies**: Update score, play sound, spawn power-up, remove from screen
+2. **Level complete**: Stop music, show UI, save progress, load next level
+3. **Power-up collected**: Enhance abilities, update UI, play effect, start timer
+
+**Professional Connection**: This pattern appears in:
+- **Frontend Frameworks**: React/Vue event systems
+- **Backend Services**: Microservice communication
+- **Game Engines**: Unity's event system
+- **Mobile Development**: iOS/Android notification systems
+
---
## GitHub Copilot Agent Challenge ๐
@@ -350,6 +534,120 @@ Consider how the pub-sub pattern can enhance game architecture. Identify which c
Learn more about Pub/Sub by [reading about it](https://docs.microsoft.com/azure/architecture/patterns/publisher-subscriber/?WT.mc_id=academic-77807-sagibbon).
+### โก **What You Can Do in the Next 5 Minutes**
+- [ ] Open any HTML5 game online and inspect its code using DevTools
+- [ ] Create a simple HTML5 Canvas element and draw a basic shape
+- [ ] Try using `setInterval` to create a simple animation loop
+- [ ] Explore the Canvas API documentation and try a drawing method
+
+### ๐ฏ **What You Can Accomplish This Hour**
+- [ ] Complete the post-lesson quiz and understand game development concepts
+- [ ] Set up your game project structure with HTML, CSS, and JavaScript files
+- [ ] Create a basic game loop that updates and renders continuously
+- [ ] Draw your first game sprites on the canvas
+- [ ] Implement basic asset loading for images and sounds
+
+### ๐
**Your Week-Long Game Creation**
+- [ ] Complete the full space game with all planned features
+- [ ] Add polished graphics, sound effects, and smooth animations
+- [ ] Implement game states (start screen, gameplay, game over)
+- [ ] Create a scoring system and player progress tracking
+- [ ] Make your game responsive and accessible across devices
+- [ ] Share your game online and gather feedback from players
+
+### ๐ **Your Month-Long Game Development**
+- [ ] Build multiple games exploring different genres and mechanics
+- [ ] Learn a game development framework like Phaser or Three.js
+- [ ] Contribute to open source game development projects
+- [ ] Master advanced game programming patterns and optimization
+- [ ] Create a portfolio showcasing your game development skills
+- [ ] Mentor others interested in game development and interactive media
+
+## ๐ฏ Your Game Development Mastery Timeline
+
+```mermaid
+timeline
+ title Game Architecture Learning Progression
+
+ section Object Patterns (20 minutes)
+ Code Organization: Class inheritance
+ : Composition patterns
+ : Factory functions
+ : Behavior mixing
+
+ section Communication Systems (25 minutes)
+ Event Architecture: Pub/Sub implementation
+ : Message design
+ : Event emitters
+ : Loose coupling
+
+ section Game Object Design (30 minutes)
+ Entity Systems: Property management
+ : Behavior composition
+ : State handling
+ : Lifecycle management
+
+ section Architecture Patterns (35 minutes)
+ System Design: Component systems
+ : Observer pattern
+ : Command pattern
+ : State machines
+
+ section Advanced Concepts (45 minutes)
+ Scalable Architecture: Performance optimization
+ : Memory management
+ : Modular design
+ : Testing strategies
+
+ section Game Engine Concepts (1 week)
+ Professional Development: Scene graphs
+ : Asset management
+ : Rendering pipelines
+ : Physics integration
+
+ section Framework Mastery (2 weeks)
+ Modern Game Development: React game patterns
+ : Canvas optimization
+ : WebGL basics
+ : PWA games
+
+ section Industry Practices (1 month)
+ Professional Skills: Team collaboration
+ : Code reviews
+ : Game design patterns
+ : Performance profiling
+```
+
+### ๐ ๏ธ Your Game Architecture Toolkit Summary
+
+After completing this lesson, you now have:
+- **Design Pattern Mastery**: Understanding of inheritance vs composition trade-offs
+- **Event-Driven Architecture**: Pub/sub implementation for scalable communication
+- **Object-Oriented Design**: Class hierarchies and behavior composition
+- **Modern JavaScript**: Factory functions, spread syntax, and ES6+ patterns
+- **Scalable Architecture**: Loose coupling and modular design principles
+- **Game Development Foundation**: Entity systems and component patterns
+- **Professional Patterns**: Industry-standard approaches to code organization
+
+**Real-World Applications**: These patterns directly apply to:
+- **Frontend Frameworks**: React/Vue component architecture and state management
+- **Backend Services**: Microservice communication and event-driven systems
+- **Mobile Development**: iOS/Android app architecture and notification systems
+- **Game Engines**: Unity, Unreal, and web-based game development
+- **Enterprise Software**: Event sourcing and distributed system design
+- **API Design**: RESTful services and real-time communication
+
+**Professional Skills Gained**: You can now:
+- **Design** scalable software architectures using proven patterns
+- **Implement** event-driven systems that handle complex interactions
+- **Choose** appropriate code organization strategies for different scenarios
+- **Debug** and maintain loosely coupled systems effectively
+- **Communicate** technical decisions using industry-standard terminology
+
+**Next Level**: You're ready to implement these patterns in a real game, explore advanced game development topics, or apply these architectural concepts to web applications!
+
+๐ **Achievement Unlocked**: You've mastered fundamental software architecture patterns that power everything from simple games to complex enterprise systems!
+
## Assignment
[Mock up a game](assignment.md)
diff --git a/6-space-game/2-drawing-to-canvas/README.md b/6-space-game/2-drawing-to-canvas/README.md
index ab9e9a17..896b14ec 100644
--- a/6-space-game/2-drawing-to-canvas/README.md
+++ b/6-space-game/2-drawing-to-canvas/README.md
@@ -1,11 +1,58 @@
# Build a Space Game Part 2: Draw Hero and Monsters to Canvas
+```mermaid
+journey
+ title Your Canvas Graphics Journey
+ section Foundation
+ Understand Canvas API: 3: Student
+ Learn coordinate system: 4: Student
+ Draw basic shapes: 4: Student
+ section Image Handling
+ Load game assets: 4: Student
+ Handle async loading: 5: Student
+ Position sprites: 5: Student
+ section Game Rendering
+ Create game screen: 5: Student
+ Build formations: 5: Student
+ Optimize performance: 4: Student
+```
+
The Canvas API is one of web development's most powerful features for creating dynamic, interactive graphics right in your browser. In this lesson, we'll transform that blank HTML `