Reading the Homepage
Let's do a deep dive into the K12worX homepage code. We'll go line-by-line through app/page.tsx to understand exactly how it works.
What You'll Learn
- How to read a complete React component from top to bottom
- What imports tell you about the code
- How JSX structures the visual layout
- How Tailwind classes create styling
- Common patterns you'll see everywhere
Before You Start
Open the file in VS Code:
app/page.tsx
Keep it side-by-side with this guide so you can follow along.
The Complete File Structure
Every React component follows this pattern:
- Imports at the top
- Main function that defines the component
- Return statement with JSX
- Export at the bottom (or inline)
Let's examine each part!
Part 1: The Imports (Lines 1-2)
import LandingLayout from "@/components/layout/LandingLayout";
import Link from "next/link";
What This Tells Us
Line 1: import LandingLayout from "@/components/layout/LandingLayout"
- Importing a component from our codebase
@/is a shortcut for the project root directory- We'll wrap our homepage in this layout
- LandingLayout provides consistent structure (header, footer, etc.)
Line 2: import Link from "next/link"
- Importing from Next.js (external library)
Linkcreates navigation between pages- Better than
<a>tags (faster, preserves state)
Pattern to recognize: Imports from "next/*" or "react" are external libraries. Imports with @/ or ./ are our own code.
Part 2: The Component Function (Line 4)
export default function HomePage() {
Breaking This Down
export default:
- Makes this component available to other files
- "default" means you can import it without curly braces
- This component can now be used elsewhere
function HomePage():
- Standard JavaScript function
- Name matches the file purpose (HomePage for home page)
- No parameters needed (pages rarely take props)
Convention: Component names use PascalCase (HomePage, not homePage or home_page)
Part 3: The Return Statement (Line 5)
return (
<LandingLayout>
What's Happening
return (:
- Every React component returns JSX
- JSX is the HTML-like syntax
- Parentheses group multiple lines
<LandingLayout>:
- Using the imported component as a wrapper
- Everything inside will be wrapped by LandingLayout
- This gives us the header, footer, and overall page structure
Part 4: Hero Section (Lines 7-38)
{/* Hero Section */}
<section className="bg-gradient-to-r from-blue-600 to-purple-600 text-white">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-24">
<div className="text-center">
Understanding Each Part
{/* Hero Section */}:
- Comment in JSX
- Must use
{/* */}syntax (not regular//or/* */) - Doesn't appear in browser
<section className="...">:
- Semantic HTML5 element for a page section
classNamenotclass(JSX requirement)- All Tailwind classes for styling
Tailwind Classes Explained:
bg-gradient-to-r: Background gradient going rightfrom-blue-600 to-purple-600: Gradient colorstext-white: White text colormax-w-7xl: Maximum width (container)mx-auto: Center the containerpx-4 sm:px-6 lg:px-8: Padding (responsive)py-24: Vertical padding
Pattern: Outer <section> sets background, inner <div> centers content
Launch Status Badge (Lines 11-15)
<div className="mb-8">
<span className="inline-block px-4 py-2 bg-yellow-400 text-blue-900 text-sm font-semibold rounded-full mb-4">
π Currently in Launch Preparation
</span>
</div>
What's happening:
- Container
<div>with margin-bottom <span>styled as a badge/pill- Emoji + text inside
- Tailwind makes it yellow with dark blue text
Styling breakdown:
inline-block: Allows padding on inline elementpx-4 py-2: Internal spacingbg-yellow-400: Bright yellow backgroundtext-blue-900: Dark blue textrounded-full: Fully rounded corners (pill shape)
Main Headline (Lines 16-18)
<h1 className="text-4xl md:text-6xl font-bold mb-6">
Every Student Can Achieve Their Full Academic Potential
</h1>
Breakdown:
<h1>: Top-level heading (most important)- Responsive text sizing:
text-4xlon mobile,text-6xlon medium+ screens font-bold: Heavy font weightmb-6: Margin bottom for spacing
Pattern: md:text-6xl means "on medium screens and up, use text-6xl"
Subtitle (Lines 19-21)
<p className="text-xl md:text-2xl mb-8 max-w-4xl mx-auto">
A student-powered network of AI-amplified tutors and mentors, celebrating the potential of students in underserved communities across the United States.
</p>
Breakdown:
<p>: Paragraph elementtext-xl md:text-2xl: Responsive sizingmax-w-4xl mx-auto: Constrain width and center
Why constrain width? Long lines of text are hard to read. max-w-4xl keeps it readable.
Call-to-Action Buttons (Lines 22-35)
<div className="flex flex-col sm:flex-row gap-4 justify-center">
<Link
href="/launching"
className="px-8 py-3 bg-white text-blue-600 font-semibold rounded-lg hover:bg-gray-100 transition-colors"
>
Join the Launching Committee
</Link>
<Link
href="/get-involved"
className="px-8 py-3 border-2 border-white text-white font-semibold rounded-lg hover:bg-white hover:text-blue-600 transition-colors"
>
Get Updates
</Link>
</div>
Container analysis:
flex: Makes children flow in a row/columnflex-col sm:flex-row: Column on mobile, row on small+ screensgap-4: Space between buttonsjustify-center: Center the buttons
Link component breakdown:
href="/launching": Destination URL- Next.js
Linkenables fast navigation - Styled like a button with Tailwind classes
Button styles:
- Primary button (white background): Stands out more
- Secondary button (border only): Less prominent
hover:*classes: Change appearance on mouse hovertransition-colors: Smooth color change animation
Pattern: Use Link from Next.js instead of <a> for internal navigation
Part 5: Mission Overview Section (Lines 40-82)
<section className="py-16 bg-gray-50">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div className="text-center mb-12">
<h2 className="text-3xl font-bold text-gray-900 mb-4">Our Mission</h2>
<p className="text-lg text-gray-600 max-w-3xl mx-auto">
To celebrate the potential of students in underserved US communities by closing the educational opportunity gap.
</p>
</div>
Section pattern:
- Outer
<section>with background color - Container
<div>that centers content - Heading + intro paragraph
- Main content below
Color scheme:
bg-gray-50: Very light gray backgroundtext-gray-900: Almost black texttext-gray-600: Medium gray for subtitle
Two-Column Grid (Lines 50-80)
<div className="grid grid-cols-1 md:grid-cols-2 gap-12 items-center">
<div>
<h3 className="text-2xl font-bold text-gray-900 mb-4">AI-Amplified Tutoring</h3>
<p className="text-gray-600 mb-6">
Unlike traditional tutoring programs, we supercharge every session with K12worX technology.
Our tutors are guided by AI-driven insights, making their time exponentially more valuable
and driving measurable academic outcomes.
</p>
<Link
href="/technology"
className="text-blue-600 font-semibold hover:text-blue-800 transition-colors"
>
Learn about our technology β
</Link>
</div>
<div>
<h3 className="text-2xl font-bold text-gray-900 mb-4">Student-Powered Network</h3>
<p className="text-gray-600 mb-6">
High school and college students don't just tutorβthey lead. They build and manage local chapters,
gaining real-world experience in leadership, marketing, and community organizing while making
a meaningful impact.
</p>
<Link
href="/model"
className="text-blue-600 font-semibold hover:text-blue-800 transition-colors"
>
Explore our model β
</Link>
</div>
</div>
Grid layout:
grid: Enable CSS Grid layoutgrid-cols-1 md:grid-cols-2: 1 column on mobile, 2 on medium+ screensgap-12: Space between grid itemsitems-center: Vertically center items
Each column contains:
<h3>: Subheading<p>: Description text<Link>: Text link (not button) to related page
Pattern: Responsive grids stack on mobile, side-by-side on desktop
Part 6: Three-Column Feature Cards (Lines 95-125)
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
<div className="text-center p-6 bg-blue-50 rounded-lg">
<div className="w-12 h-12 bg-blue-600 rounded-lg mx-auto mb-4 flex items-center justify-center">
<span className="text-white text-xl">π―</span>
</div>
<h3 className="text-xl font-semibold mb-2">Laser-Focused Sessions</h3>
<p className="text-gray-600">
AI-driven insights identify specific learning gaps, making every tutoring hour count.
</p>
</div>
{/* ... two more similar cards ... */}
</div>
Three-column pattern:
grid-cols-1 md:grid-cols-3: 1 column mobile, 3 on medium+ screens- Each card is identical structure, different content
Card anatomy:
- Icon container: Colored square with emoji
- Heading: Card title
- Description: Short paragraph
Card styling:
bg-blue-50/bg-purple-50/bg-green-50: Very light colored backgroundsrounded-lg: Rounded cornersp-6: Internal paddingtext-center: Center all text
Pattern: Repeating card structure with color variations
Part 7: Call-to-Action Section (Lines 130-173)
<section className="py-16 bg-blue-600 text-white">
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 text-center">
<h2 className="text-3xl font-bold mb-4">Be Part of Something Transformational</h2>
<p className="text-xl mb-8 max-w-3xl mx-auto">
We're in the exciting launching stage, and there are meaningful ways to get involved right now.
Your participation today will help shape the future of educational equity.
</p>
Design pattern: Dark background with white text (inverse of earlier sections)
Three-Card Grid (Lines 138-171)
<div className="grid grid-cols-1 md:grid-cols-3 gap-6 mt-12">
<div className="bg-white bg-opacity-10 rounded-lg p-6">
<h3 className="text-xl font-semibold mb-2">Launching Committee</h3>
<p className="mb-4">Help design and launch this organization</p>
<Link
href="/launching"
className="inline-block px-6 py-2 bg-white text-blue-600 font-semibold rounded hover:bg-gray-100 transition-colors"
>
Learn More
</Link>
</div>
{/* ... two more similar cards ... */}
</div>
Card on colored background:
bg-white bg-opacity-10: White background at 10% opacity (semi-transparent)- Creates subtle distinction from section background
- Button uses full white for contrast
Pattern: Cards on colored backgrounds use transparency for subtle separation
Part 8: Closing Tags (Lines 173-176)
</LandingLayout>
);
}
Breakdown:
</LandingLayout>: Closes the layout wrapper);: Closes the return statement}: Closes the function
Key Patterns You Learned
Pattern 1: Responsive Design
className="text-4xl md:text-6xl"
className="grid-cols-1 md:grid-cols-3"
Mobile-first: Base styles for mobile, md:* for larger screens
Pattern 2: Container Pattern
<section>
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
{/* Content here */}
</div>
</section>
Every section uses this pattern to center and constrain content
Pattern 3: Spacing Utilities
mb-4 // margin-bottom: 1rem
py-16 // padding-vertical: 4rem
gap-8 // gap: 2rem
Tailwind spacing scale: 4 = 1rem, 8 = 2rem, 16 = 4rem, etc.
Pattern 4: Color Variations
bg-blue-50 // Very light blue
bg-blue-600 // Standard blue
bg-blue-900 // Very dark blue
Number scale: 50 (lightest) β 900 (darkest)
Pattern 5: Hover States
hover:bg-gray-100
hover:text-blue-600
transition-colors
Interactive elements should have hover states for better UX
Hands-On Exercise
Exercise 1: Change Section Order
Try moving the "Mission Overview" section to appear after the feature cards.
Steps:
- Find the Mission Overview
<section>(lines 40-82) - Cut it (Cmd+X or Ctrl+X)
- Paste it after the feature cards section
- Save and check the browser
What you'll learn: Sections are independent blocks you can reorder
Exercise 2: Add a New Feature Card
Add a 4th card to the three-column feature section.
Steps:
- Copy one existing card (lines 96-104)
- Paste it after the third card
- Change the emoji to π
- Change the background to
bg-yellow-50 - Change the icon background to
bg-yellow-600 - Change the title and description
- Save and view
What you'll learn: How to duplicate and modify component patterns
Exercise 3: Update Color Scheme
Change the hero section from blue/purple to green/teal.
Find:
bg-gradient-to-r from-blue-600 to-purple-600
Change to:
bg-gradient-to-r from-green-600 to-teal-600
What you'll learn: How Tailwind color utilities work
Common Questions
Q: Why className instead of class?
A: JSX is JavaScript, and class is a reserved keyword in JavaScript. React uses className instead.
Q: What's the difference between <section> and <div>?
A: <section> is semantic HTML that indicates a thematic grouping. It helps screen readers and SEO. <div> is generic. Use <section> for major page sections.
Q: Why so many nested <div> elements?
A: Each div serves a purpose:
- Outer div: background color and padding
- Middle div: max-width container to center content
- Inner div: specific layout (grid, flex, etc.)
Q: Can I remove the responsive classes?
A: You can, but the site will look bad on mobile! The responsive classes (md:, sm:, etc.) are crucial for mobile-friendly design.
Troubleshooting
Problem: Changed text but it didn't update
Solutions:
- Make sure you saved the file (Cmd+S / Ctrl+S)
- Check terminal for errors
- Try hard refresh (Cmd+Shift+R / Ctrl+Shift+R)
Problem: Broke the layout by removing a closing tag
Solution:
- Look for the error in terminal or browser
- Find the line number mentioned
- Add the missing
</tag> - Or use Cmd+Z / Ctrl+Z to undo
Problem: Colors don't work after changing them
Solution:
- Tailwind requires valid color names
- Use: red, blue, green, yellow, purple, pink, indigo, gray
- With numbers: 50, 100, 200, ... 900
- Example:
text-red-600,bg-blue-100
Quick Reference
Import external library:
import Link from 'next/link'
Import our component:
import Header from '@/components/layout/Header'
Comment in JSX:
{/* This is a comment */}
Responsive class:
className="text-sm md:text-lg lg:text-xl"
Link to another page:
<Link href="/about">About Us</Link>
Container pattern:
<div className="max-w-7xl mx-auto px-4">
{/* Content */}
</div>
What's Next
Now that you've seen a complete page, let's look at a simpler component to understand the basic anatomy: